Socket
Socket
Sign inDemoInstall

passerror

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    passerror

Simple helper for handling error and success with two different callbacks


Version published
Weekly downloads
71K
increased by35.77%
Maintainers
1
Install size
7.05 kB
Created
Weekly downloads
 

Readme

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

Last updated on 30 Oct 2015

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc