Socket
Book a DemoInstallSign in
Socket

glovjs-async

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glovjs-async

GLOV.js Async Utility Library

latest
Source
npmnpm
Version
0.0.4
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

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');

FAQs

Package last updated on 03 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts