deno.land / x / rambda@v9.1.1 / source / mapParallelAsyncWithLimit.js

mapParallelAsyncWithLimit.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { mapParallelAsync, mapParallelAsyncFn } from './mapParallelAsync.js'import { splitEvery } from './splitEvery.js'
async function mapParallelAsyncWithLimitFn( iterable, limit, list){ if (list.length < limit) return mapParallelAsync(iterable, list)
const slices = splitEvery(limit, list)
let toReturn = [] for (const slice of slices){ const iterableResult = await mapParallelAsyncFn(iterable, slice) toReturn = [ ...toReturn, ...iterableResult ] }
return toReturn}
export function mapParallelAsyncWithLimit( iterable, limit, list){ if (arguments.length === 2){ return async _list => mapParallelAsyncWithLimitFn( iterable, limit, _list ) }
return new Promise((resolve, reject) => { mapParallelAsyncWithLimitFn( iterable, limit, list ) .then(resolve) .catch(reject) })}
rambda

Version Info

Tagged at
2 months ago