@irrelon/emitter 6.0.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -101,7 +101,46 @@ export declare class Emitter<EventsInterface extends EmitterEventsInterface<Even
101
101
  off<EventName extends keyof EventsInterface>(eventName: EventName, id: string, listener?: EventListenerCallback<EventsInterface[EventName]>): this;
102
102
  off<EventName extends keyof EventsInterface>(eventName: EventName, listener?: EventListenerCallback<EventsInterface[EventName]>): this;
103
103
  off<EventName extends keyof EventsInterface>(eventName: EventName): this;
104
+ _emitToSingleListener<EventName extends keyof EventsInterface>(listener: EventListenerCallback<EventsInterface[EventName]>, data: Parameters<EventsInterface[EventName]>): ReturnType<EventsInterface[EventName]> | ListenerReturnFlag;
104
105
  _emitToArrayOfListeners<EventName extends keyof EventsInterface>(arr: EventListenerCallback<EventsInterface[EventName]>[], data: Parameters<EventsInterface[EventName]>): (ReturnType<EventsInterface[EventName]> | ListenerReturnFlag)[];
106
+ /**
107
+ * Call an event listener by name. The `rpc()` function differs from `emit()` in
108
+ * that it will only call and return data from the first event listener for the
109
+ * event rather than all event listeners. If you have more than one event listener
110
+ * assigned to the event, all others except the first will be ignored and will
111
+ * not receive the event.
112
+ * @param eventName The name of the event to call the listener for.
113
+ * @param {...any} data The arguments to send to the listening method.
114
+ * If you are sending multiple arguments, separate them with a comma so
115
+ * that they are received by the function as separate arguments.
116
+ * @return {number}
117
+ * @example #Call the Event Listener
118
+ * // Emit the event named "hello"
119
+ * myEntity.emit('hello');
120
+ * @example #Call the Event Listener With Data Object
121
+ * // Emit the event named "hello"
122
+ * myEntity.emit('hello', {moo: true});
123
+ * @example #Call the Event Listener With Multiple Data Values
124
+ * // Emit the event named "hello"
125
+ * myEntity.emit('hello', {moo: true}, 'someString');
126
+ * @example #Register the Listener for Event Data
127
+ * // Set a listener to listen for the data (multiple values emitted
128
+ * // from an event are passed as function arguments)
129
+ * myEntity.on('hello', function (arg1, arg2) {
130
+ * console.log("Arguments:", arg1, arg2);
131
+ * return "foo";
132
+ * }
133
+ *
134
+ * // Emit the event named "hello"
135
+ * const result = myEntity.emit('hello', 'data1', 'data2');
136
+ * console.log("Result:", result);
137
+ *
138
+ * // The console output is:
139
+ * // Arguments: data1 data2
140
+ * // Result: "foo"
141
+ */
142
+ rpc<EventName extends keyof EventsInterface>(eventName: EventName, ...data: Parameters<EventsInterface[EventName]>): ReturnType<EventsInterface[EventName]> | ListenerReturnFlag;
143
+ rpcId<EventName extends keyof EventsInterface>(eventName: EventName, id: string, ...data: Parameters<EventsInterface[EventName]>): ReturnType<EventsInterface[EventName]> | ListenerReturnFlag;
105
144
  /**
106
145
  * Emit an event by name.
107
146
  * @param eventName The name of the event to emit.
@@ -121,15 +160,20 @@ export declare class Emitter<EventsInterface extends EmitterEventsInterface<Even
121
160
  * @example #Listen for Event Data
122
161
  * // Set a listener to listen for the data (multiple values emitted
123
162
  * // from an event are passed as function arguments)
124
- * myEntity.on('hello', function (arg1, arg2) {
125
- * console.log(arg1, arg2);
163
+ * myEntity.on('hello', function (arg1, arg2) {
164
+ * console.log("Arguments:", arg1, arg2);
165
+ * return "foo";
126
166
  * }
127
167
  *
128
168
  * // Emit the event named "hello"
129
- * myEntity.emit('hello', 'data1', 'data2');
169
+ * // The result is returned as an array of all return values
170
+ * // from all the listeners for the event
171
+ * const result = myEntity.emit('hello', 'data1', 'data2');
172
+ * console.log("Result:", result);
130
173
  *
131
174
  * // The console output is:
132
- * // data1, data2
175
+ * // Arguments: data1 data2
176
+ * // Result: ["foo"]
133
177
  */
134
178
  emit<EventName extends keyof EventsInterface>(eventName: EventName, ...data: Parameters<EventsInterface[EventName]>): (ReturnType<EventsInterface[EventName]> | ListenerReturnFlag)[];
135
179
  emitId<EventName extends keyof EventsInterface>(eventName: EventName, id: string, ...data: Parameters<EventsInterface[EventName]>): (ReturnType<EventsInterface[EventName]> | ListenerReturnFlag)[];
@@ -152,6 +152,9 @@ class Emitter {
152
152
  // Both id and listener were provided, remove for the specific id
153
153
  return this._off(eventName, rest[0], rest[1]);
154
154
  }
155
+ _emitToSingleListener(listener, data) {
156
+ return listener(...data);
157
+ }
155
158
  _emitToArrayOfListeners(arr, data) {
156
159
  const arrCount = arr.length;
157
160
  const resultArr = [];
@@ -170,6 +173,71 @@ class Emitter {
170
173
  }
171
174
  return resultArr;
172
175
  }
176
+ /**
177
+ * Call an event listener by name. The `rpc()` function differs from `emit()` in
178
+ * that it will only call and return data from the first event listener for the
179
+ * event rather than all event listeners. If you have more than one event listener
180
+ * assigned to the event, all others except the first will be ignored and will
181
+ * not receive the event.
182
+ * @param eventName The name of the event to call the listener for.
183
+ * @param {...any} data The arguments to send to the listening method.
184
+ * If you are sending multiple arguments, separate them with a comma so
185
+ * that they are received by the function as separate arguments.
186
+ * @return {number}
187
+ * @example #Call the Event Listener
188
+ * // Emit the event named "hello"
189
+ * myEntity.emit('hello');
190
+ * @example #Call the Event Listener With Data Object
191
+ * // Emit the event named "hello"
192
+ * myEntity.emit('hello', {moo: true});
193
+ * @example #Call the Event Listener With Multiple Data Values
194
+ * // Emit the event named "hello"
195
+ * myEntity.emit('hello', {moo: true}, 'someString');
196
+ * @example #Register the Listener for Event Data
197
+ * // Set a listener to listen for the data (multiple values emitted
198
+ * // from an event are passed as function arguments)
199
+ * myEntity.on('hello', function (arg1, arg2) {
200
+ * console.log("Arguments:", arg1, arg2);
201
+ * return "foo";
202
+ * }
203
+ *
204
+ * // Emit the event named "hello"
205
+ * const result = myEntity.emit('hello', 'data1', 'data2');
206
+ * console.log("Result:", result);
207
+ *
208
+ * // The console output is:
209
+ * // Arguments: data1 data2
210
+ * // Result: "foo"
211
+ */
212
+ rpc(eventName, ...data) {
213
+ return this.rpcId(eventName, "*", ...data);
214
+ }
215
+ rpcId(eventName, id, ...data) {
216
+ if (!this._eventListeners || !this._eventListeners[eventName]) {
217
+ throw new Error("Cannot make an rpc call without at least one event listener and none were found");
218
+ }
219
+ let emitterResult;
220
+ this._eventsEmitting = true;
221
+ if (this._eventListeners[eventName][id]) {
222
+ // Handle id emit
223
+ const arr = this._eventListeners[eventName][id];
224
+ emitterResult = this._emitToSingleListener(arr[0], data);
225
+ }
226
+ else if (id !== "*" && this._eventListeners[eventName]["*"]) {
227
+ // Handle global emit if the id passed wasn't already a global (*) id
228
+ const arr = this._eventListeners[eventName]["*"];
229
+ emitterResult = this._emitToSingleListener(arr[0], data);
230
+ }
231
+ else {
232
+ if (id === "*") {
233
+ throw new Error(`Cannot make an rpc call to event "${eventName}" without at least one event listener and none were found, register a listener via on("${eventName}", () => { ...some listener code })`);
234
+ }
235
+ throw new Error(`Cannot make an rpc call to event "${eventName}" and id "${id}" without at least one event listener and none were found, register a listener via on("${eventName}", "${id}", () => { ...some listener code })`);
236
+ }
237
+ this._eventsEmitting = false;
238
+ this._processRemovalQueue();
239
+ return emitterResult;
240
+ }
173
241
  /**
174
242
  * Emit an event by name.
175
243
  * @param eventName The name of the event to emit.
@@ -189,15 +257,20 @@ class Emitter {
189
257
  * @example #Listen for Event Data
190
258
  * // Set a listener to listen for the data (multiple values emitted
191
259
  * // from an event are passed as function arguments)
192
- * myEntity.on('hello', function (arg1, arg2) {
193
- * console.log(arg1, arg2);
260
+ * myEntity.on('hello', function (arg1, arg2) {
261
+ * console.log("Arguments:", arg1, arg2);
262
+ * return "foo";
194
263
  * }
195
264
  *
196
265
  * // Emit the event named "hello"
197
- * myEntity.emit('hello', 'data1', 'data2');
266
+ * // The result is returned as an array of all return values
267
+ * // from all the listeners for the event
268
+ * const result = myEntity.emit('hello', 'data1', 'data2');
269
+ * console.log("Result:", result);
198
270
  *
199
271
  * // The console output is:
200
- * // data1, data2
272
+ * // Arguments: data1 data2
273
+ * // Result: ["foo"]
201
274
  */
202
275
  emit(eventName, ...data) {
203
276
  return this.emitId(eventName, "*", ...data);
@@ -189,6 +189,29 @@ describe("Emitter", () => {
189
189
  assert_1.default.strictEqual(results[0], "Foo1 Return Value", "Return data for foo1 was not correct");
190
190
  assert_1.default.strictEqual(results[1], "Foo2 Return Value", "Return data for foo2 was not correct");
191
191
  }));
