Skip to content

th3rius/paralysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Paralysis

Maps over promises concurrently.

import parallel from "paralysis";

const ids = [1, 2, 3, 4, 5];
const concurrency = 2;

async function getUser(id) {
  const response = await fetch(
    `https://jsonplaceholder.typicode.com/users/${id}`,
  );
  const user = await response.json();
  return user;
}

const users = await parallel(ids, getUser, concurrency);

This is similar to Promise.all(), but accepts an optional concurrency limit.

About

Map over promises concurrently

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published