fastseries
Zero-overhead asynchronous series/each/map function calls
Last updated 5 years ago by matteo.collina .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ npm install fastseries 
SYNC missed versions from official npm registry.

fastseries

ci npm version Coverage Status Dependency Status

Zero-overhead series function call for node.js. Also supports each and map!

If you need zero-overhead parallel function call, check out fastparallel.

js-standard-style

Example for series call

var series = require('fastseries')({
  // 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)
}

Example for each and map calls

var series = require('fastseries')({
  // 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)
}

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.

Benchmarks

Benchmark for doing 3 calls setImmediate 1 million times:

benchSetImmediate*1000000: 2460.623ms
benchAsyncSeries*1000000: 3064.569ms
benchAsyncEachSeries*1000000: 2913.525ms
benchAsyncMapSeries*1000000: 3020.794ms
benchNeoSeries*1000000: 2617.064ms
benchNeoEachSeries*1000000: 2621.672ms
benchNeoMapSeries*1000000: 2611.294ms
benchTinyEachAsync*1000000: 2706.457ms
benchFastSeries*1000000: 2540.653ms
benchFastSeriesNoResults*1000000: 2538.674ms
benchFastSeriesEach*1000000: 2534.856ms
benchFastSeriesEachResults*1000000: 2545.394ms

Benchmarks taken on Node 12.16.1 on a dedicated server.

See bench.js for mode details.

License

ISC

Current Tags

  • 2.0.0                                ...           latest (5 years ago)

18 Versions

  • 2.0.0                                ...           5 years ago
  • 1.7.2                                ...           9 years ago
  • 1.7.1                                ...           9 years ago
  • 1.7.0                                ...           9 years ago
  • 1.6.1                                ...           9 years ago
  • 1.6.0                                ...           9 years ago
  • 1.5.0                                ...           9 years ago
  • 1.4.0                                ...           9 years ago
  • 1.3.1                                ...           10 years ago
  • 1.3.0                                ...           10 years ago
  • 1.2.0                                ...           10 years ago
  • 1.1.3                                ...           10 years ago
  • 1.1.2                                ...           10 years ago
  • 1.1.1                                ...           10 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
  • 0.0.1                                ...           10 years ago
Maintainers (1)
Downloads
Total 17
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (9)
Dependents (3)

© 2010 - cnpmjs.org x YWFE | Home | YWFE