Skip to content

Instantly share code, notes, and snippets.

@NickNaso
Created May 25, 2018 18:09
Show Gist options
  • Save NickNaso/d0ee9f5f1611060b04ab61f17ad4ce2e to your computer and use it in GitHub Desktop.
Save NickNaso/d0ee9f5f1611060b04ab61f17ad4ce2e to your computer and use it in GitHub Desktop.
Inherits from Event Emitter
'use strict'
const EventEmitter = require('events').EventEmitter
const NativeEmitter = require('bindings')('native_emitter').NativeEmitter
const inherits = require('util').inherits
inherits(NativeEmitter, EventEmitter)
const emitter = new NativeEmitter()
emitter.on('start', () => {
console.log('### START ...')
})
emitter.on('data', (evt) => {
console.log(evt)
})
emitter.on('end', () => {
console.log('### END ###')
})
emitter.callAndEmit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment