ysmood / yaku

A lightweight promise library
https://tonicdev.com/ysmood/yaku
MIT License
291 stars 28 forks source link

Implement Promise.try() ? #54

Closed Offirmo closed 4 years ago

Offirmo commented 6 years ago

I'm sure you know, but it's a proposal http://2ality.com/2017/08/promise-try.html and is already integrated in other Promise libs (ex. bluebird)

Would be nice to have!

ysmood commented 6 years ago

I already implemented a more abstract one called retry, please read the doc: https://github.com/ysmood/yaku#retrycountdown-span-fn-this

When you set the countdown to 1, it somehow works like Promise.try. The only difference is the error it throws is an array.

If that doesn't meet your need, I can implement one for you. BTW, you can make a PR for it, it's just lines of code. Here's the contribution guide: https://github.com/ysmood/yaku#contribution.