You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

async-method

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-method

Makes async methods work with callbacks and promises


Version published
Weekly downloads
549
decreased by-20.55%
Maintainers
1
Install size
960 kB
Created
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

Package last updated on 06 Aug 2018

Did you know?

Socket

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc