@gby/destroyable 1.0.0 → 1.0.2
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/dist/Destroyable.d.ts +24 -6
- package/dist/DestroyableSub.d.ts +14 -2
- package/dist/DestroyableSub.d.ts.map +1 -1
- package/dist/createDestroyableSubClass.d.ts +10 -4
- package/dist/createDestroyableSubClass.d.ts.map +1 -1
- package/doc/api/destroyable.createdestroyablesubclass.md +9 -3
- package/doc/api/destroyable.destroyablesub.md +1 -1
- package/doc/api/destroyable.destroyablesubclass.md +1 -1
- package/doc/api/destroyable.nodedestroyable.md +7 -1
- package/doc/api/destroyable.webdestroyable.md +7 -1
- package/package.json +1 -1
package/dist/Destroyable.d.ts
CHANGED
|
@@ -18,9 +18,8 @@ import { FunDestroyer as FunDestroyer_2 } from './Destroyable';
|
|
|
18
18
|
* @param ParentClass
|
|
19
19
|
* @returns
|
|
20
20
|
*/
|
|
21
|
-
export declare function createDestroyableSubClass<P extends new (...args: any) =>
|
|
21
|
+
export declare function createDestroyableSubClass<P extends new (...args: any) => Object>(ParentClass: P): {
|
|
22
22
|
new (...args: any): {
|
|
23
|
-
[x: string]: any;
|
|
24
23
|
/**
|
|
25
24
|
* 是否已经销毁
|
|
26
25
|
*/
|
|
@@ -81,6 +80,13 @@ export declare function createDestroyableSubClass<P extends new (...args: any) =
|
|
|
81
80
|
* 会依次执行销毁,并且只有上一个销毁完成之后才会执行下一个销毁
|
|
82
81
|
*/
|
|
83
82
|
destroyAsync(): Promise<true | undefined>;
|
|
83
|
+
constructor: Function;
|
|
84
|
+
toString(): string;
|
|
85
|
+
toLocaleString(): string;
|
|
86
|
+
valueOf(): Object;
|
|
87
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
|
88
|
+
isPrototypeOf(v: Object): boolean;
|
|
89
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
|
84
90
|
};
|
|
85
91
|
} & P;
|
|
86
92
|
|
|
@@ -153,12 +159,12 @@ export declare class Destroyable {
|
|
|
153
159
|
/**
|
|
154
160
|
* createDestroyableSubClass 创建的类的实例类型
|
|
155
161
|
*/
|
|
156
|
-
export declare type DestroyableSub<ParentClass extends new (...args: any) =>
|
|
162
|
+
export declare type DestroyableSub<ParentClass extends new (...args: any) => Object> = InstanceType<DestroyableSubClass<ParentClass>>;
|
|
157
163
|
|
|
158
164
|
/**
|
|
159
165
|
* createDestroyableSubClass 创建的类的类型
|
|
160
166
|
*/
|
|
161
|
-
export declare type DestroyableSubClass<ParentClass extends new (...args: any) =>
|
|
167
|
+
export declare type DestroyableSubClass<ParentClass extends new (...args: any) => Object> = ReturnType<typeof createDestroyableSubClass<ParentClass>>;
|
|
162
168
|
|
|
163
169
|
/**
|
|
164
170
|
* 销毁 Destroyable 对象
|
|
@@ -184,7 +190,6 @@ export declare type FunDestroyer = () => void;
|
|
|
184
190
|
*/
|
|
185
191
|
export declare const NodeDestroyable: {
|
|
186
192
|
new (...args: any): {
|
|
187
|
-
[x: string]: any;
|
|
188
193
|
readonly isDestroyed: boolean;
|
|
189
194
|
_isDestroyed: boolean;
|
|
190
195
|
_destroyers: FunDestroyer_2[];
|
|
@@ -201,6 +206,13 @@ export declare const NodeDestroyable: {
|
|
|
201
206
|
destroyThis(): void;
|
|
202
207
|
destroy(): true | undefined;
|
|
203
208
|
destroyAsync(): Promise<true | undefined>;
|
|
209
|
+
constructor: Function;
|
|
210
|
+
toString(): string;
|
|
211
|
+
toLocaleString(): string;
|
|
212
|
+
valueOf(): Object;
|
|
213
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
|
214
|
+
isPrototypeOf(v: Object): boolean;
|
|
215
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
|
204
216
|
};
|
|
205
217
|
} & typeof EventEmitter;
|
|
206
218
|
|
|
@@ -224,7 +236,6 @@ export declare function throwOnDestroyed(): void;
|
|
|
224
236
|
*/
|
|
225
237
|
export declare const WebDestroyable: {
|
|
226
238
|
new (...args: any): {
|
|
227
|
-
[x: string]: any;
|
|
228
239
|
readonly isDestroyed: boolean;
|
|
229
240
|
_isDestroyed: boolean;
|
|
230
241
|
_destroyers: FunDestroyer_2[];
|
|
@@ -241,6 +252,13 @@ export declare const WebDestroyable: {
|
|
|
241
252
|
destroyThis(): void;
|
|
242
253
|
destroy(): true | undefined;
|
|
243
254
|
destroyAsync(): Promise<true | undefined>;
|
|
255
|
+
constructor: Function;
|
|
256
|
+
toString(): string;
|
|
257
|
+
toLocaleString(): string;
|
|
258
|
+
valueOf(): Object;
|
|
259
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
|
260
|
+
isPrototypeOf(v: Object): boolean;
|
|
261
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
|
244
262
|
};
|
|
245
263
|
} & typeof EventBus;
|
|
246
264
|
|
package/dist/DestroyableSub.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { EventEmitter } from "node:events";
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const WebDestroyable: {
|
|
7
7
|
new (...args: any): {
|
|
8
|
-
[x: string]: any;
|
|
9
8
|
readonly isDestroyed: boolean;
|
|
10
9
|
_isDestroyed: boolean;
|
|
11
10
|
_destroyers: import("./Destroyable").FunDestroyer[];
|
|
@@ -22,6 +21,13 @@ export declare const WebDestroyable: {
|
|
|
22
21
|
destroyThis(): void;
|
|
23
22
|
destroy(): true | undefined;
|
|
24
23
|
destroyAsync(): Promise<true | undefined>;
|
|
24
|
+
constructor: Function;
|
|
25
|
+
toString(): string;
|
|
26
|
+
toLocaleString(): string;
|
|
27
|
+
valueOf(): Object;
|
|
28
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
|
29
|
+
isPrototypeOf(v: Object): boolean;
|
|
30
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
|
25
31
|
};
|
|
26
32
|
} & typeof EventBus;
|
|
27
33
|
/**
|
|
@@ -37,7 +43,6 @@ export type WebDestroyable = InstanceType<WebDestroyableClass>;
|
|
|
37
43
|
*/
|
|
38
44
|
export declare const NodeDestroyable: {
|
|
39
45
|
new (...args: any): {
|
|
40
|
-
[x: string]: any;
|
|
41
46
|
readonly isDestroyed: boolean;
|
|
42
47
|
_isDestroyed: boolean;
|
|
43
48
|
_destroyers: import("./Destroyable").FunDestroyer[];
|
|
@@ -54,6 +59,13 @@ export declare const NodeDestroyable: {
|
|
|
54
59
|
destroyThis(): void;
|
|
55
60
|
destroy(): true | undefined;
|
|
56
61
|
destroyAsync(): Promise<true | undefined>;
|
|
62
|
+
constructor: Function;
|
|
63
|
+
toString(): string;
|
|
64
|
+
toLocaleString(): string;
|
|
65
|
+
valueOf(): Object;
|
|
66
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
|
67
|
+
isPrototypeOf(v: Object): boolean;
|
|
68
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
|
57
69
|
};
|
|
58
70
|
} & typeof EventEmitter;
|
|
59
71
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DestroyableSub.d.ts","sourceRoot":"","sources":["../src/DestroyableSub.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"DestroyableSub.d.ts","sourceRoot":"","sources":["../src/DestroyableSub.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAsC,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,cAAc,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;uBAA0C,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,OAAO,eAAe,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,oBAAoB,CAAC,CAAC"}
|
|
@@ -6,9 +6,8 @@ import type { FunDestroyer } from "./Destroyable";
|
|
|
6
6
|
* @param ParentClass
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
|
-
export declare function createDestroyableSubClass<P extends new (...args: any) =>
|
|
9
|
+
export declare function createDestroyableSubClass<P extends new (...args: any) => Object>(ParentClass: P): {
|
|
10
10
|
new (...args: any): {
|
|
11
|
-
[x: string]: any;
|
|
12
11
|
/**
|
|
13
12
|
* 是否已经销毁
|
|
14
13
|
*/
|
|
@@ -69,14 +68,21 @@ export declare function createDestroyableSubClass<P extends new (...args: any) =
|
|
|
69
68
|
* 会依次执行销毁,并且只有上一个销毁完成之后才会执行下一个销毁
|
|
70
69
|
*/
|
|
71
70
|
destroyAsync(): Promise<true | undefined>;
|
|
71
|
+
constructor: Function;
|
|
72
|
+
toString(): string;
|
|
73
|
+
toLocaleString(): string;
|
|
74
|
+
valueOf(): Object;
|
|
75
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
|
76
|
+
isPrototypeOf(v: Object): boolean;
|
|
77
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
|
72
78
|
};
|
|
73
79
|
} & P;
|
|
74
80
|
/**
|
|
75
81
|
* createDestroyableSubClass 创建的类的类型
|
|
76
82
|
*/
|
|
77
|
-
export type DestroyableSubClass<ParentClass extends new (...args: any) =>
|
|
83
|
+
export type DestroyableSubClass<ParentClass extends new (...args: any) => Object> = ReturnType<typeof createDestroyableSubClass<ParentClass>>;
|
|
78
84
|
/**
|
|
79
85
|
* createDestroyableSubClass 创建的类的实例类型
|
|
80
86
|
*/
|
|
81
|
-
export type DestroyableSub<ParentClass extends new (...args: any) =>
|
|
87
|
+
export type DestroyableSub<ParentClass extends new (...args: any) => Object> = InstanceType<DestroyableSubClass<ParentClass>>;
|
|
82
88
|
//# sourceMappingURL=createDestroyableSubClass.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDestroyableSubClass.d.ts","sourceRoot":"","sources":["../src/createDestroyableSubClass.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,KAAK,
|
|
1
|
+
{"version":3,"file":"createDestroyableSubClass.d.ts","sourceRoot":"","sources":["../src/createDestroyableSubClass.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGlD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,EAAE,WAAW,EAAE,CAAC;kBAA9B,GAAG;QAO7D;;WAEG;;;QAMH;;WAEG;qBACU,YAAY,EAAE;QAE3B;;;;WAIG;mBACQ,CAAC,SAAS,YAAY,OAAO,CAAC,GAAG,CAAC;QAK7C;;;;WAIG;yBACc,CAAC,SAAS,YAAY,OAAO,CAAC,GAAG,CAAC;QAMnD;;;;;WAKG;mBACQ,CAAC,8BAA8B,CAAC,SAAS,OAAO,GAAG,CAAC;QAQ/D;;;;WAIG;yBACc,CAAC,8BAA8B,CAAC,GAAG,CAAC;QASrD;;;WAGG;gBACK,CAAC,SAAS,YAAY,OAAO,CAAC,GAAG,CAAC;gBAClC,CAAC,8BAA8B,CAAC,iBAAiB,OAAO,GAAG,CAAC;gBAC5D,CAAC,SAAS,iBAAiB,YAAY,YAAY,CAAC,iBAAiB,OAAO,GAAG,CAAC;sBAS1E,CAAC,SAAS,YAAY,OAAO,CAAC,GAAG,CAAC;sBAClC,CAAC,8BAA8B,CAAC,GAAG,CAAC;sBACpC,CAAC,SAAS,iBAAiB,YAAY,YAAY,CAAC,GAAG,CAAC;QActE;;;;WAIG;;QAMH;;WAEG;;QAkBH;;;;WAIG;;;;;;;;;;MAiDV;AAMD;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,WAAW,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,IAAI,UAAU,CAAC,OAAO,yBAAyB,CAAC,WAAW,CAAC,CAAC,CAAC;AAE9I;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,WAAW,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,IAAI,YAAY,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC"}
|
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
**Signature:**
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
export declare function createDestroyableSubClass<P extends new (...args: any) =>
|
|
12
|
+
export declare function createDestroyableSubClass<P extends new (...args: any) => Object>(ParentClass: P): {
|
|
13
13
|
new (...args: any): {
|
|
14
|
-
[x: string]: any;
|
|
15
14
|
readonly isDestroyed: boolean;
|
|
16
15
|
_isDestroyed: boolean;
|
|
17
16
|
_destroyers: FunDestroyer[];
|
|
@@ -28,6 +27,13 @@ export declare function createDestroyableSubClass<P extends new (...args: any) =
|
|
|
28
27
|
destroyThis(): void;
|
|
29
28
|
destroy(): true | undefined;
|
|
30
29
|
destroyAsync(): Promise<true | undefined>;
|
|
30
|
+
constructor: Function;
|
|
31
|
+
toString(): string;
|
|
32
|
+
toLocaleString(): string;
|
|
33
|
+
valueOf(): Object;
|
|
34
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
|
35
|
+
isPrototypeOf(v: Object): boolean;
|
|
36
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
|
31
37
|
};
|
|
32
38
|
} & P;
|
|
33
39
|
```
|
|
@@ -67,7 +73,7 @@ P
|
|
|
67
73
|
</tbody></table>
|
|
68
74
|
**Returns:**
|
|
69
75
|
|
|
70
|
-
{ new (...args: any): {
|
|
76
|
+
{ new (...args: any): { readonly isDestroyed: boolean; \_isDestroyed: boolean; \_destroyers: [FunDestroyer](./destroyable.fundestroyer.md)<!-- -->\[\]; disposeFun<T extends [FunDestroyer](./destroyable.fundestroyer.md)<!-- -->>(fun: T): T; cancelDisposeFun<T extends [FunDestroyer](./destroyable.fundestroyer.md)<!-- -->>(fun: T): T; disposeObj<T extends /\*elided\*/ any>(obj: T, sync?: boolean): T; cancelDisposeObj<T extends /\*elided\*/ any>(obj: T): T; dispose<T extends [FunDestroyer](./destroyable.fundestroyer.md)<!-- -->>(fun: T): T; dispose<T extends /\*elided\*/ any>(obj: T, asyncDestroy?: boolean): T; dispose<T extends /\*elided\*/ any \| [FunDestroyer](./destroyable.fundestroyer.md)<!-- -->>(objOrFun: T, asyncDestroy?: boolean): T; cancelDispose<T extends [FunDestroyer](./destroyable.fundestroyer.md)<!-- -->>(fun: T): T; cancelDispose<T extends /\*elided\*/ any>(obj: T): T; cancelDispose<T extends /\*elided\*/ any \| [FunDestroyer](./destroyable.fundestroyer.md)<!-- -->>(objOrFun: T): T; destroyThis(): void; destroy(): true \| undefined; destroyAsync(): Promise<true \| undefined>; constructor: Function; toString(): string; toLocaleString(): string; valueOf(): Object; hasOwnProperty(v: PropertyKey): boolean; isPrototypeOf(v: Object): boolean; propertyIsEnumerable(v: PropertyKey): boolean; }; } & P
|
|
71
77
|
|
|
72
78
|
|
|
73
79
|
## Remarks
|
|
@@ -9,7 +9,7 @@ createDestroyableSubClass 创建的类的实例类型
|
|
|
9
9
|
**Signature:**
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
export type DestroyableSub<ParentClass extends new (...args: any) =>
|
|
12
|
+
export type DestroyableSub<ParentClass extends new (...args: any) => Object> = InstanceType<DestroyableSubClass<ParentClass>>;
|
|
13
13
|
```
|
|
14
14
|
**References:** [DestroyableSubClass](./destroyable.destroyablesubclass.md)
|
|
15
15
|
|
|
@@ -9,5 +9,5 @@ createDestroyableSubClass 创建的类的类型
|
|
|
9
9
|
**Signature:**
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
export type DestroyableSubClass<ParentClass extends new (...args: any) =>
|
|
12
|
+
export type DestroyableSubClass<ParentClass extends new (...args: any) => Object> = ReturnType<typeof createDestroyableSubClass<ParentClass>>;
|
|
13
13
|
```
|
|
@@ -11,7 +11,6 @@ NodeDestroyable 类对象
|
|
|
11
11
|
```typescript
|
|
12
12
|
NodeDestroyable: {
|
|
13
13
|
new (...args: any): {
|
|
14
|
-
[x: string]: any;
|
|
15
14
|
readonly isDestroyed: boolean;
|
|
16
15
|
_isDestroyed: boolean;
|
|
17
16
|
_destroyers: import("./Destroyable").FunDestroyer[];
|
|
@@ -28,6 +27,13 @@ NodeDestroyable: {
|
|
|
28
27
|
destroyThis(): void;
|
|
29
28
|
destroy(): true | undefined;
|
|
30
29
|
destroyAsync(): Promise<true | undefined>;
|
|
30
|
+
constructor: Function;
|
|
31
|
+
toString(): string;
|
|
32
|
+
toLocaleString(): string;
|
|
33
|
+
valueOf(): Object;
|
|
34
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
|
35
|
+
isPrototypeOf(v: Object): boolean;
|
|
36
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
|
31
37
|
};
|
|
32
38
|
} & typeof EventEmitter
|
|
33
39
|
```
|
|
@@ -11,7 +11,6 @@ WebDestroyable 类对象
|
|
|
11
11
|
```typescript
|
|
12
12
|
WebDestroyable: {
|
|
13
13
|
new (...args: any): {
|
|
14
|
-
[x: string]: any;
|
|
15
14
|
readonly isDestroyed: boolean;
|
|
16
15
|
_isDestroyed: boolean;
|
|
17
16
|
_destroyers: import("./Destroyable").FunDestroyer[];
|
|
@@ -28,6 +27,13 @@ WebDestroyable: {
|
|
|
28
27
|
destroyThis(): void;
|
|
29
28
|
destroy(): true | undefined;
|
|
30
29
|
destroyAsync(): Promise<true | undefined>;
|
|
30
|
+
constructor: Function;
|
|
31
|
+
toString(): string;
|
|
32
|
+
toLocaleString(): string;
|
|
33
|
+
valueOf(): Object;
|
|
34
|
+
hasOwnProperty(v: PropertyKey): boolean;
|
|
35
|
+
isPrototypeOf(v: Object): boolean;
|
|
36
|
+
propertyIsEnumerable(v: PropertyKey): boolean;
|
|
31
37
|
};
|
|
32
38
|
} & typeof EventBus
|
|
33
39
|
```
|