| var test = require('tape'), | ||
| EventEmitter = require('events').EventEmitter, | ||
| onError = require('..') | ||
| test('on-error().alwaysWithError', function (t) { | ||
| var h = function errHandler () {} | ||
| t.equal(typeof onError(h).alwaysWithError, 'function', 'should be a function') | ||
| t.throws(onError(h).alwaysWithError, 'requires a callback') | ||
| test('when passed an error', function (t) { | ||
| var emitter = new EventEmitter, | ||
| emits = [], | ||
| otherCalls = [] | ||
| emitter.on('error', function (err) { | ||
| emits.push(err) | ||
| }) | ||
| function otherHandler () { | ||
| var args = Array.prototype.slice.call(arguments, 0) | ||
| otherCalls.push(args) | ||
| return true | ||
| } | ||
| var anError = new Error('error 1'), | ||
| handler = onError.emit(emitter).alwaysWithError(otherHandler) | ||
| t.equals(handler(anError, 5, 10), true, 'should return true') | ||
| t.equal(emits.length, 1, 'should invoke error handler') | ||
| t.equal(otherCalls.length, 1, 'should invoke always handler') | ||
| t.equal(emits[0], anError, 'should pass error to emitter') | ||
| t.deepEqual(otherCalls[0], [anError, 5, 10], 'should pass all args to always handler') | ||
| t.end() | ||
| }) | ||
| test('when passed no error', function (t) { | ||
| var emitter = new EventEmitter, | ||
| emits = [], | ||
| otherCalls = [] | ||
| emitter.on('error', function (err) { | ||
| emits.push(err) | ||
| }) | ||
| function otherHandler () { | ||
| var args = Array.prototype.slice.call(arguments, 0) | ||
| otherCalls.push(args) | ||
| return true | ||
| } | ||
| var handler = onError.emit(emitter).alwaysWithError(otherHandler) | ||
| t.equals(handler(null, 5, 10), true, 'should return true') | ||
| t.equal(emits.length, 0, 'should not invoke error handler') | ||
| t.equal(otherCalls.length, 1, 'should invoke always handler') | ||
| t.deepEqual(otherCalls[0], [null, 5, 10], 'should pass all args to always handler') | ||
| t.end() | ||
| }) | ||
| t.end() | ||
| }) |
+53
| var test = require('tape'), | ||
| EventEmitter = require('events').EventEmitter, | ||
| onError = require('..') | ||
| test('on-error().always', function (t) { | ||
| var h = function errHandler () {} | ||
| t.equal(typeof onError(h).always, 'function', 'should be a function') | ||
| t.throws(onError(h).always, 'requires a callback') | ||
| test('when passed an error', function (t) { | ||
| var emitter = new EventEmitter, | ||
| emits = [], | ||
| otherCalls = [] | ||
| emitter.on('error', function (err) { | ||
| emits.push(err) | ||
| }) | ||
| function otherHandler () { | ||
| var args = Array.prototype.slice.call(arguments, 0) | ||
| otherCalls.push(args) | ||
| return true | ||
| } | ||
| var anError = new Error('error 1'), | ||
| handler = onError.emit(emitter).always(otherHandler) | ||
| t.equals(handler(anError, 5, 10), true, 'should return true') | ||
| t.equal(emits.length, 1, 'should invoke error handler') | ||
| t.equal(otherCalls.length, 1, 'should invoke always handler') | ||
| t.equal(emits[0], anError, 'should pass error to emitter') | ||
| t.deepEqual(otherCalls[0], [5, 10], 'should pass non-error args to always handler') | ||
| t.end() | ||
| }) | ||
| test('when passed no error', function (t) { | ||
| var emitter = new EventEmitter, | ||
| emits = [], | ||
| otherCalls = [] | ||
| emitter.on('error', function (err) { | ||
| emits.push(err) | ||
| }) | ||
| function otherHandler () { | ||
| var args = Array.prototype.slice.call(arguments, 0) | ||
| otherCalls.push(args) | ||
| return true | ||
| } | ||
| var handler = onError.emit(emitter).always(otherHandler) | ||
| t.equals(handler(null, 5, 10), true, 'should return true') | ||
| t.equal(emits.length, 0, 'should not invoke error handler') | ||
| t.equal(otherCalls.length, 1, 'should invoke always handler') | ||
| t.deepEqual(otherCalls[0], [5, 10], 'should pass non-error args to always handler') | ||
| t.end() | ||
| }) | ||
| t.end() | ||
| }) |
+37
| var test = require('tape'), | ||
| EventEmitter = require('events').EventEmitter, | ||
| onError = require('..') | ||
| test('on-error.emit', function (t) { | ||
| var emitter = new EventEmitter | ||
| t.equal(typeof onError.emit, 'function', 'should be a function') | ||
| t.throws(onError.emit, 'should require an emitter') | ||
| t.ok(typeof onError.emit(emitter) === 'function', 'should return a function') | ||
| test('when passed an error', function (t) { | ||
| var emitter = new EventEmitter, | ||
| emits = [] | ||
| emitter.on('error', function (err) { | ||
| emits.push(err) | ||
| }) | ||
| var anError = new Error('error 1') | ||
| t.notOk(onError.emit(emitter)(anError), 'should return undefined') | ||
| t.equal(emits.length, 1, 'should emit') | ||
| t.equal(emits[0], anError, 'should emit given error') | ||
| t.end() | ||
| }) | ||
| test('when passed no error', function (t) { | ||
| var emitter = new EventEmitter, | ||
| emits = [] | ||
| emitter.on('error', function (err) { | ||
| emits.push(err) | ||
| }) | ||
| t.notOk(onError.emit(emitter)(null), 'should return undefined') | ||
| t.equal(emits.length, 0, 'should not emit') | ||
| t.end() | ||
| }) | ||
| t.end() | ||
| }) |
| var test = require('tape'), | ||
| onError = require('..') | ||
| test('on-error().otherwise', function (t) { | ||
| var h = function errHandler () {} | ||
| t.equal(typeof onError(h).otherwise, 'function', 'should be a function') | ||
| t.throws(onError(h).otherwise, 'requires a callback') | ||
| test('when passed an error', function (t) { | ||
| var errorCalls = [], | ||
| otherCalls = [] | ||
| function errHandler () { | ||
| var args = Array.prototype.slice.call(arguments, 0) | ||
| errorCalls.push(args) | ||
| } | ||
| function otherHandler () { | ||
| var args = Array.prototype.slice.call(arguments, 0) | ||
| otherCalls.push(args) | ||
| } | ||
| var anError = new Error('error 1'), | ||
| handler = onError(errHandler).otherwise(otherHandler) | ||
| t.notOk(handler(anError), 'should return undefined') | ||
| t.equal(errorCalls.length, 1, 'should invoke error handler') | ||
| t.equal(otherCalls.length, 0, 'should not invoke otherwise handler') | ||
| t.equal(errorCalls[0][0], anError, 'should pass error to handler') | ||
| t.end() | ||
| }) | ||
| test('when passed no error', function (t) { | ||
| var errorCalls = [], | ||
| otherCalls = [] | ||
| function errHandler () { | ||
| var args = Array.prototype.slice.call(arguments, 0) | ||
| errorCalls.push(args) | ||
| } | ||
| function otherHandler () { | ||
| var args = Array.prototype.slice.call(arguments, 0) | ||
| otherCalls.push(args) | ||
| return true | ||
| } | ||
| var handler = onError(errHandler).otherwise(otherHandler) | ||
| t.equal(handler(null, 5, 10), true, 'should return true') | ||
| t.equal(errorCalls.length, 0, 'should not invoke error handler') | ||
| t.equal(otherCalls.length, 1, 'should invoke otherwise handler') | ||
| t.deepEqual(otherCalls[0], [5, 10], 'should pass non-error args to otherwise handler') | ||
| t.end() | ||
| }) | ||
| t.end() | ||
| }) |
+28
-13
@@ -1,11 +0,15 @@ | ||
| var onError = require('..') | ||
| var EventEmitter = require('events').EventEmitter, | ||
| onError = require('..') | ||
| function fail (cb) { | ||
| cb(new Error('failed')) | ||
| // fake something that works | ||
| function doSomething (cb) { | ||
| cb(null, 'success') | ||
| } | ||
| function succeed (cb) { | ||
| cb(null, 'success') | ||
| // fake something that breaks | ||
| function failToDoSomething (cb) { | ||
| cb(new Error('failed')) | ||
| } | ||
| // error handler | ||
| function handleIt (err) { | ||
@@ -15,14 +19,25 @@ console.error(err) | ||
| fail(onError(handleIt, function (status) { | ||
| console.log('will not see this') | ||
| // if error handleIt, otherwise... | ||
| doSomething(onError(handleIt).otherwise(function (message) { | ||
| console.log('will see this: %s', message) | ||
| })) | ||
| fail(onError(handleIt, {alwaysCall: true}, function (err, status) { | ||
| // When always call specified, err is passed | ||
| console.log('will see this') | ||
| failToDoSomething(onError(handleIt).otherwise(function (message) { | ||
| console.log('will NOT see this: %s', message) | ||
| })) | ||
| succeed(onError(handleIt, function (status) { | ||
| // Gets called with status of success | ||
| console.log(status) | ||
| // if error handleIt, and also... | ||
| failToDoSomething(onError(handleIt).also(function (message) { | ||
| console.log('will see this too: %s', message) | ||
| })) | ||
| // if error handleIt, and also (include error for also func)... | ||
| failToDoSomething(onError(handleIt).alsoWithError(function (err, message) { | ||
| console.log('will see this too (with the error): %s, %s', err, message) | ||
| })) | ||
| // maybe we want to emit the error instead... | ||
| var emitter = new EventEmitter().on('error', console.log) | ||
| failToDoSomething(onError.emit(emitter).otherwise(function (message) { | ||
| // will not get here | ||
| })) |
+44
-12
@@ -1,16 +0,48 @@ | ||
| module.exports = function onError (errHandler, options, cb) { | ||
| if (arguments.length === 2) | ||
| cb = options, options = {} | ||
| var assert = require('assert') | ||
| return function () { | ||
| if (arguments[0]) | ||
| errHandler(arguments[0]) | ||
| if (!cb) return | ||
| if (options.alwaysCall) | ||
| return cb.apply(cb, arguments) | ||
| if (arguments[0]) return | ||
| return cb.apply(cb, Array.prototype.slice.call(arguments, 1)) | ||
| module.exports = onError | ||
| function onError (errCb) { | ||
| assert(typeof errCb === 'function', 'on-error requires a callback') | ||
| function errHandler () { | ||
| if (arguments[0]) errCb.call(this, arguments[0]) | ||
| } | ||
| return decorated(errHandler) | ||
| } | ||
| onError.emit = function (emitter) { | ||
| assert(typeof emitter.emit === 'function', 'on-error.emit requires an EventEmitter') | ||
| module.exports.emit = require('emit-error') | ||
| function errHandler () { | ||
| if (arguments[0]) emitter.emit('error', arguments[0]) | ||
| } | ||
| return decorated(errHandler) | ||
| } | ||
| function decorated (errHandler) { | ||
| errHandler.otherwise = function (otherwiseCb) { | ||
| assert(typeof otherwiseCb === 'function', 'on-error.otherwise requires a callback') | ||
| return function otherwiseHandler () { | ||
| if (arguments[0]) return errHandler(arguments[0]) | ||
| return otherwiseCb.apply(this, Array.prototype.slice.call(arguments, 1)) | ||
| } | ||
| } | ||
| errHandler.always = function (alwaysCb) { | ||
| assert(typeof alwaysCb === 'function', 'on-error.always requires a callback') | ||
| return function alwaysHandler () { | ||
| if (arguments[0]) errHandler(arguments[0]) | ||
| return alwaysCb.apply(this, Array.prototype.slice.call(arguments, 1)) | ||
| } | ||
| } | ||
| errHandler.alwaysWithError = function (alwaysCb) { | ||
| assert(typeof alwaysCb === 'function', 'on-error.alwaysWithError requires a callback') | ||
| return function alwaysHandler () { | ||
| if (arguments[0]) errHandler(arguments[0]) | ||
| return alwaysCb.apply(this, arguments) | ||
| } | ||
| } | ||
| return errHandler | ||
| } |
+4
-16
@@ -16,5 +16,2 @@ .PHONY: help test test-grep | ||
| runner=tape | ||
| ifdef npm_config_testling | ||
| runner=testling | ||
| endif | ||
| ifdef npm_config_dot | ||
@@ -32,3 +29,3 @@ reporter=dot | ||
| @echo $(cc_blue)"To run tests:"$(cc_normal) | ||
| @echo " [grep=pattern] npm test [--dot | --spec] [--coverage | --testling]" | ||
| @echo " [grep=pattern] npm test [--dot | --spec] [--coverage ]" | ||
| @echo | ||
@@ -40,3 +37,2 @@ @echo $(cc_blue)"To run benchmarks:"$(cc_normal) | ||
| test: | ||
| $(if $(filter testling, $(runner)), @echo "Running tests in browser via testling.",) | ||
| $(if $(grep), @echo "Running test files that match pattern: $(grep)\n",) | ||
@@ -49,5 +45,5 @@ @mkdir -p coverage | ||
| @rm -f coverage/linterror | ||
| $(if $(filter tap, $(reporter)), $(if $(filter testling, $(runner)), @find ./test -name "*.js" -type f -maxdepth 1 | grep ""$(grep) | xargs browserify -- | testling, @find ./test -name "*.js" -type f -maxdepth 1 | grep ""$(grep) | xargs istanbul cover --report lcovonly --print none tape --),) | ||
| $(if $(filter dot, $(reporter)), $(if $(filter testling, $(runner)), @find ./test -name "*.js" -type f -maxdepth 1 | grep ""$(grep) | xargs browserify -- | testling | tap-dot, @find ./test -name "*.js" -type f -maxdepth 1 | grep ""$(grep) | xargs istanbul cover --report lcovonly --print none tape -- | tap-dot),) | ||
| $(if $(filter spec, $(reporter)), $(if $(filter testling, $(runner)), @find ./test -name "*.js" -type f -maxdepth 1 | grep ""$(grep) | xargs browserify -- | testling | tap-spec, @find ./test -name "*.js" -type f -maxdepth 1 | grep ""$(grep) | xargs istanbul cover --report lcovonly --print none tape -- | tap-spec),) | ||
| $(if $(filter tap, $(reporter)), @find ./test -name "*.js" -type f -maxdepth 1 | grep ""$(grep) | xargs istanbul cover --report lcovonly --print none tape --) | ||
| $(if $(filter dot, $(reporter)), @find ./test -name "*.js" -type f -maxdepth 1 | grep ""$(grep) | xargs istanbul cover --report lcovonly --print none tape -- | tap-dot) | ||
| $(if $(filter spec, $(reporter)), @find ./test -name "*.js" -type f -maxdepth 1 | grep ""$(grep) | xargs istanbul cover --report lcovonly --print none tape -- | tap-spec) | ||
| ifdef npm_config_coverage | ||
@@ -63,9 +59,1 @@ @echo | ||
| $(if $(filter-out tap, $(reporter)), @printf $(cc_normal),) | ||
| benchmark: | ||
| @echo | ||
| @date | ||
| $(if $(grep), @echo "Running perf files that match pattern: $(grep)",) | ||
| @echo "--------------------------------------------------------------" | ||
| @PERFS=`find ./perf -name "*.js" -type f -maxdepth 1 | grep ""$(grep)`; for PERF in $$PERFS; do node $$PERF; done | ||
| @echo "--------------------------------------------------------------" |
+6
-20
| { | ||
| "name": "on-error", | ||
| "version": "1.1.0", | ||
| "description": "Execute error handler instead of, or in addition to callback, when 1st callback argument is truthy", | ||
| "version": "2.0.0", | ||
| "description": "Handle callback errors without the if blocks.", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "make test", | ||
| "benchmark": "make benchmark", | ||
| "travis-test": "make test && ((cat coverage/lcov.info | coveralls) || exit 0)", | ||
@@ -20,3 +19,6 @@ "view-cover": "open coverage/index.html", | ||
| "error", | ||
| "callback" | ||
| "callback", | ||
| "emit", | ||
| "event", | ||
| "emitter" | ||
| ], | ||
@@ -41,18 +43,2 @@ "license": "MIT", | ||
| }, | ||
| "testling": { | ||
| "files": "test/*.js", | ||
| "browsers": [ | ||
| "ie/8..latest", | ||
| "firefox/16..latest", | ||
| "firefox/nightly", | ||
| "chrome/22..latest", | ||
| "chrome/canary", | ||
| "opera/12..latest", | ||
| "opera/next", | ||
| "safari/5.1..latest", | ||
| "ipad/6.0..latest", | ||
| "iphone/6.0..latest", | ||
| "android-browser/4.2..latest" | ||
| ] | ||
| }, | ||
| "dependencies": { | ||
@@ -59,0 +45,0 @@ "emit-error": "^2.0.0" |
+49
-72
| # on-error | ||
| [](http://badge.fury.io/js/on-error) | ||
| [](https://travis-ci.org/jasonpincin/on-error) | ||
| [](https://coveralls.io/r/jasonpincin/on-error?branch=master) | ||
| [](http://badge.fury.io/js/on-error) | ||
| [](https://david-dm.org/jasonpincin/on-error) | ||
| Handle callback errors by executing an error handler function, or emitting the error, instead of or in | ||
| addition to executing the callback. | ||
| Handle callback errors without the `if` blocks. | ||
| On error, execute separate error handler function, or emit it. On no error, execute regular callback | ||
| (with or without error stripped). | ||
| ## example | ||
| ``` | ||
| var onError = require('on-error') | ||
| ```javascript | ||
| // if error handleIt, otherwise... | ||
| doSomething(onError(handleIt).otherwise(function (message) { | ||
| console.log('will see this: %s', message) | ||
| })) | ||
| function fail (cb) { | ||
| cb(new Error('failed')) | ||
| } | ||
| function succeed (cb) { | ||
| cb(null, 'success') | ||
| } | ||
| ``` | ||
| Using error handler function: | ||
| ``` | ||
| function handleIt (err) { | ||
| console.error(err) | ||
| } | ||
| fail(onError(handleIt, function (status) { | ||
| console.log('will not see this') | ||
| failToDoSomething(onError(handleIt).otherwise(function (message) { | ||
| console.log('will NOT see this: %s', message) | ||
| })) | ||
| fail(onError(handleIt, {alwaysCall: true}, function (err, status) { | ||
| // When always call specified, err is passed | ||
| console.log('will see this') | ||
| // if error handleIt, and always... | ||
| failToDoSomething(onError(handleIt).always(function (message) { | ||
| console.log('will see this too: %s', message) | ||
| })) | ||
| succeed(onError(handleIt, function (status) { | ||
| // Gets called with status of success | ||
| console.log(status) | ||
| // if error handleIt, and always (include error for always func)... | ||
| failToDoSomething(onError(handleIt).alwaysWithError(function (err, message) { | ||
| console.log('will see this too (with the error): %s, %s', err, message) | ||
| })) | ||
| ``` | ||
| 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') | ||
| // maybe we want to emit the error instead... | ||
| var emitter = new EventEmitter().on('error', console.log) | ||
| failToDoSomething(onError.emit(emitter).otherwise(function (message) { | ||
| // will not get here | ||
| })) | ||
@@ -60,52 +44,45 @@ ``` | ||
| ### onError | ||
| ```javascript | ||
| var onError = require('on-error') | ||
| ``` | ||
| `var onError = require('on-error')` | ||
| ### onError(cb) | ||
| ### var wrappedCb = onError(errHandler [, options, cb]) | ||
| Returns a function that when called with a truthy first argument, will execute `cb` with said | ||
| argument. | ||
| Returns a function that when called with a truthy first argument, will execute the errHandler | ||
| with the 1st (error) argument supplied to the wrappedCb. If the option `alwaysCall` is define, | ||
| the provided `cb` will be executed in all cases with all arguments supplied to `wrappedCb`, otherwise | ||
| if the 1st argument to `wrappedCb` is falsey, the supplied `cb` will be executed with all but the | ||
| 1st argument supplied to `wrappedCb`. | ||
| ### onError.emit(emitter) | ||
| If no callback `cb` is provided, then the generated callback will simply execute `errHandler` when | ||
| called with a non-falsey 1st argument. | ||
| Returns a function that when called with a truthy first argument, will emit `error` on the provided | ||
| event `emitter` with said argument. | ||
| *options:* | ||
| - alwaysCall: `true` or `false` - if true, the provided callback `cb` will always be called (and include | ||
| the 1st argument), otherwise it will only be called when a the first argument is falsey (and without the | ||
| 1st argument) | ||
| ### onError(cb1).otherwise(cb2) | ||
| ### var wrappedCb = onError.emit(emitter [, options, cb]) | ||
| Returns a function that when called with a truthy first argument, will execute `cb1` with said | ||
| argument. When executed with a non-truthy 1st argument, `cb2` will instead be executed with | ||
| the error argument stripped. | ||
| 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. | ||
| `.otherwise` may always be chained from `onError.emit()` | ||
| ### onError(cb1).always(cb2) | ||
| ## testing | ||
| Returns a function that when called with a truthy first argument, will execute `cb1` with said | ||
| argument. In addition, `cb2` will always be executed with the error argument stripped. | ||
| `npm test [--dot | --spec] [--coverage]` | ||
| `.always` may always be chained from `onError.emit()` | ||
| ### options | ||
| ### onError(cb1).alwaysWithError(cb2) | ||
| * `--dot` - output test results as dots instead of tap | ||
| * `--spec` - output test results as spec instead of tap | ||
| * `--coverage` - display text cover report | ||
| * `--testling` - run tests in browser via testling (cannot be used with --coverage and | ||
| expects both browserify and testling to be installed globally) | ||
| Returns a function that when called with a truthy first argument, will execute `cb1` with said | ||
| argument. In addition, `cb2` will always be executed with the error argument in-tact. | ||
| ### patterns | ||
| `.alwaysWithError` may always be chained from `onError.emit()` | ||
| Only run test files matching a certain pattern by prefixing the | ||
| test command with `grep=pattern`. Example: | ||
| ## testing | ||
| ``` | ||
| grep=connect npm test --dot | ||
| ``` | ||
| `npm test [--dot | --spec] [--coverage]` | ||
| ### html coverage report | ||
| Alternatively, only run test files matching a certain pattern by prefixing the command | ||
| with `grep=pattern`. Example: `grep=init npm test` | ||
| Open it with `npm run view-cover` or `npm run vc` | ||
| Open an html coverage report after running tests with `npm run view-cover` or `npm run vc` |
+26
-16
@@ -5,21 +5,31 @@ var test = require('tape'), | ||
| test('on-error', function (t) { | ||
| function handleIt () { | ||
| var args = Array.prototype.slice.call(arguments, 0) | ||
| errorCalls.push(args) | ||
| } | ||
| function callback () { | ||
| var args = Array.prototype.slice.call(arguments, 0) | ||
| return args | ||
| } | ||
| var errorCalls = [] | ||
| 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') | ||
| t.deepEqual(onError(handleIt, {alwaysCall:true}, callback)(new Error('error 2')), [new Error('error 2')], 'should return args on error with alwaysCall') | ||
| t.deepEqual(onError(handleIt, callback)(null, 1, 2), [1, 2], 'should return args on no error') | ||
| t.notOk(onError(handleIt)(new Error('error 2')), 'should return undefined on error with no cb') | ||
| t.deepEqual(onError(handleIt)(), undefined, 'should return undefined on no error with no cb') | ||
| t.deepEqual(errorCalls.length, 3, 'should have emitted 3 error events') | ||
| t.equal(typeof onError, 'function', 'should be a function') | ||
| t.throws(onError, 'requires a callback') | ||
| test('when passed an error', function (t) { | ||
| var errorCalls = [] | ||
| function errHandler () { | ||
| var args = Array.prototype.slice.call(arguments, 0) | ||
| errorCalls.push(args) | ||
| } | ||
| var anError = new Error('error 1') | ||
| t.notOk(onError(errHandler)(anError), 'should return undefined') | ||
| t.equal(errorCalls.length, 1, 'should invoke error handler') | ||
| t.equal(errorCalls[0][0], anError, 'should pass error to handler') | ||
| t.end() | ||
| }) | ||
| test('when passed no error', function (t) { | ||
| var errorCalls = [] | ||
| function errHandler () { | ||
| var args = Array.prototype.slice.call(arguments, 0) | ||
| errorCalls.push(args) | ||
| } | ||
| t.notOk(onError(errHandler)(null), 'should return undefined') | ||
| t.equal(errorCalls.length, 0, 'should not invoke error handler') | ||
| t.end() | ||
| }) | ||
| t.end() | ||
| }) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22574
49.4%15
36.36%279
398.21%88
-20.72%1
Infinity%