{"_id":"on-error","_rev":"13-ca507faef871239d577289a8eb7b1ac0","name":"on-error","description":"Handle callback errors without the if blocks.","dist-tags":{"latest":"2.1.0"},"versions":{"1.0.0":{"name":"on-error","version":"1.0.0","description":"Execute error handler instead of, or in addition to callback, when 1st callback argument is truthy","main":"index.js","scripts":{"test":"make test","benchmark":"make benchmark","travis-test":"make test && ((cat coverage/lcov.info | coveralls) || exit 0)","view-cover":"open coverage/index.html","vc":"open coverage/index.html","help":"make help"},"repository":{"type":"git","url":"git://github.com/jasonpincin/on-error.git"},"keywords":["error","callback"],"license":"MIT","bugs":{"url":"https://github.com/jasonpincin/on-error/issues"},"homepage":"https://github.com/jasonpincin/on-error","author":{"name":"Jason Pincin","email":"jason@pincin.com","url":"http://jason.pincin.com/"},"contributors":[],"devDependencies":{"istanbul":"~0.2.8","jshint":"^2.5.10","tap-dot":"^0.2.2","tap-spec":"~0.1.9","tape":"~2.12.3"},"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"]},"gitHead":"baa44a06ac239efc6d9f72ef162a59f17b0f3124","_id":"on-error@1.0.0","_shasum":"0c7d713a765e1a05fa6f0ed9abbde8167e6aea8e","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jasonpincin","email":"jason@pincin.com"},"maintainers":[{"name":"jasonpincin","email":"jason@pincin.com"}],"dist":{"shasum":"0c7d713a765e1a05fa6f0ed9abbde8167e6aea8e","tarball":"https://registry.npmjs.org/on-error/-/on-error-1.0.0.tgz","integrity":"sha512-94MzLQCwyfYQ6DFNPlQwODsoan/cjyaXnCN4T3SVDWU96paIP6EIpkKZh7sJIrAm7sN+doWLEttGU/k3yhsauQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE0oI/hc8NJfPEBQ5CsiIXqvSOiMB/MwXFJ4LjIYjLPjAiABQPapsQwYOnWBeuD5oznsydOW7y+bdSlEgXcP9cJSFA=="}]}},"1.1.0":{"name":"on-error","version":"1.1.0","description":"Execute error handler instead of, or in addition to callback, when 1st callback argument is truthy","main":"index.js","scripts":{"test":"make test","benchmark":"make benchmark","travis-test":"make test && ((cat coverage/lcov.info | coveralls) || exit 0)","view-cover":"open coverage/index.html","vc":"open coverage/index.html","help":"make help"},"repository":{"type":"git","url":"git://github.com/jasonpincin/on-error.git"},"keywords":["error","callback"],"license":"MIT","bugs":{"url":"https://github.com/jasonpincin/on-error/issues"},"homepage":"https://github.com/jasonpincin/on-error","author":{"name":"Jason Pincin","email":"jason@pincin.com","url":"http://jason.pincin.com/"},"contributors":[],"devDependencies":{"istanbul":"~0.2.8","jshint":"^2.5.10","tap-dot":"^0.2.2","tap-spec":"~0.1.9","tape":"~2.12.3"},"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":{"emit-error":"^2.0.0"},"gitHead":"be48fea069cf4bec28e8336f64efd306f49263b9","_id":"on-error@1.1.0","_shasum":"e8710bcb8cbc43b4c5d34867548862fc79cfb488","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jasonpincin","email":"jason@pincin.com"},"maintainers":[{"name":"jasonpincin","email":"jason@pincin.com"}],"dist":{"shasum":"e8710bcb8cbc43b4c5d34867548862fc79cfb488","tarball":"https://registry.npmjs.org/on-error/-/on-error-1.1.0.tgz","integrity":"sha512-jiO5VYMiIYD91GBF1NOQm4aobAVpJrgaMm/+G4VMDt6vJTLCrqdISjcXv07tWJHj7+w351qimvmcxErBdLyZXA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCtm1651ojTf0tSOPjH2TcnpMIAIc2xYrQ8SwZYt8xsewIgSnk2Vh132xtpmrhsRCU+TvbBhuxELvSObdZ2cnpc36g="}]}},"2.0.0":{"name":"on-error","version":"2.0.0","description":"Handle callback errors without the if blocks.","main":"index.js","scripts":{"test":"make test","travis-test":"make test && ((cat coverage/lcov.info | coveralls) || exit 0)","view-cover":"open coverage/index.html","vc":"open coverage/index.html","help":"make help"},"repository":{"type":"git","url":"git://github.com/jasonpincin/on-error.git"},"keywords":["error","callback","emit","event","emitter"],"license":"MIT","bugs":{"url":"https://github.com/jasonpincin/on-error/issues"},"homepage":"https://github.com/jasonpincin/on-error","author":{"name":"Jason Pincin","email":"jason@pincin.com","url":"http://jason.pincin.com/"},"contributors":[],"devDependencies":{"istanbul":"~0.2.8","jshint":"^2.5.10","tap-dot":"^0.2.2","tap-spec":"~0.1.9","tape":"~2.12.3"},"dependencies":{"emit-error":"^2.0.0"},"gitHead":"07019c69c477a65707adf2defc3b38473a8576a5","_id":"on-error@2.0.0","_shasum":"1ea2bed8ca88ab15c3b0448739e78ceef1cbca20","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jasonpincin","email":"jason@pincin.com"},"maintainers":[{"name":"jasonpincin","email":"jason@pincin.com"}],"dist":{"shasum":"1ea2bed8ca88ab15c3b0448739e78ceef1cbca20","tarball":"https://registry.npmjs.org/on-error/-/on-error-2.0.0.tgz","integrity":"sha512-yuzM1wTIVBoDTm2VX7WCzsh7sKnYFzUGdOL++m6yCViaqZJcifW3T1rH68yRJRlL7JXhLD8hQEwHdexeed3a1g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBo4NAvITPu6JMaKpOKoj9ad29Fw7+jcTA1qI6jYs4llAiBfMKzByQuivDPHTGBc0IoSvR6g4BrXoyLlak0ddKtq5w=="}]}},"2.0.1":{"name":"on-error","version":"2.0.1","description":"Handle callback errors without the if blocks.","main":"index.js","scripts":{"test":"make test","travis-test":"make test && ((cat coverage/lcov.info | coveralls) || exit 0)","view-cover":"open coverage/index.html","vc":"open coverage/index.html","help":"make help"},"repository":{"type":"git","url":"git://github.com/jasonpincin/on-error.git"},"keywords":["error","callback","emit","event","emitter"],"license":"MIT","bugs":{"url":"https://github.com/jasonpincin/on-error/issues"},"homepage":"https://github.com/jasonpincin/on-error","author":{"name":"Jason Pincin","email":"jason@pincin.com","url":"http://jason.pincin.com/"},"contributors":[],"devDependencies":{"istanbul":"~0.2.8","jshint":"^2.5.10","tap-dot":"^0.2.2","tap-spec":"~0.1.9","tape":"~2.12.3"},"dependencies":{},"gitHead":"4fb86ea44c197ddfd19baa146f89134a1a3eb609","_id":"on-error@2.0.1","_shasum":"cd34e35e6f1f76651085bf60a3bd3c31dac5ccfb","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jasonpincin","email":"jason@pincin.com"},"maintainers":[{"name":"jasonpincin","email":"jason@pincin.com"}],"dist":{"shasum":"cd34e35e6f1f76651085bf60a3bd3c31dac5ccfb","tarball":"https://registry.npmjs.org/on-error/-/on-error-2.0.1.tgz","integrity":"sha512-VLRWui1NX2SRuA+qruc378GpWjvDArBLWRabqpToQqX/dgZrGSOw24TytRdfwclcq7esayOwlRukwxo1eqIjMw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF7nPPsAzcZrIxKXwRhbQPnvR7tQALCNQ7iT+S/yH3YdAiEAsDQHcgxaM4o7qGwlaP6CLATiO1673lx9go6z1LH495w="}]}},"2.0.2":{"name":"on-error","version":"2.0.2","description":"Handle callback errors without the if blocks.","main":"index.js","scripts":{"test":"make test","travis-test":"make test && ((cat coverage/lcov.info | coveralls) || exit 0)","view-cover":"open coverage/index.html","vc":"open coverage/index.html","help":"make help"},"repository":{"type":"git","url":"git://github.com/jasonpincin/on-error.git"},"keywords":["error","callback","emit","event","emitter"],"license":"MIT","bugs":{"url":"https://github.com/jasonpincin/on-error/issues"},"homepage":"https://github.com/jasonpincin/on-error","author":{"name":"Jason Pincin","email":"jason@pincin.com","url":"http://jason.pincin.com/"},"contributors":[],"devDependencies":{"istanbul":"~0.2.8","jshint":"^2.5.10","tap-dot":"^0.2.2","tap-spec":"~0.1.9","tape":"~2.12.3"},"dependencies":{},"gitHead":"4694d8db97076309b34c625f683dfa67e04b642d","_id":"on-error@2.0.2","_shasum":"c0853456eb5f6c6abb84ad5085031e6230820a32","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"jasonpincin","email":"jason@pincin.com"},"maintainers":[{"name":"jasonpincin","email":"jason@pincin.com"}],"dist":{"shasum":"c0853456eb5f6c6abb84ad5085031e6230820a32","tarball":"https://registry.npmjs.org/on-error/-/on-error-2.0.2.tgz","integrity":"sha512-18KthhLSXrjn05x/bDJw7xf0kZb9WLZjvWXQXGEgcwwCSnD5LdUFOJor2d1qEq923ndJ1P+dwE7Bws3rGM6Y/w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDlxvhMcjxZEbcMkOCM68bIb7He7DhRiUjJipqijFD+cQIgaP5cw5MXpbuaVzurI9pqEzDxEaJlfS/PvRwsajbRh5c="}]}},"2.1.0":{"name":"on-error","version":"2.1.0","description":"Handle callback errors without the if blocks.","main":"index.js","scripts":{"test":"make npm-test","coverage":"make npm-coverage"},"repository":{"type":"git","url":"git://github.com/jasonpincin/on-error.git"},"keywords":["error","callback","emit","event","emitter"],"license":"MIT","bugs":{"url":"https://github.com/jasonpincin/on-error/issues"},"homepage":"https://github.com/jasonpincin/on-error","author":{"name":"Jason Pincin","email":"jason@pincin.com","url":"http://jason.pincin.com/"},"contributors":[],"devDependencies":{"eslint":"~0.24.1","istanbul":"~0.3.17","tap-dot":"~1.0.0","tap-spec":"~4.0.2","tape":"~4.0.1"},"dependencies":{},"gitHead":"d440ba6f68396d44317faa0239151f74c0bd5f0a","_id":"on-error@2.1.0","_shasum":"bac56e4b49804c49167150dad2759b4261117dce","_from":".","_npmVersion":"2.9.1","_nodeVersion":"0.12.3","_npmUser":{"name":"jasonpincin","email":"jason@pincin.com"},"maintainers":[{"name":"jasonpincin","email":"jason@pincin.com"}],"dist":{"shasum":"bac56e4b49804c49167150dad2759b4261117dce","tarball":"https://registry.npmjs.org/on-error/-/on-error-2.1.0.tgz","integrity":"sha512-wpKXxCW2wXLI+9DB9DDBVuOCN9C5rjyaP4GWwqhgrSd2ys1Vyc9yGaPmC5HSOdQ30x9zCLozi9mHx3lm01E+LQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDerlckPeau2Qf/nnYXqpMvdvdXYcUiFchoifDx8Wa3ygIgH/WJTvaVww+QQeZCjp0QVgHf2rwdBrnbQKfiAlCLITk="}]}}},"readme":"# on-error\n\n[![NPM version](https://badge.fury.io/js/on-error.png)](http://badge.fury.io/js/on-error)\n[![Build Status](https://travis-ci.org/jasonpincin/on-error.svg?branch=master)](https://travis-ci.org/jasonpincin/on-error)\n[![Coverage Status](https://coveralls.io/repos/jasonpincin/on-error/badge.png?branch=master)](https://coveralls.io/r/jasonpincin/on-error?branch=master)\n[![Davis Dependency Status](https://david-dm.org/jasonpincin/on-error.png)](https://david-dm.org/jasonpincin/on-error)\n\nGenerate error-first callback handlers naturally. \n\nHandle errors via a dedicated error handler function, or by emitting them. \nOptionally invoke a 2nd function on no error, or regardless of error.\n\nPotentially reduce the number of branches needing tests.\n\n## examples\n\n```javascript\nvar onError = require('on-error')\n\n// error handler\nfunction handleIt (err) {}\n\n// just do something on error\nfailToDoSomething(onError(handleIt))\n// or emit it\nfailToDoSomething(onError.emit(emitter))\n\n// if doSomething invokes this generated callback with an error\n// handleIt will be called with that error, otherwise our \n// anonymous function will be called with all remaining arguments\ndoSomething(onError(handleIt).otherwise(function (message) {\n    console.log('will see this: %s', message)\n}))\n\nfailToDoSomething(onError(handleIt).otherwise(function (message) {\n    console.log('will NOT see this: %s', message)\n}))\n\n// if error handleIt, and always...\nfailToDoSomething(onError(handleIt).always(function (message) {\n    console.log('will see this too: %s', message)\n}))\n\n// if error handleIt, and always (include error for always func)...\nfailToDoSomething(onError(handleIt).alwaysWithError(function (err, message) {\n    console.log('will see this too (with the error): %s, %s', err, message)\n}))\n\n// maybe we want to emit the error instead...\nvar emitter = new EventEmitter().on('error', console.log)\nfailToDoSomething(onError.emit(emitter).otherwise(function (message) {\n    // will not get here\n}))\n\n// or, *gasp*, chain to a promise\ndoSomething(onError(reject).otherwise(resolve))\n```\n\n## api\n\n```javascript\nvar onError = require('on-error')\n```\n\n### onError(cb)\n\nReturns a function that when called with a truthy first argument, will execute `cb` with said argument.\n\n### onError.emit(emitter)\n\nReturns a function that when called with a truthy first argument, will emit `error` on the provided event `emitter` with said argument.\n\n### onError(cb1).otherwise(cb2)\n\nReturns 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.\n\n`.otherwise` may also be chained from `onError.emit()`\n\n### onError(cb1).otherwiseWithError(cb2)\n\nReturns 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 in-tact.\n\n`.otherwiseWithError` may also be chained from `onError.emit()`\n\n### onError(cb1).always(cb2)\n\nReturns 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.\n\n`.always` may also be chained from `onError.emit()`\n\n### onError(cb1).alwaysWithError(cb2)\n\nReturns 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.\n\n`.alwaysWithError` may also be chained from `onError.emit()`\n\n## testing\n\n`npm test [--dot | --spec] [--grep=pattern]`\n\nSpecifying `--dot` or `--spec` will change the output from the default TAP style. \nSpecifying `--grep` will only run the test files that match the given pattern.\n\n## coverage\n\n`npm run coverage [--html]`\n\nThis will output a textual coverage report. Including `--html` will also open an HTML coverage report in the default browser.\n","maintainers":[{"name":"jasonpincin","email":"jason@pincin.com"}],"time":{"modified":"2022-06-22T21:26:55.116Z","created":"2014-12-08T18:36:56.330Z","1.0.0":"2014-12-08T18:36:56.330Z","1.1.0":"2014-12-08T19:36:12.247Z","2.0.0":"2015-01-23T20:53:41.871Z","2.0.1":"2015-01-23T21:00:02.435Z","2.0.2":"2015-01-24T05:57:14.307Z","2.1.0":"2015-07-22T12:31:11.708Z"},"homepage":"https://github.com/jasonpincin/on-error","keywords":["error","callback","emit","event","emitter"],"repository":{"type":"git","url":"git://github.com/jasonpincin/on-error.git"},"contributors":[],"author":{"name":"Jason Pincin","email":"jason@pincin.com","url":"http://jason.pincin.com/"},"bugs":{"url":"https://github.com/jasonpincin/on-error/issues"},"license":"MIT","readmeFilename":"README.md"}