Skip to content

Commit

Permalink
compact like in ruby, but for hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Sep 8, 2010
1 parent fa2d72b commit 0d8e1e6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ function Hash (hash, extra) {
return memoized.values;
} });

Object.defineProperty(self, 'compact', { get : function () {
return Hash(hash).filter(function (x) { return x !== undefined });
} });

Object.defineProperty(self, 'clone', { get : function () {
return Hash(Hash.clone(hash));
} });
Expand Down

0 comments on commit 0d8e1e6

Please sign in to comment.