package
Fast execution of an array of functions with the same value as input that can be altered.
npm install fast-iteratorGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Fast execution of an array of functions with the same value as input that can be altered.
npm i fast-iterator --saveconst fast = require('fast-iterator')
fast(
[fn1, fn2, fn3], // the array of functions to execute
{ context: true } // a custom context for every function
)(
iterator.bind({ a: 'a', b: 'b' }), // an iterator function to pass custom parameters
{ hello: 'world' }, // the value to update
done // the function to call once the work has been done
)
function fn1 (a, b, result, done) {
console.log(a, b, result, this)
done(null, { ciao: 'mondo' })
}
function fn2 (a, b, result, done) {
console.log
Output:
a b { hello: 'world' } { context: true }
a b { ciao: 'mondo' } { context: true }
a b { winter: 'is coming' } { context: true }
{ winter: 'has come' } { context: true }If you need to release the internal Object holder for performances reasons, you can call the fourth parameter of the iterator: release.
function iterator (fn, result, done, release) {
if (someCondition) return release()
return fn(this.a, this.b, result, done)
}This project is kindly sponsored by LetzDoIt.
Licensed under MIT.
Estimated unpacked size across 2 packages.
11.4 kB
Includes dependencies.