serializeasync

0.0.1 • Public • Published

serializeasync

Make sure that an async function is not run multiple times at once.

var serializeAsync = require('serializeasync');

function cannotRunInParallel(cb) {
    require('fs').writeFile('/foo/bar.txt', 'utf-8', cb);
}

var serialized = serializeAsync(cannotRunInParallel);

// Now it's safe to do this (the second invocation will be queued up
// until the first has completed):

serialized(function () {});
serialized(function () {});

You can also control set the concurrency level to more than one:

var serialized = serializeAsync(cannotRunInParallel, {maxConcurrency: 4});

Installation

Make sure you have node.js and npm installed, then run:

npm install serializeasync

License

3-clause BSD license -- see the LICENSE file for details.

Readme

Keywords

none

Package Sidebar

Install

npm i serializeasync

Weekly Downloads

787

Version

0.0.1

License

BSD

Last publish

Collaborators

  • papandreou