Comparing version
@@ -100,4 +100,4 @@ const assert = require('assert'); | ||
function limiter(max_parallel) { | ||
let avail = max_parallel; | ||
function limiter(limit) { | ||
let avail = limit; | ||
let head = null; | ||
@@ -104,0 +104,0 @@ let tail = null; |
{ | ||
"name": "glov-async", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "GLOV.js Async Utility Library", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"keywords": [ | ||
"glov", | ||
"glovjs" | ||
], | ||
"author": "Jimb Esser (https://github.com/Jimbly)", | ||
@@ -7,0 +12,0 @@ "repository": { |
@@ -6,9 +6,9 @@ GLOV.js async utility library | ||
* Never forces setTimeout/nextTick, so empty lists or synchronous tasks are optimally efficient, creating no inter-generational garbage. | ||
* All parallel async functions (each, eachLimit, parallel, parallelLimit) process every entry and do not return to the final function until all processing is complete, even if some entry errors before then. This avoids terrible edge-case bugs where the calling code things an asynchronous batch has finished executing (because one part of the batch terminated with error), yet some children are still running. | ||
* All parallel async functions (each, eachLimit, parallel, parallelLimit) process every entry and do not return to the final function until all processing is complete, even if some entry errors before then. This avoids terrible edge-case bugs where the calling code thinks an asynchronous batch has finished executing (because one part of the batch terminated with error), yet some children are still running. | ||
Example API usage (admittedly will all actually run synchronously): | ||
```javascript | ||
const { asyncEach, asyncEachLimit, asyncParallel, asyncParallelLimit, asyncLimiter } = require('glovjs-async'); | ||
const { asyncEach, asyncEachLimit, asyncParallel, asyncParallelLimit, asyncLimiter } = require('glov-async'); | ||
// Also valid: | ||
// const async = require('glovjs-async'); | ||
// const async = require('glov-async'); | ||
// async.each(...), etc | ||
@@ -20,5 +20,5 @@ | ||
console.log(thing); | ||
next(); | ||
}, function (err) { | ||
console.log('Done'); | ||
next(null, 'baz'); | ||
}, function (err, results) { | ||
console.log('Done', results); // prints Done ['baz', 'baz'] | ||
}); | ||
@@ -58,2 +58,2 @@ | ||
console.log('Done'); | ||
``` | ||
``` |
7624
32.73%4
33.33%175
31.58%57
1.79%