Powerful promise utils collections
Install
yarn add mighty-promise
# or
npm i mighty-promise
Use
import {Progressive} from 'mighty-promise'
import {Progressive} from 'https://deno.land/x/mighty_promise@v0.0.6/mod.ts'
map
can split a large task on arr
to several small tasks. It can be used to prevent heavy calculation from blocking the thread.
option
definition
interface ProgressiveOptions {
// in ms
minInterval?: number;
// in ms
maxExecutionDuration?: number;
useIdleCallback?: boolean;
}
import {map} from 'mighty-promise'
async function tasks(taskInfo: string[]) {
map(tasks, task => {
runTask(task);
}, {maxExecutionDuration: 10})
}
It is the same as map
, but the output is ignored.