simpleasync
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -74,3 +74,3 @@ | ||
var fnl = fn.length; | ||
var objcount = { count: 0 }; | ||
var objcount = { count: 0, errors: 0 }; | ||
@@ -97,3 +97,7 @@ for (var j = 0; j < fnl; j++) { | ||
if (err) { | ||
failfn(err); | ||
objcount.errors++; | ||
if (objcount.errors == 1) | ||
failfn(err); | ||
return; | ||
@@ -105,3 +109,3 @@ } | ||
if (objcount.count >= maxcount) { | ||
if (objcount.count >= maxcount && !objcount.errors) { | ||
data = newdata; | ||
@@ -108,0 +112,0 @@ setTimeout(doStep, 0); |
{ "name": "simpleasync" | ||
, "description": "Simple flow library to chain and run functions with asynchronous calls" | ||
, "keywords": [ "node", "asynchronous", "library" ] | ||
, "version": "0.0.6" | ||
, "version": "0.0.7" | ||
, "author": "Angel 'Java' Lopez <webmaster@ajlopez.com> (http://www.ajlopez.com)" | ||
, "repository": { "type": "git", "url": "git://github.com/ajlopez/SimpleAsync.git" } | ||
, "main": "./lib/simpleasync.js" | ||
, "engines": { "node": ">= 0.6.0 && < 0.13.0" } | ||
, "engines": { "node": ">= 0.10.0" } | ||
, "scripts": { | ||
@@ -15,4 +15,4 @@ "test": "simpleunit test" | ||
, "devDependencies": { | ||
"simpleunit": "0.0.6" | ||
"simpleunit": "0.0.7" | ||
} | ||
} |
@@ -149,2 +149,8 @@ # SimpleAsync | ||
``` | ||
The asynchronous functions accepted by a consecutive series of `do` are executed with concurrency. The data collected | ||
by the functions are assembled in an array, that is the data feeded into the next step. In the above example, the three | ||
async functions of `do` returned and array with | ||
``` | ||
[ 2, 3, 4 ] | ||
``` | ||
@@ -193,2 +199,4 @@ `map` accepts function with callback, too: | ||
- 0.0.5: Published, fix async map with empty array | ||
- 0.0.6: Published, use setTimeout instead setImmediate | ||
- 0.0.7: Published, improved do implementation, engine versions updated | ||
@@ -195,0 +203,0 @@ ## License |
@@ -55,2 +55,3 @@ | ||
.then(function (data) { | ||
test.fail(); | ||
}) | ||
@@ -57,0 +58,0 @@ .fail(function (err) { |
@@ -72,1 +72,27 @@ | ||
} | ||
exports['map with error'] = function (test) { | ||
test.async(); | ||
var total = 0; | ||
var seq = async() | ||
.map(function (item, next) { | ||
if (item == 2) | ||
next("error", null); | ||
else | ||
next(null, item * item); | ||
}) | ||
.then(function (data) { | ||
test.fail(); | ||
}) | ||
.fail(function (err) { | ||
test.equal(err, "error"); | ||
test.done(); | ||
}); | ||
test.ok(seq); | ||
test.strictEqual(seq.run([1,2,3]), seq); | ||
} | ||
21017
473
215