New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

onerr

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onerr

Simple error handling utility function

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

onerr

Simple error handling utility function

How to install

npm install onerr

Usage

JavaScript

This module allows you to replace the common ideom

function doSomethingAsync(arg, callback) {
  // [...]
  goFetchSomethingAsync(arg, function(err, data) {
    if (err != null) {
      return callback(err);
    }
    // Do something with data
  });
}

with

var onerr = require("onerr");

function doSomethingAsync(arg, callback) {
  // [...]
  goFetchSomethingAsync(arg, onerr(callback, function(data) {
    // Do something with data
  }));
}

CoffeeScript

It looks even nicer in CoffeeScript:

onerr = require "onerr"

middlewareFunction = (req, res, next) ->
  # [...]
  goFetchSomethingAsync req, onerr next, (data) ->
    # Do something with data

FAQs

Package last updated on 17 Jun 2013

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