typed-promisify
Typescript promise helpers: promisify(), map(), and _try(). You will need ES6 promises. These helpers preserve types in the promises, enabling better typechecking and VS Code intellisense:
API
;
promisify(fn)
Convert a node style callback function to one returning a promise.
Example:
; stat'test.txt' .thenconsole.logstats;
map(elts, fn)
Promise aware map.
Elts can be a promise for an array, an array of promises, or a promise for an array of promises. Fn can be synchronous or return a promise.
Returns a promises that resolves when all applied promises resolve (similar to Promise.all).
Example:
;; tp.mapelts, stat .thenconsole.logstats;
_try(fn, arg1, arg2...)
Call a synchronous function to kick off a promise chain.
Example:
tp._tryfs.writeFileSync, 'test.txt', 'hello world' .then .thenconsole.log'sucess' .catchconsole.log'failure';