Socket
Socket
Sign inDemoInstall

promy

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

promy

Conditional promisify


Version published
Weekly downloads
31
increased by121.43%
Maintainers
1
Weekly downloads
 
Created
Source

promy

Conditional promisify. Transform callback-based function to callback-and-promise-based one.

Build Status NPM version

Install

npm install promy

Usage

If you have some async function getting calback as second parameter you can do something like this:

const promy = require('promy');
const fn = promy(
    require('./someAsyncCallbackBasedFunction')
);

Now promisified function can be used in two ways. It can return promise if called with only one first argument, or it can run callback if it given as second argument.

// callback way:

fn(arg, (err, res) => {
    console.log(err ? err : res);
});


//promise way:

fn(arg)
    .then((res) => console.log(res))
    .catch((err) => console.log(err));

License

MIT

Keywords

FAQs

Package last updated on 19 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