P - Toolkit for managing multiple promises

Overview

@antfu/p

NPM version

Toolkit for managing multiple promises.

Without
const items = [1, 2, 3, 4, 5]

(await Promise.all(items
  .map(async i => {
    const v = await multiply(i, 3)
    const even = await isEven(v)
    return [even, v]
  })))
    .filter(x => x[0])
    .map(x => x[1])
import P from '@antfu/p'

const items = [1, 2, 3, 4, 5]

await P(items)
  .map(async i => await multiply(i, 3))
  .filter(async i => await isEven(i))
// [6, 12]
import P from '@antfu/p'

const p = P()

// collect promises that are not necessarily needed to be resolved right away
p.add(promiseTask1)

someOtherTasks()

p.add(promiseTask2)
p.add(promiseTask3)

// resolve all collected promises
await p
// => Promise.all([promiseTask1, promiseTask2, promiseTask3])
import P from '@antfu/p'

// limits the number of concurrent tasks
await P(myTasks, { concurrency: 5 })

Sponsors

License

MIT License © 2021 Anthony Fu

You might also like...

Write JSX-driven components with functions, promises and generators.

Crank.js Write JSX-driven components with functions, promises and generators. Documentation is available at crank.js.org. Crank.js is in a beta phase,

Jan 1, 2023

:hourglass_flowing_sand: A higher order component for loading components with promises.

:hourglass_flowing_sand: A higher order component for loading components with promises.

A higher order component for loading components with dynamic imports. Install yarn add react-loadable Example import Loadable from 'react-loadable'; i

Jan 3, 2023

A solid, fast Promises/A+ and when() implementation, plus other async goodies.

when.js When.js is a rock solid, battle-tested Promises/A+ and when() implementation, including a complete ES6 Promise shim. It's a powerful combinati

Dec 18, 2022

The ultimate generator based flow-control goodness for nodejs (supports thunks, promises, etc)

co Generator based control flow goodness for nodejs and the browser, using promises, letting you write non-blocking code in a nice-ish way. Co v4 co@4

Jan 2, 2023

Map over promises concurrently

p-map Map over promises concurrently Useful when you need to run promise-returning & async functions multiple times with different inputs concurrently

Dec 31, 2022

Helps you write libraries that accept both promises and callbacks.

What is it? promise-breaker makes it easy to write functions that will accept an optional callback, or return a Promise if a callback is not provided.

Aug 11, 2022

Run async code one after another by scheduling promises.

promise-scheduler Run async code in a synchronous order by scheduling promises, with the possibility to cancel pending or active tasks. Optimized for

Dec 17, 2021

Resolve parallel promises in key-value pairs whilst maintaining type information

async-kv Resolves promises in key-value pairs maintaining type information. Prerequisites NodeJS 12 or later Installation npm i async-kv yarn add asyn

Feb 17, 2022

🐶 Learn JS Promises, with your friend 👑 Princess!

🐶 Learn JS Promises, with your friend 👑 Princess!

Jun 9, 2022

Converts an iterable, iterable of Promises, or async iterable into a Promise of an Array.

iterate-all A utility function that converts any of these: IterableT IterablePromiseT AsyncIterableT AsyncIterablePromiseT Into this: Prom

Jun 7, 2022

Ajax library with XHR2, promises and request limit

qwest 4.5.0 ⚠ I finally decided to archive this repository. ⚠ At first, I developed Qwest because at the time other libraries were lacking of a proper

Sep 14, 2022

A request library that returns promises, inspired by request

then-request A request library that returns promises and supports both browsers and node.js Installation npm install then-request Usage request(metho

Nov 29, 2022

A polyfill for ES6-style Promises

ES6-Promise (subset of rsvp.js) This is a polyfill of the ES6 Promise. The implementation is a subset of rsvp.js extracted by @jakearchibald, if you'r

Dec 28, 2022

A Promise-compatible abstraction that defers resolving/rejecting promises to another closure.

Deferred Promise The DeferredPromise class is a Promise-compatible abstraction that defers resolving/rejecting promises to another closure. This class

Dec 15, 2022

Remembering promises that were made!

remember-promise A simple utility to remember promises that were made! It is greatly inspired by the p-memoize utility but with additional built-in fe

Dec 15, 2022

A small utility for managing an undo stack

svelte-undo A small utility for managing an undo stack, that you can subscribe to in your Svelte applications (or indeed anywhere else). Demo here. Us

Dec 21, 2022

🚀 The ultimate library for managing multi-channel notifications with a single API.

🚀 The ultimate library for managing multi-channel notifications with a single API.

🚀 The ultimate library for managing multi-channel notifications with a single API.

Jan 4, 2023

A dashboard for managing orders and inventory for a wordpress e-commerce site which has woo commerce plugin installed

A dashboard for managing orders and inventory for a wordpress e-commerce site which has woo commerce plugin installed

WordPressWooCommerceDashboard - A dashboard for managing orders and inventory for a wordpress e-commerce site which has woo commerce plugin installed. This program provides shipping tracking for Delhivery.

Jan 3, 2022

A powerful little tool for managing CSS animations

NO LONGER BEING SUPPORTED Please consider https://github.com/ThrivingKings/animo instead animo.js A powerful little tool for managing CSS animations.

Jan 2, 2023
Releases(v0.1.0)
Owner
Anthony Fu
A ship in harbor is safe, but that is not what ships are built for.
Anthony Fu
The ultimate generator based flow-control goodness for nodejs (supports thunks, promises, etc)

co Generator based control flow goodness for nodejs and the browser, using promises, letting you write non-blocking code in a nice-ish way. Co v4 co@4

TJ Holowaychuk 11.8k Jan 2, 2023
Map over promises concurrently

p-map Map over promises concurrently Useful when you need to run promise-returning & async functions multiple times with different inputs concurrently

Sindre Sorhus 929 Dec 31, 2022
Helps you write libraries that accept both promises and callbacks.

What is it? promise-breaker makes it easy to write functions that will accept an optional callback, or return a Promise if a callback is not provided.

Jason Walton 83 Aug 11, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
🔥 Dreamy-db - A Powerful database for storing, accessing, and managing multiple database.

Dreamy-db About Dreamy-db - A Powerful database for storing, accessing, and managing multiple databases. A powerful node.js module that allows you to

Dreamy Developer 24 Dec 22, 2022
A simple to-do app for managing daily tasks built with Webpack, JavaScript, HTML, and CSS with the functionality to manipulate multiple completed tasks and store them to local storage.

TODO LIST APP In this project, I have built a simple HTML list of To Do tasks. The list is styled according to the listed specifications . This simple

Selma Belhadj 8 Jun 7, 2022
True P2P concept for your p2p powered website/app/client. MSC/MEP (Multiple Strategy Concept/Multiple Entry Points)

TRUE P2P CONCEPT - Lets redecentralize the web This repo is just conceptual. Active development of the endproduct (TRUE P2P) happens here https://gith

Bo 6 Mar 29, 2022
⚡🚀 Call multiple view functions, from multiple Smart Contracts, in a single RPC query!

ethers-multicall ⚡ ?? Call multiple view functions, from multiple Smart Contracts, in a single RPC query! Querying an RPC endpoint can be very costly

Morpho Labs 20 Dec 30, 2022