async-validate
Advanced tools
Comparing version 0.7.1 to 0.7.2
@@ -6,3 +6,2 @@ function mapSeries(list, cb, complete) { | ||
cb(item, function(err, result) { | ||
/* istanbul ignore next: not going to mock this */ | ||
if(err) { | ||
@@ -26,7 +25,12 @@ return complete(err, out); | ||
function map(list, cb, complete) { | ||
var out = []; | ||
var out = [] | ||
, e; | ||
function run(item, index) { | ||
cb(item, function(err, result) { | ||
/* istanbul ignore next: not going to mock this */ | ||
if(err) { | ||
// do not call complete again on error | ||
// condition | ||
if(e) { | ||
return; | ||
}else if(err) { | ||
e = err; | ||
return complete(err, out); | ||
@@ -33,0 +37,0 @@ } |
@@ -23,3 +23,5 @@ var iterator = require('./iterator') | ||
rules = clone(rules); | ||
// do not clone rules when deep is set | ||
// initial clone is a deep clone | ||
rules = opts.deep ? rules : clone(rules); | ||
@@ -133,4 +135,2 @@ // wrap shorthand declaration without `fields` | ||
//var keys = options.keys || Object.keys(this.rules.fields || this.rules); | ||
// iterate list data | ||
@@ -157,7 +157,2 @@ func(series, function(rule, callback) { | ||
// bail on first error | ||
//if(options.first && errors && errors.length) { | ||
//return complete(err, errors, options, cb); | ||
//} | ||
// not deep so continue on to next in series | ||
@@ -174,4 +169,2 @@ if(!deep) { | ||
//console.log('field key %s', key); | ||
var opts = clone(options) | ||
@@ -305,2 +298,3 @@ , descriptor = rule.fields[key] | ||
} | ||
target = target || (Array.isArray(source) ? [] : {}); | ||
@@ -307,0 +301,0 @@ for(k in source) { |
{ | ||
"name": "async-validate", | ||
"description": "Asynchronous validation for node and the browser", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"author": "muji <noop@xpm.io>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -22,2 +22,30 @@ var expect = require('chai').expect | ||
it("should callback with error (mapSeries)", function(done) { | ||
iterator.mapSeries([1,2,3], | ||
function multiply(num, cb) { | ||
cb(new Error('mock error')); | ||
}, | ||
function complete(err, results) { | ||
function fn() { | ||
throw err; | ||
} | ||
expect(fn).throws(Error); | ||
done(); | ||
}); | ||
}); | ||
it("should callback with error (map)", function(done) { | ||
iterator.map([1,2,3], | ||
function multiply(num, cb) { | ||
cb(new Error('mock error')); | ||
}, | ||
function complete(err, results) { | ||
function fn() { | ||
throw err; | ||
} | ||
expect(fn).throws(Error); | ||
done(); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
131553
78
2866