1 var test = require('tap').test;
2 var traverse = require('../');
4 test('stop', function (t) {
6 traverse('abcdefghij'.split('')).forEach(function (node) {
7 if (typeof node === 'string') {
9 if (node === 'e') this.stop()
17 test('stopMap', function (t) {
18 var s = traverse('abcdefghij'.split('')).map(function (node) {
19 if (typeof node === 'string') {
20 if (node === 'e') this.stop()
21 return node.toUpperCase();
25 t.equal(s, 'ABCDEfghij');
29 test('stopReduce', function (t) {
32 b : [ 6, [ 7, 8, 9 ] ]
34 var xs = traverse(obj).reduce(function (acc, node) {
36 if (node === 7) this.stop();
42 t.same(xs, [ 4, 5, 6 ]);