SGrondin / bottleneck

Job scheduler and rate limiter, supports Clustering
MIT License
1.82k stars 75 forks source link

Allow failed event handler to return Promise<void> or number #126

Closed dobesv closed 5 years ago

dobesv commented 5 years ago

The type for the failed event only allowed you to return a Promise<number> or void. However, you might want to return a number synchronously, or return void asynchronously. This change allows those other cases in the failed event handler.

SGrondin commented 5 years ago

Yes, this was an oversight on my part. Thank you for fixing it 👍

I applied your change to the EJS file bottleneck.d.ts.ejs as it generates the bottleneck.d.ts.ejs file. I also added a few typings tests in test.ts and finally allowed users to return null (sync and async). https://github.com/SGrondin/bottleneck/commit/712db2f736fd243bf262760e053714acb5535ead

It's been released in v2.19.1 🎉 https://github.com/SGrondin/bottleneck/releases/tag/v2.19.1

Thank you for your contribution!