@yume-chan/event 0.0.17 → 0.0.18

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.
package/CHANGELOG.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "name": "@yume-chan/event",
3
3
  "entries": [
4
+ {
5
+ "version": "0.0.18",
6
+ "tag": "@yume-chan/event_v0.0.18",
7
+ "date": "Wed, 25 Jan 2023 21:33:49 GMT",
8
+ "comments": {}
9
+ },
4
10
  {
5
11
  "version": "0.0.17",
6
12
  "tag": "@yume-chan/event_v0.0.17",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Change Log - @yume-chan/event
2
2
 
3
- This log was last generated on Tue, 18 Oct 2022 09:32:30 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 25 Jan 2023 21:33:49 GMT and should not be manually modified.
4
+
5
+ ## 0.0.18
6
+ Wed, 25 Jan 2023 21:33:49 GMT
7
+
8
+ _Version update only_
4
9
 
5
10
  ## 0.0.17
6
11
  Tue, 18 Oct 2022 09:32:30 GMT
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020-2022 Simon Chan
3
+ Copyright (c) 2020-2023 Simon Chan
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,16 +1,19 @@
1
- import type { Disposable } from './disposable.js';
2
- import type { EventListener, RemoveEventListener } from './event.js';
1
+ import { type Disposable } from "./disposable.js";
2
+ import { type EventListener, type RemoveEventListener } from "./event.js";
3
3
  export interface EventListenerInfo<TEvent, TResult = unknown> {
4
- listener: EventListener<TEvent, any, any, TResult>;
4
+ listener: EventListener<TEvent, unknown, unknown[], TResult>;
5
5
  thisArg: unknown;
6
6
  args: unknown[];
7
7
  }
8
+ export interface AddEventListener<TEvent, TResult = unknown> {
9
+ (listener: EventListener<TEvent, unknown, [], TResult>): RemoveEventListener;
10
+ <TThis, TArgs extends unknown[]>(listener: EventListener<TEvent, TThis, TArgs, TResult>, thisArg: TThis, ...args: TArgs): RemoveEventListener;
11
+ }
8
12
  export declare class EventEmitter<TEvent, TResult = unknown> implements Disposable {
9
13
  protected readonly listeners: EventListenerInfo<TEvent, TResult>[];
10
14
  constructor();
11
15
  protected addEventListener(info: EventListenerInfo<TEvent, TResult>): RemoveEventListener;
12
- event(listener: EventListener<TEvent, unknown, [], TResult>): RemoveEventListener;
13
- event<TThis, TArgs extends unknown[]>(listener: EventListener<TEvent, TThis, TArgs, TResult>, thisArg: TThis, ...args: TArgs): RemoveEventListener;
16
+ event: AddEventListener<TEvent, TResult>;
14
17
  fire(e: TEvent): void;
15
18
  dispose(): void;
16
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"event-emitter.d.ts","sourceRoot":"","sources":["../src/event-emitter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAErE,MAAM,WAAW,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO;IACxD,QAAQ,EAAE,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAEnD,OAAO,EAAE,OAAO,CAAC;IAEjB,IAAI,EAAE,OAAO,EAAE,CAAC;CACnB;AAED,qBAAa,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAE,YAAW,UAAU;IACtE,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAM;;IAMxE,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,mBAAmB;IAalF,KAAK,CACR,QAAQ,EAAE,aAAa,CAAC,MAAM,EAAE,OAAO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iB,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAM;;IAMxE,SAAS,CAAC,gBAAgB,CACtB,IAAI,EAAE,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,GACzC,mBAAmB;IAaf,KAAK,EAAE,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAmB7C;IAEK,IAAI,CAAC,CAAC,EAAE,MAAM;IAMd,OAAO;CAGjB"}
@@ -14,14 +14,14 @@ export class EventEmitter {
14
14
  remove.dispose = remove;
15
15
  return remove;
16
16
  }
17
- event(listener, thisArg, ...args) {
17
+ event = (listener, thisArg, ...args) => {
18
18
  const info = {
19
- listener,
19
+ listener: listener,
20
20
  thisArg,
21
21
  args,
22
22
  };
23
23
  return this.addEventListener(info);
24
- }
24
+ };
25
25
  fire(e) {
26
26
  for (const info of this.listeners.slice()) {
27
27
  info.listener.apply(info.thisArg, [e, ...info.args]);
@@ -1 +1 @@
1
- {"version":3,"file":"event-emitter.js","sourceRoot":"","sources":["../src/event-emitter.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,YAAY;IACF,SAAS,GAAyC,EAAE,CAAC;IAExE;QACI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAES,gBAAgB,CAAC,IAAwC;QAC/D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE1B,MAAM,MAAM,GAAwB,GAAG,EAAE;YACrC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC3C,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;gBACd,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;aACnC;QACL,CAAC,CAAC;QACF,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;QACxB,OAAO,MAAM,CAAC;IAClB,CAAC;IAUM,K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;QACA,MAAM,IAAI,GAAuC;YAC7C,QAAQ,EAAE,QAKT;YACD,OAAO;YACP,IAAI;SACP,CAAC;QACF,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC,CAAC;IAEK,IAAI,CAAC,CAAS;QACjB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE;YACvC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SACxD;IACL,CAAC;IAEM,OAAO;QACV,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9B,CAAC;CACJ"}
package/esm/event.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Disposable } from './disposable.js';
1
+ import { type Disposable } from "./disposable.js";
2
2
  export interface EventListener<TEvent, TThis, TArgs extends unknown[], TResult> {
3
3
  (this: TThis, e: TEvent, ...args: TArgs): TResult;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,WAAW,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,SAAS,OAAO,EAAE,EAAE,OAAO;IAC1E,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC;CACrD;AAED,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACnD,IAAI,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,KAAK,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO;IAC5C;;OAEG;IACH,CAAC,QAAQ,EAAE,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,GAAG,mBAAmB,CAAC;IAE7E;;OAEG;IACH,CAAC,KAAK,EAAE,KAAK,SAAS,OAAO,EAAE,EAC3B,QAAQ,EAAE,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EACtD,OAAO,EAAE,KAAK,EACd,GAAG,IAAI,EAAE,KAAK,GACf,mBAAmB,CAAC;CAC1B"}
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,WAAW,aAAa,CAC1B,MAAM,EACN,KAAK,EACL,KAAK,SAAS,OAAO,EAAE,EACvB,OAAO;IAEP,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC;CACrD;AAED,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACnD,IAAI,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,KAAK,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO;IAC5C;;OAEG;IACH,CACI,QAAQ,EAAE,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,GACtD,mBAAmB,CAAC;IAEvB;;OAEG;IACH,CAAC,KAAK,EAAE,KAAK,SAAS,OAAO,EAAE,EAC3B,QAAQ,EAAE,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EACtD,OAAO,EAAE,KAAK,EACd,GAAG,IAAI,EAAE,KAAK,GACf,mBAAmB,CAAC;CAC1B"}
package/esm/utils.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { Event } from './event.js';
2
- export declare function once<T>(event: Event<T, any>): Promise<T>;
1
+ import { type Event } from "./event.js";
2
+ export declare function once<T>(event: Event<T, unknown>): Promise<T>;
3
3
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,wBAAsB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAM9D"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,wBAAsB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAMlE"}
package/esm/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import { PromiseResolver } from '@yume-chan/async';
1
+ import { PromiseResolver } from "@yume-chan/async";
2
2
  export async function once(event) {
3
3
  const resolver = new PromiseResolver();
4
4
  const dispose = event(resolver.resolve);
package/esm/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,MAAM,CAAC,KAAK,UAAU,IAAI,CAAI,KAAoB;IAC9C,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAK,CAAC;IAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC;IACtC,OAAO,EAAE,CAAC;IACV,OAAO,MAAM,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAInD,MAAM,CAAC,KAAK,UAAU,IAAI,CAAI,KAAwB;IAClD,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAK,CAAC;IAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC;IACtC,OAAO,EAAE,CAAC;IACV,OAAO,MAAM,CAAC;AAClB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yume-chan/event",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "Event/EventEmitter",
5
5
  "keywords": [
6
6
  "event",
@@ -27,16 +27,22 @@
27
27
  "types": "esm/index.d.ts",
28
28
  "dependencies": {
29
29
  "@yume-chan/async": "^2.2.0",
30
- "tslib": "^2.4.0"
30
+ "tslib": "^2.4.1"
31
31
  },
32
32
  "devDependencies": {
33
- "jest": "^28.1.2",
34
- "typescript": "^4.7.4",
35
- "@yume-chan/ts-package-builder": "^1.0.0"
33
+ "@jest/globals": "^29.3.1",
34
+ "@yume-chan/eslint-config": "^1.0.0",
35
+ "@yume-chan/tsconfig": "^1.0.0",
36
+ "cross-env": "^7.0.3",
37
+ "eslint": "^8.31.0",
38
+ "jest": "^29.3.1",
39
+ "ts-jest": "^29.0.4",
40
+ "typescript": "^4.9.4"
36
41
  },
37
42
  "scripts": {
38
- "build": "build-ts-package",
39
- "build:watch": "build-ts-package --incremental",
40
- "//test": "jest --coverage"
43
+ "build": "tsc -b tsconfig.build.json",
44
+ "build:watch": "tsc -b tsconfig.build.json",
45
+ "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage",
46
+ "lint": "eslint src/**/*.ts --fix"
41
47
  }
42
48
  }
@@ -1,14 +1,25 @@
1
- import type { Disposable } from './disposable.js';
2
- import type { EventListener, RemoveEventListener } from './event.js';
1
+ import { type Disposable } from "./disposable.js";
2
+ import { type EventListener, type RemoveEventListener } from "./event.js";
3
3
 
4
4
  export interface EventListenerInfo<TEvent, TResult = unknown> {
5
- listener: EventListener<TEvent, any, any, TResult>;
5
+ listener: EventListener<TEvent, unknown, unknown[], TResult>;
6
6
 
7
7
  thisArg: unknown;
8
8
 
9
9
  args: unknown[];
10
10
  }
11
11
 
12
+ export interface AddEventListener<TEvent, TResult = unknown> {
13
+ (
14
+ listener: EventListener<TEvent, unknown, [], TResult>
15
+ ): RemoveEventListener;
16
+ <TThis, TArgs extends unknown[]>(
17
+ listener: EventListener<TEvent, TThis, TArgs, TResult>,
18
+ thisArg: TThis,
19
+ ...args: TArgs
20
+ ): RemoveEventListener;
21
+ }
22
+
12
23
  export class EventEmitter<TEvent, TResult = unknown> implements Disposable {
13
24
  protected readonly listeners: EventListenerInfo<TEvent, TResult>[] = [];
14
25
 
@@ -16,7 +27,9 @@ export class EventEmitter<TEvent, TResult = unknown> implements Disposable {
16
27
  this.event = this.event.bind(this);
17
28
  }
18
29
 
19
- protected addEventListener(info: EventListenerInfo<TEvent, TResult>): RemoveEventListener {
30
+ protected addEventListener(
31
+ info: EventListenerInfo<TEvent, TResult>
32
+ ): RemoveEventListener {
20
33
  this.listeners.push(info);
21
34
 
22
35
  const remove: RemoveEventListener = () => {
@@ -29,26 +42,26 @@ export class EventEmitter<TEvent, TResult = unknown> implements Disposable {
29
42
  return remove;
30
43
  }
31
44
 
32
- public event(
33
- listener: EventListener<TEvent, unknown, [], TResult>
34
- ): RemoveEventListener;
35
- public event<TThis, TArgs extends unknown[]>(
36
- listener: EventListener<TEvent, TThis, TArgs, TResult>,
37
- thisArg: TThis,
38
- ...args: TArgs
39
- ): RemoveEventListener;
40
- public event<TThis, TArgs extends unknown[]>(
45
+ public event: AddEventListener<TEvent, TResult> = <
46
+ TThis,
47
+ TArgs extends unknown[]
48
+ >(
41
49
  listener: EventListener<TEvent, TThis, TArgs, TResult>,
42
50
  thisArg?: TThis,
43
51
  ...args: TArgs
44
- ): RemoveEventListener {
52
+ ) => {
45
53
  const info: EventListenerInfo<TEvent, TResult> = {
46
- listener,
54
+ listener: listener as EventListener<
55
+ TEvent,
56
+ unknown,
57
+ unknown[],
58
+ TResult
59
+ >,
47
60
  thisArg,
48
61
  args,
49
62
  };
50
63
  return this.addEventListener(info);
51
- }
64
+ };
52
65
 
53
66
  public fire(e: TEvent) {
54
67
  for (const info of this.listeners.slice()) {
package/src/event.ts CHANGED
@@ -1,6 +1,11 @@
1
- import type { Disposable } from './disposable.js';
1
+ import { type Disposable } from "./disposable.js";
2
2
 
3
- export interface EventListener<TEvent, TThis, TArgs extends unknown[], TResult> {
3
+ export interface EventListener<
4
+ TEvent,
5
+ TThis,
6
+ TArgs extends unknown[],
7
+ TResult
8
+ > {
4
9
  (this: TThis, e: TEvent, ...args: TArgs): TResult;
5
10
  }
6
11
 
@@ -12,7 +17,9 @@ export interface Event<TEvent, TResult = unknown> {
12
17
  /**
13
18
  * Attaches an event listener.
14
19
  */
15
- (listener: EventListener<TEvent, unknown, [], TResult>): RemoveEventListener;
20
+ (
21
+ listener: EventListener<TEvent, unknown, [], TResult>
22
+ ): RemoveEventListener;
16
23
 
17
24
  /**
18
25
  * Attaches an event listener that bind to `this` and `args`.
package/src/utils.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { PromiseResolver } from '@yume-chan/async';
2
- import type { Event } from './event.js';
1
+ import { PromiseResolver } from "@yume-chan/async";
3
2
 
4
- export async function once<T>(event: Event<T, any>): Promise<T> {
3
+ import { type Event } from "./event.js";
4
+
5
+ export async function once<T>(event: Event<T, unknown>): Promise<T> {
5
6
  const resolver = new PromiseResolver<T>();
6
7
  const dispose = event(resolver.resolve);
7
8
  const result = await resolver.promise;
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "./node_modules/@yume-chan/tsconfig/tsconfig.base.json"
3
+ }
@@ -0,0 +1 @@
1
+ {"program":{"fileNames":["../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es5.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2015.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2016.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2017.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2018.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2019.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2020.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2021.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2022.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.esnext.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2015.core.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2017.object.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2017.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2019.array.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2019.object.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2019.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2020.date.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2020.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2020.number.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2021.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2022.array.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2022.error.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2022.object.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.es2022.string.d.ts","../../common/temp/node_modules/.pnpm/typescript@4.9.4/node_modules/typescript/lib/lib.esnext.intl.d.ts","../../common/temp/node_modules/.pnpm/tslib@2.4.1/node_modules/tslib/tslib.d.ts","./src/disposable.ts","./src/event.ts","./src/event-emitter.ts","../../common/temp/node_modules/.pnpm/@yume-chan+async@2.2.0/node_modules/@yume-chan/async/dts/async-operation-manager.d.ts","../../common/temp/node_modules/.pnpm/@yume-chan+async@2.2.0/node_modules/@yume-chan/async/dts/delay.d.ts","../../common/temp/node_modules/.pnpm/@yume-chan+async@2.2.0/node_modules/@yume-chan/async/dts/promise-resolver.d.ts","../../common/temp/node_modules/.pnpm/@yume-chan+async@2.2.0/node_modules/@yume-chan/async/dts/index.d.ts","./src/utils.ts","./src/index.ts"],"fileInfos":[{"version":"8730f4bf322026ff5229336391a18bcaa1f94d4f82416c8b2f3954e2ccaae2ba","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","impliedFormat":1},{"version":"7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","impliedFormat":1},{"version":"8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","impliedFormat":1},{"version":"5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","impliedFormat":1},{"version":"4b421cbfb3a38a27c279dec1e9112c3d1da296f77a1a85ddadf7e7a425d45d18","impliedFormat":1},{"version":"1fc5ab7a764205c68fa10d381b08417795fc73111d6dd16b5b1ed36badb743d9","impliedFormat":1},{"version":"746d62152361558ea6d6115cf0da4dd10ede041d14882ede3568bce5dc4b4f1f","impliedFormat":1},{"version":"d11a03592451da2d1065e09e61f4e2a9bf68f780f4f6623c18b57816a9679d17","impliedFormat":1},{"version":"aea179452def8a6152f98f63b191b84e7cbd69b0e248c91e61fb2e52328abe8c","impliedFormat":1},{"version":"adb996790133eb33b33aadb9c09f15c2c575e71fb57a62de8bf74dbf59ec7dfb","affectsGlobalScope":true,"impliedFormat":1},{"version":"8cc8c5a3bac513368b0157f3d8b31cfdcfe78b56d3724f30f80ed9715e404af8","affectsGlobalScope":true,"impliedFormat":1},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true,"impliedFormat":1},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true,"impliedFormat":1},{"version":"5f406584aef28a331c36523df688ca3650288d14f39c5d2e555c95f0d2ff8f6f","affectsGlobalScope":true,"impliedFormat":1},{"version":"22f230e544b35349cfb3bd9110b6ef37b41c6d6c43c3314a31bd0d9652fcec72","affectsGlobalScope":true,"impliedFormat":1},{"version":"7ea0b55f6b315cf9ac2ad622b0a7813315bb6e97bf4bb3fbf8f8affbca7dc695","affectsGlobalScope":true,"impliedFormat":1},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb26de841c52236d8222f87e9e6a235332e0788af8c87a71e9e210314300410a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true,"impliedFormat":1},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true,"impliedFormat":1},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true,"impliedFormat":1},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true,"impliedFormat":1},{"version":"81cac4cbc92c0c839c70f8ffb94eb61e2d32dc1c3cf6d95844ca099463cf37ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true,"impliedFormat":1},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true,"impliedFormat":1},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true,"impliedFormat":1},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true,"impliedFormat":1},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true,"impliedFormat":1},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true,"impliedFormat":1},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true,"impliedFormat":1},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true,"impliedFormat":1},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true,"impliedFormat":1},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true,"impliedFormat":1},{"version":"5e5e095c4470c8bab227dbbc61374878ecead104c74ab9960d3adcccfee23205","affectsGlobalScope":true,"impliedFormat":1},{"version":"09aa50414b80c023553090e2f53827f007a301bc34b0495bfb2c3c08ab9ad1eb","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7f680a43f8cd12a6b6122c07c54ba40952b0c8aa140dcfcf32eb9e6cb028596","affectsGlobalScope":true,"impliedFormat":1},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true,"impliedFormat":1},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true,"impliedFormat":1},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true,"impliedFormat":1},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true,"impliedFormat":1},{"version":"2768ef564cfc0689a1b76106c421a2909bdff0acbe87da010785adab80efdd5c","affectsGlobalScope":true,"impliedFormat":1},{"version":"b248e32ca52e8f5571390a4142558ae4f203ae2f94d5bac38a3084d529ef4e58","affectsGlobalScope":true,"impliedFormat":1},{"version":"6c55633c733c8378db65ac3da7a767c3cf2cf3057f0565a9124a16a3a2019e87","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true,"impliedFormat":1},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true,"impliedFormat":1},{"version":"34c839eaaa6d78c8674ae2c37af2236dee6831b13db7b4ef4df3ec889a04d4f2","affectsGlobalScope":true,"impliedFormat":1},{"version":"34478567f8a80171f88f2f30808beb7da15eac0538ae91282dd33dce928d98ed","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab7d58e6161a550ff92e5aff755dc37fe896245348332cd5f1e1203479fe0ed1","affectsGlobalScope":true,"impliedFormat":1},{"version":"6bda95ea27a59a276e46043b7065b55bd4b316c25e70e29b572958fa77565d43","affectsGlobalScope":true,"impliedFormat":1},{"version":"aedb8de1abb2ff1095c153854a6df7deae4a5709c37297f9d6e9948b6806fa66","affectsGlobalScope":true,"impliedFormat":1},{"version":"a4da0551fd39b90ca7ce5f68fb55d4dc0c1396d589b612e1902f68ee090aaada","affectsGlobalScope":true,"impliedFormat":1},{"version":"11ffe3c281f375fff9ffdde8bbec7669b4dd671905509079f866f2354a788064","affectsGlobalScope":true,"impliedFormat":1},{"version":"52d1bb7ab7a3306fd0375c8bff560feed26ed676a5b0457fa8027b563aecb9a4","affectsGlobalScope":true,"impliedFormat":1},{"version":"14a84fbe4ec531dcbaf5d2594fd95df107258e60ae6c6a076404f13c3f66f28e","impliedFormat":1},{"version":"0d5297f764f6110b559feb32ea2187cf4dfb257bc329fd1a0fd2402b610fea64","signature":"9602940107f96356f0708201bd3104167e35b19b6280c213f8a0a8295ebe7dec","impliedFormat":99},{"version":"e6dd036a71f95bcf9ac2ecbb998dd5bf03d73199b05c87afd2bcfe8ab9474da9","signature":"90d073f69184e7a1fb9ecf644548a21a8127046fe742569a67c8c4426371dc9a","impliedFormat":99},{"version":"e7ed0fb1865ce25af9e9ad00f3f30d918a44fe2bd288f1d6439626c393b4b513","signature":"fd1e6177b73be34e6c29b307ae0f42c9bf53da63a522c4be3f61377492c5656a","impliedFormat":99},{"version":"f6ad331f1763968b8a2d5575c1a8581f056009464e98415a266cab49762bc7a5","impliedFormat":1},{"version":"64c06222c2538b7a0f3fa219749ed7ecc5242842b80022886dad9c672ed6b723","impliedFormat":1},{"version":"b309791da689ee6cc3029bd77ff301b011a490021f1c5e87b97029a2ab1c8a1a","impliedFormat":1},{"version":"82c533a262f28b1acb619f27b323e2079ce804852d6ff030958e9e822aa824a0","impliedFormat":1},{"version":"7bd434f77ce71086bbbb9f5cb7bd47496a7bc2e4a611ffd14c59452dadf64ba2","signature":"a42e7e381e1dbb4ac874ec08cd00ca796c225f123ca95559ea2c3dbebf49d84d","impliedFormat":99},{"version":"d5edda8d8b4b801ff7fa71803fd6bc236b39626b5c1c31606f80a77f11d1fa9e","signature":"f7f1ae1e860a5c72330769e7bd45eb4f169d8875017ff322562d778a86718919","impliedFormat":99}],"options":{"composite":true,"declaration":true,"declarationDir":"./esm","declarationMap":true,"esModuleInterop":true,"exactOptionalPropertyTypes":true,"importHelpers":true,"module":199,"noFallthroughCasesInSwitch":true,"noImplicitAny":true,"noImplicitOverride":true,"noImplicitReturns":true,"noImplicitThis":true,"noUncheckedIndexedAccess":true,"noUnusedLocals":true,"outDir":"./esm","rootDir":"./src","skipLibCheck":true,"sourceMap":true,"strict":true,"stripInternal":true,"target":9},"fileIdsList":[[59,60,61],[55],[55,56,57],[55,56],[55,56,57,58,63],[55,57,62],[56,57],[56],[56,57,58,63],[57]],"referencedMap":[[62,1],[56,2],[58,3],[57,4],[64,5],[63,6]],"exportedModulesMap":[[62,1],[58,7],[57,8],[64,9],[63,10]],"semanticDiagnosticsPerFile":[59,60,62,61,55,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,35,32,33,34,36,7,37,42,43,38,39,40,41,8,47,44,45,46,48,9,49,50,51,52,53,1,10,54,56,58,57,64,63],"latestChangedDtsFile":"./esm/index.d.ts"},"version":"4.9.4"}