🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

passerror

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

passerror

Simple helper for handling error and success with two different callbacks

1.1.1
latest
Source
npm
Version published
Weekly downloads
57K
-31.13%
Maintainers
1
Weekly downloads
 
Created
Source

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.

FAQs

Package last updated on 30 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts