A simple module for working with serial callbacks, works on node and browser
Last updated 7 years ago by chemzqm .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install node-serial 
SYNC missed versions from official npm registry.


Serial provide a simple way for management of serial async call, you can remember the API just by a glance.

If you think async and promise is somehow complecated, consider to use chemzqm/parallel and chemzqm/serial to make your life easier.


Via npm:

npm install node-serial

Via component:

component install chemzqm/serial

Test on node and browser

You must have component installed for browser usage and mocha, mocha-phantomjs installed for testing.

$ npm install -g component mocha mocha-phantomjs
$ git clone
$ npm install
$ make
#run test on server side
$ make test
#run test on phantomjs
$ make phantomjs


function square(n, done) {
    done(null, n * n);
  }, 100);
var Serial = reuiqre('serial'); //The name is 'node-serial' in node environment
var serial = new Serial();
[1, 2, 3].forEach(function(){
  serial.add(function(done, ctx){
    square( 1 + (ctx.res || 0), function (err ,res) {
      done(err, res);
serial.done(function (err, ctx) {
  if (err) throw err;
  // ctx.res => 25



Init new Serial instance.


Set the timeout to number ms, default is 10s.

Note this timeout if for individual callback function.


Add Function to serial, the first argument is a callback function, it should be called with error as first argument and result you need as secound argument. the secound argument is a ctx obejct, it's res attribute contains the result of the previous function call, you can save any object on ctx as you need.


The callback function is called with error (null or undefined if not exist) and the result array when all the request get finished (or timeout reached).

Note, this function should only be called once.



Current Tags

  • 0.1.1                                ...           latest (7 years ago)

2 Versions

  • 0.1.1                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
Maintainers (1)
Today 0
This Week 1
This Month 39
Last Day 0
Last Week 17
Last Month 45
Dependencies (1)
Dev Dependencies (5)

Copyright 2014 - 2016 © |