New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

async-each-map

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-each-map

Dependency free async each, map, and reduce written in ES6 package for Node.js

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
46
increased by253.85%
Maintainers
1
Weekly downloads
 
Created
Source

Async; Each, Map, Reduce

Build status Codacy NPM downloads NPM version Node version Dependency status

Efficient, light wegith, dependency free NPM package for doing asyncronous each, map, and reduce operations in Node.js.

Requirements

  • Node.JS >= v4.0.0

Install

$ npm install async-each-map --save

Usage

const each = require('async-each-map');

each(array, iterator, [callback])

Applies the iterator function to each item in array, in sequence and in order. The iterator is called with an item from the list, and a next function for when it has finished. If the iterator passes an error to the next function, the callback is immediately called with the error.

Arguments
  • array - An array to iterate over.
  • iterator(item, next) - A function to apply to each item in arr. The iterator is passed a callback(err) which must be called once it has completed. If no error has occurred, the callback should be run without arguments or with an explicit null argument. The array index is not passed to the iterator.
  • callback(error, array) - Optional A callback which is called when all iterator functions have finished, or an error occurs. When using the map functionality a second parameter is provided.
Examples
each([3, 6, 2, 9], (item, next) => {
  some.async.operation(item, error => {
    next(error);
  });
}, error => {
  if (error) { throw error; }

  console.log('Done!');
});

Map

each(['/some/file1', '/some/file2', '/some/file3'], fs.readFile, (error, files) => {
  if (error) { throw error; }

  for (const content in files) {
    console.log(content);
  }
})

Reduce

each(['/some/file1', '/some/file2', '/some/file3'], fs.exists, (error, files) => {
  if (error) { throw error; }

  for (const file in files) {
    console.log(`${file} exists`);
  }
});

MIT Licensed

Keywords

FAQs

Package last updated on 31 May 2016

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