concurrent-utils
v1.0.0
Published
Generate chunks:
Downloads
6
Readme
concurrent-utils
Generate chunks:
import { getChunk } from 'concurrent-utils'
const data = // [1000 items]
for (const chunk of getChunk(data, 100)) {
console.log(chunk) // [100 items]
}
Resolve promises with max concurrent-utils
import { resolvePromises } from 'concurrent-utils'
const actions = [
() => // async action,
() => // async action,
async () => // sync action,
async () => // sync action,
]
await resolvePromises(actions, 2)
API
getChunk(data: any[], chunkSize: number)
resolvePromises(
promiseFunctions: (() => Promise<any>)[],
maxconcurrent-utils: number // default is 10
)