Socket
Socket
Sign inDemoInstall

events-to-array

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

events-to-array

Put a bunch of emitted events in an array, for testing.


Version published
Weekly downloads
477K
increased by0.28%
Maintainers
1
Weekly downloads
 
Created
Source

events-to-array

Put a bunch of emitted events in an array, for testing.

USAGE

var assert = require('assert')
var EE = require('events')
var etoa = require('events-to-array')
var emitter = new EE()
var array = etoa(emitter)

emitter.emit('foo', 1, 2, 3)
emitter.emit('bar', { x: 1 })

// nested events get tracked as well
var subemit = new EE()
emitter.emit('sub', subemit)
subemit.emit('childEvent', { some: 'data' })
subemit.emit('anotherone', { some: 'data' }, 'many', 'args')

// CAVEAT!
emitter.emit('blaz', 'blorrg')
subemit.emit('order', 'not', 'preserved between child and parent')

// check out the array whenever
assert.deepEqual(array,
[ [ 'foo', 1, 2, 3 ],
  [ 'bar', { x: 1 } ],
  [ 'sub',
    [ [ 'childEvent', { some: 'data' } ],
      [ 'anotherone', { some: 'data' }, 'many', 'args' ],
      [ 'order', 'not', 'preserved between child and parent' ] ] ],
  [ 'blaz', 'blorrg' ] ])

eventsToArray(emitter, [ignoreList])

Returns an array with all the events emitted by the emitter.

It's your responsibility to know when to check it for the events that you expect.

FAQs

Package last updated on 02 Mar 2015

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