Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
var fs = require('fs');
fs.stat('some/file.js', function(err, result) {
if(err) {
//do stuff, or throw
return;
}
//do success stuff
});
There are two ways you can use outcome.js:
var onOutcome = outcome().result(function() {
console.log('result');
}).error(function() {
console.log('error');
});
fs.stat(__filename, onOutcome);
Or
outcome.call(fs.stat, __filename).result(function() {
console.log("RESULT");
}).error(function() {
console.log("ERROR");
})
listenersOrEm
- listeners or eventEmittervar em = new EventEmitter();
em.on('result', function() {
console.log("RESULT");
});
fs.stat(__filename, outcome(em));
Or
var onOutcome = outcome({
result: function() {
console.log("RESULT");
},
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.
});
fs.stat(outcome({
result: function(){}
}));
Calls the given function
fn
- target function to be calledtarget
- target scope - for this
outcome.call(fs.stat, null, fs).on({
error: function() { },
result: function() { }
});
//or
outcome.call(fs.stat, fs, {
error: function() { },
result: function() { }
})
Listens for any events emitted by outcome - primarily unhandledError
typeOrEvent
- type of event (string), or object of eventscallback
- callback for the listeneroutcome.on('unhandledError', function() {
//DO STUFF
});
Listens to the given event emitter.
outcome.listen(em).on({
someEvent: function(){}
});
//or
outcome.listen(em, {
someEvent: function(){}
});
Pipes events to target event emitter
outcome.call(fs.stat).emit(em);
Called when on error/result:
outcome.call(fs.stat, {
result: function() {
}
}).done(function(err, result) {
});
Called on success/result
outcome.call(fs.stat).result(function(result) {
});
Called on error
outcome.call(fs.stat).error(function(err) {
//handle error
});
Same as as above
Listens for results - error
, and result
primarily.
typeOrEvent
- type of event (string), or object of eventscallback
- callback for the listeneroutcome.call(fs.stat).on('error', function() {
}).on('result', function() {
});
//or
outcome.call(fs.stat).on({
error: function() {},
result: function() {}
})
FAQs
DRY error handling
The npm package outcome receives a total of 6,906 weekly downloads. As such, outcome popularity was classified as popular.
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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
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.