From 35298be61b782681f6d0a555a0ab8db673419293 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Wed, 8 Sep 2010 16:46:51 -0800 Subject: [PATCH] top-level Hash functions more closely mirror Hash() functions --- lib/hash.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/hash.js b/lib/hash.js index a2e25eb..bece993 100644 --- a/lib/hash.js +++ b/lib/hash.js @@ -126,6 +126,10 @@ Hash.map = function (ref, f) { return Hash(ref).map(f).items; }; +Hash.forEach = function (ref, f) { + Hash(ref).forEach(f); +}; + Hash.filter = function (ref, f) { return Hash(ref).filter(f).items; }; @@ -134,6 +138,30 @@ Hash.reduce = function (ref, f, acc) { return Hash(ref).reduce(f, acc); }; +Hash.some = function (ref, f) { + return Hash(ref).some(f); +}; + +Hash.update = function (a, b) { + return Hash(a).update(b).items; +}; + +Hash.merge = function (a, b) { + return Hash(a).merge(b).items; +}; + +Hash.valuesAt = function (ref, keys) { + return Hash(ref).valuesAt(keys); +}; + +Hash.tap = function (ref, f) { + return Hash(ref).tap(f).items; +}; + +Hash.extract = function (ref, keys) { + return Hash(ref).extract(keys).items; +}; + Hash.concat = function (xs) { var hash = Hash({}); xs.forEach(function (x) { hash.update(x) });