Hello, I'd like to propose introducing a limit.with
API to streamline the process of creating limited functions with Array.prototype.map()
const limit = pLimit(5)
// With inline function
await Promise.all(
items.map(item => limit(async () => {
await process(item)
}))
)
// With function declaration
async function processItem(item) {
await process(item)
}
await Promise.all(
items.map(item => limit(() => processItem(item)))
)
const limit = pLimit(5)
// With inline function
await Promise.all(
items.map(limit.with(async item => {
await process(item)
}))
)
// With function declaration
async function processItem(item) {
await process(item)
}
await Promise.all(
items.map(limit.with(processItem))
)
While the difference is subtle, the intention is to remove some boilerplate and improve readability. I put together a POC here and am happy to follow up with documentation, any API/naming/etc changes, and opening a PR
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too