Comparing version 0.13.0 to 1.0.0
@@ -7,7 +7,7 @@ "use strict"; | ||
let ret = []; | ||
let index = 0; | ||
var ret = []; | ||
var index = 0; | ||
let next = function *() { | ||
var next = function *() { | ||
if (index >= series.length) | ||
@@ -22,3 +22,3 @@ return; | ||
let lanes = []; | ||
var lanes = []; | ||
while (n--) | ||
@@ -25,0 +25,0 @@ lanes.push(next); |
{ | ||
"name": "async-co", | ||
"version": "0.13.0", | ||
"version": "1.0.0", | ||
"description": "Control flow for co with aync.js (v2) signatures", | ||
@@ -9,3 +9,18 @@ "main": "index.js", | ||
}, | ||
"keywords": [], | ||
"keywords": [ | ||
"async", | ||
"co", | ||
"await", | ||
"ES6 generators", | ||
"yield", | ||
"throttle", | ||
"pool", | ||
"concurrency", | ||
"promise", | ||
"promises", | ||
"queue", | ||
"deferred", | ||
"map", | ||
"Let's have a beer and talk in Paris" | ||
], | ||
"author": "Francois Leurent <131.js@cloudyks.org>", | ||
@@ -12,0 +27,0 @@ "license": "ISC", |
@@ -1,17 +0,32 @@ | ||
Control flow for co with aync.js (v2) signatures | ||
Control flow for ES6 generator (co) with async.js (v2) signatures | ||
# Motivation | ||
async-co provide javascript async/await (through ES6 generator & co) equivalent signatures of the excellent [async](https://github.com/caolan/async) workflow library. | ||
## Addition to the async library signatures | ||
Because of the Promise contract (and sane API), it's easy to "throttle" a function that return a Promise (see the "throttle" API, for a way to make an ultra simple http request pooling). | ||
# API | ||
## eachLimit(arr, concurrency, *thunk) | ||
## eachSeries(arr, *thunk) // = eachLimit concurrency = 1 | ||
## each(arr, *thunk) // = eachLimit concurrency = arr.length | ||
## async-co/eachLimit(arr, concurrency, *thunk) | ||
Nothing special here | ||
## async-co/eachSeries(arr, *thunk) | ||
// = eachLimit concurrency = 1 | ||
## async-co/each(arr, *thunk) | ||
// = eachLimit concurrency = arr.length | ||
## eachOfLimit (dict, concurrency, *thunk) | ||
## eachOfSeries(dict, *thunk) // = eachOfLimit concurrency = 1 | ||
## eachOf(dict, *thunk) // = eachOfLimit concurrency = dict.length | ||
## | ||
## async-co/eachOfLimit (dict, concurrency, *thunk) | ||
Nothing special here neither | ||
## async-co/eachOfSeries(dict, *thunk) | ||
// = eachOfLimit concurrency = 1 | ||
## async-co/eachOf(dict, *thunk) | ||
// = eachOfLimit concurrency = dict.length | ||
``` | ||
var eachLimit = require('async-co/eachLimit'); | ||
const eachLimit = require('async-co/eachLimit'); | ||
@@ -27,6 +42,59 @@ co(function *() { | ||
}); | ||
``` | ||
## q = async-co/queue(*thunk, concurrency) | ||
Return a QueueObject you can push task into. | ||
### yield q.push(task) | ||
Wait for thunk to process task (wait for worker, if needed) | ||
``` | ||
const queue = require('async-co/queue'); | ||
const fetch = require('node-fetch'); | ||
## eachSeries(arr, *thunk) | ||
var q = queue(fetch, 1); //let's be nice | ||
co(function *() { | ||
yield q.push("http://example.com/stuff.json"); | ||
}); | ||
co(function *() { | ||
yield q.push("http://example.com/otherstuff.json"); //will wait for stuff to be retrieved | ||
}); | ||
``` | ||
## async-co/throttle | ||
Throttle any function that return a promise, sugar syntax helper for async-co/queue | ||
``` | ||
const throttle = require('async-co/throttle'); | ||
var fetch = require('node-fetch'); | ||
fetch = throttle(fetch, 1); //make fetch behave nicely | ||
co(function *() { | ||
yield fetch("http://example.com/stuff.json"); | ||
}); | ||
co(function *() { | ||
yield fetch("http://example.com/otherstuff.json"); //will wait for stuff.json to be retrieved | ||
}); | ||
``` | ||
# TODO | ||
* Get rich or die tryin' | ||
# Credits | ||
* [131](https://github.com/131) | ||
* not dependant upon, yet relying on [co](https://github.com/tj/co) | ||
* inspired from the excellent [async](https://github.com/caolan/async) | ||
# Shoutbox, keywords, SEO love | ||
async/await, ES6 generators, co, async-co, promise, Promises, yield, async, queue, map, throttle, "Let's have a beer & talk in Paris" | ||
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6823
13
123
1
100