Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

async-method

Package Overview
Dependencies
2
Maintainers
1
Versions
2
Issues
File Explorer

Advanced tools

async-method

Makes async methods work with callbacks and promises

    1.0.0latest
    GitHub

Version published
Maintainers
1
Weekly downloads
602
decreased by-21.61%

Weekly downloads

Readme

Source

async-method

Makes async methods work with callbacks and promises. You have a function on your class that expects a callback as last parameter? Wrap it using the asyncMethod and it returns a promise if the callback is omitted.

installation

npm i async-method

build status

Build Status

usage

// create a class var MyClass = new Class({ multiply: asyncMethod(function(a, b, callback) { process.nextTick(function() { callback(null, a*b); }); }) }); var myClassInstance = new MyClass(); // classic callback myClassInstance.multiply(3, 5, function(err, result) { }); // es6 promise myClassInstance.multiply(3, 5).then(function(result) { }).catch(function(err) { });

Keywords

FAQs

Last updated on 06 Aug 2018

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • 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