npm install decor
0.0.2
component install nomilous/decor
0.0.2
decor
assorted function decorators
decor.deferred(fn)
- Decorates a function to be promisable
- Injects as a new first argument the promise handler (
action
) - action.
resolve()
,reject()
andnotify()
as usual from within - calling the decorated function returns the promise, availing
.then
to the caller - using q for the promising
require 'decor' promisingFunction = deferred doSomethingAsync arg1 # action.notify('50% complete') return actionreject err if err? return actionresolve res promisingFunction 'arg1' then -> # as usual # # or, more fully # promisingFunction 'arg1' then
decor.Q
- onward export of q
- so that it doesn't need to be installed twice by npm
Dev / Test
# sudo npm install ipso-cli -g
npm install
ipso -m