Skip to content

Commit

Permalink
detect test, package bump
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Oct 25, 2010
1 parent 441f3b4 commit 04b1d50
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "traverse",
"version" : "0.2.1",
"version" : "0.2.2",
"description" : "Traverse and transform objects by visiting every node on a recursive walk.",
"author" : "James Halliday",
"license" : "MIT/X11",
Expand Down
10 changes: 10 additions & 0 deletions test/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,13 @@ exports.has = function (assert) {
assert.ok(Hash.has(h, ['a','b']));
assert.equal(Hash.has(h, ['a','b','c']), false);
};

exports.detect = function (assert) {
var h = { a : 5, b : 6, c : 7, d : 8 };
var hh = Hash(h);
var gt6hh = hh.detect(function (x) { return x > 6 });
assert.ok(gt6hh == 7 || gt6hh == 8);
var gt6h = Hash.detect(h, function (x) { return x > 6 });
assert.ok(gt6h == 7 || gt6h == 8);
assert.equal(hh.detect(function (x) { return x > 100 }), undefined);
};

0 comments on commit 04b1d50

Please sign in to comment.