• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3function once(emitter, name, { signal } = {}) {
4    return new Promise((resolve, reject) => {
5        function cleanup() {
6            signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', cleanup);
7            emitter.removeListener(name, onEvent);
8            emitter.removeListener('error', onError);
9        }
10        function onEvent(...args) {
11            cleanup();
12            resolve(args);
13        }
14        function onError(err) {
15            cleanup();
16            reject(err);
17        }
18        signal === null || signal === void 0 ? void 0 : signal.addEventListener('abort', cleanup);
19        emitter.on(name, onEvent);
20        emitter.on('error', onError);
21    });
22}
23exports.default = once;
24//# sourceMappingURL=index.js.map