passerror

1.1.1 • Public • Published

passError

Handle success and failure with two different callbacks. Lets you get rid of most if (err) return cb(err); constructs.

Example

Send errors reported by fs.readFile straight to cb:

var passError = require('passerror'),
    fs = require('fs');
 
function getLines(fileName, cb) {
    fs.readFile(fileName, 'utf-8', passError(cb, function (contents) {
        cb(null, contents.split(/\r?\n|\n?\r/));
    }));
}

License

Licensed under a standard 3-clause BSD license -- see the LICENSE-file for details.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.1
    37,668
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.1
    37,668
  • 1.1.0
    14,840
  • 1.0.1
    5,833
  • 1.0.0
    1
  • 0.0.2
    6,659
  • 0.0.1
    8,472

Package Sidebar

Install

npm i passerror

Weekly Downloads

58,462

Version

1.1.1

License

BSD-3-Clause

Last publish

Collaborators

  • papandreou