Contains the class Hash.
Christophe Beyls, http://digitalia.be
MIT-style license.
| Hash.js | Contains the class Hash. |
| Hash | It wraps an object that it uses internally as a map. |
| Properties | |
| get | Retrieves a value from the hash. |
| hasKey | Check the presence of a specified key-value pair in the hash. |
| set | Adds a key-value pair to the hash or replaces a previous value associated with the key. |
| remove | Removes a key-value pair from the hash. |
| each | Calls a function for each key-value pair. |
| extend | Extends the current hash with an object containing key-value pairs. |
| empty | Checks if the hash is empty. |
| keys | Returns an array containing all the keys, in the same order as the values returned by Hash.values. |
| values | Returns an array containing all the values, in the same order as the keys returned by Hash.keys. |
| Functions | |
| $H | Shortcut to create a Hash from an Object. |
It wraps an object that it uses internally as a map. The user must use set(), get(), and remove() to add/change, retrieve and remove values, it must not access the internal object directly. null values are allowed.
var hash = new Hash({a: 'hi', b: 'world', c: 'howdy'});
hash.remove('b'); // b is removed.
hash.set('c', 'hello');
hash.get('c'); // returns 'hello'
hash.length // returns 2 (a and c)| Properties | |
| get | Retrieves a value from the hash. |
| hasKey | Check the presence of a specified key-value pair in the hash. |
| set | Adds a key-value pair to the hash or replaces a previous value associated with the key. |
| remove | Removes a key-value pair from the hash. |
| each | Calls a function for each key-value pair. |
| extend | Extends the current hash with an object containing key-value pairs. |
| empty | Checks if the hash is empty. |
| keys | Returns an array containing all the keys, in the same order as the values returned by Hash.values. |
| values | Returns an array containing all the values, in the same order as the keys returned by Hash.keys. |
| Functions | |
| $H | Shortcut to create a Hash from an Object. |
Check the presence of a specified key-value pair in the hash.
| key | The key |
True if the Hash contains a value for the specified key, otherwise false
Adds a key-value pair to the hash or replaces a previous value associated with the key.
| key | The key |
| value | The value |
Calls a function for each key-value pair. The first argument passed to the function will be the key, the second one will be the value.
| fn | The function to call for each key-value pair |
| bind | Optional, the object that will be referred to as “this” in the function |
Extends the current hash with an object containing key-value pairs. Values for duplicate keys will be replaced by the new ones.
| obj | An object containing key-value pairs |
Returns an array containing all the keys, in the same order as the values returned by Hash.values.
An array containing all the keys of the hash
Returns an array containing all the values, in the same order as the keys returned by Hash.keys.
An array containing all the values of the hash
Shortcut to create a Hash from an Object.
function $H( obj )