-
Notifications
You must be signed in to change notification settings - Fork 0
ds.utils
metmajer edited this page Mar 16, 2013
·
2 revisions
The ds.utils
module is a collection of algorithms that don't fit anywhere else.
hash(string)
Computes a hash from a string.
The method implements the Fowler–Noll–Vo or FNV hash algorithm, designed primarily for hash table and checksum use (non-cryptographic). See Wikipedia, Fowler–Noll–Vo hash function for an explanation of this algorithm and Which hashing algorithm is best for uniqueness and speed? for a comprehensive comparison of various hash algorithms.
- String string The string to be hashed.
- String Returns the hash as a base36 encoded number.
hashObject(object)
Computes a hash from the enumerable properties of an object.
The method uses the Fowler–Noll–Vo hash algorithm provided by ds.utils.hash
.
ds.utils.hashObject({x: 1, y: 2});
// => "3hr02ufj2cg"
ds.utils.hashObject({x: 2, y: 1});
// => "-4jxzz8puql0"
- Object object The object to be hashed.
- String Returns the hash as a base36 encoded number.