Comparing version 0.3.0 to 0.4.0
@@ -1,2 +0,4 @@ | ||
var async = require('./async.js'); | ||
var async = require('./async.js') | ||
, abort = require('./abort.js') | ||
; | ||
@@ -36,3 +38,3 @@ // API | ||
// and reset the list | ||
abortJobs(state); | ||
abort(state); | ||
} | ||
@@ -60,3 +62,3 @@ else | ||
{ | ||
var abort; | ||
var aborter; | ||
@@ -66,3 +68,3 @@ // allow shortcut if iterator expects only two arguments | ||
{ | ||
abort = iterator(item, async(callback)); | ||
aborter = iterator(item, async(callback)); | ||
} | ||
@@ -72,33 +74,6 @@ // otherwise go with full three arguments | ||
{ | ||
abort = iterator(item, key, async(callback)); | ||
aborter = iterator(item, key, async(callback)); | ||
} | ||
return abort; | ||
return aborter; | ||
} | ||
/** | ||
* Aborts leftover active jobs | ||
* | ||
* @param {object} state - current state object | ||
*/ | ||
function abortJobs(state) | ||
{ | ||
Object.keys(state.jobs).forEach(clean.bind(state)); | ||
// reset leftover jobs | ||
state.jobs = {}; | ||
} | ||
/** | ||
* Cleans up leftover job by invoking abort function for the provided job id | ||
* | ||
* @this state | ||
* @param {string|number} key - job id to abort | ||
*/ | ||
function clean(key) | ||
{ | ||
if (typeof this.jobs[key] == 'function') | ||
{ | ||
this.jobs[key](); | ||
} | ||
} |
@@ -21,3 +21,4 @@ // API | ||
jobs : {}, | ||
results : isNamedList ? {} : [] | ||
results : isNamedList ? {} : [], | ||
size : isNamedList ? Object.keys(list).length : list.length | ||
} | ||
@@ -24,0 +25,0 @@ ; |
{ | ||
"name": "asynckit", | ||
"version": "0.3.0", | ||
"description": "Minimal async jobs utility library", | ||
"version": "0.4.0", | ||
"description": "Minimal async jobs utility library, with streams support", | ||
"main": "index.js", | ||
@@ -14,3 +14,3 @@ "scripts": { | ||
"size": "browserify index.js | size-table asynckit", | ||
"debug": "tape test/test-*.js | tap-spec" | ||
"debug": "tape test/test-*.js" | ||
}, | ||
@@ -36,3 +36,7 @@ "pre-commit": [ | ||
"array", | ||
"object" | ||
"object", | ||
"stream", | ||
"destroy", | ||
"terminate", | ||
"abort" | ||
], | ||
@@ -39,0 +43,0 @@ "author": "Alex Indigo <iam@alexindigo.com>", |
@@ -1,3 +0,4 @@ | ||
var iterate = require('./lib/iterate.js') | ||
, initState = require('./lib/state.js') | ||
var iterate = require('./lib/iterate.js') | ||
, initState = require('./lib/state.js') | ||
, terminator = require('./lib/terminator.js') | ||
; | ||
@@ -11,5 +12,6 @@ | ||
* | ||
* @param {array|object} list - array or object (named list) to iterate over | ||
* @param {function} iterator - iterator to run | ||
* @param {function} callback - invoked when all elements processed | ||
* @param {array|object} list - array or object (named list) to iterate over | ||
* @param {function} iterator - iterator to run | ||
* @param {function} callback - invoked when all elements processed | ||
* @returns {function} - jobs terminator | ||
*/ | ||
@@ -40,2 +42,4 @@ function parallel(list, iterator, callback) | ||
} | ||
return terminator.bind(state, callback); | ||
} |
# asynckit [![NPM Module](https://img.shields.io/npm/v/asynckit.svg?style=flat)](https://www.npmjs.com/package/asynckit) | ||
Minimal async jobs utility library. | ||
Minimal async jobs utility library, with streams support. | ||
[![PhantomJS Build](https://img.shields.io/travis/alexindigo/asynckit/master.svg?label=browser&style=flat)](https://travis-ci.org/alexindigo/asynckit) | ||
[![Linux Build](https://img.shields.io/travis/alexindigo/asynckit/master.svg?label=linux:0.10-6.x&style=flat)](https://travis-ci.org/alexindigo/asynckit) | ||
[![Windows Build](https://img.shields.io/appveyor/ci/alexindigo/asynckit/master.svg?label=windows:0.10-6.x&style=flat)](https://ci.appveyor.com/project/alexindigo/asynckit) | ||
[![PhantomJS Build](https://img.shields.io/travis/alexindigo/asynckit/v0.4.0.svg?label=browser&style=flat)](https://travis-ci.org/alexindigo/asynckit) | ||
[![Linux Build](https://img.shields.io/travis/alexindigo/asynckit/v0.4.0.svg?label=linux:0.12-6.x&style=flat)](https://travis-ci.org/alexindigo/asynckit) | ||
[![Windows Build](https://img.shields.io/appveyor/ci/alexindigo/asynckit/v0.4.0.svg?label=windows:0.12-6.x&style=flat)](https://ci.appveyor.com/project/alexindigo/asynckit) | ||
[![Coverage Status](https://img.shields.io/coveralls/alexindigo/asynckit/master.svg?label=code+coverage&style=flat)](https://coveralls.io/github/alexindigo/asynckit?branch=master) | ||
[![Dependency Status](https://img.shields.io/david/alexindigo/asynckit.svg?style=flat)](https://david-dm.org/alexindigo/asynckit) | ||
[![Coverage Status](https://img.shields.io/coveralls/alexindigo/asynckit/v0.4.0.svg?label=code+coverage&style=flat)](https://coveralls.io/github/alexindigo/asynckit?branch=master) | ||
[![Dependency Status](https://img.shields.io/david/alexindigo/asynckit/v0.4.0.svg?style=flat)](https://david-dm.org/alexindigo/asynckit) | ||
[![bitHound Overall Score](https://www.bithound.io/github/alexindigo/asynckit/badges/score.svg)](https://www.bithound.io/github/alexindigo/asynckit) | ||
@@ -22,5 +22,5 @@ | ||
| :----------------- | -------: | | ||
| asynckit.js | 10.44 kB | | ||
| asynckit.min.js | 3.47 kB | | ||
| asynckit.min.js.gz | 1.32 kB | | ||
| asynckit.js | 12.34 kB | | ||
| asynckit.min.js | 4.11 kB | | ||
| asynckit.min.js.gz | 1.47 kB | | ||
@@ -218,4 +218,10 @@ | ||
TBD | ||
For example [compare-property](compare-property) package. | ||
### Streaming interface | ||
TBD | ||
## Want to Know More? | ||
@@ -222,0 +228,0 @@ |
@@ -9,9 +9,10 @@ var serialOrdered = require('./serialOrdered.js'); | ||
* | ||
* @param {array|object} list - array or object (named list) to iterate over | ||
* @param {function} iterator - iterator to run | ||
* @param {function} callback - invoked when all elements processed | ||
* @param {array|object} list - array or object (named list) to iterate over | ||
* @param {function} iterator - iterator to run | ||
* @param {function} callback - invoked when all elements processed | ||
* @returns {function} - jobs terminator | ||
*/ | ||
function serial(list, iterator, callback) | ||
{ | ||
serialOrdered(list, iterator, null, callback); | ||
return serialOrdered(list, iterator, null, callback); | ||
} |
@@ -1,3 +0,4 @@ | ||
var iterate = require('./lib/iterate.js') | ||
, initState = require('./lib/state.js') | ||
var iterate = require('./lib/iterate.js') | ||
, initState = require('./lib/state.js') | ||
, terminator = require('./lib/terminator.js') | ||
; | ||
@@ -14,6 +15,7 @@ | ||
* | ||
* @param {array|object} list - array or object (named list) to iterate over | ||
* @param {function} iterator - iterator to run | ||
* @param {function} sortMethod - custom sort function | ||
* @param {function} callback - invoked when all elements processed | ||
* @param {array|object} list - array or object (named list) to iterate over | ||
* @param {function} iterator - iterator to run | ||
* @param {function} sortMethod - custom sort function | ||
* @param {function} callback - invoked when all elements processed | ||
* @returns {function} - jobs terminator | ||
*/ | ||
@@ -44,2 +46,4 @@ function serialOrdered(list, iterator, sortMethod, callback) | ||
}); | ||
return terminator.bind(state, callback); | ||
} | ||
@@ -46,0 +50,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
27362
20
678
234
0