es-nodeify
Simple extension to ECMAScript 2015 (ES6) promises. It provides Promise
with a nodeify()
prototype function, similar to what various promise libraries offer.
It gives your library's promise-based asynchronous functions a way to handle an optional callback function(error, result)
parameter, effectively turning it into a classic Node.js style asynchronous function. When the callback is omitted, it returns a Promise
, as if nodeify()
was never called.
Please note that es-nodeify (as the prefix suggests) works with the ECMAScript 2015 Promise
prototype only. Either make sure you're using native ECMAScript 2015, or use a compliant Promise library.
Installation
Install with npm:
npm install --save es-nodeify
Usage
; module { return { // ... };};
You can then use the above module in 2 ways:
let someFunction = ; ; ;
License
Published under the MIT License.