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 - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

6

breakify.js

@@ -11,7 +11,11 @@ /**

callback(null, value);
// If there's an error, first run the callback to continue the original error logic
}).catch((err) => {
callback(err);
});
// Then catch it again and log it to console to prevent unhandled promise rejections.
}).catch((err) => {
console.log(err);
})
}
module.exports = breakify;

2

package.json
{
"name": "breakify",
"version": "1.0.0",
"version": "1.0.1",
"description": "The opposite of promisify.",

@@ -5,0 +5,0 @@ "main": "breakify.js",

# 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)`.
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