Socket
Book a DemoInstallSign in
Socket

callback2promise

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callback2promise

converts nodejs style callback functions to promise

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
16
-15.79%
Maintainers
1
Weekly downloads
 
Created
Source

callback2promise

Converts functions with node style callbacks to promise (es6)

installation

npm install callback2promise --save

usage


var c2p = require('callback2promise');

// ordinary function with any number of parameters and a callback at the end
var nodeStyleFunc = function(param1, param2, callback){
  setTimeout(
    function(){ 
      callback(null, 'done') 
    }, 200);
}

// convert the function to a promise
var promise = c2p(nodeStyleFunc)(param1, param2);

promise
  .then(result => console.log(result))
  .catch(err => console.log(err));

Keywords

convert

FAQs

Package last updated on 25 May 2017

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