1.0.3 • Published 1 year ago

yuguaa-limit v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

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();
1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago