source: trip-planner-front/node_modules/eventemitter-asyncresource/dist/src/index.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1"use strict";
2const events_1 = require("events");
3const async_hooks_1 = require("async_hooks");
4const kEventEmitter = Symbol('kEventEmitter');
5const kAsyncResource = Symbol('kAsyncResource');
6class EventEmitterReferencingAsyncResource extends async_hooks_1.AsyncResource {
7 constructor(ee, type, options) {
8 super(type, options);
9 this[kEventEmitter] = ee;
10 }
11 get eventEmitter() {
12 return this[kEventEmitter];
13 }
14}
15class EventEmitterAsyncResource extends events_1.EventEmitter {
16 constructor(options) {
17 let name;
18 if (typeof options === 'string') {
19 name = options;
20 options = undefined;
21 }
22 else {
23 name = (options === null || options === void 0 ? void 0 : options.name) || new.target.name;
24 }
25 super(options);
26 this[kAsyncResource] =
27 new EventEmitterReferencingAsyncResource(this, name, options);
28 }
29 emit(event, ...args) {
30 return this.asyncResource.runInAsyncScope(super.emit, this, event, ...args);
31 }
32 emitDestroy() {
33 this.asyncResource.emitDestroy();
34 }
35 asyncId() {
36 return this.asyncResource.asyncId();
37 }
38 triggerAsyncId() {
39 return this.asyncResource.triggerAsyncId();
40 }
41 get asyncResource() {
42 return this[kAsyncResource];
43 }
44 static get EventEmitterAsyncResource() { return EventEmitterAsyncResource; }
45}
46module.exports = EventEmitterAsyncResource;
47//# sourceMappingURL=index.js.map
Note: See TracBrowser for help on using the repository browser.