@kojiro.ueda/promise-pool
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

promise-pool

PromisePool creates a pool that limits the number of concurrent JavaScript operations using Promise.

how to use

import { PromisePool } from "https://deno.land/x/promise_pool@0.0.3/index.ts";

const pool = new PromisePool({ concurrency: 2 /* default 1 */ });

await Promise.all([
  pool.open(async () => {
    console.log("running 1")
    // some async process.
  }),
  pool.open(async () => {
    console.log("running 2")
    // some async process.
  }),
  pool.open(async () => {
    console.log("running 3")
    // some async process.
  }),
  pool.open(async () => {
    // some async process.
    console.log("running 4")
  }),
]);

console.log("done!")

Readme

Keywords

none

Package Sidebar

Install

npm i @kojiro.ueda/promise-pool

Weekly Downloads

1

Version

0.0.4

License

MIT

Unpacked Size

11.2 kB

Total Files

27

Last publish

Collaborators

  • kojiro.ueda