Skip to content

Commit

Permalink
passing test for deep reduce and this.stop()
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Jun 10, 2011
1 parent 0ee24cc commit 9aea0a1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,19 @@ exports.stopMap = function () {

assert.equal(s, 'ABCDEfghij');
};

exports.stopReduce = function () {
var obj = {
a : [ 4, 5 ],
b : [ 6, [ 7, 8, 9 ] ]
};
var xs = traverse(obj).reduce(function (acc, node) {
if (this.isLeaf) {
if (node === 7) this.stop();
else acc.push(node)
}
return acc;
}, []);

assert.deepEqual(xs, [ 4, 5, 6 ]);
};

0 comments on commit 9aea0a1

Please sign in to comment.