Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow not to copy/paste throwOnTimeout #214

Open
IlyaSemenov opened this issue Nov 19, 2024 · 0 comments
Open

Allow not to copy/paste throwOnTimeout #214

IlyaSemenov opened this issue Nov 19, 2024 · 0 comments

Comments

@IlyaSemenov
Copy link

IlyaSemenov commented Nov 19, 2024

Currently, user must always copy/paste { throwOnTimeout: true } in each and every .add() call otherwise they end up with void in their typings:

import Queue from "p-queue"

const queue = new Queue({
  concurrency: 1,
  interval: 1500,
  intervalCap: 1,
  throwOnTimeout: true, // regardless of this
})

// typed as number | void 
const value1 = await queue.add(async () => 123)

// typed as number
const value2 = await queue.add(async () => 123, { throwOnTimeout: true })

Can we please have some way to reduce this boilerplate? Either extend class typings to lookup the init options, or add a shortcut method such as queue.execute (?) which will do { throwOnTimeout: true } on its own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant