1.2.0 • Published 2 years ago

@ricokahler/pool v1.2.0

Weekly downloads
421
License
MIT
Repository
github
Last release
2 years ago

@ricokahler/pool · codecov github status checks bundlephobia semantic-release

Pool is like Promise.all but you can specify how many concurrent tasks you want at once.

Well tested. | Zero dependencies and small size.

npm i @ricokahler/pool
import pool from '@ricokahler/pool';

async function blah() {
  const texts = await pool({
    collection: [1, 2, 3, 4, 5],
    maxConcurrency: 2, // only fetch two pages at a time
    task: async (n) => {
      const response = await fetch(`/go/download/something/${n}`);
      const text = await response.text();
      return text;
    },
  });

  console.log(texts); // an array of the 5 items downloaded
}

maxConcurrency is optional. If omitted it will default to just using Promise.all with no max concurrency.

1.2.0

2 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.2-alpha.2

3 years ago

1.1.2-alpha.1

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago