Skip to content

Commit

Permalink
new valuesAt and extract functions
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Aug 27, 2010
1 parent 094ab55 commit 883f015
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,21 @@ function Hash (hash, extra) {
merge : function (h) {
return self.copy.update(h);
},
valuesAt : function (keys) {
return keys.map(function (key) { return hash[key] });
},
tap : function (f) {
f.call(self, hash);
memoized = {};
return self;
},
extract : function (keys) {
var acc = {};
keys.forEach(function (key) {
acc[key] = hash[key];
});
return Hash(acc);
},
end : hash,
items : hash
};
Expand Down

0 comments on commit 883f015

Please sign in to comment.