@itwin/core-bentley 3.0.0-dev.78 → 3.0.0-dev.79
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/lib/{AccessToken.d.ts → cjs/AccessToken.d.ts} +0 -0
- package/lib/cjs/AccessToken.d.ts.map +1 -0
- package/lib/{AccessToken.js → cjs/AccessToken.js} +0 -0
- package/lib/cjs/AccessToken.js.map +1 -0
- package/lib/{Assert.d.ts → cjs/Assert.d.ts} +0 -0
- package/lib/cjs/Assert.d.ts.map +1 -0
- package/lib/{Assert.js → cjs/Assert.js} +0 -0
- package/lib/cjs/Assert.js.map +1 -0
- package/lib/{AsyncMutex.d.ts → cjs/AsyncMutex.d.ts} +0 -0
- package/lib/cjs/AsyncMutex.d.ts.map +1 -0
- package/lib/{AsyncMutex.js → cjs/AsyncMutex.js} +0 -0
- package/lib/cjs/AsyncMutex.js.map +1 -0
- package/lib/{BeEvent.d.ts → cjs/BeEvent.d.ts} +0 -0
- package/lib/cjs/BeEvent.d.ts.map +1 -0
- package/lib/{BeEvent.js → cjs/BeEvent.js} +0 -0
- package/lib/cjs/BeEvent.js.map +1 -0
- package/lib/{BeSQLite.d.ts → cjs/BeSQLite.d.ts} +0 -0
- package/lib/cjs/BeSQLite.d.ts.map +1 -0
- package/lib/{BeSQLite.js → cjs/BeSQLite.js} +0 -0
- package/lib/cjs/BeSQLite.js.map +1 -0
- package/lib/{BentleyError.d.ts → cjs/BentleyError.d.ts} +0 -0
- package/lib/cjs/BentleyError.d.ts.map +1 -0
- package/lib/{BentleyError.js → cjs/BentleyError.js} +0 -0
- package/lib/cjs/BentleyError.js.map +1 -0
- package/lib/{BentleyLoggerCategory.d.ts → cjs/BentleyLoggerCategory.d.ts} +0 -0
- package/lib/cjs/BentleyLoggerCategory.d.ts.map +1 -0
- package/lib/{BentleyLoggerCategory.js → cjs/BentleyLoggerCategory.js} +0 -0
- package/lib/cjs/BentleyLoggerCategory.js.map +1 -0
- package/lib/{ByteStream.d.ts → cjs/ByteStream.d.ts} +0 -0
- package/lib/cjs/ByteStream.d.ts.map +1 -0
- package/lib/{ByteStream.js → cjs/ByteStream.js} +0 -0
- package/lib/cjs/ByteStream.js.map +1 -0
- package/lib/{Compare.d.ts → cjs/Compare.d.ts} +0 -0
- package/lib/cjs/Compare.d.ts.map +1 -0
- package/lib/{Compare.js → cjs/Compare.js} +0 -0
- package/lib/cjs/Compare.js.map +1 -0
- package/lib/{CompressedId64Set.d.ts → cjs/CompressedId64Set.d.ts} +0 -0
- package/lib/cjs/CompressedId64Set.d.ts.map +1 -0
- package/lib/{CompressedId64Set.js → cjs/CompressedId64Set.js} +0 -0
- package/lib/cjs/CompressedId64Set.js.map +1 -0
- package/lib/{Dictionary.d.ts → cjs/Dictionary.d.ts} +0 -0
- package/lib/cjs/Dictionary.d.ts.map +1 -0
- package/lib/{Dictionary.js → cjs/Dictionary.js} +0 -0
- package/lib/cjs/Dictionary.js.map +1 -0
- package/lib/{Disposable.d.ts → cjs/Disposable.d.ts} +0 -0
- package/lib/cjs/Disposable.d.ts.map +1 -0
- package/lib/{Disposable.js → cjs/Disposable.js} +0 -0
- package/lib/cjs/Disposable.js.map +1 -0
- package/lib/{Id.d.ts → cjs/Id.d.ts} +0 -0
- package/lib/cjs/Id.d.ts.map +1 -0
- package/lib/{Id.js → cjs/Id.js} +0 -0
- package/lib/cjs/Id.js.map +1 -0
- package/lib/{IndexMap.d.ts → cjs/IndexMap.d.ts} +0 -0
- package/lib/cjs/IndexMap.d.ts.map +1 -0
- package/lib/{IndexMap.js → cjs/IndexMap.js} +0 -0
- package/lib/cjs/IndexMap.js.map +1 -0
- package/lib/{JsonUtils.d.ts → cjs/JsonUtils.d.ts} +0 -0
- package/lib/cjs/JsonUtils.d.ts.map +1 -0
- package/lib/{JsonUtils.js → cjs/JsonUtils.js} +0 -0
- package/lib/cjs/JsonUtils.js.map +1 -0
- package/lib/{LRUMap.d.ts → cjs/LRUMap.d.ts} +0 -0
- package/lib/cjs/LRUMap.d.ts.map +1 -0
- package/lib/{LRUMap.js → cjs/LRUMap.js} +0 -0
- package/lib/cjs/LRUMap.js.map +1 -0
- package/lib/{Logger.d.ts → cjs/Logger.d.ts} +0 -0
- package/lib/cjs/Logger.d.ts.map +1 -0
- package/lib/{Logger.js → cjs/Logger.js} +4 -2
- package/lib/cjs/Logger.js.map +1 -0
- package/lib/{ObservableSet.d.ts → cjs/ObservableSet.d.ts} +0 -0
- package/lib/cjs/ObservableSet.d.ts.map +1 -0
- package/lib/{ObservableSet.js → cjs/ObservableSet.js} +0 -0
- package/lib/cjs/ObservableSet.js.map +1 -0
- package/lib/{OneAtATimeAction.d.ts → cjs/OneAtATimeAction.d.ts} +0 -0
- package/lib/cjs/OneAtATimeAction.d.ts.map +1 -0
- package/lib/{OneAtATimeAction.js → cjs/OneAtATimeAction.js} +0 -0
- package/lib/cjs/OneAtATimeAction.js.map +1 -0
- package/lib/{OrderedId64Iterable.d.ts → cjs/OrderedId64Iterable.d.ts} +0 -0
- package/lib/cjs/OrderedId64Iterable.d.ts.map +1 -0
- package/lib/{OrderedId64Iterable.js → cjs/OrderedId64Iterable.js} +0 -0
- package/lib/cjs/OrderedId64Iterable.js.map +1 -0
- package/lib/{OrderedSet.d.ts → cjs/OrderedSet.d.ts} +0 -0
- package/lib/cjs/OrderedSet.d.ts.map +1 -0
- package/lib/{OrderedSet.js → cjs/OrderedSet.js} +0 -0
- package/lib/cjs/OrderedSet.js.map +1 -0
- package/lib/{PriorityQueue.d.ts → cjs/PriorityQueue.d.ts} +0 -0
- package/lib/cjs/PriorityQueue.d.ts.map +1 -0
- package/lib/{PriorityQueue.js → cjs/PriorityQueue.js} +0 -0
- package/lib/cjs/PriorityQueue.js.map +1 -0
- package/lib/{ProcessDetector.d.ts → cjs/ProcessDetector.d.ts} +0 -0
- package/lib/cjs/ProcessDetector.d.ts.map +1 -0
- package/lib/{ProcessDetector.js → cjs/ProcessDetector.js} +0 -0
- package/lib/cjs/ProcessDetector.js.map +1 -0
- package/lib/{SortedArray.d.ts → cjs/SortedArray.d.ts} +0 -0
- package/lib/cjs/SortedArray.d.ts.map +1 -0
- package/lib/{SortedArray.js → cjs/SortedArray.js} +0 -0
- package/lib/cjs/SortedArray.js.map +1 -0
- package/lib/{StringUtils.d.ts → cjs/StringUtils.d.ts} +0 -0
- package/lib/cjs/StringUtils.d.ts.map +1 -0
- package/lib/{StringUtils.js → cjs/StringUtils.js} +0 -0
- package/lib/cjs/StringUtils.js.map +1 -0
- package/lib/{Time.d.ts → cjs/Time.d.ts} +0 -0
- package/lib/cjs/Time.d.ts.map +1 -0
- package/lib/{Time.js → cjs/Time.js} +0 -0
- package/lib/cjs/Time.js.map +1 -0
- package/lib/{UtilityTypes.d.ts → cjs/UtilityTypes.d.ts} +0 -0
- package/lib/cjs/UtilityTypes.d.ts.map +1 -0
- package/lib/{UtilityTypes.js → cjs/UtilityTypes.js} +0 -0
- package/lib/cjs/UtilityTypes.js.map +1 -0
- package/lib/{core-bentley.d.ts → cjs/core-bentley.d.ts} +0 -0
- package/lib/cjs/core-bentley.d.ts.map +1 -0
- package/lib/{core-bentley.js → cjs/core-bentley.js} +0 -0
- package/lib/cjs/core-bentley.js.map +1 -0
- package/lib/{partitionArray.d.ts → cjs/partitionArray.d.ts} +0 -0
- package/lib/cjs/partitionArray.d.ts.map +1 -0
- package/lib/{partitionArray.js → cjs/partitionArray.js} +0 -0
- package/lib/cjs/partitionArray.js.map +1 -0
- package/lib/esm/AccessToken.d.ts +9 -0
- package/lib/esm/AccessToken.d.ts.map +1 -0
- package/lib/esm/AccessToken.js +9 -0
- package/lib/esm/AccessToken.js.map +1 -0
- package/lib/esm/Assert.d.ts +16 -0
- package/lib/esm/Assert.d.ts.map +1 -0
- package/lib/esm/Assert.js +23 -0
- package/lib/esm/Assert.js.map +1 -0
- package/lib/esm/AsyncMutex.d.ts +27 -0
- package/lib/esm/AsyncMutex.d.ts.map +1 -0
- package/lib/esm/AsyncMutex.js +40 -0
- package/lib/esm/AsyncMutex.js.map +1 -0
- package/lib/esm/BeEvent.d.ts +82 -0
- package/lib/esm/BeEvent.d.ts.map +1 -0
- package/lib/esm/BeEvent.js +145 -0
- package/lib/esm/BeEvent.js.map +1 -0
- package/lib/esm/BeSQLite.d.ts +171 -0
- package/lib/esm/BeSQLite.d.ts.map +1 -0
- package/lib/esm/BeSQLite.js +181 -0
- package/lib/esm/BeSQLite.js.map +1 -0
- package/lib/esm/BentleyError.d.ts +378 -0
- package/lib/esm/BentleyError.d.ts.map +1 -0
- package/lib/esm/BentleyError.js +698 -0
- package/lib/esm/BentleyError.js.map +1 -0
- package/lib/esm/BentleyLoggerCategory.d.ts +12 -0
- package/lib/esm/BentleyLoggerCategory.d.ts.map +1 -0
- package/lib/esm/BentleyLoggerCategory.js +17 -0
- package/lib/esm/BentleyLoggerCategory.js.map +1 -0
- package/lib/esm/ByteStream.d.ts +63 -0
- package/lib/esm/ByteStream.d.ts.map +1 -0
- package/lib/esm/ByteStream.js +88 -0
- package/lib/esm/ByteStream.js.map +1 -0
- package/lib/esm/Compare.d.ts +48 -0
- package/lib/esm/Compare.d.ts.map +1 -0
- package/lib/esm/Compare.js +52 -0
- package/lib/esm/Compare.js.map +1 -0
- package/lib/esm/CompressedId64Set.d.ts +135 -0
- package/lib/esm/CompressedId64Set.d.ts.map +1 -0
- package/lib/esm/CompressedId64Set.js +424 -0
- package/lib/esm/CompressedId64Set.js.map +1 -0
- package/lib/esm/Dictionary.d.ts +126 -0
- package/lib/esm/Dictionary.d.ts.map +1 -0
- package/lib/esm/Dictionary.js +200 -0
- package/lib/esm/Dictionary.js.map +1 -0
- package/lib/esm/Disposable.d.ts +81 -0
- package/lib/esm/Disposable.d.ts.map +1 -0
- package/lib/esm/Disposable.js +113 -0
- package/lib/esm/Disposable.js.map +1 -0
- package/lib/esm/Id.d.ts +274 -0
- package/lib/esm/Id.d.ts.map +1 -0
- package/lib/esm/Id.js +612 -0
- package/lib/esm/Id.js.map +1 -0
- package/lib/esm/IndexMap.d.ts +66 -0
- package/lib/esm/IndexMap.d.ts.map +1 -0
- package/lib/esm/IndexMap.js +87 -0
- package/lib/esm/IndexMap.js.map +1 -0
- package/lib/esm/JsonUtils.d.ts +79 -0
- package/lib/esm/JsonUtils.d.ts.map +1 -0
- package/lib/esm/JsonUtils.js +131 -0
- package/lib/esm/JsonUtils.js.map +1 -0
- package/lib/esm/LRUMap.d.ts +130 -0
- package/lib/esm/LRUMap.d.ts.map +1 -0
- package/lib/esm/LRUMap.js +327 -0
- package/lib/esm/LRUMap.js.map +1 -0
- package/lib/esm/Logger.d.ts +140 -0
- package/lib/esm/Logger.d.ts.map +1 -0
- package/lib/esm/Logger.js +245 -0
- package/lib/esm/Logger.js.map +1 -0
- package/lib/esm/ObservableSet.d.ts +24 -0
- package/lib/esm/ObservableSet.d.ts.map +1 -0
- package/lib/esm/ObservableSet.js +48 -0
- package/lib/esm/ObservableSet.js.map +1 -0
- package/lib/esm/OneAtATimeAction.d.ts +32 -0
- package/lib/esm/OneAtATimeAction.d.ts.map +1 -0
- package/lib/esm/OneAtATimeAction.js +87 -0
- package/lib/esm/OneAtATimeAction.js.map +1 -0
- package/lib/esm/OrderedId64Iterable.d.ts +75 -0
- package/lib/esm/OrderedId64Iterable.d.ts.map +1 -0
- package/lib/esm/OrderedId64Iterable.js +233 -0
- package/lib/esm/OrderedId64Iterable.js.map +1 -0
- package/lib/esm/OrderedSet.d.ts +41 -0
- package/lib/esm/OrderedSet.d.ts.map +1 -0
- package/lib/esm/OrderedSet.js +60 -0
- package/lib/esm/OrderedSet.js.map +1 -0
- package/lib/esm/PriorityQueue.d.ts +71 -0
- package/lib/esm/PriorityQueue.d.ts.map +1 -0
- package/lib/esm/PriorityQueue.js +137 -0
- package/lib/esm/PriorityQueue.js.map +1 -0
- package/lib/esm/ProcessDetector.d.ts +60 -0
- package/lib/esm/ProcessDetector.d.ts.map +1 -0
- package/lib/esm/ProcessDetector.js +68 -0
- package/lib/esm/ProcessDetector.js.map +1 -0
- package/lib/esm/SortedArray.d.ts +233 -0
- package/lib/esm/SortedArray.d.ts.map +1 -0
- package/lib/esm/SortedArray.js +295 -0
- package/lib/esm/SortedArray.js.map +1 -0
- package/lib/esm/StringUtils.d.ts +23 -0
- package/lib/esm/StringUtils.d.ts.map +1 -0
- package/lib/esm/StringUtils.js +141 -0
- package/lib/esm/StringUtils.js.map +1 -0
- package/lib/esm/Time.d.ts +123 -0
- package/lib/esm/Time.d.ts.map +1 -0
- package/lib/esm/Time.js +141 -0
- package/lib/esm/Time.js.map +1 -0
- package/lib/esm/UtilityTypes.d.ts +75 -0
- package/lib/esm/UtilityTypes.d.ts.map +1 -0
- package/lib/esm/UtilityTypes.js +22 -0
- package/lib/esm/UtilityTypes.js.map +1 -0
- package/lib/esm/core-bentley.d.ts +71 -0
- package/lib/esm/core-bentley.d.ts.map +1 -0
- package/lib/esm/core-bentley.js +75 -0
- package/lib/esm/core-bentley.js.map +1 -0
- package/lib/esm/partitionArray.d.ts +22 -0
- package/lib/esm/partitionArray.d.ts.map +1 -0
- package/lib/esm/partitionArray.js +40 -0
- package/lib/esm/partitionArray.js.map +1 -0
- package/package.json +9 -6
- package/lib/AccessToken.d.ts.map +0 -1
- package/lib/AccessToken.js.map +0 -1
- package/lib/Assert.d.ts.map +0 -1
- package/lib/Assert.js.map +0 -1
- package/lib/AsyncMutex.d.ts.map +0 -1
- package/lib/AsyncMutex.js.map +0 -1
- package/lib/BeEvent.d.ts.map +0 -1
- package/lib/BeEvent.js.map +0 -1
- package/lib/BeSQLite.d.ts.map +0 -1
- package/lib/BeSQLite.js.map +0 -1
- package/lib/BentleyError.d.ts.map +0 -1
- package/lib/BentleyError.js.map +0 -1
- package/lib/BentleyLoggerCategory.d.ts.map +0 -1
- package/lib/BentleyLoggerCategory.js.map +0 -1
- package/lib/ByteStream.d.ts.map +0 -1
- package/lib/ByteStream.js.map +0 -1
- package/lib/Compare.d.ts.map +0 -1
- package/lib/Compare.js.map +0 -1
- package/lib/CompressedId64Set.d.ts.map +0 -1
- package/lib/CompressedId64Set.js.map +0 -1
- package/lib/Dictionary.d.ts.map +0 -1
- package/lib/Dictionary.js.map +0 -1
- package/lib/Disposable.d.ts.map +0 -1
- package/lib/Disposable.js.map +0 -1
- package/lib/Id.d.ts.map +0 -1
- package/lib/Id.js.map +0 -1
- package/lib/IndexMap.d.ts.map +0 -1
- package/lib/IndexMap.js.map +0 -1
- package/lib/JsonUtils.d.ts.map +0 -1
- package/lib/JsonUtils.js.map +0 -1
- package/lib/LRUMap.d.ts.map +0 -1
- package/lib/LRUMap.js.map +0 -1
- package/lib/Logger.d.ts.map +0 -1
- package/lib/Logger.js.map +0 -1
- package/lib/ObservableSet.d.ts.map +0 -1
- package/lib/ObservableSet.js.map +0 -1
- package/lib/OneAtATimeAction.d.ts.map +0 -1
- package/lib/OneAtATimeAction.js.map +0 -1
- package/lib/OrderedId64Iterable.d.ts.map +0 -1
- package/lib/OrderedId64Iterable.js.map +0 -1
- package/lib/OrderedSet.d.ts.map +0 -1
- package/lib/OrderedSet.js.map +0 -1
- package/lib/PriorityQueue.d.ts.map +0 -1
- package/lib/PriorityQueue.js.map +0 -1
- package/lib/ProcessDetector.d.ts.map +0 -1
- package/lib/ProcessDetector.js.map +0 -1
- package/lib/SortedArray.d.ts.map +0 -1
- package/lib/SortedArray.js.map +0 -1
- package/lib/StringUtils.d.ts.map +0 -1
- package/lib/StringUtils.js.map +0 -1
- package/lib/Time.d.ts.map +0 -1
- package/lib/Time.js.map +0 -1
- package/lib/UtilityTypes.d.ts.map +0 -1
- package/lib/UtilityTypes.js.map +0 -1
- package/lib/core-bentley.d.ts.map +0 -1
- package/lib/core-bentley.js.map +0 -1
- package/lib/partitionArray.d.ts.map +0 -1
- package/lib/partitionArray.js.map +0 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Utils
|
|
3
|
+
*/
|
|
4
|
+
/** A duration of time. Can be either positive (towards future) or negative (in the past).
|
|
5
|
+
* BeDurations are immutable.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare class BeDuration {
|
|
9
|
+
private readonly _milliseconds;
|
|
10
|
+
private constructor();
|
|
11
|
+
/** The duration in milliseconds */
|
|
12
|
+
get milliseconds(): number;
|
|
13
|
+
get seconds(): number;
|
|
14
|
+
/** Create a BeDuration from seconds.
|
|
15
|
+
* @param seconds the number of seconds for this BeDuration
|
|
16
|
+
*/
|
|
17
|
+
static fromSeconds(seconds: number): BeDuration;
|
|
18
|
+
/** Create a BeDuration from milliseconds.
|
|
19
|
+
* @param milliseconds the number of milliseconds for this BeDuration
|
|
20
|
+
*/
|
|
21
|
+
static fromMilliseconds(milliseconds: number): BeDuration;
|
|
22
|
+
/** Determine whether this BeDuration is 0 seconds */
|
|
23
|
+
get isZero(): boolean;
|
|
24
|
+
/** Determine whether this BeDuration is towards the future */
|
|
25
|
+
get isTowardsFuture(): boolean;
|
|
26
|
+
/** Determine whether this BeDuration is towards the past */
|
|
27
|
+
get isTowardsPast(): boolean;
|
|
28
|
+
/** Subtract a BeDuration from this BeDuration, returning a new BeDuration. */
|
|
29
|
+
minus(other: BeDuration): BeDuration;
|
|
30
|
+
/** Add a BeDuration to this BeDuration, returning a new BeDuration */
|
|
31
|
+
plus(other: BeDuration): BeDuration;
|
|
32
|
+
/** Utility function to just wait for the specified time
|
|
33
|
+
* @param ms Duration in milliseconds to wait
|
|
34
|
+
* @return Promise that resolves after the specified wait period
|
|
35
|
+
*/
|
|
36
|
+
static wait(ms: number): Promise<void>;
|
|
37
|
+
/** Utility function to wait for either the specified time or a promise, whichever resolves first
|
|
38
|
+
* @param ms Maximum duration in milliseconds to wait
|
|
39
|
+
* @param promise A pending promise to wait for
|
|
40
|
+
* @return Promise that resolves after the specified wait period or the provided promise resolves, whichever comes first
|
|
41
|
+
*/
|
|
42
|
+
static race<T>(ms: number, promise: PromiseLike<T>): Promise<T | void>;
|
|
43
|
+
/** Utility function to just wait for the specified time
|
|
44
|
+
* @return Promise that resolves after the specified wait period
|
|
45
|
+
*/
|
|
46
|
+
wait(): Promise<void>;
|
|
47
|
+
/** Execute a function after delaying by this duration.
|
|
48
|
+
* @param fn the function to execute after the delay
|
|
49
|
+
* @param scope An optional object scope to serve as the 'this' pointer when `fn` is invoked.
|
|
50
|
+
* @param args optional arguments to `fn`
|
|
51
|
+
* @return Promise resolved by `fn`
|
|
52
|
+
*/
|
|
53
|
+
executeAfter<T>(fn: (...args: any[]) => T, scope?: any, ...args: any[]): Promise<T>;
|
|
54
|
+
}
|
|
55
|
+
/** A specific point in time relative to the current time.
|
|
56
|
+
* BeTimePoints are used for timing operations. They are created from a BeDuration relative to the "now".
|
|
57
|
+
* BeTimePoints are immutable.
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare class BeTimePoint {
|
|
61
|
+
private readonly _milliseconds;
|
|
62
|
+
/** the time in milliseconds, of this BeTimePoint (relative to January 1, 1970 00:00:00 UTC.) */
|
|
63
|
+
get milliseconds(): number;
|
|
64
|
+
private constructor();
|
|
65
|
+
/** Create a BeTimePoint from Date.now() */
|
|
66
|
+
static now(): BeTimePoint;
|
|
67
|
+
/** Create a BeTimePoint at a specified duration in the future from now
|
|
68
|
+
* @param val the duration from now
|
|
69
|
+
*/
|
|
70
|
+
static fromNow(val: BeDuration): BeTimePoint;
|
|
71
|
+
/** Create a BeTimePoint at a specified duration in the past before now
|
|
72
|
+
* @param val the duration before now
|
|
73
|
+
*/
|
|
74
|
+
static beforeNow(val: BeDuration): BeTimePoint;
|
|
75
|
+
/** Determine whether this BeTimePoint is a time in the future from the time this method is called (it calls now()!) */
|
|
76
|
+
get isInFuture(): boolean;
|
|
77
|
+
/** Determine whether this BeTimePoint is a time that has already passed before the time this method is called (it calls now()!) */
|
|
78
|
+
get isInPast(): boolean;
|
|
79
|
+
/** Determine whether this BeTimePoint happens before another one.
|
|
80
|
+
* @param other the other BeTimePoint.
|
|
81
|
+
*/
|
|
82
|
+
before(other: BeTimePoint): boolean;
|
|
83
|
+
/** Determine whether this BeTimePoint happens after another one.
|
|
84
|
+
* @param other the other BeTimePoint.
|
|
85
|
+
*/
|
|
86
|
+
after(other: BeTimePoint): boolean;
|
|
87
|
+
/** Subtract a BeDuration from this BeTimePoint, returning a new BeTimePoint. This moves this BeTimePoint backwards in time if BeDuration.isTowardsFuture() === true
|
|
88
|
+
* @param duration the duration to subtract.
|
|
89
|
+
*/
|
|
90
|
+
minus(duration: BeDuration): BeTimePoint;
|
|
91
|
+
/** Subtract a BeDuration from this BeTimePoint, returning a new BeTimePoint. This moves this BeTimePoint backwards in time if BeDuration.isTowardsFuture() === true
|
|
92
|
+
* @param duration the duration to subtract.
|
|
93
|
+
*/
|
|
94
|
+
plus(duration: BeDuration): BeTimePoint;
|
|
95
|
+
}
|
|
96
|
+
/** A StopWatch for timing operations.
|
|
97
|
+
* @public
|
|
98
|
+
*/
|
|
99
|
+
export declare class StopWatch {
|
|
100
|
+
description?: string | undefined;
|
|
101
|
+
private _start?;
|
|
102
|
+
private _stop?;
|
|
103
|
+
/** Get the elapsed time since start() on a running timer. */
|
|
104
|
+
get current(): BeDuration;
|
|
105
|
+
/** Get the elapsed time, in seconds, since start() on a running timer. */
|
|
106
|
+
get currentSeconds(): number;
|
|
107
|
+
/** Get the elapsed time between start() and stop() on this timer. */
|
|
108
|
+
get elapsed(): BeDuration;
|
|
109
|
+
/** Get the elapsed time, in seconds, between start() and stop() on this timer. */
|
|
110
|
+
get elapsedSeconds(): number;
|
|
111
|
+
/** ctor for StopWatch
|
|
112
|
+
* @param description optional string stored with the StopWatch
|
|
113
|
+
* @param startImmediately if true, StopWatch is started when created. Otherwise, call start() explicitly.
|
|
114
|
+
*/
|
|
115
|
+
constructor(description?: string | undefined, startImmediately?: boolean);
|
|
116
|
+
/** Start the stopwatch. Any future time measurements will be based on this new value. */
|
|
117
|
+
start(): void;
|
|
118
|
+
/** Stop the stopwatch so that the duration can be viewed later. */
|
|
119
|
+
stop(): BeDuration;
|
|
120
|
+
/** Clear the StopWatch */
|
|
121
|
+
reset(): void;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=Time.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Time.d.ts","sourceRoot":"","sources":["../../src/Time.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO;IAEP,mCAAmC;IACnC,IAAW,YAAY,WAAiC;IACxD,IAAW,OAAO,WAAwC;IAE1D;;OAEG;WACW,WAAW,CAAC,OAAO,EAAE,MAAM;IACzC;;OAEG;WACW,gBAAgB,CAAC,YAAY,EAAE,MAAM;IACnD,qDAAqD;IACrD,IAAW,MAAM,YAAuC;IACxD,8DAA8D;IAC9D,IAAW,eAAe,IAAI,OAAO,CAAmC;IACxE,4DAA4D;IAC5D,IAAW,aAAa,IAAI,OAAO,CAAmC;IACtE,8EAA8E;IACvE,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;IAC3C,sEAAsE;IAC/D,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;IAE1C;;;OAGG;WACiB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD;;;;OAIG;WACiB,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAWnF;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlC;;;;;OAKG;IACU,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC;CAGjG;AAED;;;;GAIG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,gGAAgG;IAChG,IAAW,YAAY,WAAiC;IACxD,OAAO;IAEP,2CAA2C;WAC7B,GAAG;IAEjB;;OAEG;WACW,OAAO,CAAC,GAAG,EAAE,UAAU;IAErC;;OAEG;WACW,SAAS,CAAC,GAAG,EAAE,UAAU;IAEvC,uHAAuH;IACvH,IAAW,UAAU,IAAI,OAAO,CAA4C;IAE5E,mIAAmI;IACnI,IAAW,QAAQ,IAAI,OAAO,CAA4C;IAE1E;;OAEG;IACI,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO;IAE1C;;OAEG;IACI,KAAK,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO;IAEzC;;OAEG;IACI,KAAK,CAAC,QAAQ,EAAE,UAAU,GAAG,WAAW;IAE/C;;OAEG;IACI,IAAI,CAAC,QAAQ,EAAE,UAAU;CACjC;AAED;;GAEG;AACH,qBAAa,SAAS;IAeD,WAAW,CAAC;IAd/B,OAAO,CAAC,MAAM,CAAC,CAAc;IAC7B,OAAO,CAAC,KAAK,CAAC,CAAc;IAC5B,6DAA6D;IAC7D,IAAW,OAAO,IAAI,UAAU,CAAyH;IACzJ,0EAA0E;IAC1E,IAAW,cAAc,IAAI,MAAM,CAAiC;IACpE,qEAAqE;IACrE,IAAW,OAAO,IAAI,UAAU,CAAoK;IACpM,mFAAmF;IACnF,IAAW,cAAc,IAAI,MAAM,CAAiC;IACpE;;;OAGG;gBACgB,WAAW,CAAC,oBAAQ,EAAE,gBAAgB,UAAQ;IACjE,yFAAyF;IAClF,KAAK,IAAI,IAAI;IACpB,mEAAmE;IAC5D,IAAI,IAAI,UAAU;IACzB,0BAA0B;IACnB,KAAK,IAAI,IAAI;CACrB"}
|
package/lib/esm/Time.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
/** A duration of time. Can be either positive (towards future) or negative (in the past).
|
|
9
|
+
* BeDurations are immutable.
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export class BeDuration {
|
|
13
|
+
constructor(milliseconds = 0) { this._milliseconds = milliseconds; }
|
|
14
|
+
/** The duration in milliseconds */
|
|
15
|
+
get milliseconds() { return this._milliseconds; }
|
|
16
|
+
get seconds() { return this._milliseconds / 1000; }
|
|
17
|
+
/** Create a BeDuration from seconds.
|
|
18
|
+
* @param seconds the number of seconds for this BeDuration
|
|
19
|
+
*/
|
|
20
|
+
static fromSeconds(seconds) { return new BeDuration(seconds * 1000); }
|
|
21
|
+
/** Create a BeDuration from milliseconds.
|
|
22
|
+
* @param milliseconds the number of milliseconds for this BeDuration
|
|
23
|
+
*/
|
|
24
|
+
static fromMilliseconds(milliseconds) { return new BeDuration(milliseconds); }
|
|
25
|
+
/** Determine whether this BeDuration is 0 seconds */
|
|
26
|
+
get isZero() { return this._milliseconds === 0; }
|
|
27
|
+
/** Determine whether this BeDuration is towards the future */
|
|
28
|
+
get isTowardsFuture() { return this._milliseconds > 0; }
|
|
29
|
+
/** Determine whether this BeDuration is towards the past */
|
|
30
|
+
get isTowardsPast() { return this._milliseconds < 0; }
|
|
31
|
+
/** Subtract a BeDuration from this BeDuration, returning a new BeDuration. */
|
|
32
|
+
minus(other) { return new BeDuration(this._milliseconds - other._milliseconds); }
|
|
33
|
+
/** Add a BeDuration to this BeDuration, returning a new BeDuration */
|
|
34
|
+
plus(other) { return new BeDuration(this._milliseconds + other._milliseconds); }
|
|
35
|
+
/** Utility function to just wait for the specified time
|
|
36
|
+
* @param ms Duration in milliseconds to wait
|
|
37
|
+
* @return Promise that resolves after the specified wait period
|
|
38
|
+
*/
|
|
39
|
+
static async wait(ms) {
|
|
40
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
41
|
+
}
|
|
42
|
+
/** Utility function to wait for either the specified time or a promise, whichever resolves first
|
|
43
|
+
* @param ms Maximum duration in milliseconds to wait
|
|
44
|
+
* @param promise A pending promise to wait for
|
|
45
|
+
* @return Promise that resolves after the specified wait period or the provided promise resolves, whichever comes first
|
|
46
|
+
*/
|
|
47
|
+
static async race(ms, promise) {
|
|
48
|
+
let timeout;
|
|
49
|
+
const waitPromise = new Promise((resolve) => {
|
|
50
|
+
timeout = setTimeout(resolve, ms);
|
|
51
|
+
});
|
|
52
|
+
return Promise.race([waitPromise, promise]).finally(() => {
|
|
53
|
+
if (timeout)
|
|
54
|
+
clearTimeout(timeout);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** Utility function to just wait for the specified time
|
|
58
|
+
* @return Promise that resolves after the specified wait period
|
|
59
|
+
*/
|
|
60
|
+
async wait() {
|
|
61
|
+
return new Promise((resolve) => setTimeout(resolve, this._milliseconds));
|
|
62
|
+
}
|
|
63
|
+
/** Execute a function after delaying by this duration.
|
|
64
|
+
* @param fn the function to execute after the delay
|
|
65
|
+
* @param scope An optional object scope to serve as the 'this' pointer when `fn` is invoked.
|
|
66
|
+
* @param args optional arguments to `fn`
|
|
67
|
+
* @return Promise resolved by `fn`
|
|
68
|
+
*/
|
|
69
|
+
async executeAfter(fn, scope, ...args) {
|
|
70
|
+
return new Promise((resolve) => setTimeout(() => resolve(fn.apply(scope, args)), this._milliseconds));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** A specific point in time relative to the current time.
|
|
74
|
+
* BeTimePoints are used for timing operations. They are created from a BeDuration relative to the "now".
|
|
75
|
+
* BeTimePoints are immutable.
|
|
76
|
+
* @public
|
|
77
|
+
*/
|
|
78
|
+
export class BeTimePoint {
|
|
79
|
+
constructor(milliseconds) { this._milliseconds = milliseconds; }
|
|
80
|
+
/** the time in milliseconds, of this BeTimePoint (relative to January 1, 1970 00:00:00 UTC.) */
|
|
81
|
+
get milliseconds() { return this._milliseconds; }
|
|
82
|
+
/** Create a BeTimePoint from Date.now() */
|
|
83
|
+
static now() { return new BeTimePoint(Date.now()); }
|
|
84
|
+
/** Create a BeTimePoint at a specified duration in the future from now
|
|
85
|
+
* @param val the duration from now
|
|
86
|
+
*/
|
|
87
|
+
static fromNow(val) { return new BeTimePoint(Date.now() + val.milliseconds); }
|
|
88
|
+
/** Create a BeTimePoint at a specified duration in the past before now
|
|
89
|
+
* @param val the duration before now
|
|
90
|
+
*/
|
|
91
|
+
static beforeNow(val) { return new BeTimePoint(Date.now() - val.milliseconds); }
|
|
92
|
+
/** Determine whether this BeTimePoint is a time in the future from the time this method is called (it calls now()!) */
|
|
93
|
+
get isInFuture() { return Date.now() < this._milliseconds; }
|
|
94
|
+
/** Determine whether this BeTimePoint is a time that has already passed before the time this method is called (it calls now()!) */
|
|
95
|
+
get isInPast() { return Date.now() > this._milliseconds; }
|
|
96
|
+
/** Determine whether this BeTimePoint happens before another one.
|
|
97
|
+
* @param other the other BeTimePoint.
|
|
98
|
+
*/
|
|
99
|
+
before(other) { return this._milliseconds < other._milliseconds; }
|
|
100
|
+
/** Determine whether this BeTimePoint happens after another one.
|
|
101
|
+
* @param other the other BeTimePoint.
|
|
102
|
+
*/
|
|
103
|
+
after(other) { return this._milliseconds > other._milliseconds; }
|
|
104
|
+
/** Subtract a BeDuration from this BeTimePoint, returning a new BeTimePoint. This moves this BeTimePoint backwards in time if BeDuration.isTowardsFuture() === true
|
|
105
|
+
* @param duration the duration to subtract.
|
|
106
|
+
*/
|
|
107
|
+
minus(duration) { return new BeTimePoint(this._milliseconds - duration.milliseconds); }
|
|
108
|
+
/** Subtract a BeDuration from this BeTimePoint, returning a new BeTimePoint. This moves this BeTimePoint backwards in time if BeDuration.isTowardsFuture() === true
|
|
109
|
+
* @param duration the duration to subtract.
|
|
110
|
+
*/
|
|
111
|
+
plus(duration) { return new BeTimePoint(this._milliseconds + duration.milliseconds); }
|
|
112
|
+
}
|
|
113
|
+
/** A StopWatch for timing operations.
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
export class StopWatch {
|
|
117
|
+
/** ctor for StopWatch
|
|
118
|
+
* @param description optional string stored with the StopWatch
|
|
119
|
+
* @param startImmediately if true, StopWatch is started when created. Otherwise, call start() explicitly.
|
|
120
|
+
*/
|
|
121
|
+
constructor(description, startImmediately = false) {
|
|
122
|
+
this.description = description;
|
|
123
|
+
if (startImmediately)
|
|
124
|
+
this.start();
|
|
125
|
+
}
|
|
126
|
+
/** Get the elapsed time since start() on a running timer. */
|
|
127
|
+
get current() { return BeDuration.fromMilliseconds(BeTimePoint.now().milliseconds - (!!this._start ? this._start.milliseconds : 0)); }
|
|
128
|
+
/** Get the elapsed time, in seconds, since start() on a running timer. */
|
|
129
|
+
get currentSeconds() { return this.current.seconds; }
|
|
130
|
+
/** Get the elapsed time between start() and stop() on this timer. */
|
|
131
|
+
get elapsed() { return BeDuration.fromMilliseconds((!!this._stop ? this._stop.milliseconds : BeTimePoint.now().milliseconds) - (!!this._start ? this._start.milliseconds : 0)); }
|
|
132
|
+
/** Get the elapsed time, in seconds, between start() and stop() on this timer. */
|
|
133
|
+
get elapsedSeconds() { return this.elapsed.seconds; }
|
|
134
|
+
/** Start the stopwatch. Any future time measurements will be based on this new value. */
|
|
135
|
+
start() { this.reset(); this._start = BeTimePoint.now(); }
|
|
136
|
+
/** Stop the stopwatch so that the duration can be viewed later. */
|
|
137
|
+
stop() { this._stop = BeTimePoint.now(); return this.elapsed; }
|
|
138
|
+
/** Clear the StopWatch */
|
|
139
|
+
reset() { this._start = this._stop = undefined; }
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=Time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Time.js","sourceRoot":"","sources":["../../src/Time.ts"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/D","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/** A duration of time. Can be either positive (towards future) or negative (in the past).\n * BeDurations are immutable.\n * @public\n */\nexport class BeDuration {\n private readonly _milliseconds: number;\n private constructor(milliseconds: number = 0) { this._milliseconds = milliseconds; }\n\n /** The duration in milliseconds */\n public get milliseconds() { return this._milliseconds; }\n public get seconds() { return this._milliseconds / 1000; }\n\n /** Create a BeDuration from seconds.\n * @param seconds the number of seconds for this BeDuration\n */\n public static fromSeconds(seconds: number) { return new BeDuration(seconds * 1000); }\n /** Create a BeDuration from milliseconds.\n * @param milliseconds the number of milliseconds for this BeDuration\n */\n public static fromMilliseconds(milliseconds: number) { return new BeDuration(milliseconds); }\n /** Determine whether this BeDuration is 0 seconds */\n public get isZero() { return this._milliseconds === 0; }\n /** Determine whether this BeDuration is towards the future */\n public get isTowardsFuture(): boolean { return this._milliseconds > 0; }\n /** Determine whether this BeDuration is towards the past */\n public get isTowardsPast(): boolean { return this._milliseconds < 0; }\n /** Subtract a BeDuration from this BeDuration, returning a new BeDuration. */\n public minus(other: BeDuration): BeDuration { return new BeDuration(this._milliseconds - other._milliseconds); }\n /** Add a BeDuration to this BeDuration, returning a new BeDuration */\n public plus(other: BeDuration): BeDuration { return new BeDuration(this._milliseconds + other._milliseconds); }\n\n /** Utility function to just wait for the specified time\n * @param ms Duration in milliseconds to wait\n * @return Promise that resolves after the specified wait period\n */\n public static async wait(ms: number): Promise<void> {\n return new Promise<void>((resolve: any) => setTimeout(resolve, ms));\n }\n\n /** Utility function to wait for either the specified time or a promise, whichever resolves first\n * @param ms Maximum duration in milliseconds to wait\n * @param promise A pending promise to wait for\n * @return Promise that resolves after the specified wait period or the provided promise resolves, whichever comes first\n */\n public static async race<T>(ms: number, promise: PromiseLike<T>): Promise<T | void> {\n let timeout: any;\n const waitPromise = new Promise<void>((resolve) => {\n timeout = setTimeout(resolve, ms);\n });\n return Promise.race([waitPromise, promise]).finally(() => {\n if (timeout)\n clearTimeout(timeout);\n });\n }\n\n /** Utility function to just wait for the specified time\n * @return Promise that resolves after the specified wait period\n */\n public async wait(): Promise<void> {\n return new Promise<void>((resolve: any) => setTimeout(resolve, this._milliseconds));\n }\n\n /** Execute a function after delaying by this duration.\n * @param fn the function to execute after the delay\n * @param scope An optional object scope to serve as the 'this' pointer when `fn` is invoked.\n * @param args optional arguments to `fn`\n * @return Promise resolved by `fn`\n */\n public async executeAfter<T>(fn: (...args: any[]) => T, scope?: any, ...args: any[]): Promise<T> {\n return new Promise<T>((resolve: any) => setTimeout(() => resolve(fn.apply(scope, args)), this._milliseconds));\n }\n}\n\n/** A specific point in time relative to the current time.\n * BeTimePoints are used for timing operations. They are created from a BeDuration relative to the \"now\".\n * BeTimePoints are immutable.\n * @public\n */\nexport class BeTimePoint {\n private readonly _milliseconds: number;\n /** the time in milliseconds, of this BeTimePoint (relative to January 1, 1970 00:00:00 UTC.) */\n public get milliseconds() { return this._milliseconds; }\n private constructor(milliseconds: number) { this._milliseconds = milliseconds; }\n\n /** Create a BeTimePoint from Date.now() */\n public static now() { return new BeTimePoint(Date.now()); }\n\n /** Create a BeTimePoint at a specified duration in the future from now\n * @param val the duration from now\n */\n public static fromNow(val: BeDuration) { return new BeTimePoint(Date.now() + val.milliseconds); }\n\n /** Create a BeTimePoint at a specified duration in the past before now\n * @param val the duration before now\n */\n public static beforeNow(val: BeDuration) { return new BeTimePoint(Date.now() - val.milliseconds); }\n\n /** Determine whether this BeTimePoint is a time in the future from the time this method is called (it calls now()!) */\n public get isInFuture(): boolean { return Date.now() < this._milliseconds; }\n\n /** Determine whether this BeTimePoint is a time that has already passed before the time this method is called (it calls now()!) */\n public get isInPast(): boolean { return Date.now() > this._milliseconds; }\n\n /** Determine whether this BeTimePoint happens before another one.\n * @param other the other BeTimePoint.\n */\n public before(other: BeTimePoint): boolean { return this._milliseconds < other._milliseconds; }\n\n /** Determine whether this BeTimePoint happens after another one.\n * @param other the other BeTimePoint.\n */\n public after(other: BeTimePoint): boolean { return this._milliseconds > other._milliseconds; }\n\n /** Subtract a BeDuration from this BeTimePoint, returning a new BeTimePoint. This moves this BeTimePoint backwards in time if BeDuration.isTowardsFuture() === true\n * @param duration the duration to subtract.\n */\n public minus(duration: BeDuration): BeTimePoint { return new BeTimePoint(this._milliseconds - duration.milliseconds); }\n\n /** Subtract a BeDuration from this BeTimePoint, returning a new BeTimePoint. This moves this BeTimePoint backwards in time if BeDuration.isTowardsFuture() === true\n * @param duration the duration to subtract.\n */\n public plus(duration: BeDuration) { return new BeTimePoint(this._milliseconds + duration.milliseconds); }\n}\n\n/** A StopWatch for timing operations.\n * @public\n */\nexport class StopWatch {\n private _start?: BeTimePoint;\n private _stop?: BeTimePoint;\n /** Get the elapsed time since start() on a running timer. */\n public get current(): BeDuration { return BeDuration.fromMilliseconds(BeTimePoint.now().milliseconds - (!!this._start ? this._start.milliseconds : 0)); }\n /** Get the elapsed time, in seconds, since start() on a running timer. */\n public get currentSeconds(): number { return this.current.seconds; }\n /** Get the elapsed time between start() and stop() on this timer. */\n public get elapsed(): BeDuration { return BeDuration.fromMilliseconds((!!this._stop ? this._stop.milliseconds : BeTimePoint.now().milliseconds) - (!!this._start ? this._start.milliseconds : 0)); }\n /** Get the elapsed time, in seconds, between start() and stop() on this timer. */\n public get elapsedSeconds(): number { return this.elapsed.seconds; }\n /** ctor for StopWatch\n * @param description optional string stored with the StopWatch\n * @param startImmediately if true, StopWatch is started when created. Otherwise, call start() explicitly.\n */\n constructor(public description?: string, startImmediately = false) { if (startImmediately) this.start(); }\n /** Start the stopwatch. Any future time measurements will be based on this new value. */\n public start(): void { this.reset(); this._start = BeTimePoint.now(); }\n /** Stop the stopwatch so that the duration can be viewed later. */\n public stop(): BeDuration { this._stop = BeTimePoint.now(); return this.elapsed; }\n /** Clear the StopWatch */\n public reset(): void { this._start = this._stop = undefined; }\n}\n"]}
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
/** Generically represents a class `T`, for use in type annotations.
|
|
11
|
+
* @note A variable of type `Constructor<T>` matches a class `T` only if `T` has a **public** constructor.
|
|
12
|
+
* @see [[asInstanceOf]] to attempt to cast an arbitrary value to class `T`.
|
|
13
|
+
* @see [[isInstanceOf]] to determine if an arbitrary value is an instance of class `T`.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare type Constructor<T> = new (...args: any[]) => T;
|
|
17
|
+
/** Returns true if `obj` is an object of class `T`.
|
|
18
|
+
* @see [[asInstanceOf]] to cast `obj` to class `T`.
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare function isInstanceOf<T>(obj: any, constructor: Constructor<T>): boolean;
|
|
22
|
+
/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.
|
|
23
|
+
* @see [[isInstanceOf]] to query whether `obj` is of class `T`.
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export declare function asInstanceOf<T>(obj: any, constructor: Constructor<T>): T | undefined;
|
|
27
|
+
/** Extracts the names of all public properties of `T` that are not of type `function`.
|
|
28
|
+
* This includes properties defined using `get` syntax. Care should be used when using this type in conjunction with
|
|
29
|
+
* the object spread (`...`) operator, because the spread operator omits properties defined using `get` syntax and, therefore,
|
|
30
|
+
* so too does the type that TypeScript infers from that operator.
|
|
31
|
+
* `get` syntax. For example:
|
|
32
|
+
* ```ts
|
|
33
|
+
* class Thing {
|
|
34
|
+
* private _a = "a"; // a private variable
|
|
35
|
+
* public b = "b"; // a public variable
|
|
36
|
+
* public get c() { return "c"; } // a public property
|
|
37
|
+
* public d() { return "d"; } // a public method
|
|
38
|
+
* public e = () => "e"; // a public variable of type `function`
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* // The following can have the values "b" or "c" - those are the public, non-function properties of Thing.
|
|
42
|
+
* let nonFunctionProperty: NonFunctionPropertyNamesOf<Thing> = "c";
|
|
43
|
+
*
|
|
44
|
+
* // The following produces an error: "Property 'c' is missing in type '{ b: string; e: () => string; }' but required in type 'NonFunctionPropertiesOf<Thing>'"
|
|
45
|
+
* const thing1 = new Thing();
|
|
46
|
+
* const thing2: NonFunctionPropertiesOf<Thing> = { ...thing1 };
|
|
47
|
+
* ```
|
|
48
|
+
* @see [[NonFunctionPropertiesOf]] to obtain a type that includes only these properties.
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export declare type NonFunctionPropertyNamesOf<T> = {
|
|
52
|
+
[K in keyof T]: T[K] extends Function ? never : K;
|
|
53
|
+
}[keyof T];
|
|
54
|
+
/** Produces a type consisting of all of the public properties of `T` except for those of type `function`.
|
|
55
|
+
* @see [[NonFunctionPropertyNamesOf]] for potential pitfalls when used in conjunction with the object spread operator.
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export declare type NonFunctionPropertiesOf<T> = Pick<T, NonFunctionPropertyNamesOf<T>>;
|
|
59
|
+
/** Any function returning a Promise.
|
|
60
|
+
* @see [[AsyncMethodsOf]] to extract all async methods from a type.
|
|
61
|
+
* @see [[PromiseReturnType]] to extract the type to which the Promise resolves.
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
export declare type AsyncFunction = (...args: any) => Promise<any>;
|
|
65
|
+
/** Extracts the names of all function properties of `T` that return a Promise.
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare type AsyncMethodsOf<T> = {
|
|
69
|
+
[P in keyof T]: T[P] extends AsyncFunction ? P : never;
|
|
70
|
+
}[keyof T];
|
|
71
|
+
/** Extracts the type to which the Promise returned by an async function resolves.
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
export declare type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;
|
|
75
|
+
//# sourceMappingURL=UtilityTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UtilityTypes.d.ts","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;GAEG;AACH,oBAAY,OAAO,CAAC,CAAC,IAAI;IACvB,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC/B,CAAC;AAEF;;;;;GAKG;AACH,oBAAY,WAAW,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAEvD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAE9E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAEpF;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,oBAAY,0BAA0B,CAAC,CAAC,IAAI;KACzC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GAAG,KAAK,GAAG,CAAC;CAClD,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX;;;GAGG;AACH,oBAAY,uBAAuB,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhF;;;;GAIG;AACH,oBAAY,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAE3D;;GAEG;AACH,oBAAY,cAAc,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,aAAa,GAAG,CAAC,GAAG,KAAK;CAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AAEpG;;GAEG;AACH,oBAAY,iBAAiB,CAAC,CAAC,SAAS,aAAa,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC"}
|
|
@@ -0,0 +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
|
+
}
|
|
22
|
+
//# sourceMappingURL=UtilityTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UtilityTypes.js","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAiBH;;;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/** 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"]}
|
|
@@ -0,0 +1,71 @@
|
|
|
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 "./BeSQLite";
|
|
8
|
+
export * from "./ByteStream";
|
|
9
|
+
export * from "./Compare";
|
|
10
|
+
export * from "./CompressedId64Set";
|
|
11
|
+
export * from "./Dictionary";
|
|
12
|
+
export * from "./Disposable";
|
|
13
|
+
export * from "./Id";
|
|
14
|
+
export * from "./IndexMap";
|
|
15
|
+
export * from "./JsonUtils";
|
|
16
|
+
export * from "./Logger";
|
|
17
|
+
export * from "./LRUMap";
|
|
18
|
+
export * from "./ObservableSet";
|
|
19
|
+
export * from "./OneAtATimeAction";
|
|
20
|
+
export * from "./OrderedId64Iterable";
|
|
21
|
+
export * from "./OrderedSet";
|
|
22
|
+
export * from "./partitionArray";
|
|
23
|
+
export * from "./PriorityQueue";
|
|
24
|
+
export * from "./ProcessDetector";
|
|
25
|
+
export * from "./SortedArray";
|
|
26
|
+
export * from "./StringUtils";
|
|
27
|
+
export * from "./Time";
|
|
28
|
+
export * from "./UtilityTypes";
|
|
29
|
+
/** @packageDocumentation
|
|
30
|
+
* @module Utils
|
|
31
|
+
*/
|
|
32
|
+
/** @docs-package-description
|
|
33
|
+
* The core-bentley package contains classes to solve problems that are common for both client and server use cases.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* @docs-group-description BeSQLite
|
|
37
|
+
* Classes for working with SQLite databases. SQLite underlies IModelDb and ECDb - see [Executing ECSQL]($docs/learning/ECSQL.md)
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* @docs-group-description Configuration
|
|
41
|
+
* Class for easily managing configuration variables for an iModel.js application.
|
|
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 Utils
|
|
65
|
+
* Miscellaneous utility classes.
|
|
66
|
+
*/
|
|
67
|
+
/**
|
|
68
|
+
* @docs-group-description ProcessDetector
|
|
69
|
+
* Functions for determining the type of the current JavaScript process.
|
|
70
|
+
*/
|
|
71
|
+
//# sourceMappingURL=core-bentley.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-bentley.d.ts","sourceRoot":"","sources":["../../src/core-bentley.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAE/B;;GAEG;AAEH;;GAEG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG"}
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
export * from "./AccessToken";
|
|
6
|
+
export * from "./Assert";
|
|
7
|
+
export * from "./AsyncMutex";
|
|
8
|
+
export * from "./BeEvent";
|
|
9
|
+
export * from "./BentleyError";
|
|
10
|
+
export * from "./BentleyLoggerCategory";
|
|
11
|
+
export * from "./BeSQLite";
|
|
12
|
+
export * from "./ByteStream";
|
|
13
|
+
export * from "./Compare";
|
|
14
|
+
export * from "./CompressedId64Set";
|
|
15
|
+
export * from "./Dictionary";
|
|
16
|
+
export * from "./Disposable";
|
|
17
|
+
export * from "./Id";
|
|
18
|
+
export * from "./IndexMap";
|
|
19
|
+
export * from "./JsonUtils";
|
|
20
|
+
export * from "./Logger";
|
|
21
|
+
export * from "./LRUMap";
|
|
22
|
+
export * from "./ObservableSet";
|
|
23
|
+
export * from "./OneAtATimeAction";
|
|
24
|
+
export * from "./OrderedId64Iterable";
|
|
25
|
+
export * from "./OrderedSet";
|
|
26
|
+
export * from "./partitionArray";
|
|
27
|
+
export * from "./PriorityQueue";
|
|
28
|
+
export * from "./ProcessDetector";
|
|
29
|
+
export * from "./SortedArray";
|
|
30
|
+
export * from "./StringUtils";
|
|
31
|
+
export * from "./Time";
|
|
32
|
+
export * from "./UtilityTypes";
|
|
33
|
+
/** @packageDocumentation
|
|
34
|
+
* @module Utils
|
|
35
|
+
*/
|
|
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 Configuration
|
|
45
|
+
* Class for easily managing configuration variables for an iModel.js application.
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* @docs-group-description Errors
|
|
49
|
+
* Classes for working with errors.
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* @docs-group-description Events
|
|
53
|
+
* Classes for raising and handling events.
|
|
54
|
+
*/
|
|
55
|
+
/**
|
|
56
|
+
* @docs-group-description Ids
|
|
57
|
+
* Classes for working with unique identifiers.
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* @docs-group-description Logging
|
|
61
|
+
* Classes for configuring and logging diagnostic messages - see [Learning about Logging]($docs/learning/common/Logging.md)
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* @docs-group-description Collections
|
|
65
|
+
* Specialized, customizable collection classes like priority queues.
|
|
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
|
+
//# sourceMappingURL=core-bentley.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-bentley.js","sourceRoot":"","sources":["../../src/core-bentley.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAE/B;;GAEG;AAEH;;GAEG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG;AACH;;;GAGG","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*--------------------------------------------------------------------------------------------*/\nexport * from \"./AccessToken\";\nexport * from \"./Assert\";\nexport * from \"./AsyncMutex\";\nexport * from \"./BeEvent\";\nexport * from \"./BentleyError\";\nexport * from \"./BentleyLoggerCategory\";\nexport * from \"./BeSQLite\";\nexport * from \"./ByteStream\";\nexport * from \"./Compare\";\nexport * from \"./CompressedId64Set\";\nexport * from \"./Dictionary\";\nexport * from \"./Disposable\";\nexport * from \"./Id\";\nexport * from \"./IndexMap\";\nexport * from \"./JsonUtils\";\nexport * from \"./Logger\";\nexport * from \"./LRUMap\";\nexport * from \"./ObservableSet\";\nexport * from \"./OneAtATimeAction\";\nexport * from \"./OrderedId64Iterable\";\nexport * from \"./OrderedSet\";\nexport * from \"./partitionArray\";\nexport * from \"./PriorityQueue\";\nexport * from \"./ProcessDetector\";\nexport * from \"./SortedArray\";\nexport * from \"./StringUtils\";\nexport * from \"./Time\";\nexport * from \"./UtilityTypes\";\n\n/** @packageDocumentation\n * @module Utils\n */\n\n/** @docs-package-description\n * The core-bentley package contains classes to solve problems that are common for both client and server use cases.\n */\n/**\n * @docs-group-description BeSQLite\n * Classes for working with SQLite databases. SQLite underlies IModelDb and ECDb - see [Executing ECSQL]($docs/learning/ECSQL.md)\n */\n/**\n * @docs-group-description Configuration\n * Class for easily managing configuration variables for an iModel.js application.\n */\n/**\n * @docs-group-description Errors\n * Classes for working with errors.\n */\n/**\n * @docs-group-description Events\n * Classes for raising and handling events.\n */\n/**\n * @docs-group-description Ids\n * Classes for working with unique identifiers.\n */\n/**\n * @docs-group-description Logging\n * Classes for configuring and logging diagnostic messages - see [Learning about Logging]($docs/learning/common/Logging.md)\n */\n/**\n * @docs-group-description Collections\n * Specialized, customizable collection classes like priority queues.\n */\n/**\n * @docs-group-description Utils\n * Miscellaneous utility classes.\n */\n/**\n * @docs-group-description ProcessDetector\n * Functions for determining the type of the current JavaScript process.\n */\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Collections
|
|
3
|
+
*/
|
|
4
|
+
/** Partitions an array in-place according to some criterion, such that elements that fulfill the criterion are grouped in the lower
|
|
5
|
+
* portion of the array, and those that fail to fulfill the criterion are grouped in the upper portion of the array.
|
|
6
|
+
* @param array The array to be partitioned.
|
|
7
|
+
* @param criterion A function invoked for each element of the array, returning whether the element fulfills the criterion.
|
|
8
|
+
* @returns The index of the upper partition, i.e., of the first element that fails the criterion. If all elements fulfill the criterion, this is the length of the array.
|
|
9
|
+
* @note The relative ordering of elements within each partition is unspecified.
|
|
10
|
+
* Example:
|
|
11
|
+
* ```ts
|
|
12
|
+
* function isEven(n: number) { return 0 === n % 2; }
|
|
13
|
+
* const list = [ 1, 2, 3, 4, 5 ];
|
|
14
|
+
* const firstOddIndex = partitionArray(list, isEven); // firstOddIndex = 2
|
|
15
|
+
* // 2 and 4 now appear before 1, 3, and 5 in the list; their ordering is otherwise unspecified.
|
|
16
|
+
* for (let i = 0; i < list.length; i++)
|
|
17
|
+
* assert(isEven(list[i]) === i < firstOddIndex);
|
|
18
|
+
* ```
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare function partitionArray<T>(array: T[], criterion: (element: T) => boolean): number;
|
|
22
|
+
//# sourceMappingURL=partitionArray.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partitionArray.d.ts","sourceRoot":"","sources":["../../src/partitionArray.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,OAAO,GAAG,MAAM,CAcxF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
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 Collections
|
|
7
|
+
*/
|
|
8
|
+
/** Partitions an array in-place according to some criterion, such that elements that fulfill the criterion are grouped in the lower
|
|
9
|
+
* portion of the array, and those that fail to fulfill the criterion are grouped in the upper portion of the array.
|
|
10
|
+
* @param array The array to be partitioned.
|
|
11
|
+
* @param criterion A function invoked for each element of the array, returning whether the element fulfills the criterion.
|
|
12
|
+
* @returns The index of the upper partition, i.e., of the first element that fails the criterion. If all elements fulfill the criterion, this is the length of the array.
|
|
13
|
+
* @note The relative ordering of elements within each partition is unspecified.
|
|
14
|
+
* Example:
|
|
15
|
+
* ```ts
|
|
16
|
+
* function isEven(n: number) { return 0 === n % 2; }
|
|
17
|
+
* const list = [ 1, 2, 3, 4, 5 ];
|
|
18
|
+
* const firstOddIndex = partitionArray(list, isEven); // firstOddIndex = 2
|
|
19
|
+
* // 2 and 4 now appear before 1, 3, and 5 in the list; their ordering is otherwise unspecified.
|
|
20
|
+
* for (let i = 0; i < list.length; i++)
|
|
21
|
+
* assert(isEven(list[i]) === i < firstOddIndex);
|
|
22
|
+
* ```
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export function partitionArray(array, criterion) {
|
|
26
|
+
let index = 0;
|
|
27
|
+
let partition = array.length;
|
|
28
|
+
while (index < partition) {
|
|
29
|
+
const elem = array[index];
|
|
30
|
+
if (criterion(elem)) {
|
|
31
|
+
++index;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
array[index] = array[--partition];
|
|
35
|
+
array[partition] = elem;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return partition;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=partitionArray.js.map
|