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

asyncmap

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asyncmap

Map array with async functions.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

JS Async Map

Map array with async functions.

Features

  • map array with async function
  • map promise which resolves to array
  • map in parallel
  • map in serial with customized step

Installation

npm i -S asyncmap

Usage

map array with async func
const results = await map([1,2,3], async (value, index) => await someAsyncFunc(value, index))
map promise which resolves to array
const results = await map(Promise.resolve([1,2,3]), async (value, index) => await someAsyncFunc(value, index))
map one by one

In the above examples, promise are resolved in parallel. However, you can easily map them one by one.

// map(1) returns another map function which maps values one by one 
const results = await map(1)([1,2,3], async (value, index) => await someAsyncFunc(value, index))
map step by step

As you guess, map can receive not only 1 as the step param. You can give any positive number as step, so within the step, values are resolved in parallel, but steps are resolved one by one.

// map(step) returns another map function which maps value step by step in serial but in parallel within the each step
const results = await map(7)(_.range(100), async (value, index) => await someAsyncFunc(value, index))

License

MIT

FAQs

Package last updated on 25 Jul 2017

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