You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
450 B
JavaScript
24 lines
450 B
JavaScript
3 months ago
|
"use strict";
|
||
|
|
||
|
const createEventEmitter = require("create-event-emitter");
|
||
|
const promisifyEvent = require("./");
|
||
|
|
||
|
// Demonstrated with a dummy event emitter, but it works with any EventEmitter
|
||
|
let emitter = createEventEmitter();
|
||
|
|
||
|
(async function () {
|
||
|
console.log("waiting...");
|
||
|
await promisifyEvent(emitter, "test");
|
||
|
console.log("emitted!");
|
||
|
})();
|
||
|
|
||
|
console.log("emitting...");
|
||
|
emitter.emit("test");
|
||
|
|
||
|
/* Output:
|
||
|
|
||
|
waiting...
|
||
|
emitting...
|
||
|
emitted!
|
||
|
*/
|