Skip to content

Commit

Permalink
refactor(parallel): use clamp to simplify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
MarlonPassos-git authored and aleclarson committed Dec 1, 2024
1 parent 0d0e678 commit 952a9dd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/async/parallel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
AggregateError,
clamp,
flat,
fork,
isNumber,
Expand Down Expand Up @@ -99,7 +100,7 @@ export async function parallel<T, K>(
}

const queues = Promise.all(
list(1, Math.min(Math.max(options.limit, 1), array.length)).map(
list(1, clamp(options.limit, 1, array.length)).map(
() => new Promise(processor),
),
)
Expand Down

0 comments on commit 952a9dd

Please sign in to comment.