Sha256: 7e19d0149eefad4f4a3d3faac900f08efd78fe515124fbdc11a117e4468ef79f
Contents?: true
Size: 440 Bytes
Versions: 64
Compression:
Stored size: 440 Bytes
Contents
export default class EventEmitter { constructor(events = []) { this.events = new Map(events); } on(name, cb) { this.events.set(name, [ ...(this.events.has(name) ? this.events.get(name) : []), cb ]); return () => this.events.set(name, this.events.get(name).filter(fn => fn !== cb)); } emit(name, ...args) { return this.events.has(name) && this.events.get(name).map(fn => fn(...args)); } }
Version data entries
64 entries across 64 versions & 1 rubygems