Profiles·Public

eventemitter2

semver>=6.0.0postconditions12functions6last verified2026-04-16coverage score100%

Postconditions — what we check

  • EventEmitter2 · eventemitter2-001
    error
    Whenerror event emitted without listener
    ThrowsUncaught exception unless ignoreErrors configured
    Required handlingCaller MUST attach error event listener
    costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible
    Sources[1]
  • emit · eventemitter2-emit-unhandled-error
    error
    Whenerror event emitted with no listener and ignoreErrors: false (default)
    ThrowsError — either re-throws the emitted Error instance or throws new Error("Uncaught, unspecified 'error' event.")
    Required handlingCaller MUST attach .on('error', handler) before emitting error events, or pass ignoreErrors:true to the constructor
    costmediumin prodimmediate exceptionusers seeservice unavailablevisibilityvisible
    Sources[2]
  • emitAsync · eventemitter2-emit-async-unhandled-error
    error
    WhenemitAsync('error', err) called with no 'error' listener registered and ignoreErrors: false
    ThrowsReturns Promise.reject(err) — a rejected Promise with the error or a string message
    Required handlingCaller MUST attach .on('error', handler) OR wrap emitAsync() in try/catch or .catch()
    costmediumin proddelayed failureusers seedegraded performancevisibilitysilent
    Sources[2]
  • emitAsync · eventemitter2-emit-async-listener-rejection
    warning
    Whenany registered listener throws or returns a rejected Promise
    ThrowsReturns rejected Promise with the first listener's rejection reason (Promise.all semantics)
    Required handlingCaller MUST await emitAsync() and wrap in try/catch, or chain .catch()
    costlowin proddelayed failureusers seedegraded performancevisibilitysilent
    Sources[2][3]
  • waitFor · eventemitter2-wait-for-timeout
    warning
    Whentimeout option is > 0 and the event is not emitted within that duration
    ThrowsRejects with Error('timeout') — the rejection message is literally 'timeout'
    Required handlingCaller MUST wrap waitFor() in try/catch or .catch() when using timeout option
    costlowin proddelayed failureusers seedegraded performancevisibilitysilent
    Sources[2]
  • waitFor · eventemitter2-wait-for-cancel
    warning
    Whenpromise.cancel() is called before the event fires
    ThrowsRejects with Error('canceled')
    Required handlingCaller MUST handle rejection if cancel() can be called on in-flight promises
    costlowin proddelayed failureusers seedegraded performancevisibilitysilent
    Sources[2]
  • waitFor · eventemitter2-wait-for-handle-error
    warning
    WhenhandleError: true in options AND the event fires with a truthy first argument
    ThrowsRejects with the first argument as the error reason
    Required handlingCaller MUST wrap in try/catch when handleError option is enabled
    costlowin proddelayed failureusers seedegraded performancevisibilitysilent
    Sources[2][4]
  • EventEmitter2.once · eventemitter2-static-once-error-rejection
    error
    Whenthe emitter emits 'error' before the target event fires
    ThrowsRejects with the error emitted — the rejection reason is the Error object from the error event
    Required handlingCaller MUST wrap EventEmitter2.once() in try/catch or chain .catch()
    costmediumin proddelayed failureusers seedegraded performancevisibilitysilent
    Sources[2]
  • EventEmitter2.once · eventemitter2-static-once-timeout
    warning
    Whentimeout option is > 0 and the event does not fire within that duration
    ThrowsRejects with Error('timeout')
    Required handlingCaller MUST wrap in try/catch or .catch() when using timeout option
    costlowin proddelayed failureusers seedegraded performancevisibilitysilent
    Sources[2]
  • EventEmitter2.once · eventemitter2-static-once-cancel
    warning
    Whenpromise.cancel() is called before the event fires
    ThrowsRejects with Error('canceled')
    Required handlingCaller MUST handle rejection if cancel() can be called on in-flight promises
    costlowin proddelayed failureusers seedegraded performancevisibilitysilent
    Sources[2]
  • listenTo · eventemitter2-listen-to-invalid-target
    error
    Whentarget parameter is not an object, or target does not implement addEventListener/on/addListener
    ThrowsTypeError('target musts be an object') or Error('target does not implement any known event API')
    Required handlingCaller MUST validate target implements an event API before calling listenTo()
    costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisible
    Sources[2]
  • listenTo · eventemitter2-listen-to-invalid-options
    warning
    Whenoptions.on or options.off are provided but are not functions
    ThrowsTypeError('on method must be a function') or TypeError('off method must be a function')
    Required handlingCaller MUST ensure on/off hooks in options are valid functions when using custom subscription API
    costlowin prodimmediate exceptionusers seeservice unavailablevisibilityvisible
    Sources[2]

Sources

Every postcondition cites at least one of these. Numbered to match the footnotes above.

  1. [1]github.com/EventEmitter2/EventEmitter2https://github.com/EventEmitter2/EventEmitter2
  2. [2]github.com/EventEmitter2/EventEmitter2https://github.com/EventEmitter2/EventEmitter2/blob/master/lib/eventemitter2.js
  3. [3]developer.mozilla.org/en-US/docshttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all
  4. [4]github.com/EventEmitter2/EventEmitter2https://github.com/EventEmitter2/EventEmitter2/blob/master/README.md
Need a different package?
Request a profile