Ƭ Task<T
>: () => Promise
<T
>
Name |
---|
T |
▸ (): Promise
<T
>
A Task is a nullary function that returns a promise
Promise
<T
>
▸ throttleAll<T
>(limit
, tasks
): Promise
<T
[]>
Run tasks with limited concurency.
example
const task1 = () => new Promise((resolve) => {
setTimeout(resolve, 100, 1);
});
const task2 = () => Promise.resolve(2);
throttleAll(1, [task1, task2])
.then((values) => { console.log(values) });
// task2 will run after task1 finishes
// logs: `[1, 2]`
Name |
---|
T |
Name | Type | Description |
---|---|---|
limit |
number |
Limit of tasks that run at once. |
tasks |
Task <T >[] |
List of tasks to run. |
Promise
<T
[]>
A promise that fulfills to an array of the results of the input promises or rejects immediately upon any of the input tasks rejecting.