Socket
Socket
Sign inDemoInstall

async-method

Package Overview
Dependencies
28
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    async-method

Makes async methods work with callbacks and promises


Version published
Maintainers
1
Install size
960 kB
Created

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 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