1 var assert = require('assert');
2 var traverse = require('../');
4 exports.stop = function () {
6 traverse('abcdefghij'.split('')).forEach(function (node) {
7 if (typeof node === 'string') {
9 if (node === 'e') this.stop()
13 assert.equal(visits, 5);
16 exports.stopMap = function () {
17 var s = traverse('abcdefghij'.split('')).map(function (node) {
18 if (typeof node === 'string') {
19 if (node === 'e') this.stop()
20 return node.toUpperCase();
24 assert.equal(s, 'ABCDEfghij');
27 exports.stopReduce = function () {
30 b : [ 6, [ 7, 8, 9 ] ]
32 var xs = traverse(obj).reduce(function (acc, node) {
34 if (node === 7) this.stop();
40 assert.deepEqual(xs, [ 4, 5, 6 ]);