Socket
Book a DemoInstallSign in
Socket

nitroglycerin

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nitroglycerin

Makes JavaScript functions throw exceptions on errors

latest
Source
npmnpm
Version
1.1.2
Version published
Maintainers
3
Created
Source

Nitroglycerin

Circle CI Dependency Status Coverage Status

Makes JavaScript functions so volatile and explosive that they immediately throw on errors.

This is mostly useful for testing and simple command-line scripts. In production you most likely don't want to throw exceptions.

How it works

Let's say you have a small piece of test code that needs to set something up:

resetDatabase (err) ->
  if err then throw new Error(err)
  createUser name: 'Alfred Nobel', (err, alfred) ->
    if err then throw new Error(err)
    # run your tests using alfred here

Checking that these calls didn't error out requires a bit of ceremony in Node.js, either in the form of manual error checking as described above, promises, or async.waterfall. Nitroglycerin removes most of this ceremony:

N = require 'nitroglycerin'

resetDatabase N ->
  createUser name: 'Alfred Nobel', N (alfred) ->
    # run your tests using alfred here

The functions wrapped in Nitroglycerin will immediately throw an exception when they receive an error or execute the callback with the error argument stripped.

Development

See the developer documentation

FAQs

Package last updated on 06 Jul 2016

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