Comparing version 1.2.0 to 1.2.1
"use strict"; | ||
const setImmediate = require('./setImmediate'); | ||
@@ -9,11 +10,20 @@ module.exports = function *(series, n, thunk, ctx) { | ||
var index = 0; | ||
var cancel = false; | ||
var next = function *() { | ||
if (index >= series.length) | ||
if (index >= series.length || cancel) | ||
return; | ||
let i = index++; | ||
ret[i] = yield thunk.call(ctx || this, series[i]); | ||
//force async HERE, so we MIGHT stop replenishing after error | ||
yield new Promise(setImmediate); | ||
try { //stop replenishing after error | ||
ret[i] = yield thunk.call(ctx || this, series[i]); | ||
} catch(err) { | ||
cancel = true; | ||
throw err; | ||
} | ||
yield next; //continue in lane | ||
@@ -20,0 +30,0 @@ } |
{ | ||
"name": "async-co", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Control flow for co with async.js (v2) signatures", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"mocha": "node node_modules/mocha/bin/_mocha -r mocha-plugin-co", | ||
"test": "node node_modules/istanbul/lib/cli.js cover --report text-summary --report html --report lcov node_modules/mocha/bin/_mocha -- -r mocha-plugin-co", | ||
"coveralls": "npm install coveralls && node ./node_modules/coveralls/bin/coveralls.js < ./coverage/lcov.info" | ||
}, | ||
@@ -28,3 +30,9 @@ "keywords": [ | ||
"dependencies": {}, | ||
"devDependencies": {}, | ||
"devDependencies": { | ||
"expect.js": "^0.3.1", | ||
"istanbul": "^0.3.20", | ||
"mocha": "^3.1.2", | ||
"mocha-plugin-co": "^1.0.0", | ||
"nyks": "^3.1.1" | ||
}, | ||
"repository": { | ||
@@ -31,0 +39,0 @@ "type": "git", |
@@ -10,3 +10,3 @@ "use strict"; | ||
yield pickworker(); | ||
var ret = yield thunk.apply(this, task); | ||
var ret = yield thunk.call(this, task); | ||
freeworker(); | ||
@@ -13,0 +13,0 @@ return Promise.resolve(ret); |
Control flow ala ES7 async/await using ES6 generator (thanks to [tj/co](https://github.com/tj/co)) with async.js (v2) signatures | ||
# Motivation | ||
[async-co](https://github.com/131/async-co) provide javascript async/await (through ES6 generator & co) equivalent signatures of the excellent [async](https://github.com/caolan/async) workflow library. | ||
[async-co](https://github.com/131/async-co) provide javascript async/await (through ES6 generator & co) equivalent signatures of the excellent [async](https://github.com/caolan/async) workflow library. | ||
Module are exported in standard commonJS module format and written in pure ES5/ES6 strict format. (no transpilation required nor used). | ||
Use browserify if you need async-co modules in a browser environnement. | ||
[![Build Status](https://travis-ci.org/131/async-co.svg?branch=master)](https://travis-ci.org/131/async-co) | ||
[![Coverage Status](https://coveralls.io/repos/github/131/async-co/badge.svg?branch=master)](https://coveralls.io/github/131/async-co?branch=master) | ||
[![Version](https://img.shields.io/npm/v/async-co.svg)](https://www.npmjs.com/package/async-co) | ||
**async-co** is not a wrapper on **async**, but rather leverages the full potential of native async/await & promises contract. Code tend to be small & very efficient (far more simplier than using callbacks), just give [async-co/queue.js](https://github.com/131/async-co/blob/master/queue.js) a look | ||
@@ -46,2 +55,6 @@ | ||
## async-co/setImmediate(fn) | ||
Call a function in javascript next tick (using setImmediate API, or timeout 0 pollyfill) | ||
## q = async-co/queue(*thunk, concurrency) | ||
@@ -84,5 +97,6 @@ Return a QueueObject you can push task into. | ||
``` | ||
# Tests | ||
async-co is tested against async test suite. | ||
# TODO | ||
@@ -89,0 +103,0 @@ * Get rich or die tryin' |
@@ -9,5 +9,5 @@ "use strict"; | ||
return function () { | ||
return q([].slice.apply(arguments)); | ||
return q.apply(q, arguments); | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
0
121
9615
5
15
130