JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 48814
  • Score
    100M100P100Q147227F
  • License BSD-3-Clause

Simple helper for handling error and success with two different callbacks

Package Exports

  • passerror

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (passerror) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.