package
Minimal async jobs utility library, with streams support
npm install asynckitGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 1 packages.
26.0 kB
Includes dependencies.
Minimal async jobs utility library, with streams support.
AsyncKit provides harness for parallel and serial iterators over list of items represented by arrays or objects.
Optionally it accepts abort function (should be synchronously return by iterator for each item), and terminates left over jobs upon an error event. For specific iteration order built-in (ascending and descending) and custom sort helpers also supported, via asynckit.serialOrdered method.
It ensures async operations to keep behavior more stable and prevent Maximum call stack size exceeded errors, from sync iterators.
| compression | size |
|---|---|
| asynckit.js | 12.34 kB |
| asynckit.min.js | 4.11 kB |
| asynckit.min.js.gz | 1.47 kB |
$ npm install --save asynckitRuns iterator over provided array in parallel. Stores output in the result array,
on the matching positions. In unlikely event of an error from one of the jobs,
will terminate rest of the active jobs (if abort function is provided)
and return error along with salvaged data to the main callback function.
var parallel = require('asynckit').parallel
, assert = require('assert')
;
var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
, expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
, expectedTarget = [ 1, 1, 2, 4, 8,
More examples could be found in test/test-parallel-array.js.
Also it supports named jobs, listed via object.
var parallel = require('asynckit/parallel')
, assert = require('assert')
;
var source = { first: 1, one: 1, four: 4, sixteen: 16, sixtyFour: 64, thirtyTwo: 32, eight: 8, two: 2 }
, expectedResult = { first: 2, one: 2, four: 8, sixteen: 32, sixtyFour: 128, thirtyTwo: 64, eight: 16, two: 4 }
, expectedTarget = [ 1, 1, 2, 4
More examples could be found in test/test-parallel-object.js.
Runs iterator over provided array sequentially. Stores output in the result array,
on the matching positions. In unlikely event of an error from one of the jobs,
will not proceed to the rest of the items in the list
and return error along with salvaged data to the main callback function.
var serial = require('asynckit/serial')
, assert = require('assert')
;
var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
, expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
, expectedTarget = [ 0, 1, 2, 3, 4,
More examples could be found in test/test-serial-array.js.
Also it supports named jobs, listed via object.
var serial = require('asynckit').serial
, assert = require('assert')
;
var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
, expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
, expectedTarget = [ 0, 1, 2, 3, 4,
More examples could be found in test/test-serial-object.js.
Note: Since object is an unordered collection of properties,
it may produce unexpected results with sequential iterations.
Whenever order of the jobs' execution is important please use serialOrdered method.
TBD
For example compare-property package.
TBD
More examples can be found in test folder.
Or open an issue with questions and/or suggestions.
AsyncKit is licensed under the MIT license.