Transforms Node.js-style callback-based function into a Promise-based.
This implementation is TypeScript-friendly.
Returns a function that will wrap the given
of taking a callback, the returned function will return a promise whose
fate is decided by the callback behavior of the given node function.
The node function should conform to node.js convention of accepting
a callback as last argument and calling that callback with error
as the first argument and success value on the second argument.
nodeFunction calls its callback with multiple success values,
the fulfillment value will be the first fulfillment item.
true means the resulting promise will always
fulfill with an array of the callback's success value(s). This is needed
because promises only support a single success value while some callback
API's have multiple success value. The default is to ignore all but
the first success value of a callback function.
If you pass a
nodeFunction will be called as a method
npm install --save ts-pfy
;;;readFile 'test.txt' .thenvalue.byteLength ;
this context to use with function.
Should multiple arguments be returned as an array?
false only a first argument are returned in Promise.