mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
20 lines
357 B
TypeScript
20 lines
357 B
TypeScript
import { EventEmitter } from 'events'
|
|
|
|
import eventToPromise = require('event-to-promise');
|
|
|
|
{
|
|
const ee = new EventEmitter()
|
|
const ep = eventToPromise(ee, 'custom')
|
|
|
|
ep.then(console.log)
|
|
ee.emit('custom')
|
|
}
|
|
|
|
{
|
|
const et = new EventTarget()
|
|
const tp = eventToPromise.multi(et, ['custom'])
|
|
|
|
tp.then(console.log)
|
|
et.dispatchEvent(new Event('custom'))
|
|
}
|