From 04b1d50e73870026fd21ab9ccea609c3f1351080 Mon Sep 17 00:00:00 2001 From: James Halliday Date: Mon, 25 Oct 2010 05:05:40 +0000 Subject: [PATCH] detect test, package bump --- package.json | 2 +- test/hash.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 95cecd8..88dba7f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/hash.js b/test/hash.js index d77f9f9..d761692 100755 --- a/test/hash.js +++ b/test/hash.js @@ -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); +};