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

breakify

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

breakify

The opposite of promisify.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

breakify

The opposite of promisify.

Seems silly, right? Except if you're in the middle of converting a project from callbacks to promises and you don't want to try to convert a few hundred files at once, some functions will still have to return their values through callbacks despite it being promises from there on down.

Usage

const breakify  = require('breakify');

function callbackFunction(callback) {
    const wrapper = async () => {
        const someFunctionAsync = promisify(someFunction);
        const value = await someFunctionAsync();

        if (value === 0) {
            throw new Error("You can't have 0, don't you know that?");
        }

        return value;
    }

    breakify(wrapper(), callback);
}

If your promiseReturningFunction returns a value, callback is called as callback(null, value), and if it throws an error, it is called as callback(err).

Keywords

FAQs

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

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