Hello, I'd like to propose introducing a limit.with API to streamline the process of creating limited functions with Array.prototype.map()
Current API:
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)))
)
Proposed API:
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
Hello, I'd like to propose introducing a
limit.with
API to streamline the process of creating limited functions withArray.prototype.map()
Current API:
Proposed API:
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