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

now-and-later

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

now-and-later

Map over an array of values in parallel or series, passing each through the async iterator. Optionally, specify lifecycle extension points for before the iterator runs, after completion, or upon error.

  • 0.0.6
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is now-and-later?

The now-and-later npm package is designed to execute functions in a specific order, allowing for both series and parallel execution with support for mapping and iterating over collections. It provides a way to manage and coordinate asynchronous tasks, making it easier to handle complex flows in Node.js applications.

What are now-and-later's main functionalities?

Map Series

Executes an iterator function on each item in an array, in series. Each iterator is called with the item, key, and a callback function. The results are collected and passed to the final callback.

const nal = require('now-and-later');
nal.mapSeries(['a', 'b', 'c'], function(value, key, cb) {
  setTimeout(function() {
    cb(null, value.toUpperCase());
  }, 1000);
}, function(err, results) {
  console.log(results); // ['A', 'B', 'C']
});

Map

Similar to mapSeries, but executes the iterator functions in parallel. The final callback is called once all iterators have completed.

const nal = require('now-and-later');
nal.map(['a', 'b', 'c'], function(value, key, cb) {
  setTimeout(function() {
    cb(null, value.toUpperCase());
  }, 1000);
}, function(err, results) {
  console.log(results); // ['A', 'B', 'C']
});

Map Values

Executes an iterator function on each property of an object, in parallel. The iterator is called with the value, key, and a callback function. The results are collected into an object and passed to the final callback.

const nal = require('now-and-later');
const obj = { a: 1, b: 2, c: 3 };
nal.mapValues(obj, function(value, key, cb) {
  setTimeout(function() {
    cb(null, value * 2);
  }, 1000);
}, function(err, results) {
  console.log(results); // { a: 2, b: 4, c: 6 }
});

Map Values Series

Works like mapValues but executes the iterator functions in series.

const nal = require('now-and-later');
const obj = { a: 1, b: 2, c: 3 };
nal.mapValuesSeries(obj, function(value, key, cb) {
  setTimeout(function() {
    cb(null, value * 2);
  }, 1000);
}, function(err, results) {
  console.log(results); // { a: 2, b: 4, c: 6 }
});

Other packages similar to now-and-later

Keywords

FAQs

Package last updated on 01 Sep 2014

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