Package Exports
- chunkify
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (chunkify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
chunkify
An ES6-developed node module that prevents long-running scripts from blocking the JavaScript thread.
Install
$ npm install --save chunkifyUsage
Import the module:
import chunkify from 'chunkify'API
chunkify.array(Array array, Function fn, [Object options])
options is an object literal that specifies a non-negative delay value, and a positive chunk value.
chunkis the number of items inarrayto successively invokefnon before yielding back to the main thread. Default is1.delayis the minimal time in milliseconds to wait before continuing to invokefnon the next item inarray. Default is0.
fn is successively invoked on array. At every chunkth invocation, control is given back to the main thread. After delay milliseconds, fn picks back up where it left off. This continues until all items in array have been processed.
Returns a Promise that resolves with array when fn has been invoked on all items in array.
If any invocation of fn throws an error, the promise is rejected with an object {error, item}, where error is the caught Error, and item is the member of array where fn(item) threw. No further processing happens after the failure.
Future Plans
Expose a generator-friendly API.
Contributing
Development is in snake_case ES6.
Get the source.
$ git clone git@github.com:yangmillstheory/chunkifyInstall dependencies.
$ npm installCompile sources.
$ node_modules/.bin/gulp buildRun tests.
$ npm testLicense
MIT © 2015, Victor Alvarez