Socket
Socket
Sign inDemoInstall

decor

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    decor

assorted function decorators


Version published
Weekly downloads
6
increased by200%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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() and notify() as usual from within
  • calling the decorated function returns the promise, availing .then to the caller
  • using q for the promising

{deferred} = require 'decor'

promisingFunction = deferred (action, arg1, argN) -> 
    
    doSomethingAsync arg1, (err, res) -> 

        # action.notify('50% complete')
        return action.reject err if err?
        return action.resolve res


promisingFunction( 'arg1' ).then -> # as usual

#
# or, more fully
#

promisingFunction( 'arg1' ).then(

    (result) -> 
    (error)  -> 
    (notify) -> 

)

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

FAQs

Last updated on 24 Dec 2013

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc