This package has been deprecated

Author message:

Renamed to glov-async

glovjs-async

0.0.4 • Public • Published

GLOV.js async utility library

Behavioral differences from other similar libraries:

  • Never forces setTimeout/nextTick, so empty lists or synchronous tasks are optimally efficient, creating no inter-generational garbage.
  • All parallel async functions (each, eachLimit, parallel, parallelLimit) process every entry and do not return to the final function until all processing is complete, even if some entry errors before then. This avoids terrible edge-case bugs where the calling code things an asynchronous batch has finished executing (because one part of the batch terminated with error), yet some children are still running.

Example API usage (admittedly will all actually run synchronously):

const { asyncEach, asyncEachLimit, asyncParallel, asyncParallelLimit, asyncLimiter } = require('glovjs-async');
// Also valid:
//  const async = require('glovjs-async');
//  async.each(...), etc

let collection = ['foo', 'bar'];

asyncEach(collection, function (thing, next) {
  console.log(thing);
  next();
}, function (err) {
  console.log('Done');
});

asyncEachLimit(collection, 1, function (thing, next) {
  console.log(thing);
  next();
}, function (err) {
  console.log('Done');
});

let tasks = [
  function (next) {
    console.log('thing 1');
    next();
  },
  function (next) {
    console.log('thing 2');
    next();
  },
];

asyncParallel(tasks, function (err) {
  console.log('Done');
});

asyncParallelLimit(tasks, 1, function (err) {
  console.log('Done');
});

let limiter = asyncLimiter(1);
limiter(tasks[0]);
limiter(tasks[1], function (err) {
  console.log('Task 1 finished');
});
console.log('Done');

Readme

Keywords

none

Package Sidebar

Install

npm i glovjs-async

Weekly Downloads

1

Version

0.0.4

License

MIT

Unpacked Size

5.75 kB

Total Files

3

Last publish

Collaborators

  • jimbly