Instapromise
instapromise
Promisify with
.promise
instapromise
lets you promisify node-style asynchronous functions by putting a .promise
after them or after the object for methods.
It's a part of exponent and this module is influenced from fibrous.
When one of the maintainers of instapromise
was questioned about why the code was in coffeescript :
There’s basically two reasons for that:
It’s based on some of the work the people who made fibrous did and they wrote their stuff in coffeescript
I used to write a bunch of coffeescript before babel made it reasonable to write ES7+ stuff
I wrote it back then, its pretty stable now.
I haven’t made any changes to it in months so I don’t think it should be necessary to modify the source too much.
Also I do like the way that its commented fairly well.
Get it: npm install --save instapromise
Usage:
1 2 |
|
Basically, instapromise
is one of it's kind a module that is cheeky, tiny and takes a diffrenet apporach on promisifying async functions,
you need to just require('instapromise')
and then you could just use a .promise
!
1 2 3 4 |
|
P.S: The original function is available as a property on the promise-generating function .___instapromiseOriginalFunction___
GIF FTW!
Thanks to James Ide and Charlie Cheever for instapromise!