New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

emit-error

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emit-error

Emit error if callback is executed with a non-null 1st argument

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-44.44%
Maintainers
1
Weekly downloads
 
Created
Source

emit-error

Build Status Coverage Status NPM version Davis Dependency Status

browser support

Emit error if callback is executed with a non-null 1st argument

example

var EventEmitter = require('events').EventEmitter,
    emitError    = require('..')

function callback (err) {
    console.log('did not get an error')
}

function onError (err) {
    console.error('got error: ' + err)
}

var emitter = new EventEmitter().on('error', onError)
var doSomething = emitError(emitter, callback)

doSomething(new Error('broke'))
doSomething()

output of above:

got error: Error: broke
did not get an error

toc

api

emitError

var emitError = require('emit-error')

var wrappedCb = emitError(emitter [, options, cb])

Returns a function that when called with a non-falsey first argument, will emit that value as an error event on the given event emitter. If a falsey first argument is passed to the generated function, or if an options object is provided with a property of alwaysCall set to true, then the provided callback cb will be executed with all arguments passed to the generated function.

If no callback cb is provided, then the generated callback will simply emit error events when called with a non-falsey 1st argument.

options:

  • alwaysCall: true or false - if true, the provided callback cb will always be called, otherwise it will only be called when a the first argument is falsey

testing

npm test [--dot | --spec] [--coverage]

options

  • --dot - output test results as dots instead of tap
  • --spec - output test results as spec instead of tap
  • --coverage - display text cover report
  • --testling - run tests in browser via testling (cannot be used with --coverage and expects both browserify and testling to be installed globally)

patterns

Only run test files matching a certain pattern by prefixing the test command with grep=pattern. Example:

grep=connect npm test --dot

html coverage report

Open it with npm run view-cover or npm run vc

FAQs

Package last updated on 24 Sep 2014

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc