Comparing version 0.1.0 to 0.1.1
12
index.js
@@ -27,11 +27,11 @@ 'use strict'; | ||
if (typeof obj !== 'object' | ||
|| nativeConstructors.indexOf(obj.constructor) !== -1) { | ||
return itrfn(obj, path, cb); | ||
} | ||
async.each(Object.keys(obj), function(key, cb) { | ||
var val = obj[key]; | ||
var thisPath = path.concat(key); | ||
if (typeof val === 'object' | ||
&& nativeConstructors.indexOf(val.constructor) === -1) { | ||
abyss.traverse(val, itrfn, cb, thisPath); | ||
} else { | ||
itrfn(val, thisPath, cb); | ||
} | ||
abyss.traverse(val, itrfn, cb, thisPath); | ||
}, cb); | ||
@@ -38,0 +38,0 @@ }; |
{ | ||
"name": "abyss", | ||
"description": "Deep and asynchronous.", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"author": "Qix (http://github.com/Qix-)", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
20
test.js
@@ -21,2 +21,10 @@ 'use strict'; | ||
describe('traverse()', function() { | ||
it('should \'traverse\' non-object', function(done) { | ||
abyss.traverse('Hello', function(v, path, cb) { | ||
v.should.equal('Hello'); | ||
path.should.be.lengthOf(0); | ||
done(); | ||
}); | ||
}); | ||
it('should iterate all properties', function(done) { | ||
@@ -66,2 +74,14 @@ var keyCount = 0; | ||
describe('test()', function() { | ||
it('should validate non-objects (string)', function(done) { | ||
abyss.test(function(v) { return v === 'hello' }, 'hello', function(equal) { | ||
equal.should.equal(true); | ||
done(); | ||
}); | ||
}); | ||
it('should validate non-objects (regex)', function(done) { | ||
abyss.test(/^..l+.$/, 'hello', function(equal) { | ||
equal.should.equal(true); | ||
done(); | ||
}); | ||
}); | ||
it('should validate literal values', function(done) { | ||
@@ -68,0 +88,0 @@ abyss.test({a:1}, obj, function(equal) { |
11014
326