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

batched-promise-all

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

batched-promise-all

:flight_departure: zero deps utility for keeping your memory footprint manageable with varying datasets

  • 0.9.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
increased by875.86%
Maintainers
1
Weekly downloads
 
Created
Source

batched-promise-all

:flight_departure: zero deps utility for keeping your memory footprint manageable with varying datasets

Get started

yarn add batched-promise-all
npm i batched-promise-all

Usage

import { batchedPromiseAll } from 'batched-promise-all'

const array = ['a', 'b', 'c', 'd', 'e', 'f', 'g']

const r = await batchedPromiseAll(
  // this will be 4x slower and consume 1/4 of memory compared to the Promise.all(array.map(...))
  array,
  async (item, index) => {
    // your iterator callback-same as you would use for .map method on your array
    await delay()
    return [item, index]
  },
  2 // batch size
)

Why would you use this?

When dealing with big data sets awaiting thousands of promises at once can easily make your node.js process run out of memory-especially if you're running on small instances. Using batched-promise-all you can avoid this easily with a single import.

Keywords

FAQs

Package last updated on 15 Jul 2020

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