@itwin/core-bentley 3.5.0-dev.14 → 3.5.0-dev.16
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.md +10 -1
- package/lib/cjs/AccessToken.d.ts +8 -8
- package/lib/cjs/AccessToken.js +9 -9
- package/lib/cjs/AccessToken.js.map +1 -1
- package/lib/cjs/Assert.d.ts +25 -25
- package/lib/cjs/Assert.js +45 -45
- package/lib/cjs/Assert.js.map +1 -1
- package/lib/cjs/AsyncMutex.d.ts +26 -26
- package/lib/cjs/AsyncMutex.js +43 -43
- package/lib/cjs/AsyncMutex.js.map +1 -1
- package/lib/cjs/BeEvent.d.ts +81 -81
- package/lib/cjs/BeEvent.js +156 -156
- package/lib/cjs/BeEvent.js.map +1 -1
- package/lib/cjs/BeSQLite.d.ts +170 -170
- package/lib/cjs/BeSQLite.js +183 -183
- package/lib/cjs/BeSQLite.js.map +1 -1
- package/lib/cjs/BentleyError.d.ts +376 -376
- package/lib/cjs/BentleyError.js +699 -699
- package/lib/cjs/BentleyError.js.map +1 -1
- package/lib/cjs/BentleyLoggerCategory.d.ts +11 -11
- package/lib/cjs/BentleyLoggerCategory.js +19 -19
- package/lib/cjs/BentleyLoggerCategory.js.map +1 -1
- package/lib/cjs/ByteStream.d.ts +92 -92
- package/lib/cjs/ByteStream.js +133 -133
- package/lib/cjs/ByteStream.js.map +1 -1
- package/lib/cjs/ClassUtils.d.ts +14 -14
- package/lib/cjs/ClassUtils.js +27 -27
- package/lib/cjs/ClassUtils.js.map +1 -1
- package/lib/cjs/Compare.d.ts +47 -47
- package/lib/cjs/Compare.js +75 -75
- package/lib/cjs/Compare.js.map +1 -1
- package/lib/cjs/CompressedId64Set.d.ts +134 -134
- package/lib/cjs/CompressedId64Set.js +428 -428
- package/lib/cjs/CompressedId64Set.js.map +1 -1
- package/lib/cjs/Dictionary.d.ts +125 -125
- package/lib/cjs/Dictionary.js +203 -203
- package/lib/cjs/Dictionary.js.map +1 -1
- package/lib/cjs/Disposable.d.ts +80 -80
- package/lib/cjs/Disposable.js +120 -120
- package/lib/cjs/Disposable.js.map +1 -1
- package/lib/cjs/Id.d.ts +277 -277
- package/lib/cjs/Id.js +629 -629
- package/lib/cjs/Id.js.map +1 -1
- package/lib/cjs/IndexMap.d.ts +65 -65
- package/lib/cjs/IndexMap.js +91 -91
- package/lib/cjs/IndexMap.js.map +1 -1
- package/lib/cjs/JsonSchema.d.ts +77 -77
- package/lib/cjs/JsonSchema.js +9 -9
- package/lib/cjs/JsonSchema.js.map +1 -1
- package/lib/cjs/JsonUtils.d.ts +78 -78
- package/lib/cjs/JsonUtils.js +151 -151
- package/lib/cjs/JsonUtils.js.map +1 -1
- package/lib/cjs/LRUMap.d.ts +129 -129
- package/lib/cjs/LRUMap.js +333 -333
- package/lib/cjs/LRUMap.js.map +1 -1
- package/lib/cjs/Logger.d.ts +141 -141
- package/lib/cjs/Logger.js +254 -254
- package/lib/cjs/Logger.js.map +1 -1
- package/lib/cjs/ObservableSet.d.ts +23 -23
- package/lib/cjs/ObservableSet.js +51 -51
- package/lib/cjs/ObservableSet.js.map +1 -1
- package/lib/cjs/OneAtATimeAction.d.ts +31 -31
- package/lib/cjs/OneAtATimeAction.js +94 -94
- package/lib/cjs/OneAtATimeAction.js.map +1 -1
- package/lib/cjs/OrderedId64Iterable.d.ts +74 -74
- package/lib/cjs/OrderedId64Iterable.js +235 -235
- package/lib/cjs/OrderedId64Iterable.js.map +1 -1
- package/lib/cjs/OrderedSet.d.ts +40 -40
- package/lib/cjs/OrderedSet.js +64 -64
- package/lib/cjs/OrderedSet.js.map +1 -1
- package/lib/cjs/PriorityQueue.d.ts +70 -70
- package/lib/cjs/PriorityQueue.js +140 -140
- package/lib/cjs/PriorityQueue.js.map +1 -1
- package/lib/cjs/ProcessDetector.d.ts +59 -59
- package/lib/cjs/ProcessDetector.js +71 -71
- package/lib/cjs/ProcessDetector.js.map +1 -1
- package/lib/cjs/SortedArray.d.ts +232 -232
- package/lib/cjs/SortedArray.js +303 -303
- package/lib/cjs/SortedArray.js.map +1 -1
- package/lib/cjs/StatusCategory.d.ts +30 -30
- package/lib/cjs/StatusCategory.js +460 -460
- package/lib/cjs/StatusCategory.js.map +1 -1
- package/lib/cjs/StringUtils.d.ts +22 -22
- package/lib/cjs/StringUtils.js +148 -148
- package/lib/cjs/StringUtils.js.map +1 -1
- package/lib/cjs/Time.d.ts +122 -122
- package/lib/cjs/Time.js +152 -152
- package/lib/cjs/Time.js.map +1 -1
- package/lib/cjs/Tracing.d.ts +40 -40
- package/lib/cjs/Tracing.js +130 -130
- package/lib/cjs/Tracing.js.map +1 -1
- package/lib/cjs/TypedArrayBuilder.d.ts +97 -97
- package/lib/cjs/TypedArrayBuilder.js +134 -134
- package/lib/cjs/TypedArrayBuilder.js.map +1 -1
- package/lib/cjs/UnexpectedErrors.d.ts +43 -43
- package/lib/cjs/UnexpectedErrors.js +68 -68
- package/lib/cjs/UnexpectedErrors.js.map +1 -1
- package/lib/cjs/UtilityTypes.d.ts +86 -86
- package/lib/cjs/UtilityTypes.js +26 -26
- package/lib/cjs/UtilityTypes.js.map +1 -1
- package/lib/cjs/YieldManager.d.ts +18 -18
- package/lib/cjs/YieldManager.js +34 -34
- package/lib/cjs/YieldManager.js.map +1 -1
- package/lib/cjs/core-bentley.d.ts +74 -74
- package/lib/cjs/core-bentley.js +90 -90
- package/lib/cjs/core-bentley.js.map +1 -1
- package/lib/cjs/partitionArray.d.ts +21 -21
- package/lib/cjs/partitionArray.js +43 -43
- package/lib/cjs/partitionArray.js.map +1 -1
- package/lib/esm/AccessToken.d.ts +8 -8
- package/lib/esm/AccessToken.js +8 -8
- package/lib/esm/AccessToken.js.map +1 -1
- package/lib/esm/Assert.d.ts +25 -25
- package/lib/esm/Assert.js +41 -41
- package/lib/esm/Assert.js.map +1 -1
- package/lib/esm/AsyncMutex.d.ts +26 -26
- package/lib/esm/AsyncMutex.js +39 -39
- package/lib/esm/AsyncMutex.js.map +1 -1
- package/lib/esm/BeEvent.d.ts +81 -81
- package/lib/esm/BeEvent.js +150 -150
- package/lib/esm/BeEvent.js.map +1 -1
- package/lib/esm/BeSQLite.d.ts +170 -170
- package/lib/esm/BeSQLite.js +180 -180
- package/lib/esm/BeSQLite.js.map +1 -1
- package/lib/esm/BentleyError.d.ts +376 -376
- package/lib/esm/BentleyError.js +695 -695
- package/lib/esm/BentleyError.js.map +1 -1
- package/lib/esm/BentleyLoggerCategory.d.ts +11 -11
- package/lib/esm/BentleyLoggerCategory.js +16 -16
- package/lib/esm/BentleyLoggerCategory.js.map +1 -1
- package/lib/esm/ByteStream.d.ts +92 -92
- package/lib/esm/ByteStream.js +129 -129
- package/lib/esm/ByteStream.js.map +1 -1
- package/lib/esm/ClassUtils.d.ts +14 -14
- package/lib/esm/ClassUtils.js +22 -22
- package/lib/esm/ClassUtils.js.map +1 -1
- package/lib/esm/Compare.d.ts +47 -47
- package/lib/esm/Compare.js +63 -63
- package/lib/esm/Compare.js.map +1 -1
- package/lib/esm/CompressedId64Set.d.ts +134 -134
- package/lib/esm/CompressedId64Set.js +423 -423
- package/lib/esm/CompressedId64Set.js.map +1 -1
- package/lib/esm/Dictionary.d.ts +125 -125
- package/lib/esm/Dictionary.js +199 -199
- package/lib/esm/Dictionary.js.map +1 -1
- package/lib/esm/Disposable.d.ts +80 -80
- package/lib/esm/Disposable.js +112 -112
- package/lib/esm/Disposable.js.map +1 -1
- package/lib/esm/Id.d.ts +277 -277
- package/lib/esm/Id.js +625 -625
- package/lib/esm/Id.js.map +1 -1
- package/lib/esm/IndexMap.d.ts +65 -65
- package/lib/esm/IndexMap.js +86 -86
- package/lib/esm/IndexMap.js.map +1 -1
- package/lib/esm/JsonSchema.d.ts +77 -77
- package/lib/esm/JsonSchema.js +8 -8
- package/lib/esm/JsonSchema.js.map +1 -1
- package/lib/esm/JsonUtils.d.ts +78 -78
- package/lib/esm/JsonUtils.js +148 -148
- package/lib/esm/JsonUtils.js.map +1 -1
- package/lib/esm/LRUMap.d.ts +129 -129
- package/lib/esm/LRUMap.js +326 -326
- package/lib/esm/LRUMap.js.map +1 -1
- package/lib/esm/Logger.d.ts +141 -141
- package/lib/esm/Logger.js +249 -249
- package/lib/esm/Logger.js.map +1 -1
- package/lib/esm/ObservableSet.d.ts +23 -23
- package/lib/esm/ObservableSet.js +47 -47
- package/lib/esm/ObservableSet.js.map +1 -1
- package/lib/esm/OneAtATimeAction.d.ts +31 -31
- package/lib/esm/OneAtATimeAction.js +89 -89
- package/lib/esm/OneAtATimeAction.js.map +1 -1
- package/lib/esm/OrderedId64Iterable.d.ts +74 -74
- package/lib/esm/OrderedId64Iterable.js +232 -232
- package/lib/esm/OrderedId64Iterable.js.map +1 -1
- package/lib/esm/OrderedSet.d.ts +40 -40
- package/lib/esm/OrderedSet.js +59 -59
- package/lib/esm/OrderedSet.js.map +1 -1
- package/lib/esm/PriorityQueue.d.ts +70 -70
- package/lib/esm/PriorityQueue.js +136 -136
- package/lib/esm/PriorityQueue.js.map +1 -1
- package/lib/esm/ProcessDetector.d.ts +59 -59
- package/lib/esm/ProcessDetector.js +67 -67
- package/lib/esm/ProcessDetector.js.map +1 -1
- package/lib/esm/SortedArray.d.ts +232 -232
- package/lib/esm/SortedArray.js +296 -296
- package/lib/esm/SortedArray.js.map +1 -1
- package/lib/esm/StatusCategory.d.ts +30 -30
- package/lib/esm/StatusCategory.js +454 -454
- package/lib/esm/StatusCategory.js.map +1 -1
- package/lib/esm/StringUtils.d.ts +22 -22
- package/lib/esm/StringUtils.js +142 -142
- package/lib/esm/StringUtils.js.map +1 -1
- package/lib/esm/Time.d.ts +122 -122
- package/lib/esm/Time.js +146 -146
- package/lib/esm/Time.js.map +1 -1
- package/lib/esm/Tracing.d.ts +40 -40
- package/lib/esm/Tracing.js +126 -126
- package/lib/esm/Tracing.js.map +1 -1
- package/lib/esm/TypedArrayBuilder.d.ts +97 -97
- package/lib/esm/TypedArrayBuilder.js +127 -127
- package/lib/esm/TypedArrayBuilder.js.map +1 -1
- package/lib/esm/UnexpectedErrors.d.ts +43 -43
- package/lib/esm/UnexpectedErrors.js +64 -64
- package/lib/esm/UnexpectedErrors.js.map +1 -1
- package/lib/esm/UtilityTypes.d.ts +86 -86
- package/lib/esm/UtilityTypes.js +21 -21
- package/lib/esm/UtilityTypes.js.map +1 -1
- package/lib/esm/YieldManager.d.ts +18 -18
- package/lib/esm/YieldManager.js +30 -30
- package/lib/esm/YieldManager.js.map +1 -1
- package/lib/esm/core-bentley.d.ts +74 -74
- package/lib/esm/core-bentley.js +78 -78
- package/lib/esm/core-bentley.js.map +1 -1
- package/lib/esm/partitionArray.d.ts +21 -21
- package/lib/esm/partitionArray.js +39 -39
- package/lib/esm/partitionArray.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Utils
|
|
3
|
-
*/
|
|
4
|
-
/** The inverse of TypeScript's Readonly<T> type, producing a type that has all the properties of `T` with any `readonly` modifiers removed.
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export declare type Mutable<T> = {
|
|
8
|
-
-readonly [K in keyof T]: T[K];
|
|
9
|
-
};
|
|
10
|
-
/** Make a new type from an existing type `T`, with set of required properties `K` optional.
|
|
11
|
-
* @public
|
|
12
|
-
*/
|
|
13
|
-
export declare type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
14
|
-
/** Make a new type from an existing type `T`, with set of optional properties `K` required.
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
export declare type MarkRequired<T, K extends keyof T> = Pick<Required<T>, K> & Omit<T, K>;
|
|
18
|
-
/** Generically represents a class `T`, for use in type annotations.
|
|
19
|
-
* @note A variable of type `Constructor<T>` matches a class `T` only if `T` has a **public** constructor.
|
|
20
|
-
* @see [[asInstanceOf]] to attempt to cast an arbitrary value to class `T`.
|
|
21
|
-
* @see [[isInstanceOf]] to determine if an arbitrary value is an instance of class `T`.
|
|
22
|
-
* @public
|
|
23
|
-
*/
|
|
24
|
-
export declare type Constructor<T> = new (...args: any[]) => T;
|
|
25
|
-
/** Returns true if `obj` is an object of class `T`.
|
|
26
|
-
* @see [[asInstanceOf]] to cast `obj` to class `T`.
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
|
-
export declare function isInstanceOf<T>(obj: any, constructor: Constructor<T>): boolean;
|
|
30
|
-
/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.
|
|
31
|
-
* @see [[isInstanceOf]] to query whether `obj` is of class `T`.
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
export declare function asInstanceOf<T>(obj: any, constructor: Constructor<T>): T | undefined;
|
|
35
|
-
/** Extracts the names of all public properties of `T` that are not of type `function`.
|
|
36
|
-
* This includes properties defined using `get` syntax. Care should be used when using this type in conjunction with
|
|
37
|
-
* the object spread (`...`) operator, because the spread operator omits properties defined using `get` syntax and, therefore,
|
|
38
|
-
* so too does the type that TypeScript infers from that operator.
|
|
39
|
-
* `get` syntax. For example:
|
|
40
|
-
* ```ts
|
|
41
|
-
* class Thing {
|
|
42
|
-
* private _a = "a"; // a private variable
|
|
43
|
-
* public b = "b"; // a public variable
|
|
44
|
-
* public get c() { return "c"; } // a public property
|
|
45
|
-
* public d() { return "d"; } // a public method
|
|
46
|
-
* public e = () => "e"; // a public variable of type `function`
|
|
47
|
-
* }
|
|
48
|
-
*
|
|
49
|
-
* // The following can have the values "b" or "c" - those are the public, non-function properties of Thing.
|
|
50
|
-
* let nonFunctionProperty: NonFunctionPropertyNamesOf<Thing> = "c";
|
|
51
|
-
*
|
|
52
|
-
* // The following produces an error: "Property 'c' is missing in type '{ b: string; e: () => string; }' but required in type 'NonFunctionPropertiesOf<Thing>'"
|
|
53
|
-
* const thing1 = new Thing();
|
|
54
|
-
* const thing2: NonFunctionPropertiesOf<Thing> = { ...thing1 };
|
|
55
|
-
* ```
|
|
56
|
-
* @see [[NonFunctionPropertiesOf]] to obtain a type that includes only these properties.
|
|
57
|
-
* @public
|
|
58
|
-
*/
|
|
59
|
-
export declare type NonFunctionPropertyNamesOf<T> = {
|
|
60
|
-
[K in keyof T]: T[K] extends Function ? never : K;
|
|
61
|
-
}[keyof T];
|
|
62
|
-
/** Produces a type consisting of all of the public properties of `T` except for those of type `function`.
|
|
63
|
-
* @see [[NonFunctionPropertyNamesOf]] for potential pitfalls when used in conjunction with the object spread operator.
|
|
64
|
-
* @public
|
|
65
|
-
*/
|
|
66
|
-
export declare type NonFunctionPropertiesOf<T> = Pick<T, NonFunctionPropertyNamesOf<T>>;
|
|
67
|
-
/** Any function returning a Promise.
|
|
68
|
-
* @see [[AsyncMethodsOf]] to extract all async methods from a type.
|
|
69
|
-
* @see [[PromiseReturnType]] to extract the type to which the Promise resolves.
|
|
70
|
-
* @public
|
|
71
|
-
*/
|
|
72
|
-
export declare type AsyncFunction = (...args: any) => Promise<any>;
|
|
73
|
-
/** Extracts the names of all function properties of `T` that return a Promise.
|
|
74
|
-
* @public
|
|
75
|
-
*/
|
|
76
|
-
export declare type AsyncMethodsOf<T> = {
|
|
77
|
-
[P in keyof T]: T[P] extends AsyncFunction ? P : never;
|
|
78
|
-
}[keyof T];
|
|
79
|
-
/** Extracts the type to which the Promise returned by an async function resolves.
|
|
80
|
-
* @public
|
|
81
|
-
*/
|
|
82
|
-
export declare type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;
|
|
83
|
-
/** Extracts a subset of literals `U` from a union of literals `T` in a type-safe way.
|
|
84
|
-
* @beta
|
|
85
|
-
*/
|
|
86
|
-
export declare type ExtractLiterals<T, U extends T> = Extract<T, U>;
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Utils
|
|
3
|
+
*/
|
|
4
|
+
/** The inverse of TypeScript's Readonly<T> type, producing a type that has all the properties of `T` with any `readonly` modifiers removed.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare type Mutable<T> = {
|
|
8
|
+
-readonly [K in keyof T]: T[K];
|
|
9
|
+
};
|
|
10
|
+
/** Make a new type from an existing type `T`, with set of required properties `K` optional.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
14
|
+
/** Make a new type from an existing type `T`, with set of optional properties `K` required.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export declare type MarkRequired<T, K extends keyof T> = Pick<Required<T>, K> & Omit<T, K>;
|
|
18
|
+
/** Generically represents a class `T`, for use in type annotations.
|
|
19
|
+
* @note A variable of type `Constructor<T>` matches a class `T` only if `T` has a **public** constructor.
|
|
20
|
+
* @see [[asInstanceOf]] to attempt to cast an arbitrary value to class `T`.
|
|
21
|
+
* @see [[isInstanceOf]] to determine if an arbitrary value is an instance of class `T`.
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export declare type Constructor<T> = new (...args: any[]) => T;
|
|
25
|
+
/** Returns true if `obj` is an object of class `T`.
|
|
26
|
+
* @see [[asInstanceOf]] to cast `obj` to class `T`.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export declare function isInstanceOf<T>(obj: any, constructor: Constructor<T>): boolean;
|
|
30
|
+
/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.
|
|
31
|
+
* @see [[isInstanceOf]] to query whether `obj` is of class `T`.
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare function asInstanceOf<T>(obj: any, constructor: Constructor<T>): T | undefined;
|
|
35
|
+
/** Extracts the names of all public properties of `T` that are not of type `function`.
|
|
36
|
+
* This includes properties defined using `get` syntax. Care should be used when using this type in conjunction with
|
|
37
|
+
* the object spread (`...`) operator, because the spread operator omits properties defined using `get` syntax and, therefore,
|
|
38
|
+
* so too does the type that TypeScript infers from that operator.
|
|
39
|
+
* `get` syntax. For example:
|
|
40
|
+
* ```ts
|
|
41
|
+
* class Thing {
|
|
42
|
+
* private _a = "a"; // a private variable
|
|
43
|
+
* public b = "b"; // a public variable
|
|
44
|
+
* public get c() { return "c"; } // a public property
|
|
45
|
+
* public d() { return "d"; } // a public method
|
|
46
|
+
* public e = () => "e"; // a public variable of type `function`
|
|
47
|
+
* }
|
|
48
|
+
*
|
|
49
|
+
* // The following can have the values "b" or "c" - those are the public, non-function properties of Thing.
|
|
50
|
+
* let nonFunctionProperty: NonFunctionPropertyNamesOf<Thing> = "c";
|
|
51
|
+
*
|
|
52
|
+
* // The following produces an error: "Property 'c' is missing in type '{ b: string; e: () => string; }' but required in type 'NonFunctionPropertiesOf<Thing>'"
|
|
53
|
+
* const thing1 = new Thing();
|
|
54
|
+
* const thing2: NonFunctionPropertiesOf<Thing> = { ...thing1 };
|
|
55
|
+
* ```
|
|
56
|
+
* @see [[NonFunctionPropertiesOf]] to obtain a type that includes only these properties.
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
export declare type NonFunctionPropertyNamesOf<T> = {
|
|
60
|
+
[K in keyof T]: T[K] extends Function ? never : K;
|
|
61
|
+
}[keyof T];
|
|
62
|
+
/** Produces a type consisting of all of the public properties of `T` except for those of type `function`.
|
|
63
|
+
* @see [[NonFunctionPropertyNamesOf]] for potential pitfalls when used in conjunction with the object spread operator.
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
66
|
+
export declare type NonFunctionPropertiesOf<T> = Pick<T, NonFunctionPropertyNamesOf<T>>;
|
|
67
|
+
/** Any function returning a Promise.
|
|
68
|
+
* @see [[AsyncMethodsOf]] to extract all async methods from a type.
|
|
69
|
+
* @see [[PromiseReturnType]] to extract the type to which the Promise resolves.
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
export declare type AsyncFunction = (...args: any) => Promise<any>;
|
|
73
|
+
/** Extracts the names of all function properties of `T` that return a Promise.
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
export declare type AsyncMethodsOf<T> = {
|
|
77
|
+
[P in keyof T]: T[P] extends AsyncFunction ? P : never;
|
|
78
|
+
}[keyof T];
|
|
79
|
+
/** Extracts the type to which the Promise returned by an async function resolves.
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
export declare type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;
|
|
83
|
+
/** Extracts a subset of literals `U` from a union of literals `T` in a type-safe way.
|
|
84
|
+
* @beta
|
|
85
|
+
*/
|
|
86
|
+
export declare type ExtractLiterals<T, U extends T> = Extract<T, U>;
|
|
87
87
|
//# sourceMappingURL=UtilityTypes.d.ts.map
|
package/lib/cjs/UtilityTypes.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
/** @packageDocumentation
|
|
7
|
-
* @module Utils
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.asInstanceOf = exports.isInstanceOf = void 0;
|
|
11
|
-
/** Returns true if `obj` is an object of class `T`.
|
|
12
|
-
* @see [[asInstanceOf]] to cast `obj` to class `T`.
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
function isInstanceOf(obj, constructor) {
|
|
16
|
-
return "object" === typeof obj && obj instanceof constructor;
|
|
17
|
-
}
|
|
18
|
-
exports.isInstanceOf = isInstanceOf;
|
|
19
|
-
/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.
|
|
20
|
-
* @see [[isInstanceOf]] to query whether `obj` is of class `T`.
|
|
21
|
-
* @public
|
|
22
|
-
*/
|
|
23
|
-
function asInstanceOf(obj, constructor) {
|
|
24
|
-
return isInstanceOf(obj, constructor) ? obj : undefined;
|
|
25
|
-
}
|
|
26
|
-
exports.asInstanceOf = asInstanceOf;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module Utils
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.asInstanceOf = exports.isInstanceOf = void 0;
|
|
11
|
+
/** Returns true if `obj` is an object of class `T`.
|
|
12
|
+
* @see [[asInstanceOf]] to cast `obj` to class `T`.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
function isInstanceOf(obj, constructor) {
|
|
16
|
+
return "object" === typeof obj && obj instanceof constructor;
|
|
17
|
+
}
|
|
18
|
+
exports.isInstanceOf = isInstanceOf;
|
|
19
|
+
/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.
|
|
20
|
+
* @see [[isInstanceOf]] to query whether `obj` is of class `T`.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
function asInstanceOf(obj, constructor) {
|
|
24
|
+
return isInstanceOf(obj, constructor) ? obj : undefined;
|
|
25
|
+
}
|
|
26
|
+
exports.asInstanceOf = asInstanceOf;
|
|
27
27
|
//# sourceMappingURL=UtilityTypes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UtilityTypes.js","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA2BH;;;GAGG;AACH,SAAgB,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,QAAQ,KAAK,OAAO,GAAG,IAAI,GAAG,YAAY,WAAW,CAAC;AAC/D,CAAC;AAFD,oCAEC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,YAAY,CAAI,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AAFD,oCAEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utils\n */\n\n/** The inverse of TypeScript's Readonly<T> type, producing a type that has all the properties of `T` with any `readonly` modifiers removed.\n * @public\n */\nexport type Mutable<T> = {\n -readonly [K in keyof T]: T[K];\n};\n\n/** Make a new type from an existing type `T`, with set of required properties `K` optional.\n * @public\n */\nexport type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\n\n/** Make a new type from an existing type `T`, with set of optional properties `K` required.\n * @public\n */\nexport type MarkRequired<T, K extends keyof T> = Pick<Required<T>, K> & Omit<T, K>;\n\n/** Generically represents a class `T`, for use in type annotations.\n * @note A variable of type `Constructor<T>` matches a class `T` only if `T` has a **public** constructor.\n * @see [[asInstanceOf]] to attempt to cast an arbitrary value to class `T`.\n * @see [[isInstanceOf]] to determine if an arbitrary value is an instance of class `T`.\n * @public\n */\nexport type Constructor<T> = new (...args: any[]) => T;\n\n/** Returns true if `obj` is an object of class `T`.\n * @see [[asInstanceOf]] to cast `obj` to class `T`.\n * @public\n */\nexport function isInstanceOf<T>(obj: any, constructor: Constructor<T>): boolean {\n return \"object\" === typeof obj && obj instanceof constructor;\n}\n\n/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.\n * @see [[isInstanceOf]] to query whether `obj` is of class `T`.\n * @public\n */\nexport function asInstanceOf<T>(obj: any, constructor: Constructor<T>): T | undefined {\n return isInstanceOf<T>(obj, constructor) ? obj as T : undefined;\n}\n\n/** Extracts the names of all public properties of `T` that are not of type `function`.\n * This includes properties defined using `get` syntax. Care should be used when using this type in conjunction with\n * the object spread (`...`) operator, because the spread operator omits properties defined using `get` syntax and, therefore,\n * so too does the type that TypeScript infers from that operator.\n * `get` syntax. For example:\n * ```ts\n * class Thing {\n * private _a = \"a\"; // a private variable\n * public b = \"b\"; // a public variable\n * public get c() { return \"c\"; } // a public property\n * public d() { return \"d\"; } // a public method\n * public e = () => \"e\"; // a public variable of type `function`\n * }\n *\n * // The following can have the values \"b\" or \"c\" - those are the public, non-function properties of Thing.\n * let nonFunctionProperty: NonFunctionPropertyNamesOf<Thing> = \"c\";\n *\n * // The following produces an error: \"Property 'c' is missing in type '{ b: string; e: () => string; }' but required in type 'NonFunctionPropertiesOf<Thing>'\"\n * const thing1 = new Thing();\n * const thing2: NonFunctionPropertiesOf<Thing> = { ...thing1 };\n * ```\n * @see [[NonFunctionPropertiesOf]] to obtain a type that includes only these properties.\n * @public\n */\nexport type NonFunctionPropertyNamesOf<T> = {\n [K in keyof T]: T[K] extends Function ? never : K;\n}[keyof T];\n\n/** Produces a type consisting of all of the public properties of `T` except for those of type `function`.\n * @see [[NonFunctionPropertyNamesOf]] for potential pitfalls when used in conjunction with the object spread operator.\n * @public\n */\nexport type NonFunctionPropertiesOf<T> = Pick<T, NonFunctionPropertyNamesOf<T>>;\n\n/** Any function returning a Promise.\n * @see [[AsyncMethodsOf]] to extract all async methods from a type.\n * @see [[PromiseReturnType]] to extract the type to which the Promise resolves.\n * @public\n */\nexport type AsyncFunction = (...args: any) => Promise<any>;\n\n/** Extracts the names of all function properties of `T` that return a Promise.\n * @public\n */\nexport type AsyncMethodsOf<T> = { [P in keyof T]: T[P] extends AsyncFunction ? P : never }[keyof T];\n\n/** Extracts the type to which the Promise returned by an async function resolves.\n * @public\n */\nexport type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;\n\n/** Extracts a subset of literals `U` from a union of literals `T` in a type-safe way.\n * @beta\n */\nexport type ExtractLiterals<T, U extends T> = Extract<T, U>;\n"]}
|
|
1
|
+
{"version":3,"file":"UtilityTypes.js","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA2BH;;;GAGG;AACH,SAAgB,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,QAAQ,KAAK,OAAO,GAAG,IAAI,GAAG,YAAY,WAAW,CAAC;AAC/D,CAAC;AAFD,oCAEC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,YAAY,CAAI,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AAFD,oCAEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Utils\r\n */\r\n\r\n/** The inverse of TypeScript's Readonly<T> type, producing a type that has all the properties of `T` with any `readonly` modifiers removed.\r\n * @public\r\n */\r\nexport type Mutable<T> = {\r\n -readonly [K in keyof T]: T[K];\r\n};\r\n\r\n/** Make a new type from an existing type `T`, with set of required properties `K` optional.\r\n * @public\r\n */\r\nexport type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\r\n\r\n/** Make a new type from an existing type `T`, with set of optional properties `K` required.\r\n * @public\r\n */\r\nexport type MarkRequired<T, K extends keyof T> = Pick<Required<T>, K> & Omit<T, K>;\r\n\r\n/** Generically represents a class `T`, for use in type annotations.\r\n * @note A variable of type `Constructor<T>` matches a class `T` only if `T` has a **public** constructor.\r\n * @see [[asInstanceOf]] to attempt to cast an arbitrary value to class `T`.\r\n * @see [[isInstanceOf]] to determine if an arbitrary value is an instance of class `T`.\r\n * @public\r\n */\r\nexport type Constructor<T> = new (...args: any[]) => T;\r\n\r\n/** Returns true if `obj` is an object of class `T`.\r\n * @see [[asInstanceOf]] to cast `obj` to class `T`.\r\n * @public\r\n */\r\nexport function isInstanceOf<T>(obj: any, constructor: Constructor<T>): boolean {\r\n return \"object\" === typeof obj && obj instanceof constructor;\r\n}\r\n\r\n/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.\r\n * @see [[isInstanceOf]] to query whether `obj` is of class `T`.\r\n * @public\r\n */\r\nexport function asInstanceOf<T>(obj: any, constructor: Constructor<T>): T | undefined {\r\n return isInstanceOf<T>(obj, constructor) ? obj as T : undefined;\r\n}\r\n\r\n/** Extracts the names of all public properties of `T` that are not of type `function`.\r\n * This includes properties defined using `get` syntax. Care should be used when using this type in conjunction with\r\n * the object spread (`...`) operator, because the spread operator omits properties defined using `get` syntax and, therefore,\r\n * so too does the type that TypeScript infers from that operator.\r\n * `get` syntax. For example:\r\n * ```ts\r\n * class Thing {\r\n * private _a = \"a\"; // a private variable\r\n * public b = \"b\"; // a public variable\r\n * public get c() { return \"c\"; } // a public property\r\n * public d() { return \"d\"; } // a public method\r\n * public e = () => \"e\"; // a public variable of type `function`\r\n * }\r\n *\r\n * // The following can have the values \"b\" or \"c\" - those are the public, non-function properties of Thing.\r\n * let nonFunctionProperty: NonFunctionPropertyNamesOf<Thing> = \"c\";\r\n *\r\n * // The following produces an error: \"Property 'c' is missing in type '{ b: string; e: () => string; }' but required in type 'NonFunctionPropertiesOf<Thing>'\"\r\n * const thing1 = new Thing();\r\n * const thing2: NonFunctionPropertiesOf<Thing> = { ...thing1 };\r\n * ```\r\n * @see [[NonFunctionPropertiesOf]] to obtain a type that includes only these properties.\r\n * @public\r\n */\r\nexport type NonFunctionPropertyNamesOf<T> = {\r\n [K in keyof T]: T[K] extends Function ? never : K;\r\n}[keyof T];\r\n\r\n/** Produces a type consisting of all of the public properties of `T` except for those of type `function`.\r\n * @see [[NonFunctionPropertyNamesOf]] for potential pitfalls when used in conjunction with the object spread operator.\r\n * @public\r\n */\r\nexport type NonFunctionPropertiesOf<T> = Pick<T, NonFunctionPropertyNamesOf<T>>;\r\n\r\n/** Any function returning a Promise.\r\n * @see [[AsyncMethodsOf]] to extract all async methods from a type.\r\n * @see [[PromiseReturnType]] to extract the type to which the Promise resolves.\r\n * @public\r\n */\r\nexport type AsyncFunction = (...args: any) => Promise<any>;\r\n\r\n/** Extracts the names of all function properties of `T` that return a Promise.\r\n * @public\r\n */\r\nexport type AsyncMethodsOf<T> = { [P in keyof T]: T[P] extends AsyncFunction ? P : never }[keyof T];\r\n\r\n/** Extracts the type to which the Promise returned by an async function resolves.\r\n * @public\r\n */\r\nexport type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;\r\n\r\n/** Extracts a subset of literals `U` from a union of literals `T` in a type-safe way.\r\n * @beta\r\n */\r\nexport type ExtractLiterals<T, U extends T> = Extract<T, U>;\r\n"]}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/** @internal options for constructing yield managers */
|
|
2
|
-
export interface YieldManagerOptions {
|
|
3
|
-
iterationsBeforeYield?: number;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* @internal
|
|
7
|
-
* An object allowing code to optionally yield with some frequency.
|
|
8
|
-
* useful in some intense loops that make processes unresponsive.
|
|
9
|
-
* primarily a workaround for: https://github.com/nodejs/node-addon-api/issues/1140
|
|
10
|
-
* @note see [[defaultYieldManagerOptions]], the default amount of times it must be called to cause an actual yield is 1000
|
|
11
|
-
*/
|
|
12
|
-
export declare class YieldManager {
|
|
13
|
-
options: Readonly<Required<YieldManagerOptions>>;
|
|
14
|
-
private _counter;
|
|
15
|
-
constructor(options?: YieldManagerOptions);
|
|
16
|
-
allowYield(): Promise<void>;
|
|
17
|
-
protected actualYield(): Promise<void>;
|
|
18
|
-
}
|
|
1
|
+
/** @internal options for constructing yield managers */
|
|
2
|
+
export interface YieldManagerOptions {
|
|
3
|
+
iterationsBeforeYield?: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
* An object allowing code to optionally yield with some frequency.
|
|
8
|
+
* useful in some intense loops that make processes unresponsive.
|
|
9
|
+
* primarily a workaround for: https://github.com/nodejs/node-addon-api/issues/1140
|
|
10
|
+
* @note see [[defaultYieldManagerOptions]], the default amount of times it must be called to cause an actual yield is 1000
|
|
11
|
+
*/
|
|
12
|
+
export declare class YieldManager {
|
|
13
|
+
options: Readonly<Required<YieldManagerOptions>>;
|
|
14
|
+
private _counter;
|
|
15
|
+
constructor(options?: YieldManagerOptions);
|
|
16
|
+
allowYield(): Promise<void>;
|
|
17
|
+
protected actualYield(): Promise<void>;
|
|
18
|
+
}
|
|
19
19
|
//# sourceMappingURL=YieldManager.d.ts.map
|
package/lib/cjs/YieldManager.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.YieldManager = void 0;
|
|
8
|
-
/** @internal the default options when constructing yield managers */
|
|
9
|
-
const defaultYieldManagerOptions = {
|
|
10
|
-
iterationsBeforeYield: 1000,
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* @internal
|
|
14
|
-
* An object allowing code to optionally yield with some frequency.
|
|
15
|
-
* useful in some intense loops that make processes unresponsive.
|
|
16
|
-
* primarily a workaround for: https://github.com/nodejs/node-addon-api/issues/1140
|
|
17
|
-
* @note see [[defaultYieldManagerOptions]], the default amount of times it must be called to cause an actual yield is 1000
|
|
18
|
-
*/
|
|
19
|
-
class YieldManager {
|
|
20
|
-
constructor(options = {}) {
|
|
21
|
-
this._counter = 0;
|
|
22
|
-
this.options = { ...defaultYieldManagerOptions, ...options };
|
|
23
|
-
}
|
|
24
|
-
async allowYield() {
|
|
25
|
-
this._counter = (this._counter + 1) % this.options.iterationsBeforeYield;
|
|
26
|
-
if (this._counter === 0) {
|
|
27
|
-
await this.actualYield();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async actualYield() {
|
|
31
|
-
await new Promise((r) => setTimeout(r, 0));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.YieldManager = YieldManager;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.YieldManager = void 0;
|
|
8
|
+
/** @internal the default options when constructing yield managers */
|
|
9
|
+
const defaultYieldManagerOptions = {
|
|
10
|
+
iterationsBeforeYield: 1000,
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
* An object allowing code to optionally yield with some frequency.
|
|
15
|
+
* useful in some intense loops that make processes unresponsive.
|
|
16
|
+
* primarily a workaround for: https://github.com/nodejs/node-addon-api/issues/1140
|
|
17
|
+
* @note see [[defaultYieldManagerOptions]], the default amount of times it must be called to cause an actual yield is 1000
|
|
18
|
+
*/
|
|
19
|
+
class YieldManager {
|
|
20
|
+
constructor(options = {}) {
|
|
21
|
+
this._counter = 0;
|
|
22
|
+
this.options = { ...defaultYieldManagerOptions, ...options };
|
|
23
|
+
}
|
|
24
|
+
async allowYield() {
|
|
25
|
+
this._counter = (this._counter + 1) % this.options.iterationsBeforeYield;
|
|
26
|
+
if (this._counter === 0) {
|
|
27
|
+
await this.actualYield();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async actualYield() {
|
|
31
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.YieldManager = YieldManager;
|
|
35
35
|
//# sourceMappingURL=YieldManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YieldManager.js","sourceRoot":"","sources":["../../src/YieldManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAO/F,qEAAqE;AACrE,MAAM,0BAA0B,GAAkC;IAChE,qBAAqB,EAAE,IAAI;CAC5B,CAAC;AAEF;;;;;;GAMG;AACH,MAAa,YAAY;IAIvB,YAAmB,UAA+B,EAAE;QAF5C,aAAQ,GAAG,CAAC,CAAC;QAGnB,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,0BAA0B,EAAE,GAAG,OAAO,EAAE,CAAC;IAC/D,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC;QACzE,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,EAAE;YACvB,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;SAC1B;IACH,CAAC;IAES,KAAK,CAAC,WAAW;QACzB,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;CACF;AAlBD,oCAkBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @internal options for constructing yield managers */\nexport interface YieldManagerOptions {\n iterationsBeforeYield?: number;\n}\n\n/** @internal the default options when constructing yield managers */\nconst defaultYieldManagerOptions: Required<YieldManagerOptions> = {\n iterationsBeforeYield: 1000,\n};\n\n/**\n * @internal\n * An object allowing code to optionally yield with some frequency.\n * useful in some intense loops that make processes unresponsive.\n * primarily a workaround for: https://github.com/nodejs/node-addon-api/issues/1140\n * @note see [[defaultYieldManagerOptions]], the default amount of times it must be called to cause an actual yield is 1000\n */\nexport class YieldManager {\n public options: Readonly<Required<YieldManagerOptions>>;\n private _counter = 0;\n\n public constructor(options: YieldManagerOptions = {}) {\n this.options = { ...defaultYieldManagerOptions, ...options };\n }\n\n public async allowYield() {\n this._counter = (this._counter + 1) % this.options.iterationsBeforeYield;\n if (this._counter === 0) {\n await this.actualYield();\n }\n }\n\n protected async actualYield() {\n await new Promise((r) => setTimeout(r, 0));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"YieldManager.js","sourceRoot":"","sources":["../../src/YieldManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAO/F,qEAAqE;AACrE,MAAM,0BAA0B,GAAkC;IAChE,qBAAqB,EAAE,IAAI;CAC5B,CAAC;AAEF;;;;;;GAMG;AACH,MAAa,YAAY;IAIvB,YAAmB,UAA+B,EAAE;QAF5C,aAAQ,GAAG,CAAC,CAAC;QAGnB,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,0BAA0B,EAAE,GAAG,OAAO,EAAE,CAAC;IAC/D,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC;QACzE,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,EAAE;YACvB,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;SAC1B;IACH,CAAC;IAES,KAAK,CAAC,WAAW;QACzB,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;CACF;AAlBD,oCAkBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @internal options for constructing yield managers */\r\nexport interface YieldManagerOptions {\r\n iterationsBeforeYield?: number;\r\n}\r\n\r\n/** @internal the default options when constructing yield managers */\r\nconst defaultYieldManagerOptions: Required<YieldManagerOptions> = {\r\n iterationsBeforeYield: 1000,\r\n};\r\n\r\n/**\r\n * @internal\r\n * An object allowing code to optionally yield with some frequency.\r\n * useful in some intense loops that make processes unresponsive.\r\n * primarily a workaround for: https://github.com/nodejs/node-addon-api/issues/1140\r\n * @note see [[defaultYieldManagerOptions]], the default amount of times it must be called to cause an actual yield is 1000\r\n */\r\nexport class YieldManager {\r\n public options: Readonly<Required<YieldManagerOptions>>;\r\n private _counter = 0;\r\n\r\n public constructor(options: YieldManagerOptions = {}) {\r\n this.options = { ...defaultYieldManagerOptions, ...options };\r\n }\r\n\r\n public async allowYield() {\r\n this._counter = (this._counter + 1) % this.options.iterationsBeforeYield;\r\n if (this._counter === 0) {\r\n await this.actualYield();\r\n }\r\n }\r\n\r\n protected async actualYield() {\r\n await new Promise((r) => setTimeout(r, 0));\r\n }\r\n}\r\n"]}
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
export * from "./AccessToken";
|
|
2
|
-
export * from "./Assert";
|
|
3
|
-
export * from "./AsyncMutex";
|
|
4
|
-
export * from "./BeEvent";
|
|
5
|
-
export * from "./BentleyError";
|
|
6
|
-
export * from "./BentleyLoggerCategory";
|
|
7
|
-
export * from "./StatusCategory";
|
|
8
|
-
export * from "./BeSQLite";
|
|
9
|
-
export * from "./ByteStream";
|
|
10
|
-
export * from "./ClassUtils";
|
|
11
|
-
export * from "./Compare";
|
|
12
|
-
export * from "./CompressedId64Set";
|
|
13
|
-
export * from "./Dictionary";
|
|
14
|
-
export * from "./Disposable";
|
|
15
|
-
export * from "./Id";
|
|
16
|
-
export * from "./IndexMap";
|
|
17
|
-
export * from "./JsonSchema";
|
|
18
|
-
export * from "./JsonUtils";
|
|
19
|
-
export * from "./Logger";
|
|
20
|
-
export * from "./LRUMap";
|
|
21
|
-
export * from "./ObservableSet";
|
|
22
|
-
export * from "./OneAtATimeAction";
|
|
23
|
-
export * from "./OrderedId64Iterable";
|
|
24
|
-
export * from "./OrderedSet";
|
|
25
|
-
export * from "./partitionArray";
|
|
26
|
-
export * from "./PriorityQueue";
|
|
27
|
-
export * from "./ProcessDetector";
|
|
28
|
-
export * from "./SortedArray";
|
|
29
|
-
export * from "./StringUtils";
|
|
30
|
-
export * from "./Time";
|
|
31
|
-
export * from "./Tracing";
|
|
32
|
-
export * from "./TypedArrayBuilder";
|
|
33
|
-
export * from "./UnexpectedErrors";
|
|
34
|
-
export * from "./UtilityTypes";
|
|
35
|
-
export * from "./YieldManager";
|
|
36
|
-
/** @docs-package-description
|
|
37
|
-
* The core-bentley package contains classes to solve problems that are common for both client and server use cases.
|
|
38
|
-
*/
|
|
39
|
-
/**
|
|
40
|
-
* @docs-group-description BeSQLite
|
|
41
|
-
* Classes for working with SQLite databases. SQLite underlies IModelDb and ECDb - see [Executing ECSQL]($docs/learning/ECSQL.md)
|
|
42
|
-
*/
|
|
43
|
-
/**
|
|
44
|
-
* @docs-group-description Errors
|
|
45
|
-
* Classes for working with errors.
|
|
46
|
-
*/
|
|
47
|
-
/**
|
|
48
|
-
* @docs-group-description Events
|
|
49
|
-
* Classes for raising and handling events.
|
|
50
|
-
*/
|
|
51
|
-
/**
|
|
52
|
-
* @docs-group-description Ids
|
|
53
|
-
* Classes for working with unique identifiers.
|
|
54
|
-
*/
|
|
55
|
-
/**
|
|
56
|
-
* @docs-group-description Logging
|
|
57
|
-
* Classes for configuring and logging diagnostic messages - see [Learning about Logging]($docs/learning/common/Logging.md)
|
|
58
|
-
*/
|
|
59
|
-
/**
|
|
60
|
-
* @docs-group-description Collections
|
|
61
|
-
* Specialized, customizable collection classes like priority queues.
|
|
62
|
-
*/
|
|
63
|
-
/**
|
|
64
|
-
* @docs-group-description Json
|
|
65
|
-
* utilities for dealing with Json strings and files.
|
|
66
|
-
*/
|
|
67
|
-
/**
|
|
68
|
-
* @docs-group-description Utils
|
|
69
|
-
* Miscellaneous utility classes.
|
|
70
|
-
*/
|
|
71
|
-
/**
|
|
72
|
-
* @docs-group-description ProcessDetector
|
|
73
|
-
* Functions for determining the type of the current JavaScript process.
|
|
74
|
-
*/
|
|
1
|
+
export * from "./AccessToken";
|
|
2
|
+
export * from "./Assert";
|
|
3
|
+
export * from "./AsyncMutex";
|
|
4
|
+
export * from "./BeEvent";
|
|
5
|
+
export * from "./BentleyError";
|
|
6
|
+
export * from "./BentleyLoggerCategory";
|
|
7
|
+
export * from "./StatusCategory";
|
|
8
|
+
export * from "./BeSQLite";
|
|
9
|
+
export * from "./ByteStream";
|
|
10
|
+
export * from "./ClassUtils";
|
|
11
|
+
export * from "./Compare";
|
|
12
|
+
export * from "./CompressedId64Set";
|
|
13
|
+
export * from "./Dictionary";
|
|
14
|
+
export * from "./Disposable";
|
|
15
|
+
export * from "./Id";
|
|
16
|
+
export * from "./IndexMap";
|
|
17
|
+
export * from "./JsonSchema";
|
|
18
|
+
export * from "./JsonUtils";
|
|
19
|
+
export * from "./Logger";
|
|
20
|
+
export * from "./LRUMap";
|
|
21
|
+
export * from "./ObservableSet";
|
|
22
|
+
export * from "./OneAtATimeAction";
|
|
23
|
+
export * from "./OrderedId64Iterable";
|
|
24
|
+
export * from "./OrderedSet";
|
|
25
|
+
export * from "./partitionArray";
|
|
26
|
+
export * from "./PriorityQueue";
|
|
27
|
+
export * from "./ProcessDetector";
|
|
28
|
+
export * from "./SortedArray";
|
|
29
|
+
export * from "./StringUtils";
|
|
30
|
+
export * from "./Time";
|
|
31
|
+
export * from "./Tracing";
|
|
32
|
+
export * from "./TypedArrayBuilder";
|
|
33
|
+
export * from "./UnexpectedErrors";
|
|
34
|
+
export * from "./UtilityTypes";
|
|
35
|
+
export * from "./YieldManager";
|
|
36
|
+
/** @docs-package-description
|
|
37
|
+
* The core-bentley package contains classes to solve problems that are common for both client and server use cases.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* @docs-group-description BeSQLite
|
|
41
|
+
* Classes for working with SQLite databases. SQLite underlies IModelDb and ECDb - see [Executing ECSQL]($docs/learning/ECSQL.md)
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* @docs-group-description Errors
|
|
45
|
+
* Classes for working with errors.
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* @docs-group-description Events
|
|
49
|
+
* Classes for raising and handling events.
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* @docs-group-description Ids
|
|
53
|
+
* Classes for working with unique identifiers.
|
|
54
|
+
*/
|
|
55
|
+
/**
|
|
56
|
+
* @docs-group-description Logging
|
|
57
|
+
* Classes for configuring and logging diagnostic messages - see [Learning about Logging]($docs/learning/common/Logging.md)
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* @docs-group-description Collections
|
|
61
|
+
* Specialized, customizable collection classes like priority queues.
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* @docs-group-description Json
|
|
65
|
+
* utilities for dealing with Json strings and files.
|
|
66
|
+
*/
|
|
67
|
+
/**
|
|
68
|
+
* @docs-group-description Utils
|
|
69
|
+
* Miscellaneous utility classes.
|
|
70
|
+
*/
|
|
71
|
+
/**
|
|
72
|
+
* @docs-group-description ProcessDetector
|
|
73
|
+
* Functions for determining the type of the current JavaScript process.
|
|
74
|
+
*/
|
|
75
75
|
//# sourceMappingURL=core-bentley.d.ts.map
|