Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

glov-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

glov-async

GLOV.js Async Utility Library

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
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 thinks 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('glov-async');
// Also valid:
//  const async = require('glov-async');
//  async.each(...), etc

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

asyncEach(collection, function (thing, next) {
  console.log(thing);
  next(null, 'baz');
}, function (err, results) {
  console.log('Done', results); // prints Done ['baz', 'baz']
});

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

Keywords

FAQs

Package last updated on 17 Aug 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc