Package Exports
- fastseries
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 (fastseries) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
fastseries 
Zero-overhead series function call for node.js. Also supports each and map!
Benchmark for doing 3 calls setImmediate 1 million times:
- non-reusable
setImmediate: 4013ms async.series: 6216msasync.eachSeries: 5158msasync.mapSeries: 5660msfastserieswith results: 4225msfastserieswithout results: 4316msfastseriesmap: 4171msfastserieseach: 4259ms
These benchmarks where taken via bench.js on node 4.2.2, on a MacBook
Pro Retina 2014.
If you need zero-overhead parallel function call, check out fastparallel.
Example for series call
var series = require('fastseries')({
// this is a function that will be called
// when a series completes
released: completed,
// if you want the results, then here you are
results: true
})
series(
{}, // what will be this in the functions
[something, something, something], // functions to call
42, // the first argument of the functions
done // the function to be called when the series ends
)
function late (arg, cb) {
console.log('finishing', arg)
cb(null, 'myresult-' + arg)
}
function something (arg, cb) {
setTimeout(late, 1000, arg, cb)
}
function done (err, results) {
console.log('series completed, results:', results)
}
function completed () {
console.log('series completed!')
}Example for each and map calls
var series = require('fastseries')({
// this is a function that will be called
// when a series completes
released: completed,
// if you want the results, then here you are
// passing false disables map
results: true
})
series(
{}, // what will be this in the functions
something, // functions to call
[1, 2, 3], // the first argument of the functions
done // the function to be called when the series ends
)
function late (arg, cb) {
console.log('finishing', arg)
cb(null, 'myresult-' + arg)
}
function something (arg, cb) {
setTimeout(late, 1000, arg, cb)
}
function done (err, results) {
console.log('series completed, results:', results)
}
function completed () {
console.log('series completed!')
}
Caveats
The done function will be called only once, even if more than one error happen.
This library works by caching the latest used function, so that running a new series does not cause any memory allocations.
License
ISC
