Bluebird style spread for ES6 promise
Sep 9, 2016
I like Bluebird as a Promise library because of its speed and features. One of the feature that use a lot is spread
that make it easier when handling with array-returning function in a promise chain. But ES6 promise doesn’t have spread
, so what do you do when you need spread
while using ES6 promise?
It turn out quite easy to have a pretty similar feature with spread
in ES6, you just need to write a little helper function like this:
1 | function spread (callback) { |
And you use it like this:
1 | new Promise((resolve, reject) => { |
What other Bluebird feature that you miss when using ES6 promise?