yuguaa-limit
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

yuguaa-limit

使用(类似p-limit)

import yLimit from "yuguaa-limit";
const foo = (value: any, delay: any) =>
  new Promise((resolve) => {
    setTimeout(() => resolve(value), delay);
  });

const limit = yLimit(2);
const arr = [
  limit(() => foo("1", 1000)),
  limit(() => foo("2", 5000)),
  limit(() => foo("3", 5000)),
  limit(() => foo("4", 5000)),
  limit(() => foo("5", 1000)),
  limit(() => foo("6", 5000)),
];
const getData = async () => {
  const res = await Promise.all(arr);
};
getData();

Readme

Keywords

Package Sidebar

Install

npm i yuguaa-limit

Weekly Downloads

2

Version

1.0.3

License

ISC

Unpacked Size

6.55 kB

Total Files

6

Last publish

Collaborators

  • yugu