192
+ it("Supports awaiting async and non-async rpc listener return data", () => __awaiter(void 0, void 0, void 0, function* () {
193
+ const emitter = new Emitter_1.Emitter();
194
+ let listenerFiredCount = 0;
195
+ emitter.on("foo1", () => {
196
+ return new Promise((resolve) => {
197
+ setTimeout(() => {
198
+ listenerFiredCount++;
199
+ resolve("Foo1 Return Value");
200
+ }, 1000);
201
+ });
202
+ });
203
+ emitter.on("foo2", () => {
204
+ return "Foo2 Return Value";
205
+ });
206
+ const time = new Date().getTime();
207
+ const result1 = yield emitter.rpc("foo1");
208
+ const result2 = emitter.rpc("foo2");
209
+ const delta = new Date().getTime() - time;
210
+ assert_1.default.ok(delta > 900, "Delta was not correct, await may not have paused?");
211
+ assert_1.default.ok(listenerFiredCount === 1, "listenerFiredCount was not correct, await may not have been used?");
212
+ assert_1.default.strictEqual(result1, "Foo1 Return Value", "Return data for foo1 was not correct");
213
+ assert_1.default.strictEqual(result2, "Foo2 Return Value", "Return data for foo2 was not correct");
214
+ }));
192
215
  it("Supports responding with a cancellation signal", () => __awaiter(void 0, void 0, void 0, function* () {
193
216
  const emitter = new Emitter_1.Emitter();
194
217
  let listenerFiredCount = 0;
@@ -1 +1 @@
1
- {"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/typescript/lib/lib.es2023.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../node_modules/typescript/lib/lib.es2023.array.d.ts","../../node_modules/typescript/lib/lib.es2023.collection.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../node_modules/typescript/lib/lib.esnext.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../src/emitter.ts","../../tests/emitter.test.ts","../../node_modules/@types/node/assert.d.ts","../../node_modules/@types/node/assert/strict.d.ts","../../node_modules/@types/node/globals.d.ts","../../node_modules/@types/node/async_hooks.d.ts","../../node_modules/@types/node/buffer.d.ts","../../node_modules/@types/node/child_process.d.ts","../../node_modules/@types/node/cluster.d.ts","../../node_modules/@types/node/console.d.ts","../../node_modules/@types/node/constants.d.ts","../../node_modules/@types/node/crypto.d.ts","../../node_modules/@types/node/dgram.d.ts","../../node_modules/@types/node/diagnostics_channel.d.ts","../../node_modules/@types/node/dns.d.ts","../../node_modules/@types/node/dns/promises.d.ts","../../node_modules/@types/node/domain.d.ts","../../node_modules/@types/node/events.d.ts","../../node_modules/@types/node/fs.d.ts","../../node_modules/@types/node/fs/promises.d.ts","../../node_modules/@types/node/http.d.ts","../../node_modules/@types/node/http2.d.ts","../../node_modules/@types/node/https.d.ts","../../node_modules/@types/node/inspector.d.ts","../../node_modules/@types/node/module.d.ts","../../node_modules/@types/node/net.d.ts","../../node_modules/@types/node/os.d.ts","../../node_modules/@types/node/path.d.ts","../../node_modules/@types/node/perf_hooks.d.ts","../../node_modules/@types/node/process.d.ts","../../node_modules/@types/node/punycode.d.ts","../../node_modules/@types/node/querystring.d.ts","../../node_modules/@types/node/readline.d.ts","../../node_modules/@types/node/readline/promises.d.ts","../../node_modules/@types/node/repl.d.ts","../../node_modules/@types/node/stream.d.ts","../../node_modules/@types/node/stream/promises.d.ts","../../node_modules/@types/node/stream/consumers.d.ts","../../node_modules/@types/node/stream/web.d.ts","../../node_modules/@types/node/string_decoder.d.ts","../../node_modules/@types/node/test.d.ts","../../node_modules/@types/node/timers.d.ts","../../node_modules/@types/node/timers/promises.d.ts","../../node_modules/@types/node/tls.d.ts","../../node_modules/@types/node/trace_events.d.ts","../../node_modules/@types/node/tty.d.ts","../../node_modules/@types/node/url.d.ts","../../node_modules/@types/node/util.d.ts","../../node_modules/@types/node/v8.d.ts","../../node_modules/@types/node/vm.d.ts","../../node_modules/@types/node/wasi.d.ts","../../node_modules/@types/node/worker_threads.d.ts","../../node_modules/@types/node/zlib.d.ts","../../node_modules/@types/node/globals.global.d.ts","../../node_modules/@types/node/index.d.ts","../../node_modules/@jest/expect-utils/build/index.d.ts","../../node_modules/jest-matcher-utils/node_modules/chalk/index.d.ts","../../node_modules/@sinclair/typebox/typebox.d.ts","../../node_modules/@jest/schemas/build/index.d.ts","../../node_modules/pretty-format/build/index.d.ts","../../node_modules/jest-diff/build/index.d.ts","../../node_modules/jest-matcher-utils/build/index.d.ts","../../node_modules/expect/build/index.d.ts","../../node_modules/@types/jest/index.d.ts"],"fileInfos":[{"version":"f33e5332b24c3773e930e212cbb8b6867c8ba3ec4492064ea78e55a524d57450","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","26f2f787e82c4222710f3b676b4d83eb5ad0a72fa7b746f03449e7a026ce5073","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","1c0cdb8dc619bc549c3e5020643e7cf7ae7940058e8c7e5aefa5871b6d86f44b","bed7b7ba0eb5a160b69af72814b4dde371968e40b6c5e73d3a9f7bee407d158c",{"version":"138fb588d26538783b78d1e3b2c2cc12d55840b97bf5e08bca7f7a174fbe2f17","affectsGlobalScope":true},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true},{"version":"e0275cd0e42990dc3a16f0b7c8bca3efe87f1c8ad404f80c6db1c7c0b828c59f","affectsGlobalScope":true},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"49ed889be54031e1044af0ad2c603d627b8bda8b50c1a68435fe85583901d072","affectsGlobalScope":true},{"version":"e93d098658ce4f0c8a0779e6cab91d0259efb88a318137f686ad76f8410ca270","affectsGlobalScope":true},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"acae90d417bee324b1372813b5a00829d31c7eb670d299cd7f8f9a648ac05688","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"51e547984877a62227042850456de71a5c45e7fe86b7c975c6e68896c86fa23b","affectsGlobalScope":true},{"version":"62a4966981264d1f04c44eb0f4b5bdc3d81c1a54725608861e44755aa24ad6a5","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true},{"version":"86a34c7a13de9cabc43161348f663624b56871ed80986e41d214932ddd8d6719","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"08a58483392df5fcc1db57d782e87734f77ae9eab42516028acbfe46f29a3ef7","affectsGlobalScope":true},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true},{"version":"13f6e6380c78e15e140243dc4be2fa546c287c6d61f4729bc2dd7cf449605471","affectsGlobalScope":true},{"version":"4350e5922fecd4bedda2964d69c213a1436349d0b8d260dd902795f5b94dc74b","affectsGlobalScope":true},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},{"version":"26fbc5e2e6ca6b5341a2c1b0f2a22d7727cb461f45924569dee7c39b41477756","signature":"815c63ed250d406ad551ba3690048484ee5fc4a788410760301a13d5b2af10d8"},{"version":"f7f80f896c5dbc24c28c7d2589e922de1e6258c3a47509d4e97ebe94000d58c9","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},"9122ed7070e054b73ebab37c2373a196def2d90e7d1a9a7fcd9d46b0e51fae78","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"e31b69b603075736c59065f0c89606f93068600d94b456dda77248c8b2a803a9","affectsGlobalScope":true},"21a167fec8f933752fb8157f06d28fab6817af3ad9b0bdb1908a10762391eab9",{"version":"002d6d5f044365b3fbfba0ba9be3bb57cac09b81547c8df4b0795755d2081d90","affectsGlobalScope":true},"0c0cee62cb619aed81133b904f644515ba3064487002a7da83fd8aa07b1b4abd","5a94487653355b56018122d92392beb2e5f4a6c63ba5cef83bbe1c99775ef713",{"version":"d5135ad93b33adcce80b18f8065087934cdc1730d63db58562edcf017e1aad9b","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","c4cfc9a6e2ebb8bc8c0e2392dfc4056993ced3b35069ebf132ac18ca7a562881","bb9c4ffa5e6290c6980b63c815cdd1625876dadb2efaf77edbe82984be93e55e","75ecef44f126e2ae018b4abbd85b6e8a2e2ba1638ebec56cc64274643ce3567b","f30bb836526d930a74593f7b0f5c1c46d10856415a8f69e5e2fc3db80371e362","14b5aa23c5d0ae1907bc696ac7b6915d88f7d85799cc0dc2dcf98fbce2c5a67c","5c439dafdc09abe4d6c260a96b822fa0ba5be7203c71a63ab1f1423cd9e838ea",{"version":"bae4ea23beb8397755b935cb84d3cdc6cdb0b1b4a329b90de9fc6c8774d71994","affectsGlobalScope":true},"cec36af22f514322f870e81d30675c78df82ae8bf4863f5fd4e4424c040c678d","df36874d9e56aff601e921c4b3971d37cf66d14f6455935ce821e6cad13b1823","3c135ff5bda0355f6b52a10ea931736ec7c5a80b7fb8772019054e0eaa0fd6b6","1abb206a4ecd13b21536b677d7d5f66e0d7316f0d44610197cfcc5776f78884a","dbe5aa5a5dd8bd1c6a8d11b1310c3f0cdabaacc78a37b394a8c7b14faeb5fb84","2c828a5405191d006115ab34e191b8474bc6c86ffdc401d1a9864b1b6e088a58",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"76527127c8b749bee5977408861ce3ee56ec19ddcea8704c628f98ca610283e6","7c013aa892414a7fdcfd861ae524a668eaa3ede8c7c0acafaf611948122c8d93","b68bd7bef90dab08b1866a9fee24f03d9fee10bcb3f587b074e96e61abf6d3f0","cb4f3f03480e1727eae46400606cecaa97f550186ff8fa909ebc00db4180531b",{"version":"b3624aed92dab6da8484280d3cb3e2f4130ec3f4ef3f8201c95144ae9e898bb6","affectsGlobalScope":true},"5153a2fd150e46ce57bb3f8db1318d33f6ad3261ed70ceeff92281c0608c74a3","d1a78a3c5708807e8de3e399f91df4797c62e44b02195eefc2209b2e713e54ee","36b03690b628eab08703d63f04eaa89c5df202e5f1edf3989f13ad389cd2c091","0effadd232a20498b11308058e334d3339cc5bf8c4c858393e38d9d4c0013dcf","25846d43937c672bab7e8195f3d881f93495df712ee901860effc109918938cc","556bf5c36deb62cffa1bf697c1789fe008ec82db0273025001db66732714e9d9","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff",{"version":"806ef4cac3b3d9fa4a48d849c8e084d7c72fcd7b16d76e06049a9ed742ff79c0","affectsGlobalScope":true},"44b8b584a338b190a59f4f6929d072431950c7bd92ec2694821c11bce180c8a5","23b89798789dffbd437c0c423f5d02d11f9736aea73d6abf16db4f812ff36eda","24ad30a03d6c9266b63540956868dd70fa2dc523d60d780d6586eb0c281946bc",{"version":"970a90f76d4d219ad60819d61f5994514087ba94c985647a3474a5a3d12714ed","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","4c8525f256873c7ba3135338c647eaf0ca7115a1a2805ae2d0056629461186ce","3c13ef48634e7b5012fcf7e8fce7496352c2d779a7201389ca96a2a81ee4314d","5d0a25ec910fa36595f85a67ac992d7a53dd4064a1ba6aea1c9f14ab73a023f2",{"version":"bfe39beb986d2a2e512c091cbe924f1c415bc65de54de0e2f6a0dc6f84c183d9","affectsGlobalScope":true},"2d526e6f21d8cc66ac11ada32874e95ae88d870c6c9d3d9d4e03b1d1f9ad7b8e","06d7c42d256f0ce6afe1b2b6cfbc97ab391f29dadb00dd0ae8e8f23f5bc916c3","ec4bd1b200670fb567920db572d6701ed42a9641d09c4ff6869768c8f81b404c","e59a892d87e72733e2a9ca21611b9beb52977be2696c7ba4b216cbbb9a48f5aa","d2ec52f565f0570e90b659811347bd689f8c6039b11eaaccd0f243759d46da6e","8a300fa9b698845a1f9c41ecbe2c5966634582a8e2020d51abcace9b55aa959e",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"854a39fe9c9e32cc0855380e0f16bbb25217c3b62d8a687fe2b663ba44b3b5a1","763e521cf114b80e0dd0e21ca49b9f8ae62e8999555a5e7bade8ce36b33001c2","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","032cbd1883827ca3728c1400145403b62e65b7b584a0d2115ae538c9edec7936","427ce5854885cfc34387e09de05c1d5c1acf94c2143e1693f1d9ff54880573e7","bed2c4f96fab3348be4a34d88dcb12578c1b2475b07c6acd369e99e227718d81","e3ba509d3dce019b3190ceb2f3fc88e2610ab717122dabd91a9efaa37804040d","cda0cb09b995489b7f4c57f168cd31b83dcbaa7aad49612734fb3c9c73f6e4f2","3b105d5a0dacc73812d93e90d3c7243fd5a9c0566a2e63bc2964ca12d882c8e8",{"version":"458e2fd1185e659cb800ef68d01ef77de70dcab8860bedf6d94eaebe736751f1","affectsGlobalScope":true}],"root":[64,65],"options":{"allowJs":false,"allowSyntheticDefaultImports":true,"declaration":true,"downlevelIteration":true,"esModuleInterop":true,"inlineSourceMap":false,"module":1,"outDir":"./","skipLibCheck":false,"strict":true,"target":2},"fileIdsList":[[111],[111,121],[111,123,126],[66,111],[69,111],[70,75,111],[71,81,82,89,99,110,111],[71,72,81,89,111],[73,111],[74,75,82,90,111],[75,99,107,111],[76,78,81,89,111],[77,111],[78,79,111],[80,81,111],[81,111],[81,82,83,99,110,111],[81,82,83,99,102,111],[111,115],[84,89,99,110,111],[81,82,84,85,89,99,107,110,111],[84,86,99,107,110,111],[66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117],[81,87,111],[88,110,111],[78,81,89,99,111],[90,111],[91,111],[69,92,111],[93,109,111,115],[94,111],[95,111],[81,96,97,111],[96,98,111,113],[81,99,100,101,102,111],[99,101,111],[99,100,111],[102,111],[103,111],[81,105,106,111],[105,106,111],[75,89,99,107,111],[108,111],[89,109,111],[70,84,95,110,111],[75,111],[99,111,112],[111,113],[111,114],[70,75,81,83,92,99,110,111,113,115],[99,111,116],[111,119,125],[111,123],[111,120,124],[111,122],[64,66,111]],"referencedMap":[[119,1],[122,2],[121,1],[127,3],[66,4],[67,4],[69,5],[70,6],[71,7],[72,8],[73,9],[74,10],[75,11],[76,12],[77,13],[78,14],[79,14],[80,15],[81,16],[82,17],[83,18],[68,19],[117,1],[84,20],[85,21],[86,22],[118,23],[87,24],[88,25],[89,26],[90,27],[91,28],[92,29],[93,30],[94,31],[95,32],[96,33],[97,33],[98,34],[99,35],[101,36],[100,37],[102,38],[103,39],[104,1],[105,40],[106,41],[107,42],[108,43],[109,44],[110,45],[111,46],[112,47],[113,48],[114,49],[115,50],[116,51],[126,52],[124,53],[125,54],[120,1],[123,55],[62,1],[63,1],[13,1],[12,1],[2,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[20,1],[21,1],[3,1],[4,1],[22,1],[26,1],[23,1],[24,1],[25,1],[27,1],[28,1],[29,1],[5,1],[30,1],[31,1],[32,1],[33,1],[6,1],[37,1],[34,1],[35,1],[36,1],[38,1],[7,1],[39,1],[44,1],[45,1],[40,1],[41,1],[42,1],[43,1],[8,1],[49,1],[46,1],[47,1],[48,1],[50,1],[9,1],[51,1],[52,1],[53,1],[56,1],[54,1],[55,1],[57,1],[58,1],[10,1],[1,1],[11,1],[61,1],[60,1],[59,1],[64,1],[65,56]],"exportedModulesMap":[[119,1],[122,2],[121,1],[127,3],[66,4],[67,4],[69,5],[70,6],[71,7],[72,8],[73,9],[74,10],[75,11],[76,12],[77,13],[78,14],[79,14],[80,15],[81,16],[82,17],[83,18],[68,19],[117,1],[84,20],[85,21],[86,22],[118,23],[87,24],[88,25],[89,26],[90,27],[91,28],[92,29],[93,30],[94,31],[95,32],[96,33],[97,33],[98,34],[99,35],[101,36],[100,37],[102,38],[103,39],[104,1],[105,40],[106,41],[107,42],[108,43],[109,44],[110,45],[111,46],[112,47],[113,48],[114,49],[115,50],[116,51],[126,52],[124,53],[125,54],[120,1],[123,55],[62,1],[63,1],[13,1],[12,1],[2,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[20,1],[21,1],[3,1],[4,1],[22,1],[26,1],[23,1],[24,1],[25,1],[27,1],[28,1],[29,1],[5,1],[30,1],[31,1],[32,1],[33,1],[6,1],[37,1],[34,1],[35,1],[36,1],[38,1],[7,1],[39,1],[44,1],[45,1],[40,1],[41,1],[42,1],[43,1],[8,1],[49,1],[46,1],[47,1],[48,1],[50,1],[9,1],[51,1],[52,1],[53,1],[56,1],[54,1],[55,1],[57,1],[58,1],[10,1],[1,1],[11,1],[61,1],[60,1],[59,1]],"semanticDiagnosticsPerFile":[119,122,121,127,66,67,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,68,117,84,85,86,118,87,88,89,90,91,92,93,94,95,96,97,98,99,101,100,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,126,124,125,120,123,62,63,13,12,2,14,15,16,17,18,19,20,21,3,4,22,26,23,24,25,27,28,29,5,30,31,32,33,6,37,34,35,36,38,7,39,44,45,40,41,42,43,8,49,46,47,48,50,9,51,52,53,56,54,55,57,58,10,1,11,61,60,59,64,65]},"version":"5.3.2"}
1
+ {"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/typescript/lib/lib.es2023.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../node_modules/typescript/lib/lib.es2023.array.d.ts","../../node_modules/typescript/lib/lib.es2023.collection.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../node_modules/typescript/lib/lib.esnext.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../src/emitter.ts","../../tests/emitter.test.ts","../../node_modules/@types/node/assert.d.ts","../../node_modules/@types/node/assert/strict.d.ts","../../node_modules/@types/node/globals.d.ts","../../node_modules/@types/node/async_hooks.d.ts","../../node_modules/@types/node/buffer.d.ts","../../node_modules/@types/node/child_process.d.ts","../../node_modules/@types/node/cluster.d.ts","../../node_modules/@types/node/console.d.ts","../../node_modules/@types/node/constants.d.ts","../../node_modules/@types/node/crypto.d.ts","../../node_modules/@types/node/dgram.d.ts","../../node_modules/@types/node/diagnostics_channel.d.ts","../../node_modules/@types/node/dns.d.ts","../../node_modules/@types/node/dns/promises.d.ts","../../node_modules/@types/node/domain.d.ts","../../node_modules/@types/node/events.d.ts","../../node_modules/@types/node/fs.d.ts","../../node_modules/@types/node/fs/promises.d.ts","../../node_modules/@types/node/http.d.ts","../../node_modules/@types/node/http2.d.ts","../../node_modules/@types/node/https.d.ts","../../node_modules/@types/node/inspector.d.ts","../../node_modules/@types/node/module.d.ts","../../node_modules/@types/node/net.d.ts","../../node_modules/@types/node/os.d.ts","../../node_modules/@types/node/path.d.ts","../../node_modules/@types/node/perf_hooks.d.ts","../../node_modules/@types/node/process.d.ts","../../node_modules/@types/node/punycode.d.ts","../../node_modules/@types/node/querystring.d.ts","../../node_modules/@types/node/readline.d.ts","../../node_modules/@types/node/readline/promises.d.ts","../../node_modules/@types/node/repl.d.ts","../../node_modules/@types/node/stream.d.ts","../../node_modules/@types/node/stream/promises.d.ts","../../node_modules/@types/node/stream/consumers.d.ts","../../node_modules/@types/node/stream/web.d.ts","../../node_modules/@types/node/string_decoder.d.ts","../../node_modules/@types/node/test.d.ts","../../node_modules/@types/node/timers.d.ts","../../node_modules/@types/node/timers/promises.d.ts","../../node_modules/@types/node/tls.d.ts","../../node_modules/@types/node/trace_events.d.ts","../../node_modules/@types/node/tty.d.ts","../../node_modules/@types/node/url.d.ts","../../node_modules/@types/node/util.d.ts","../../node_modules/@types/node/v8.d.ts","../../node_modules/@types/node/vm.d.ts","../../node_modules/@types/node/wasi.d.ts","../../node_modules/@types/node/worker_threads.d.ts","../../node_modules/@types/node/zlib.d.ts","../../node_modules/@types/node/globals.global.d.ts","../../node_modules/@types/node/index.d.ts","../../node_modules/@jest/expect-utils/build/index.d.ts","../../node_modules/jest-matcher-utils/node_modules/chalk/index.d.ts","../../node_modules/@sinclair/typebox/typebox.d.ts","../../node_modules/@jest/schemas/build/index.d.ts","../../node_modules/pretty-format/build/index.d.ts","../../node_modules/jest-diff/build/index.d.ts","../../node_modules/jest-matcher-utils/build/index.d.ts","../../node_modules/expect/build/index.d.ts","../../node_modules/@types/jest/index.d.ts"],"fileInfos":[{"version":"f33e5332b24c3773e930e212cbb8b6867c8ba3ec4492064ea78e55a524d57450","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","26f2f787e82c4222710f3b676b4d83eb5ad0a72fa7b746f03449e7a026ce5073","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","1c0cdb8dc619bc549c3e5020643e7cf7ae7940058e8c7e5aefa5871b6d86f44b","bed7b7ba0eb5a160b69af72814b4dde371968e40b6c5e73d3a9f7bee407d158c",{"version":"138fb588d26538783b78d1e3b2c2cc12d55840b97bf5e08bca7f7a174fbe2f17","affectsGlobalScope":true},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true},{"version":"e0275cd0e42990dc3a16f0b7c8bca3efe87f1c8ad404f80c6db1c7c0b828c59f","affectsGlobalScope":true},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"49ed889be54031e1044af0ad2c603d627b8bda8b50c1a68435fe85583901d072","affectsGlobalScope":true},{"version":"e93d098658ce4f0c8a0779e6cab91d0259efb88a318137f686ad76f8410ca270","affectsGlobalScope":true},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"acae90d417bee324b1372813b5a00829d31c7eb670d299cd7f8f9a648ac05688","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"51e547984877a62227042850456de71a5c45e7fe86b7c975c6e68896c86fa23b","affectsGlobalScope":true},{"version":"62a4966981264d1f04c44eb0f4b5bdc3d81c1a54725608861e44755aa24ad6a5","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true},{"version":"86a34c7a13de9cabc43161348f663624b56871ed80986e41d214932ddd8d6719","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"08a58483392df5fcc1db57d782e87734f77ae9eab42516028acbfe46f29a3ef7","affectsGlobalScope":true},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true},{"version":"13f6e6380c78e15e140243dc4be2fa546c287c6d61f4729bc2dd7cf449605471","affectsGlobalScope":true},{"version":"4350e5922fecd4bedda2964d69c213a1436349d0b8d260dd902795f5b94dc74b","affectsGlobalScope":true},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},{"version":"56d457af26414c080c425574ed0b56e75cc0bf96ab12d6b6977e44b7ca938934","signature":"0e330e7814a04b66aa6f8192d6da8ae183a826b5f5977bcc536b6c267170a535"},{"version":"75bacf6089744c7f756cbc4076105b078708a164084eb522ec88a14da79e5efe","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},"9122ed7070e054b73ebab37c2373a196def2d90e7d1a9a7fcd9d46b0e51fae78","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"e31b69b603075736c59065f0c89606f93068600d94b456dda77248c8b2a803a9","affectsGlobalScope":true},"21a167fec8f933752fb8157f06d28fab6817af3ad9b0bdb1908a10762391eab9",{"version":"002d6d5f044365b3fbfba0ba9be3bb57cac09b81547c8df4b0795755d2081d90","affectsGlobalScope":true},"0c0cee62cb619aed81133b904f644515ba3064487002a7da83fd8aa07b1b4abd","5a94487653355b56018122d92392beb2e5f4a6c63ba5cef83bbe1c99775ef713",{"version":"d5135ad93b33adcce80b18f8065087934cdc1730d63db58562edcf017e1aad9b","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","c4cfc9a6e2ebb8bc8c0e2392dfc4056993ced3b35069ebf132ac18ca7a562881","bb9c4ffa5e6290c6980b63c815cdd1625876dadb2efaf77edbe82984be93e55e","75ecef44f126e2ae018b4abbd85b6e8a2e2ba1638ebec56cc64274643ce3567b","f30bb836526d930a74593f7b0f5c1c46d10856415a8f69e5e2fc3db80371e362","14b5aa23c5d0ae1907bc696ac7b6915d88f7d85799cc0dc2dcf98fbce2c5a67c","5c439dafdc09abe4d6c260a96b822fa0ba5be7203c71a63ab1f1423cd9e838ea",{"version":"bae4ea23beb8397755b935cb84d3cdc6cdb0b1b4a329b90de9fc6c8774d71994","affectsGlobalScope":true},"cec36af22f514322f870e81d30675c78df82ae8bf4863f5fd4e4424c040c678d","df36874d9e56aff601e921c4b3971d37cf66d14f6455935ce821e6cad13b1823","3c135ff5bda0355f6b52a10ea931736ec7c5a80b7fb8772019054e0eaa0fd6b6","1abb206a4ecd13b21536b677d7d5f66e0d7316f0d44610197cfcc5776f78884a","dbe5aa5a5dd8bd1c6a8d11b1310c3f0cdabaacc78a37b394a8c7b14faeb5fb84","2c828a5405191d006115ab34e191b8474bc6c86ffdc401d1a9864b1b6e088a58",{"version":"e8b18c6385ff784228a6f369694fcf1a6b475355ba89090a88de13587a9391d5","affectsGlobalScope":true},"76527127c8b749bee5977408861ce3ee56ec19ddcea8704c628f98ca610283e6","7c013aa892414a7fdcfd861ae524a668eaa3ede8c7c0acafaf611948122c8d93","b68bd7bef90dab08b1866a9fee24f03d9fee10bcb3f587b074e96e61abf6d3f0","cb4f3f03480e1727eae46400606cecaa97f550186ff8fa909ebc00db4180531b",{"version":"b3624aed92dab6da8484280d3cb3e2f4130ec3f4ef3f8201c95144ae9e898bb6","affectsGlobalScope":true},"5153a2fd150e46ce57bb3f8db1318d33f6ad3261ed70ceeff92281c0608c74a3","d1a78a3c5708807e8de3e399f91df4797c62e44b02195eefc2209b2e713e54ee","36b03690b628eab08703d63f04eaa89c5df202e5f1edf3989f13ad389cd2c091","0effadd232a20498b11308058e334d3339cc5bf8c4c858393e38d9d4c0013dcf","25846d43937c672bab7e8195f3d881f93495df712ee901860effc109918938cc","556bf5c36deb62cffa1bf697c1789fe008ec82db0273025001db66732714e9d9","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff",{"version":"806ef4cac3b3d9fa4a48d849c8e084d7c72fcd7b16d76e06049a9ed742ff79c0","affectsGlobalScope":true},"44b8b584a338b190a59f4f6929d072431950c7bd92ec2694821c11bce180c8a5","23b89798789dffbd437c0c423f5d02d11f9736aea73d6abf16db4f812ff36eda","24ad30a03d6c9266b63540956868dd70fa2dc523d60d780d6586eb0c281946bc",{"version":"970a90f76d4d219ad60819d61f5994514087ba94c985647a3474a5a3d12714ed","affectsGlobalScope":true},"664d8f2d59164f2e08c543981453893bc7e003e4dfd29651ce09db13e9457980","4c8525f256873c7ba3135338c647eaf0ca7115a1a2805ae2d0056629461186ce","3c13ef48634e7b5012fcf7e8fce7496352c2d779a7201389ca96a2a81ee4314d","5d0a25ec910fa36595f85a67ac992d7a53dd4064a1ba6aea1c9f14ab73a023f2",{"version":"bfe39beb986d2a2e512c091cbe924f1c415bc65de54de0e2f6a0dc6f84c183d9","affectsGlobalScope":true},"2d526e6f21d8cc66ac11ada32874e95ae88d870c6c9d3d9d4e03b1d1f9ad7b8e","06d7c42d256f0ce6afe1b2b6cfbc97ab391f29dadb00dd0ae8e8f23f5bc916c3","ec4bd1b200670fb567920db572d6701ed42a9641d09c4ff6869768c8f81b404c","e59a892d87e72733e2a9ca21611b9beb52977be2696c7ba4b216cbbb9a48f5aa","d2ec52f565f0570e90b659811347bd689f8c6039b11eaaccd0f243759d46da6e","8a300fa9b698845a1f9c41ecbe2c5966634582a8e2020d51abcace9b55aa959e",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"854a39fe9c9e32cc0855380e0f16bbb25217c3b62d8a687fe2b663ba44b3b5a1","763e521cf114b80e0dd0e21ca49b9f8ae62e8999555a5e7bade8ce36b33001c2","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","032cbd1883827ca3728c1400145403b62e65b7b584a0d2115ae538c9edec7936","427ce5854885cfc34387e09de05c1d5c1acf94c2143e1693f1d9ff54880573e7","bed2c4f96fab3348be4a34d88dcb12578c1b2475b07c6acd369e99e227718d81","e3ba509d3dce019b3190ceb2f3fc88e2610ab717122dabd91a9efaa37804040d","cda0cb09b995489b7f4c57f168cd31b83dcbaa7aad49612734fb3c9c73f6e4f2","3b105d5a0dacc73812d93e90d3c7243fd5a9c0566a2e63bc2964ca12d882c8e8",{"version":"458e2fd1185e659cb800ef68d01ef77de70dcab8860bedf6d94eaebe736751f1","affectsGlobalScope":true}],"root":[64,65],"options":{"allowJs":false,"allowSyntheticDefaultImports":true,"declaration":true,"downlevelIteration":true,"esModuleInterop":true,"inlineSourceMap":false,"module":1,"outDir":"./","skipLibCheck":false,"strict":true,"target":2},"fileIdsList":[[111],[111,121],[111,123,126],[66,111],[69,111],[70,75,111],[71,81,82,89,99,110,111],[71,72,81,89,111],[73,111],[74,75,82,90,111],[75,99,107,111],[76,78,81,89,111],[77,111],[78,79,111],[80,81,111],[81,111],[81,82,83,99,110,111],[81,82,83,99,102,111],[111,115],[84,89,99,110,111],[81,82,84,85,89,99,107,110,111],[84,86,99,107,110,111],[66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117],[81,87,111],[88,110,111],[78,81,89,99,111],[90,111],[91,111],[69,92,111],[93,109,111,115],[94,111],[95,111],[81,96,97,111],[96,98,111,113],[81,99,100,101,102,111],[99,101,111],[99,100,111],[102,111],[103,111],[81,105,106,111],[105,106,111],[75,89,99,107,111],[108,111],[89,109,111],[70,84,95,110,111],[75,111],[99,111,112],[111,113],[111,114],[70,75,81,83,92,99,110,111,113,115],[99,111,116],[111,119,125],[111,123],[111,120,124],[111,122],[64,66,111]],"referencedMap":[[119,1],[122,2],[121,1],[127,3],[66,4],[67,4],[69,5],[70,6],[71,7],[72,8],[73,9],[74,10],[75,11],[76,12],[77,13],[78,14],[79,14],[80,15],[81,16],[82,17],[83,18],[68,19],[117,1],[84,20],[85,21],[86,22],[118,23],[87,24],[88,25],[89,26],[90,27],[91,28],[92,29],[93,30],[94,31],[95,32],[96,33],[97,33],[98,34],[99,35],[101,36],[100,37],[102,38],[103,39],[104,1],[105,40],[106,41],[107,42],[108,43],[109,44],[110,45],[111,46],[112,47],[113,48],[114,49],[115,50],[116,51],[126,52],[124,53],[125,54],[120,1],[123,55],[62,1],[63,1],[13,1],[12,1],[2,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[20,1],[21,1],[3,1],[4,1],[22,1],[26,1],[23,1],[24,1],[25,1],[27,1],[28,1],[29,1],[5,1],[30,1],[31,1],[32,1],[33,1],[6,1],[37,1],[34,1],[35,1],[36,1],[38,1],[7,1],[39,1],[44,1],[45,1],[40,1],[41,1],[42,1],[43,1],[8,1],[49,1],[46,1],[47,1],[48,1],[50,1],[9,1],[51,1],[52,1],[53,1],[56,1],[54,1],[55,1],[57,1],[58,1],[10,1],[1,1],[11,1],[61,1],[60,1],[59,1],[64,1],[65,56]],"exportedModulesMap":[[119,1],[122,2],[121,1],[127,3],[66,4],[67,4],[69,5],[70,6],[71,7],[72,8],[73,9],[74,10],[75,11],[76,12],[77,13],[78,14],[79,14],[80,15],[81,16],[82,17],[83,18],[68,19],[117,1],[84,20],[85,21],[86,22],[118,23],[87,24],[88,25],[89,26],[90,27],[91,28],[92,29],[93,30],[94,31],[95,32],[96,33],[97,33],[98,34],[99,35],[101,36],[100,37],[102,38],[103,39],[104,1],[105,40],[106,41],[107,42],[108,43],[109,44],[110,45],[111,46],[112,47],[113,48],[114,49],[115,50],[116,51],[126,52],[124,53],[125,54],[120,1],[123,55],[62,1],[63,1],[13,1],[12,1],[2,1],[14,1],[15,1],[16,1],[17,1],[18,1],[19,1],[20,1],[21,1],[3,1],[4,1],[22,1],[26,1],[23,1],[24,1],[25,1],[27,1],[28,1],[29,1],[5,1],[30,1],[31,1],[32,1],[33,1],[6,1],[37,1],[34,1],[35,1],[36,1],[38,1],[7,1],[39,1],[44,1],[45,1],[40,1],[41,1],[42,1],[43,1],[8,1],[49,1],[46,1],[47,1],[48,1],[50,1],[9,1],[51,1],[52,1],[53,1],[56,1],[54,1],[55,1],[57,1],[58,1],[10,1],[1,1],[11,1],[61,1],[60,1],[59,1]],"semanticDiagnosticsPerFile":[119,122,121,127,66,67,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,68,117,84,85,86,118,87,88,89,90,91,92,93,94,95,96,97,98,99,101,100,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,126,124,125,120,123,62,63,13,12,2,14,15,16,17,18,19,20,21,3,4,22,26,23,24,25,27,28,29,5,30,31,32,33,6,37,34,35,36,38,7,39,44,45,40,41,42,43,8,49,46,47,48,50,9,51,52,53,56,54,55,57,58,10,1,11,61,60,59,64,65]},"version":"5.3.2"}
@@ -101,7 +101,46 @@ export declare class Emitter<EventsInterface extends EmitterEventsInterface<Even
101
101
  off<EventName extends keyof EventsInterface>(eventName: EventName, id: string, listener?: EventListenerCallback<EventsInterface[EventName]>): this;
102
102
  off<EventName extends keyof EventsInterface>(eventName: EventName, listener?: EventListenerCallback<EventsInterface[EventName]>): this;
103
103
  off<EventName extends keyof EventsInterface>(eventName: EventName): this;
104
+ _emitToSingleListener<EventName extends keyof EventsInterface>(listener: EventListenerCallback<EventsInterface[EventName]>, data: Parameters<EventsInterface[EventName]>): ReturnType<EventsInterface[EventName]> | ListenerReturnFlag;
104
105
  _emitToArrayOfListeners<EventName extends keyof EventsInterface>(arr: EventListenerCallback<EventsInterface[EventName]>[], data: Parameters<EventsInterface[EventName]>): (ReturnType<EventsInterface[EventName]> | ListenerReturnFlag)[];
106
+ /**
107
+ * Call an event listener by name. The `rpc()` function differs from `emit()` in
108
+ * that it will only call and return data from the first event listener for the
109
+ * event rather than all event listeners. If you have more than one event listener
110
+ * assigned to the event, all others except the first will be ignored and will
111
+ * not receive the event.
112
+ * @param eventName The name of the event to call the listener for.
113
+ * @param {...any} data The arguments to send to the listening method.
114
+ * If you are sending multiple arguments, separate them with a comma so
115
+ * that they are received by the function as separate arguments.
116
+ * @return {number}
117
+ * @example #Call the Event Listener
118
+ * // Emit the event named "hello"
119
+ * myEntity.emit('hello');
120
+ * @example #Call the Event Listener With Data Object
121
+ * // Emit the event named "hello"
122
+ * myEntity.emit('hello', {moo: true});
123
+ * @example #Call the Event Listener With Multiple Data Values
124
+ * // Emit the event named "hello"
125
+ * myEntity.emit('hello', {moo: true}, 'someString');
126
+ * @example #Register the Listener for Event Data
127
+ * // Set a listener to listen for the data (multiple values emitted
128
+ * // from an event are passed as function arguments)
129
+ * myEntity.on('hello', function (arg1, arg2) {
130
+ * console.log("Arguments:", arg1, arg2);
131
+ * return "foo";
132
+ * }
133
+ *
134
+ * // Emit the event named "hello"
135
+ * const result = myEntity.emit('hello', 'data1', 'data2');
136
+ * console.log("Result:", result);
137
+ *
138
+ * // The console output is:
139
+ * // Arguments: data1 data2
140
+ * // Result: "foo"
141
+ */
142
+ rpc<EventName extends keyof EventsInterface>(eventName: EventName, ...data: Parameters<EventsInterface[EventName]>): ReturnType<EventsInterface[EventName]> | ListenerReturnFlag;
143
+ rpcId<EventName extends keyof EventsInterface>(eventName: EventName, id: string, ...data: Parameters<EventsInterface[EventName]>): ReturnType<EventsInterface[EventName]> | ListenerReturnFlag;
105
144
  /**
106
145
  * Emit an event by name.
107
146
  * @param eventName The name of the event to emit.
@@ -121,15 +160,20 @@ export declare class Emitter<EventsInterface extends EmitterEventsInterface<Even
121
160
  * @example #Listen for Event Data
122
161
  * // Set a listener to listen for the data (multiple values emitted
123
162
  * // from an event are passed as function arguments)
124
- * myEntity.on('hello', function (arg1, arg2) {
125
- * console.log(arg1, arg2);
163
+ * myEntity.on('hello', function (arg1, arg2) {
164
+ * console.log("Arguments:", arg1, arg2);
165
+ * return "foo";
126
166
  * }
127
167
  *
128
168
  * // Emit the event named "hello"
129
- * myEntity.emit('hello', 'data1', 'data2');
169
+ * // The result is returned as an array of all return values
170
+ * // from all the listeners for the event
171
+ * const result = myEntity.emit('hello', 'data1', 'data2');
172
+ * console.log("Result:", result);
130
173
  *
131
174
  * // The console output is:
132
- * // data1, data2
175
+ * // Arguments: data1 data2
176
+ * // Result: ["foo"]
133
177
  */
134
178
  emit<EventName extends keyof EventsInterface>(eventName: EventName, ...data: Parameters<EventsInterface[EventName]>): (ReturnType<EventsInterface[EventName]> | ListenerReturnFlag)[];
135
179
  emitId<EventName extends keyof EventsInterface>(eventName: EventName, id: string, ...data: Parameters<EventsInterface[EventName]>): (ReturnType<EventsInterface[EventName]> | ListenerReturnFlag)[];
@@ -147,6 +147,9 @@ export class Emitter {
147
147
  // Both id and listener were provided, remove for the specific id
148
148
  return this._off(eventName, rest[0], rest[1]);
149
149
  }
150
+ _emitToSingleListener(listener, data) {
151
+ return listener(...data);
152
+ }
150
153
  _emitToArrayOfListeners(arr, data) {
151
154
  const arrCount = arr.length;
152
155
  const resultArr = [];
@@ -165,6 +168,71 @@ export class Emitter {
165
168
  }
166
169
  return resultArr;
167
170
  }
171
+ /**
172
+ * Call an event listener by name. The `rpc()` function differs from `emit()` in
173
+ * that it will only call and return data from the first event listener for the
174
+ * event rather than all event listeners. If you have more than one event listener
175
+ * assigned to the event, all others except the first will be ignored and will
176
+ * not receive the event.
177
+ * @param eventName The name of the event to call the listener for.
178
+ * @param {...any} data The arguments to send to the listening method.
179
+ * If you are sending multiple arguments, separate them with a comma so
180
+ * that they are received by the function as separate arguments.
181
+ * @return {number}
182
+ * @example #Call the Event Listener
183
+ * // Emit the event named "hello"
184
+ * myEntity.emit('hello');
185
+ * @example #Call the Event Listener With Data Object
186
+ * // Emit the event named "hello"
187
+ * myEntity.emit('hello', {moo: true});
188
+ * @example #Call the Event Listener With Multiple Data Values
189
+ * // Emit the event named "hello"
190
+ * myEntity.emit('hello', {moo: true}, 'someString');
191
+ * @example #Register the Listener for Event Data
192
+ * // Set a listener to listen for the data (multiple values emitted
193
+ * // from an event are passed as function arguments)
194
+ * myEntity.on('hello', function (arg1, arg2) {
195
+ * console.log("Arguments:", arg1, arg2);
196
+ * return "foo";
197
+ * }
198
+ *
199
+ * // Emit the event named "hello"
200
+ * const result = myEntity.emit('hello', 'data1', 'data2');
201
+ * console.log("Result:", result);
202
+ *
203
+ * // The console output is:
204
+ * // Arguments: data1 data2
205
+ * // Result: "foo"
206
+ */
207
+ rpc(eventName, ...data) {
208
+ return this.rpcId(eventName, "*", ...data);
209
+ }
210
+ rpcId(eventName, id, ...data) {
211
+ if (!this._eventListeners || !this._eventListeners[eventName]) {
212
+ throw new Error("Cannot make an rpc call without at least one event listener and none were found");
213
+ }
214
+ let emitterResult;
215
+ this._eventsEmitting = true;
216
+ if (this._eventListeners[eventName][id]) {
217
+ // Handle id emit
218
+ const arr = this._eventListeners[eventName][id];
219
+ emitterResult = this._emitToSingleListener(arr[0], data);
220
+ }
221
+ else if (id !== "*" && this._eventListeners[eventName]["*"]) {
222
+ // Handle global emit if the id passed wasn't already a global (*) id
223
+ const arr = this._eventListeners[eventName]["*"];
224
+ emitterResult = this._emitToSingleListener(arr[0], data);
225
+ }
226
+ else {
227
+ if (id === "*") {
228
+ throw new Error(`Cannot make an rpc call to event "${eventName}" without at least one event listener and none were found, register a listener via on("${eventName}", () => { ...some listener code })`);
229
+ }
230
+ throw new Error(`Cannot make an rpc call to event "${eventName}" and id "${id}" without at least one event listener and none were found, register a listener via on("${eventName}", "${id}", () => { ...some listener code })`);
231
+ }
232
+ this._eventsEmitting = false;
233
+ this._processRemovalQueue();
234
+ return emitterResult;
235
+ }
168
236
  /**
169
237
  * Emit an event by name.
170
238
  * @param eventName The name of the event to emit.
@@ -184,15 +252,20 @@ export class Emitter {
184
252
  * @example #Listen for Event Data
185
253
  * // Set a listener to listen for the data (multiple values emitted
186
254
  * // from an event are passed as function arguments)
187
- * myEntity.on('hello', function (arg1, arg2) {
188
- * console.log(arg1, arg2);
255
+ * myEntity.on('hello', function (arg1, arg2) {
256
+ * console.log("Arguments:", arg1, arg2);
257
+ * return "foo";
189
258
  * }
190
259
  *
191
260
  * // Emit the event named "hello"
192
- * myEntity.emit('hello', 'data1', 'data2');
261
+ * // The result is returned as an array of all return values
262
+ * // from all the listeners for the event
263
+ * const result = myEntity.emit('hello', 'data1', 'data2');
264
+ * console.log("Result:", result);
193
265
  *
194
266
  * // The console output is:
195
- * // data1, data2
267
+ * // Arguments: data1 data2
268
+ * // Result: ["foo"]
196
269
  */
197
270
  emit(eventName, ...data) {
198
271
  return this.emitId(eventName, "*", ...data);
@@ -173,6 +173,29 @@ describe("Emitter", () => {
173
173
  assert.strictEqual(results[0], "Foo1 Return Value", "Return data for foo1 was not correct");
174
174
  assert.strictEqual(results[1], "Foo2 Return Value", "Return data for foo2 was not correct");
175
175
  });
176
+ it("Supports awaiting async and non-async rpc listener return data", async () => {
177
+ const emitter = new Emitter();
178
+ let listenerFiredCount = 0;
179
+ emitter.on("foo1", () => {
180
+ return new Promise((resolve) => {
181
+ setTimeout(() => {
182
+ listenerFiredCount++;
183
+ resolve("Foo1 Return Value");
184
+ }, 1000);
185
+ });
186
+ });
187
+ emitter.on("foo2", () => {
188
+ return "Foo2 Return Value";
189
+ });
190
+ const time = new Date().getTime();
191
+ const result1 = await emitter.rpc("foo1");
192
+ const result2 = emitter.rpc("foo2");
193
+ const delta = new Date().getTime() - time;
194
+ assert.ok(delta > 900, "Delta was not correct, await may not have paused?");
195
+ assert.ok(listenerFiredCount === 1, "listenerFiredCount was not correct, await may not have been used?");
196
+ assert.strictEqual(result1, "Foo1 Return Value", "Return data for foo1 was not correct");
197
+ assert.strictEqual(result2, "Foo2 Return Value", "Return data for foo2 was not correct");
198
+ });
176
199
  it("Supports responding with a cancellation signal", async () => {
177
200
  const emitter = new Emitter();
178
201
  let listenerFiredCount = 0;