Comparing version 1.0.0 to 1.1.0
@@ -15,1 +15,3 @@ module.exports = function onError (errHandler, options, cb) { | ||
} | ||
module.exports.emit = require('emit-error') |
{ | ||
"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') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15110
56
111
1
+ Addedemit-error@^2.0.0
+ Addedemit-error@2.0.0(transitive)