node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org ยป


Hash MultiValue

Store multiple values per key.

Very inspired from Hash::MultiValue in CPAN.


var hash = HashMultiValue({
	foo : ['aaa', 'bbb', 'ccc'],
	bar : ['111', '222', '333']
});; //=> 'ccc';
hash.get('foo'); //=> 'ccc';
hash.getAll('foo'); //=> ['aaa', 'bbb', 'ccc']

This is mainly designed for like query parameters and HTTP headers.


'get', 'getAll', 'set', 'add', 'remove', 'clear' and so on are methods for manipulating instance, so you can't access the keys named so directly. Eg:

var hash = HashMultiValue({
	foo : ['aaa', 'bbb', 'ccc'],
	get : ['111', '222']
});; //=> 'ccc'; (ok)
hash.get; //=> [Function]; (ng)
hash.get('get'); //=> '222' (ok)