Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc