Git Product home page Git Product logo

pool's Introduction

@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.

pool's People

Contributors

evantrimboli avatar renovate-bot avatar renovate[bot] avatar ricokahler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pool's Issues

Repo overhaul

This is a todo item for myself to switch to microbundle and publish with semantic release

Feature request: make it possible to abort tasks.

Use case:
Long running processes that can be aborted by the user.

Considerations:

  • cancel in progress promise
  • clear the queue
  • would possibly be a breaking change to the interface (not sure) but would be handy.
    • maybe accepting a cancel token is also ok

Version 1.1.1 - cannot find module '@ricokahler/pool'

Upgrade from version 1.0.0 to version 1.1.1 is obviously a breaking change.

Version 1.1.1 on NodeJS 14.15.4 produces the error
Cannot find module '@ricokahler/pool'"

Please use 2.x as new version or revert breaking change.

Unfortunately I could not find updated documentation which describes migration path or how to upgrade.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): update dependency @babel/preset-env to v7.23.8
  • chore(deps): update dependency semantic-release to v22.0.12
  • chore(deps): update typescript-eslint monorepo to v6.19.0 (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • chore(deps): update dependency semantic-release to v23

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/release.yml
  • actions/checkout v2
  • actions/setup-node v2
  • codecov/codecov-action v2
.github/workflows/test.yml
  • actions/checkout v2
  • actions/setup-node v2
  • codecov/codecov-action v2
npm
package.json
  • @babel/core 7.23.7
  • @babel/preset-env 7.23.7
  • @babel/preset-typescript 7.23.3
  • @rollup/plugin-babel 5.3.1
  • @rollup/plugin-node-resolve 13.3.0
  • @types/jest 29.5.11
  • @typescript-eslint/eslint-plugin 6.13.1
  • @typescript-eslint/parser 6.13.1
  • eslint 8.24.0
  • jest 29.7.0
  • prettier 2.7.1
  • regenerator-runtime 0.13.9
  • rollup 2.79.1
  • semantic-release 22.0.8
  • typescript 4.8.4

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.