passerror

Simple helper for handling error and success with two different callbacks

BSD-3-Clause 6 个版本
安装
npm install passerror
yarn add passerror
pnpm add passerror
bun add passerror
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.

版本列表
1.1.1 2015-10-30
1.1.0 2014-10-02
1.0.1 2014-02-18
1.0.0 2013-10-30
0.0.2 2013-03-07
0.0.1 2012-06-28