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

on-error

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

on-error - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

2

index.js

@@ -15,1 +15,3 @@ module.exports = function onError (errHandler, options, cb) {

}
module.exports.emit = require('emit-error')

5

package.json
{
"name": "on-error",
"version": "1.0.0",
"version": "1.1.0",
"description": "Execute error handler instead of, or in addition to callback, when 1st callback argument is truthy",

@@ -55,3 +55,6 @@ "main": "index.js",

]
},
"dependencies": {
"emit-error": "^2.0.0"
}
}

@@ -8,3 +8,4 @@ # on-error

Execute error handler instead of, or in addition to callback, when 1st callback argument is truthy
Handle callback errors by executing an error handler function, or emitting the error, instead of or in
addition to executing the callback.

@@ -23,3 +24,6 @@ ## example

}
```
Using error handler function:
```
function handleIt (err) {

@@ -44,2 +48,14 @@ console.error(err)

Using emitter:
```
var EventEmitter = require('events').EventEmitter
var emitter = new EventEmitter().on('error', function (err) {
console.error(err)
})
fail(onError.emit(emitter, function (status) {
console.log('will not see this')
}))
```
## api

@@ -67,3 +83,8 @@

### var wrappedCb = onError.emit(emitter [, options, cb])
Same behaviour as above, except errors will be emitted to `emitter` instead of passed to an error handler
function. All other options and arguments are the same.
## testing

@@ -70,0 +91,0 @@

@@ -15,2 +15,3 @@ var test = require('tape'),

t.equal(typeof onError.emit, 'function', '.emit should be a function')
t.notOk(onError(handleIt, callback)(new Error('error 1')), 'should return undefined on error without alwaysCall')

@@ -17,0 +18,0 @@ t.deepEqual(onError(handleIt, {alwaysCall:true}, callback)(new Error('error 2')), [new Error('error 2')], 'should return args on error with alwaysCall')

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