@itwin/core-bentley 3.4.0-dev.9 → 3.5.0-dev.4
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 +25 -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.d.ts.map +1 -1
- package/lib/cjs/ByteStream.js +133 -123
- 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.d.ts.map +1 -1
- package/lib/cjs/Compare.js +75 -63
- 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.d.ts.map +1 -1
- 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.d.ts.map +1 -1
- package/lib/cjs/Id.js +629 -619
- 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.d.ts.map +1 -1
- package/lib/cjs/JsonUtils.js +151 -133
- package/lib/cjs/JsonUtils.js.map +1 -1
- package/lib/cjs/LRUMap.d.ts +129 -129
- package/lib/cjs/LRUMap.d.ts.map +1 -1
- 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.d.ts.map +1 -1
- package/lib/cjs/OneAtATimeAction.js +94 -91
- 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.d.ts.map +1 -1
- package/lib/cjs/SortedArray.js +303 -301
- 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.d.ts.map +1 -1
- package/lib/cjs/StringUtils.js +148 -146
- package/lib/cjs/StringUtils.js.map +1 -1
- package/lib/cjs/Time.d.ts +122 -122
- package/lib/cjs/Time.d.ts.map +1 -1
- package/lib/cjs/Time.js +152 -146
- package/lib/cjs/Time.js.map +1 -1
- package/lib/cjs/Tracing.d.ts +40 -40
- package/lib/cjs/Tracing.d.ts.map +1 -1
- package/lib/cjs/Tracing.js +130 -127
- package/lib/cjs/Tracing.js.map +1 -1
- package/lib/cjs/TypedArrayBuilder.d.ts +98 -0
- package/lib/cjs/TypedArrayBuilder.d.ts.map +1 -0
- package/lib/cjs/TypedArrayBuilder.js +135 -0
- package/lib/cjs/TypedArrayBuilder.js.map +1 -0
- package/lib/cjs/UnexpectedErrors.d.ts +43 -43
- package/lib/cjs/UnexpectedErrors.d.ts.map +1 -1
- package/lib/cjs/UnexpectedErrors.js +68 -65
- 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 -73
- package/lib/cjs/core-bentley.d.ts.map +1 -1
- package/lib/cjs/core-bentley.js +90 -89
- 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.d.ts.map +1 -1
- package/lib/esm/ByteStream.js +129 -119
- 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.d.ts.map +1 -1
- package/lib/esm/Compare.js +63 -51
- 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.d.ts.map +1 -1
- 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.d.ts.map +1 -1
- package/lib/esm/Id.js +625 -615
- 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.d.ts.map +1 -1
- package/lib/esm/JsonUtils.js +148 -130
- package/lib/esm/JsonUtils.js.map +1 -1
- package/lib/esm/LRUMap.d.ts +129 -129
- package/lib/esm/LRUMap.d.ts.map +1 -1
- 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.d.ts.map +1 -1
- package/lib/esm/OneAtATimeAction.js +89 -86
- 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.d.ts.map +1 -1
- package/lib/esm/SortedArray.js +296 -294
- 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.d.ts.map +1 -1
- package/lib/esm/StringUtils.js +142 -140
- package/lib/esm/StringUtils.js.map +1 -1
- package/lib/esm/Time.d.ts +122 -122
- package/lib/esm/Time.d.ts.map +1 -1
- package/lib/esm/Time.js +146 -140
- package/lib/esm/Time.js.map +1 -1
- package/lib/esm/Tracing.d.ts +40 -40
- package/lib/esm/Tracing.d.ts.map +1 -1
- package/lib/esm/Tracing.js +126 -123
- package/lib/esm/Tracing.js.map +1 -1
- package/lib/esm/TypedArrayBuilder.d.ts +98 -0
- package/lib/esm/TypedArrayBuilder.d.ts.map +1 -0
- package/lib/esm/TypedArrayBuilder.js +128 -0
- package/lib/esm/TypedArrayBuilder.js.map +1 -0
- package/lib/esm/UnexpectedErrors.d.ts +43 -43
- package/lib/esm/UnexpectedErrors.d.ts.map +1 -1
- package/lib/esm/UnexpectedErrors.js +64 -61
- 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 -73
- package/lib/esm/core-bentley.d.ts.map +1 -1
- package/lib/esm/core-bentley.js +78 -77
- 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 +5 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypedArrayBuilder.js","sourceRoot":"","sources":["../../src/TypedArrayBuilder.ts"],"names":[],"mappings":"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","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 Collections\n */\n\nimport { Constructor } from \"./UtilityTypes\";\nimport { assert } from \"./Assert\";\n\n/** Options used to construct a [[TypedArrayBuilder]].\n * @public\n */\nexport interface TypedArrayBuilderOptions {\n /** Controls how much additional memory is allocated when the TypedArray needs to be resized to accomodate more elements.\n * [[TypedArrayBuilder.ensureCapacity]] multiplies the required capacity by this factor to determine the new capacity.\n * Default: 1.5\n * Minimum: 1.0, which causes the TypedArray to allocate exactly the space it needs each time it is resized.\n */\n growthFactor?: number;\n /** The number of elements to allocate memory for in the TypedArray when creating the builder.\n * If you know the minimum number of elements you intend to add to the builder, you should specify that as the\n * initial capacity to avoid reallocations when populating the array.\n * Default: 0.\n * Minimum: 0.\n */\n initialCapacity?: number;\n}\n\n/** Incrementally builds a [TypedArray] of unsigned 8-, 16-, or 32-bit integers.\n * Sometimes you wish to populate a `TypedArray`, but you don't know how many elements you will need.\n * `TypedArray` requires you to specify the size upon construction, and does not permit you to change the size later.\n *\n * `TypedArrayBuilder` manages a `TypedArray`, permitting you to [[push]] and [[append]] elements to it. It exposes two \"size\" properties\":\n * - [[capacity]], the number of elements it has currently allocated space for - i.e., the length of the underlying TypedArray; and\n * - [[length]], the number of elements that have so far been added to it, which is never bigger than [[capacity]].\n * When [[capacity]] is exceeded, a new, bigger TypedArray is allocated and the contents of the previous array are copied over to it.\n *\n * Once you've finished adding elements, you can obtain the finished `TypedArray` via [[toTypedArray]].\n * @see [[Uint8ArrayBuilder]], [[Uint16ArrayBuilder]], and [[Uint32ArrayBuilder]] to build specific types of arrays.\n * @public\n */\nexport class TypedArrayBuilder<T extends Uint8Array | Uint16Array | Uint32Array> {\n /** The constructor for the specific type of array being populated. */\n protected readonly _constructor: Constructor<T>;\n /** The underlying typed array, to be reallocated and copied when its capacity is exceeded. */\n protected _data: T;\n /** The number of elements added to the array so far. */\n protected _length: number;\n /** Multiplier applied to required capacity by [[ensureCapacity]]. */\n public readonly growthFactor: number;\n\n /** Constructs a new builder from the specified options, with a [[length]] of zero. */\n protected constructor(constructor: Constructor<T>, options?: TypedArrayBuilderOptions) {\n this._constructor = constructor;\n this._data = new constructor(options?.initialCapacity ?? 0);\n this.growthFactor = Math.max(1.0, options?.growthFactor ?? 1.5);\n this._length = 0;\n }\n\n /** The number of elements currently in the array. */\n public get length(): number {\n return this._length;\n }\n\n /** The number of elements that can fit into the memory currently allocated for the array. */\n public get capacity(): number {\n return this._data.length;\n }\n\n /** Like [TypedArray.at](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/at),\n * returns the element at the specified index, with negative integers counting back from the end of the array.\n * @note It is your responsibility to ensure the index falls within the bounds of the array.\n */\n public at(index: number): number {\n if (index < 0)\n index = this.length - index;\n\n const value = this._data[index];\n assert(value !== undefined, \"index out of bounds\");\n return value;\n }\n\n /** Ensure that [[capacity]] is at least equal to `newCapacity`.\n * This is used internally by methods like [[push]] and [[append]] to ensure the array has room for the element(s) to be added.\n * It can also be useful when you know you intend to add some number of additional elements, to minimize reallocations.\n *\n * If `newCapacity` is not greater than the current [[capacity]], this function does nothing.\n * Otherwise, it allocates a new `TypedArray` with room for `newCapacity * growthFactor` elements, and copies the contents of the previous `TypedArray` into it.\n * [[length]] remains unchanged; [[capacity]] reflects the size of the new TypeArray.\n */\n public ensureCapacity(newCapacity: number): number {\n if (this.capacity >= newCapacity)\n return this.capacity;\n\n assert(this.growthFactor >= 1.0);\n newCapacity = Math.ceil(newCapacity * this.growthFactor);\n const prevData = this._data;\n this._data = new this._constructor(newCapacity);\n this._data.set(prevData, 0);\n\n assert(this.capacity === newCapacity);\n return this.capacity;\n }\n\n /** Append the specified value, resizing if necessary. */\n public push(value: number): void {\n this.ensureCapacity(this.length + 1);\n this._data[this.length] = value;\n ++this._length;\n }\n\n /** Append an array of values, resizing (at most once) if necessary. */\n public append(values: T): void {\n const newLength = this.length + values.length;\n this.ensureCapacity(newLength);\n this._data.set(values, this.length);\n this._length = newLength;\n }\n\n /** Obtain the finished array.\n * @param includeUnusedCapacity If true, the length of the returned array will be equal to [[capacity]], with extra bytes initialized to zero; otherwise, the\n * returned array's length will be equal to [[length]].\n */\n public toTypedArray(includeUnusedCapacity = false): T {\n if (includeUnusedCapacity)\n return this._data;\n\n const subarray = this._data.subarray(0, this.length);\n assert(subarray instanceof this._constructor);\n assert(subarray.buffer === this._data.buffer);\n return subarray;\n }\n}\n\n/** A [[TypedArrayBuilder]] for producing a [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).\n * @public\n */\nexport class Uint8ArrayBuilder extends TypedArrayBuilder<Uint8Array> {\n /** @see [[TypedArrayBuilder]] constructor. */\n public constructor(options?: TypedArrayBuilderOptions) {\n super(Uint8Array, options);\n }\n}\n\n/** A [[TypedArrayBuilder]] for producing a [Uint16Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array).\n * @public\n */\nexport class Uint16ArrayBuilder extends TypedArrayBuilder<Uint16Array> {\n /** @see [[TypedArrayBuilder]] constructor. */\n public constructor(options?: TypedArrayBuilderOptions) {\n super(Uint16Array, options);\n }\n}\n\n/** A [[TypedArrayBuilder]] for producing a [Uint32Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array).\n * @public\n */\nexport class Uint32ArrayBuilder extends TypedArrayBuilder<Uint32Array> {\n /** @see [[TypedArrayBuilder]] constructor. */\n public constructor(options?: TypedArrayBuilderOptions) {\n super(Uint32Array, options);\n }\n\n /** Obtain a view of the finished array as an array of bytes. */\n public toUint8Array(includeUnusedCapacity = false): Uint8Array {\n if (includeUnusedCapacity)\n return new Uint8Array(this._data.buffer);\n\n return new Uint8Array(this._data.buffer, 0, this.length * 4);\n }\n}\n"]}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Errors
|
|
3
|
-
*/
|
|
4
|
-
/// <reference types="node" />
|
|
5
|
-
/** A function to be notified when an unexpected error happens
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
export declare type OnUnexpectedError = (error: any) => void;
|
|
9
|
-
/**
|
|
10
|
-
* Utility for handling/reporting unexpected runtime errors. This class establishes a global handler for
|
|
11
|
-
* unexpected errors, and programmers should use its `handle` method when they occur. Generally, unexpected
|
|
12
|
-
* errors should not cause program termination, and should instead be logged and swallowed. However, for
|
|
13
|
-
* development/debugging, it can be helpful to re-throw exceptions so they are not missed.
|
|
14
|
-
* @public
|
|
15
|
-
*/
|
|
16
|
-
export declare class UnexpectedErrors {
|
|
17
|
-
/** handler for re-throwing exceptions directly */
|
|
18
|
-
static readonly reThrowImmediate: (e: any) => never;
|
|
19
|
-
/** handler for re-throwing exceptions from an asynchronous interval (so the current call stack is not aborted) */
|
|
20
|
-
static readonly reThrowDeferred: (e: any) => NodeJS.Timeout;
|
|
21
|
-
/** handler for logging exception to console */
|
|
22
|
-
static readonly consoleLog: (e: any) => void;
|
|
23
|
-
/** handler for logging exception with [[Logger]] */
|
|
24
|
-
static readonly errorLog: (e: any) => void;
|
|
25
|
-
private static _telemetry;
|
|
26
|
-
private static _handler;
|
|
27
|
-
private constructor();
|
|
28
|
-
/** Add a "telemetry tracker" for unexpected errors. Useful for tracking/reporting errors without changing handler.
|
|
29
|
-
* @returns a method to remove the tracker
|
|
30
|
-
*/
|
|
31
|
-
static addTelemetry(tracker: OnUnexpectedError): () => void;
|
|
32
|
-
/** call this method when an unexpected error happens so the global handler can process it.
|
|
33
|
-
* @param error the unexpected error
|
|
34
|
-
* @param notifyTelemetry if false, don't notify telemetry trackers. Use this for exceptions from third-party code, for example.
|
|
35
|
-
*/
|
|
36
|
-
static handle(error: any, notifyTelemetry?: boolean): void;
|
|
37
|
-
/** establish a new global *unexpected error* handler.
|
|
38
|
-
* @param handler the new global handler. You may provide your own function or use one of the static members of this class.
|
|
39
|
-
* The default is [[errorLog]].
|
|
40
|
-
* @returns the previous handler. Useful to temporarily change the handler.
|
|
41
|
-
*/
|
|
42
|
-
static setHandler(handler: OnUnexpectedError): OnUnexpectedError;
|
|
43
|
-
}
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Errors
|
|
3
|
+
*/
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
/** A function to be notified when an unexpected error happens
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare type OnUnexpectedError = (error: any) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Utility for handling/reporting unexpected runtime errors. This class establishes a global handler for
|
|
11
|
+
* unexpected errors, and programmers should use its `handle` method when they occur. Generally, unexpected
|
|
12
|
+
* errors should not cause program termination, and should instead be logged and swallowed. However, for
|
|
13
|
+
* development/debugging, it can be helpful to re-throw exceptions so they are not missed.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare class UnexpectedErrors {
|
|
17
|
+
/** handler for re-throwing exceptions directly */
|
|
18
|
+
static readonly reThrowImmediate: (e: any) => never;
|
|
19
|
+
/** handler for re-throwing exceptions from an asynchronous interval (so the current call stack is not aborted) */
|
|
20
|
+
static readonly reThrowDeferred: (e: any) => NodeJS.Timeout;
|
|
21
|
+
/** handler for logging exception to console */
|
|
22
|
+
static readonly consoleLog: (e: any) => void;
|
|
23
|
+
/** handler for logging exception with [[Logger]] */
|
|
24
|
+
static readonly errorLog: (e: any) => void;
|
|
25
|
+
private static _telemetry;
|
|
26
|
+
private static _handler;
|
|
27
|
+
private constructor();
|
|
28
|
+
/** Add a "telemetry tracker" for unexpected errors. Useful for tracking/reporting errors without changing handler.
|
|
29
|
+
* @returns a method to remove the tracker
|
|
30
|
+
*/
|
|
31
|
+
static addTelemetry(tracker: OnUnexpectedError): () => void;
|
|
32
|
+
/** call this method when an unexpected error happens so the global handler can process it.
|
|
33
|
+
* @param error the unexpected error
|
|
34
|
+
* @param notifyTelemetry if false, don't notify telemetry trackers. Use this for exceptions from third-party code, for example.
|
|
35
|
+
*/
|
|
36
|
+
static handle(error: any, notifyTelemetry?: boolean): void;
|
|
37
|
+
/** establish a new global *unexpected error* handler.
|
|
38
|
+
* @param handler the new global handler. You may provide your own function or use one of the static members of this class.
|
|
39
|
+
* The default is [[errorLog]].
|
|
40
|
+
* @returns the previous handler. Useful to temporarily change the handler.
|
|
41
|
+
*/
|
|
42
|
+
static setHandler(handler: OnUnexpectedError): OnUnexpectedError;
|
|
43
|
+
}
|
|
44
44
|
//# sourceMappingURL=UnexpectedErrors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnexpectedErrors.d.ts","sourceRoot":"","sources":["../../src/UnexpectedErrors.ts"],"names":[],"mappings":"AAIA;;GAEG;;AAIH;;GAEG;AACH,oBAAY,iBAAiB,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;AAErD;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAC3B,kDAAkD;IAClD,gBAAuB,gBAAgB,MAAO,GAAG,WAAkB;IACnE,kHAAkH;IAClH,gBAAuB,eAAe,MAAO,GAAG,oBAAuC;IACvF,+CAA+C;IAC/C,gBAAuB,UAAU,MAAO,GAAG,UAAsB;IACjE,oDAAoD;IACpD,gBAAuB,QAAQ,MAAO,GAAG,UAAyC;IAElF,OAAO,CAAC,MAAM,CAAC,UAAU,CAA2B;IACpD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiB;IACxC,OAAO;IAEP;;OAEG;WACW,YAAY,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,IAAI;IAKlE;;;OAGG;WACW,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,eAAe,UAAO,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"UnexpectedErrors.d.ts","sourceRoot":"","sources":["../../src/UnexpectedErrors.ts"],"names":[],"mappings":"AAIA;;GAEG;;AAIH;;GAEG;AACH,oBAAY,iBAAiB,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;AAErD;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAC3B,kDAAkD;IAClD,gBAAuB,gBAAgB,MAAO,GAAG,WAAkB;IACnE,kHAAkH;IAClH,gBAAuB,eAAe,MAAO,GAAG,oBAAuC;IACvF,+CAA+C;IAC/C,gBAAuB,UAAU,MAAO,GAAG,UAAsB;IACjE,oDAAoD;IACpD,gBAAuB,QAAQ,MAAO,GAAG,UAAyC;IAElF,OAAO,CAAC,MAAM,CAAC,UAAU,CAA2B;IACpD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiB;IACxC,OAAO;IAEP;;OAEG;WACW,YAAY,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,IAAI;IAKlE;;;OAGG;WACW,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,eAAe,UAAO,GAAG,IAAI;IAa9D;;;;OAIG;WACW,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,iBAAiB;CAKxE"}
|
|
@@ -1,62 +1,65 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
/** @packageDocumentation
|
|
6
|
-
* @module Errors
|
|
7
|
-
*/
|
|
8
|
-
var _a;
|
|
9
|
-
import { Logger } from "./Logger";
|
|
10
|
-
/**
|
|
11
|
-
* Utility for handling/reporting unexpected runtime errors. This class establishes a global handler for
|
|
12
|
-
* unexpected errors, and programmers should use its `handle` method when they occur. Generally, unexpected
|
|
13
|
-
* errors should not cause program termination, and should instead be logged and swallowed. However, for
|
|
14
|
-
* development/debugging, it can be helpful to re-throw exceptions so they are not missed.
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
export class UnexpectedErrors {
|
|
18
|
-
constructor() { } // this is a singleton
|
|
19
|
-
/** Add a "telemetry tracker" for unexpected errors. Useful for tracking/reporting errors without changing handler.
|
|
20
|
-
* @returns a method to remove the tracker
|
|
21
|
-
*/
|
|
22
|
-
static addTelemetry(tracker) {
|
|
23
|
-
this._telemetry.push(tracker);
|
|
24
|
-
return () => this._telemetry.splice(this._telemetry.indexOf(tracker), 1);
|
|
25
|
-
}
|
|
26
|
-
/** call this method when an unexpected error happens so the global handler can process it.
|
|
27
|
-
* @param error the unexpected error
|
|
28
|
-
* @param notifyTelemetry if false, don't notify telemetry trackers. Use this for exceptions from third-party code, for example.
|
|
29
|
-
*/
|
|
30
|
-
static handle(error, notifyTelemetry = true) {
|
|
31
|
-
this._handler(error);
|
|
32
|
-
if (notifyTelemetry)
|
|
33
|
-
this._telemetry.forEach((telemetry) => {
|
|
34
|
-
try {
|
|
35
|
-
telemetry(error);
|
|
36
|
-
}
|
|
37
|
-
catch (_) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
UnexpectedErrors.
|
|
61
|
-
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module Errors
|
|
7
|
+
*/
|
|
8
|
+
var _a;
|
|
9
|
+
import { Logger } from "./Logger";
|
|
10
|
+
/**
|
|
11
|
+
* Utility for handling/reporting unexpected runtime errors. This class establishes a global handler for
|
|
12
|
+
* unexpected errors, and programmers should use its `handle` method when they occur. Generally, unexpected
|
|
13
|
+
* errors should not cause program termination, and should instead be logged and swallowed. However, for
|
|
14
|
+
* development/debugging, it can be helpful to re-throw exceptions so they are not missed.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export class UnexpectedErrors {
|
|
18
|
+
constructor() { } // this is a singleton
|
|
19
|
+
/** Add a "telemetry tracker" for unexpected errors. Useful for tracking/reporting errors without changing handler.
|
|
20
|
+
* @returns a method to remove the tracker
|
|
21
|
+
*/
|
|
22
|
+
static addTelemetry(tracker) {
|
|
23
|
+
this._telemetry.push(tracker);
|
|
24
|
+
return () => this._telemetry.splice(this._telemetry.indexOf(tracker), 1);
|
|
25
|
+
}
|
|
26
|
+
/** call this method when an unexpected error happens so the global handler can process it.
|
|
27
|
+
* @param error the unexpected error
|
|
28
|
+
* @param notifyTelemetry if false, don't notify telemetry trackers. Use this for exceptions from third-party code, for example.
|
|
29
|
+
*/
|
|
30
|
+
static handle(error, notifyTelemetry = true) {
|
|
31
|
+
this._handler(error);
|
|
32
|
+
if (notifyTelemetry) {
|
|
33
|
+
this._telemetry.forEach((telemetry) => {
|
|
34
|
+
try {
|
|
35
|
+
telemetry(error);
|
|
36
|
+
}
|
|
37
|
+
catch (_) {
|
|
38
|
+
// ignore errors from telemetry trackers
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** establish a new global *unexpected error* handler.
|
|
44
|
+
* @param handler the new global handler. You may provide your own function or use one of the static members of this class.
|
|
45
|
+
* The default is [[errorLog]].
|
|
46
|
+
* @returns the previous handler. Useful to temporarily change the handler.
|
|
47
|
+
*/
|
|
48
|
+
static setHandler(handler) {
|
|
49
|
+
const oldHandler = this._handler;
|
|
50
|
+
this._handler = handler;
|
|
51
|
+
return oldHandler;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
_a = UnexpectedErrors;
|
|
55
|
+
/** handler for re-throwing exceptions directly */
|
|
56
|
+
UnexpectedErrors.reThrowImmediate = (e) => { throw e; };
|
|
57
|
+
/** handler for re-throwing exceptions from an asynchronous interval (so the current call stack is not aborted) */
|
|
58
|
+
UnexpectedErrors.reThrowDeferred = (e) => setTimeout(() => { throw e; }, 0);
|
|
59
|
+
/** handler for logging exception to console */
|
|
60
|
+
UnexpectedErrors.consoleLog = (e) => console.error(e); // eslint-disable-line no-console
|
|
61
|
+
/** handler for logging exception with [[Logger]] */
|
|
62
|
+
UnexpectedErrors.errorLog = (e) => Logger.logException("unhandled", e);
|
|
63
|
+
UnexpectedErrors._telemetry = [];
|
|
64
|
+
UnexpectedErrors._handler = _a.errorLog; // default to error logging
|
|
62
65
|
//# sourceMappingURL=UnexpectedErrors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnexpectedErrors.js","sourceRoot":"","sources":["../../src/UnexpectedErrors.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAOlC;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAY3B,gBAAwB,CAAC,CAAC,sBAAsB;IAEhD;;OAEG;IACI,MAAM,CAAC,YAAY,CAAC,OAA0B;QACnD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,MAAM,CAAC,KAAU,EAAE,eAAe,GAAG,IAAI;QACrD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrB,IAAI,eAAe;
|
|
1
|
+
{"version":3,"file":"UnexpectedErrors.js","sourceRoot":"","sources":["../../src/UnexpectedErrors.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAOlC;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAY3B,gBAAwB,CAAC,CAAC,sBAAsB;IAEhD;;OAEG;IACI,MAAM,CAAC,YAAY,CAAC,OAA0B;QACnD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,MAAM,CAAC,KAAU,EAAE,eAAe,GAAG,IAAI;QACrD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrB,IAAI,eAAe,EAAE;YACnB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;gBACpC,IAAI;oBACF,SAAS,CAAC,KAAK,CAAC,CAAC;iBAClB;gBAAC,OAAO,CAAC,EAAE;oBACV,wCAAwC;iBACzC;YACH,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,OAA0B;QACjD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,OAAO,UAAU,CAAC;IACpB,CAAC;;;AA/CD,kDAAkD;AAC3B,iCAAgB,GAAG,CAAC,CAAM,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAE,CAAA;AACnE,kHAAkH;AAC3F,gCAAe,GAAG,CAAC,CAAM,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAE,CAAA;AACvF,+CAA+C;AACxB,2BAAU,GAAG,CAAC,CAAM,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAE,CAAA,CAAC,iCAAiC;AACnG,oDAAoD;AAC7B,yBAAQ,GAAG,CAAC,CAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAE,CAAA;AAEnE,2BAAU,GAAwB,EAAG,CAAA;AACrC,yBAAQ,GAAG,EAAI,CAAC,QAAS,CAAA,CAAC,2BAA2B","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 Errors\n */\n\nimport { Logger } from \"./Logger\";\n\n/** A function to be notified when an unexpected error happens\n * @public\n */\nexport type OnUnexpectedError = (error: any) => void;\n\n/**\n * Utility for handling/reporting unexpected runtime errors. This class establishes a global handler for\n * unexpected errors, and programmers should use its `handle` method when they occur. Generally, unexpected\n * errors should not cause program termination, and should instead be logged and swallowed. However, for\n * development/debugging, it can be helpful to re-throw exceptions so they are not missed.\n * @public\n */\nexport class UnexpectedErrors {\n /** handler for re-throwing exceptions directly */\n public static readonly reThrowImmediate = (e: any) => { throw e; };\n /** handler for re-throwing exceptions from an asynchronous interval (so the current call stack is not aborted) */\n public static readonly reThrowDeferred = (e: any) => setTimeout(() => { throw e; }, 0);\n /** handler for logging exception to console */\n public static readonly consoleLog = (e: any) => console.error(e); // eslint-disable-line no-console\n /** handler for logging exception with [[Logger]] */\n public static readonly errorLog = (e: any) => Logger.logException(\"unhandled\", e);\n\n private static _telemetry: OnUnexpectedError[] = [];\n private static _handler = this.errorLog; // default to error logging\n private constructor() { } // this is a singleton\n\n /** Add a \"telemetry tracker\" for unexpected errors. Useful for tracking/reporting errors without changing handler.\n * @returns a method to remove the tracker\n */\n public static addTelemetry(tracker: OnUnexpectedError): () => void {\n this._telemetry.push(tracker);\n return () => this._telemetry.splice(this._telemetry.indexOf(tracker), 1);\n }\n\n /** call this method when an unexpected error happens so the global handler can process it.\n * @param error the unexpected error\n * @param notifyTelemetry if false, don't notify telemetry trackers. Use this for exceptions from third-party code, for example.\n */\n public static handle(error: any, notifyTelemetry = true): void {\n this._handler(error);\n if (notifyTelemetry) {\n this._telemetry.forEach((telemetry) => {\n try {\n telemetry(error);\n } catch (_) {\n // ignore errors from telemetry trackers\n }\n });\n }\n }\n\n /** establish a new global *unexpected error* handler.\n * @param handler the new global handler. You may provide your own function or use one of the static members of this class.\n * The default is [[errorLog]].\n * @returns the previous handler. Useful to temporarily change the handler.\n */\n public static setHandler(handler: OnUnexpectedError): OnUnexpectedError {\n const oldHandler = this._handler;\n this._handler = handler;\n return oldHandler;\n }\n}\n"]}
|
|
@@ -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/esm/UtilityTypes.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
/** @packageDocumentation
|
|
6
|
-
* @module Utils
|
|
7
|
-
*/
|
|
8
|
-
/** Returns true if `obj` is an object of class `T`.
|
|
9
|
-
* @see [[asInstanceOf]] to cast `obj` to class `T`.
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export function isInstanceOf(obj, constructor) {
|
|
13
|
-
return "object" === typeof obj && obj instanceof constructor;
|
|
14
|
-
}
|
|
15
|
-
/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.
|
|
16
|
-
* @see [[isInstanceOf]] to query whether `obj` is of class `T`.
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
export function asInstanceOf(obj, constructor) {
|
|
20
|
-
return isInstanceOf(obj, constructor) ? obj : undefined;
|
|
21
|
-
}
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module Utils
|
|
7
|
+
*/
|
|
8
|
+
/** Returns true if `obj` is an object of class `T`.
|
|
9
|
+
* @see [[asInstanceOf]] to cast `obj` to class `T`.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export function isInstanceOf(obj, constructor) {
|
|
13
|
+
return "object" === typeof obj && obj instanceof constructor;
|
|
14
|
+
}
|
|
15
|
+
/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.
|
|
16
|
+
* @see [[isInstanceOf]] to query whether `obj` is of class `T`.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export function asInstanceOf(obj, constructor) {
|
|
20
|
+
return isInstanceOf(obj, constructor) ? obj : undefined;
|
|
21
|
+
}
|
|
22
22
|
//# 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,MAAM,UAAU,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,QAAQ,KAAK,OAAO,GAAG,IAAI,GAAG,YAAY,WAAW,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,YAAY,CAAI,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"UtilityTypes.js","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AA2BH;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,QAAQ,KAAK,OAAO,GAAG,IAAI,GAAG,YAAY,WAAW,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,YAAY,CAAI,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC","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,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
|