npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

clamped-promise-all

v1.1.0

Published

Executes an array of promises with a max number of parallel executions.

Readme

clamped-promise-all

Executes an array of promises with a max number of parallel executions.

This library contains two functions, clampedAll which behaves similar to Promise.all, and clampedAllSettled which behaves similar to Promise.allSettled.

Useful for situations where you may only make a specified number of parallel promises at a given time, e.g. Cloudflare Workers.

Installation

npm install clamped-promise-all

Usage

  1. require or import the version you need:
const { clampedAll, clampedAllSettled } = require('clamped-promise-all');
import { clampedAll, clampedAllSettled } from 'clamped-promise-all';
  1. Pass an array of functions that return promises, along with the maximum level of parallelization:
import { clampedAll } from 'clamped-promise-all';

const apiCalls = [
    () => fetch('https://api.github.com/search/repositories?q=clamped-promise-all'),
    () => fetch('https://api.github.com/search/repositories?q=throttled-queue'),
    () => fetch('https://api.github.com/search/repositories?q=sql-where-parser'),
    () => fetch('https://api.github.com/search/repositories?q=tokenize-this'),
];
const apiResponses = await clampedAll(apiCalls, 2); // make at most 2 api calls in parallel

clampedAllSettled works in exactly the same way as clampedAll, except its behavior and return type matches Promise.allSettled, in that it will not reject if a promise rejects.

Take note

Unlike Promise.all and Promise.allSettled, clampedAll and clampedAllSettled require an array of functions that return promises, not an array of promises themselves!

Here's a typical "real-world" map example to further illustrate the difference:

import { clampedAll } from 'clamped-promise-all';

const repos = ['clamped-promise-all', 'throttled-queue', 'sql-where-parser', 'tokenize-this'];
const apiCalls = repos.map(
    (repo) => () => fetch(`https://api.github.com/search/repositories?q=${repo}`),
);
const apiResponses = await clampedAll(apiCalls, 2); // make at most 2 api calls in parallel

Note that the repo name is not mapped to the fetch call directly, but is instead mapped to a wrapper function that then invokes the fetch.

Typescript support

The package is written in Typescript and includes types by default. Both clampedAll and clampedAllSettled are generic, and in most cases will automatically use the input array's types to create it's output type.

However, you may also specify the array item type when needed:

import { clampedAll } from 'clamped-promise-all';
const apiCalls = [
  () => fetch('https://api.github.com/search/repositories?q=clamped-promise-all'),
  () => fetch('https://api.github.com/search/repositories?q=throttled-queue'),
  () => fetch('https://api.github.com/search/repositories?q=sql-where-parser'),
  () => fetch('https://api.github.com/search/repositories?q=tokenize-this'),
];
const apiResponses = await clampedAll<GithubSearchResponse>(apiCalls, 2); // apiResponses is now typed as GithubSearchResponse[]