Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
var fs = require('fs');
fs.stat('some/file.js', function(err, data) {
if(err) {
//do stuff, or throw
return;
}
//do success stuff
});
listeners
- success, or error
var resultHandler = outcome.error(function(err) {
console.log(err);
});
//success
fs.stat(__filename, resultHandler.copy().success(function(data) {
//do stuff
}));
//success
fs.stat(__filename, resultHandler.copy().success(function(data) {
//do stuff
}));
//this fails - error is passed to above func
fs.stat('s'+__filename, resultHandler.copy().success(function(data) {
//do stuff
}));
Or
var onOutcome = outcome({
success: function() {
console.log("SUCCESS");
},
error: function() {
console.log("ERROR");
}
});
fs.stat(__filename, onOutcome);
By default, any unhandled errors are thrown. To get around this, you'll need to listen for an unhandledError
:
outcome.on('unhandledError', function(error) {
//report bugs here..., then throw again.
});
//fails
fs.stat('s'+__filename, outcome({
success: function(){}
}));
Copies the current call chain. Useful for using one error handler, and many result handlers. See first example.
Called when on error/success. Same as function(err, data) { }
fs.stat(__filename, outcome.error(function(err) {
//handle error
}).success(function(data) {
//handle result
}.done(function(err, result) {
//called on fn complete
});
Called on success
var onOutcome = outcome.success(function(data) {
});
onOutcome(null, "success!");
Called on error
var onOutcome = outcome.error(function(err) {
});
onOutcome(new Error("ERR"));
Custom response handler
outcome.handle(function(response) {
if(response.errors) this.error(response);
if(response.data) this.success(response);
});
FAQs
DRY error handling
We found that outcome demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.