@itwin/core-bentley 3.6.0-dev.65 → 3.6.0-dev.66

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.
Files changed (221) hide show
  1. package/lib/cjs/AccessToken.d.ts +10 -10
  2. package/lib/cjs/AccessToken.js +9 -9
  3. package/lib/cjs/AccessToken.js.map +1 -1
  4. package/lib/cjs/Assert.d.ts +25 -25
  5. package/lib/cjs/Assert.js +45 -45
  6. package/lib/cjs/Assert.js.map +1 -1
  7. package/lib/cjs/BeEvent.d.ts +81 -81
  8. package/lib/cjs/BeEvent.js +156 -156
  9. package/lib/cjs/BeEvent.js.map +1 -1
  10. package/lib/cjs/BeSQLite.d.ts +172 -170
  11. package/lib/cjs/BeSQLite.d.ts.map +1 -1
  12. package/lib/cjs/BeSQLite.js +185 -183
  13. package/lib/cjs/BeSQLite.js.map +1 -1
  14. package/lib/cjs/BentleyError.d.ts +378 -378
  15. package/lib/cjs/BentleyError.d.ts.map +1 -1
  16. package/lib/cjs/BentleyError.js +703 -702
  17. package/lib/cjs/BentleyError.js.map +1 -1
  18. package/lib/cjs/BentleyLoggerCategory.d.ts +11 -11
  19. package/lib/cjs/BentleyLoggerCategory.js +19 -19
  20. package/lib/cjs/BentleyLoggerCategory.js.map +1 -1
  21. package/lib/cjs/ByteStream.d.ts +110 -110
  22. package/lib/cjs/ByteStream.js +159 -159
  23. package/lib/cjs/ByteStream.js.map +1 -1
  24. package/lib/cjs/ClassUtils.d.ts +14 -14
  25. package/lib/cjs/ClassUtils.js +27 -27
  26. package/lib/cjs/ClassUtils.js.map +1 -1
  27. package/lib/cjs/Compare.d.ts +47 -47
  28. package/lib/cjs/Compare.js +75 -75
  29. package/lib/cjs/Compare.js.map +1 -1
  30. package/lib/cjs/CompressedId64Set.d.ts +134 -134
  31. package/lib/cjs/CompressedId64Set.js +428 -428
  32. package/lib/cjs/CompressedId64Set.js.map +1 -1
  33. package/lib/cjs/Dictionary.d.ts +125 -125
  34. package/lib/cjs/Dictionary.js +203 -203
  35. package/lib/cjs/Dictionary.js.map +1 -1
  36. package/lib/cjs/Disposable.d.ts +80 -80
  37. package/lib/cjs/Disposable.js +120 -120
  38. package/lib/cjs/Disposable.js.map +1 -1
  39. package/lib/cjs/Id.d.ts +285 -285
  40. package/lib/cjs/Id.js +643 -643
  41. package/lib/cjs/Id.js.map +1 -1
  42. package/lib/cjs/IndexMap.d.ts +65 -65
  43. package/lib/cjs/IndexMap.js +91 -91
  44. package/lib/cjs/IndexMap.js.map +1 -1
  45. package/lib/cjs/JsonSchema.d.ts +77 -77
  46. package/lib/cjs/JsonSchema.js +9 -9
  47. package/lib/cjs/JsonSchema.js.map +1 -1
  48. package/lib/cjs/JsonUtils.d.ts +78 -78
  49. package/lib/cjs/JsonUtils.js +151 -151
  50. package/lib/cjs/JsonUtils.js.map +1 -1
  51. package/lib/cjs/LRUMap.d.ts +129 -129
  52. package/lib/cjs/LRUMap.js +333 -333
  53. package/lib/cjs/LRUMap.js.map +1 -1
  54. package/lib/cjs/Logger.d.ts +143 -143
  55. package/lib/cjs/Logger.js +258 -258
  56. package/lib/cjs/Logger.js.map +1 -1
  57. package/lib/cjs/ObservableSet.d.ts +23 -23
  58. package/lib/cjs/ObservableSet.js +51 -51
  59. package/lib/cjs/ObservableSet.js.map +1 -1
  60. package/lib/cjs/OneAtATimeAction.d.ts +31 -31
  61. package/lib/cjs/OneAtATimeAction.js +94 -94
  62. package/lib/cjs/OneAtATimeAction.js.map +1 -1
  63. package/lib/cjs/OrderedId64Iterable.d.ts +74 -74
  64. package/lib/cjs/OrderedId64Iterable.js +235 -235
  65. package/lib/cjs/OrderedId64Iterable.js.map +1 -1
  66. package/lib/cjs/OrderedSet.d.ts +40 -40
  67. package/lib/cjs/OrderedSet.js +64 -64
  68. package/lib/cjs/OrderedSet.js.map +1 -1
  69. package/lib/cjs/PriorityQueue.d.ts +70 -70
  70. package/lib/cjs/PriorityQueue.js +140 -140
  71. package/lib/cjs/PriorityQueue.js.map +1 -1
  72. package/lib/cjs/ProcessDetector.d.ts +59 -59
  73. package/lib/cjs/ProcessDetector.js +71 -71
  74. package/lib/cjs/ProcessDetector.js.map +1 -1
  75. package/lib/cjs/SortedArray.d.ts +232 -232
  76. package/lib/cjs/SortedArray.js +303 -303
  77. package/lib/cjs/SortedArray.js.map +1 -1
  78. package/lib/cjs/StatusCategory.d.ts +30 -30
  79. package/lib/cjs/StatusCategory.js +460 -460
  80. package/lib/cjs/StatusCategory.js.map +1 -1
  81. package/lib/cjs/StringUtils.d.ts +22 -22
  82. package/lib/cjs/StringUtils.js +148 -148
  83. package/lib/cjs/StringUtils.js.map +1 -1
  84. package/lib/cjs/Time.d.ts +122 -122
  85. package/lib/cjs/Time.js +152 -152
  86. package/lib/cjs/Time.js.map +1 -1
  87. package/lib/cjs/Tracing.d.ts +40 -40
  88. package/lib/cjs/Tracing.js +130 -130
  89. package/lib/cjs/Tracing.js.map +1 -1
  90. package/lib/cjs/TupleKeyedMap.d.ts +36 -36
  91. package/lib/cjs/TupleKeyedMap.js +102 -102
  92. package/lib/cjs/TupleKeyedMap.js.map +1 -1
  93. package/lib/cjs/TypedArrayBuilder.d.ts +155 -155
  94. package/lib/cjs/TypedArrayBuilder.js +208 -208
  95. package/lib/cjs/TypedArrayBuilder.js.map +1 -1
  96. package/lib/cjs/UnexpectedErrors.d.ts +43 -43
  97. package/lib/cjs/UnexpectedErrors.js +68 -68
  98. package/lib/cjs/UnexpectedErrors.js.map +1 -1
  99. package/lib/cjs/UtilityTypes.d.ts +96 -96
  100. package/lib/cjs/UtilityTypes.js +40 -40
  101. package/lib/cjs/UtilityTypes.js.map +1 -1
  102. package/lib/cjs/YieldManager.d.ts +18 -18
  103. package/lib/cjs/YieldManager.js +34 -34
  104. package/lib/cjs/YieldManager.js.map +1 -1
  105. package/lib/cjs/core-bentley.d.ts +74 -74
  106. package/lib/cjs/core-bentley.js +90 -90
  107. package/lib/cjs/core-bentley.js.map +1 -1
  108. package/lib/cjs/partitionArray.d.ts +21 -21
  109. package/lib/cjs/partitionArray.js +43 -43
  110. package/lib/cjs/partitionArray.js.map +1 -1
  111. package/lib/esm/AccessToken.d.ts +10 -10
  112. package/lib/esm/AccessToken.js +8 -8
  113. package/lib/esm/AccessToken.js.map +1 -1
  114. package/lib/esm/Assert.d.ts +25 -25
  115. package/lib/esm/Assert.js +41 -41
  116. package/lib/esm/Assert.js.map +1 -1
  117. package/lib/esm/BeEvent.d.ts +81 -81
  118. package/lib/esm/BeEvent.js +150 -150
  119. package/lib/esm/BeEvent.js.map +1 -1
  120. package/lib/esm/BeSQLite.d.ts +172 -170
  121. package/lib/esm/BeSQLite.d.ts.map +1 -1
  122. package/lib/esm/BeSQLite.js +182 -180
  123. package/lib/esm/BeSQLite.js.map +1 -1
  124. package/lib/esm/BentleyError.d.ts +378 -378
  125. package/lib/esm/BentleyError.d.ts.map +1 -1
  126. package/lib/esm/BentleyError.js +699 -698
  127. package/lib/esm/BentleyError.js.map +1 -1
  128. package/lib/esm/BentleyLoggerCategory.d.ts +11 -11
  129. package/lib/esm/BentleyLoggerCategory.js +16 -16
  130. package/lib/esm/BentleyLoggerCategory.js.map +1 -1
  131. package/lib/esm/ByteStream.d.ts +110 -110
  132. package/lib/esm/ByteStream.js +155 -155
  133. package/lib/esm/ByteStream.js.map +1 -1
  134. package/lib/esm/ClassUtils.d.ts +14 -14
  135. package/lib/esm/ClassUtils.js +22 -22
  136. package/lib/esm/ClassUtils.js.map +1 -1
  137. package/lib/esm/Compare.d.ts +47 -47
  138. package/lib/esm/Compare.js +63 -63
  139. package/lib/esm/Compare.js.map +1 -1
  140. package/lib/esm/CompressedId64Set.d.ts +134 -134
  141. package/lib/esm/CompressedId64Set.js +423 -423
  142. package/lib/esm/CompressedId64Set.js.map +1 -1
  143. package/lib/esm/Dictionary.d.ts +125 -125
  144. package/lib/esm/Dictionary.js +199 -199
  145. package/lib/esm/Dictionary.js.map +1 -1
  146. package/lib/esm/Disposable.d.ts +80 -80
  147. package/lib/esm/Disposable.js +112 -112
  148. package/lib/esm/Disposable.js.map +1 -1
  149. package/lib/esm/Id.d.ts +285 -285
  150. package/lib/esm/Id.js +639 -639
  151. package/lib/esm/Id.js.map +1 -1
  152. package/lib/esm/IndexMap.d.ts +65 -65
  153. package/lib/esm/IndexMap.js +86 -86
  154. package/lib/esm/IndexMap.js.map +1 -1
  155. package/lib/esm/JsonSchema.d.ts +77 -77
  156. package/lib/esm/JsonSchema.js +8 -8
  157. package/lib/esm/JsonSchema.js.map +1 -1
  158. package/lib/esm/JsonUtils.d.ts +78 -78
  159. package/lib/esm/JsonUtils.js +148 -148
  160. package/lib/esm/JsonUtils.js.map +1 -1
  161. package/lib/esm/LRUMap.d.ts +129 -129
  162. package/lib/esm/LRUMap.js +326 -326
  163. package/lib/esm/LRUMap.js.map +1 -1
  164. package/lib/esm/Logger.d.ts +143 -143
  165. package/lib/esm/Logger.js +253 -253
  166. package/lib/esm/Logger.js.map +1 -1
  167. package/lib/esm/ObservableSet.d.ts +23 -23
  168. package/lib/esm/ObservableSet.js +47 -47
  169. package/lib/esm/ObservableSet.js.map +1 -1
  170. package/lib/esm/OneAtATimeAction.d.ts +31 -31
  171. package/lib/esm/OneAtATimeAction.js +89 -89
  172. package/lib/esm/OneAtATimeAction.js.map +1 -1
  173. package/lib/esm/OrderedId64Iterable.d.ts +74 -74
  174. package/lib/esm/OrderedId64Iterable.js +232 -232
  175. package/lib/esm/OrderedId64Iterable.js.map +1 -1
  176. package/lib/esm/OrderedSet.d.ts +40 -40
  177. package/lib/esm/OrderedSet.js +59 -59
  178. package/lib/esm/OrderedSet.js.map +1 -1
  179. package/lib/esm/PriorityQueue.d.ts +70 -70
  180. package/lib/esm/PriorityQueue.js +136 -136
  181. package/lib/esm/PriorityQueue.js.map +1 -1
  182. package/lib/esm/ProcessDetector.d.ts +59 -59
  183. package/lib/esm/ProcessDetector.js +67 -67
  184. package/lib/esm/ProcessDetector.js.map +1 -1
  185. package/lib/esm/SortedArray.d.ts +232 -232
  186. package/lib/esm/SortedArray.js +296 -296
  187. package/lib/esm/SortedArray.js.map +1 -1
  188. package/lib/esm/StatusCategory.d.ts +30 -30
  189. package/lib/esm/StatusCategory.js +454 -454
  190. package/lib/esm/StatusCategory.js.map +1 -1
  191. package/lib/esm/StringUtils.d.ts +22 -22
  192. package/lib/esm/StringUtils.js +142 -142
  193. package/lib/esm/StringUtils.js.map +1 -1
  194. package/lib/esm/Time.d.ts +122 -122
  195. package/lib/esm/Time.js +146 -146
  196. package/lib/esm/Time.js.map +1 -1
  197. package/lib/esm/Tracing.d.ts +40 -40
  198. package/lib/esm/Tracing.js +126 -126
  199. package/lib/esm/Tracing.js.map +1 -1
  200. package/lib/esm/TupleKeyedMap.d.ts +36 -36
  201. package/lib/esm/TupleKeyedMap.js +98 -98
  202. package/lib/esm/TupleKeyedMap.js.map +1 -1
  203. package/lib/esm/TypedArrayBuilder.d.ts +155 -155
  204. package/lib/esm/TypedArrayBuilder.js +200 -200
  205. package/lib/esm/TypedArrayBuilder.js.map +1 -1
  206. package/lib/esm/UnexpectedErrors.d.ts +43 -43
  207. package/lib/esm/UnexpectedErrors.js +64 -64
  208. package/lib/esm/UnexpectedErrors.js.map +1 -1
  209. package/lib/esm/UtilityTypes.d.ts +96 -96
  210. package/lib/esm/UtilityTypes.js +34 -34
  211. package/lib/esm/UtilityTypes.js.map +1 -1
  212. package/lib/esm/YieldManager.d.ts +18 -18
  213. package/lib/esm/YieldManager.js +30 -30
  214. package/lib/esm/YieldManager.js.map +1 -1
  215. package/lib/esm/core-bentley.d.ts +74 -74
  216. package/lib/esm/core-bentley.js +78 -78
  217. package/lib/esm/core-bentley.js.map +1 -1
  218. package/lib/esm/partitionArray.d.ts +21 -21
  219. package/lib/esm/partitionArray.js +39 -39
  220. package/lib/esm/partitionArray.js.map +1 -1
  221. package/package.json +3 -3
package/lib/esm/Time.d.ts CHANGED
@@ -1,123 +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 in milliseconds. */
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
- }
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 in milliseconds. */
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
123
  //# sourceMappingURL=Time.d.ts.map
package/lib/esm/Time.js CHANGED
@@ -1,147 +1,147 @@
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 in milliseconds. */
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() {
136
- this.reset();
137
- this._start = BeTimePoint.now();
138
- }
139
- /** Stop the stopwatch so that the duration can be viewed later. */
140
- stop() {
141
- this._stop = BeTimePoint.now();
142
- return this.elapsed;
143
- }
144
- /** Clear the StopWatch */
145
- reset() { this._start = this._stop = undefined; }
146
- }
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 in milliseconds. */
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() {
136
+ this.reset();
137
+ this._start = BeTimePoint.now();
138
+ }
139
+ /** Stop the stopwatch so that the duration can be viewed later. */
140
+ stop() {
141
+ this._stop = BeTimePoint.now();
142
+ return this.elapsed;
143
+ }
144
+ /** Clear the StopWatch */
145
+ reset() { this._start = this._stop = undefined; }
146
+ }
147
147
  //# sourceMappingURL=Time.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Time.js","sourceRoot":"","sources":["../../src/Time.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH;;;GAGG;AACH,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,IAAW,OAAO,KAAiB,OAAO,UAAU,CAAC,gBAAgB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzJ,0EAA0E;IAC1E,IAAW,cAAc,KAAa,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACpE,qFAAqF;IACrF,IAAW,OAAO,KAAiB,OAAO,UAAU,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpM,mFAAmF;IACnF,IAAW,cAAc,KAAa,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAUpE,yFAAyF;IAClF,KAAK;QACV,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAClC,CAAC;IAED,mEAAmE;IAC5D,IAAI;QACT,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,0BAA0B;IACnB,KAAK,KAAW,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC;CAC/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 in milliseconds. */\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) {\n if (startImmediately)\n this.start();\n }\n\n /** Start the stopwatch. Any future time measurements will be based on this new value. */\n public start(): void {\n this.reset();\n this._start = BeTimePoint.now();\n }\n\n /** Stop the stopwatch so that the duration can be viewed later. */\n public stop(): BeDuration {\n this._stop = BeTimePoint.now();\n return this.elapsed;\n }\n\n /** Clear the StopWatch */\n public reset(): void { this._start = this._stop = undefined; }\n}\n"]}
1
+ {"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GAAG,SAAS,CAAC,CAAC,CAAC;CAC/D","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Utils\r\n */\r\n\r\n/** A duration of time. Can be either positive (towards future) or negative (in the past).\r\n * BeDurations are immutable.\r\n * @public\r\n */\r\nexport class BeDuration {\r\n private readonly _milliseconds: number;\r\n private constructor(milliseconds: number = 0) { this._milliseconds = milliseconds; }\r\n\r\n /** The duration in milliseconds */\r\n public get milliseconds() { return this._milliseconds; }\r\n public get seconds() { return this._milliseconds / 1000; }\r\n\r\n /** Create a BeDuration from seconds.\r\n * @param seconds the number of seconds for this BeDuration\r\n */\r\n public static fromSeconds(seconds: number) { return new BeDuration(seconds * 1000); }\r\n /** Create a BeDuration from milliseconds.\r\n * @param milliseconds the number of milliseconds for this BeDuration\r\n */\r\n public static fromMilliseconds(milliseconds: number) { return new BeDuration(milliseconds); }\r\n /** Determine whether this BeDuration is 0 seconds */\r\n public get isZero() { return this._milliseconds === 0; }\r\n /** Determine whether this BeDuration is towards the future */\r\n public get isTowardsFuture(): boolean { return this._milliseconds > 0; }\r\n /** Determine whether this BeDuration is towards the past */\r\n public get isTowardsPast(): boolean { return this._milliseconds < 0; }\r\n /** Subtract a BeDuration from this BeDuration, returning a new BeDuration. */\r\n public minus(other: BeDuration): BeDuration { return new BeDuration(this._milliseconds - other._milliseconds); }\r\n /** Add a BeDuration to this BeDuration, returning a new BeDuration */\r\n public plus(other: BeDuration): BeDuration { return new BeDuration(this._milliseconds + other._milliseconds); }\r\n\r\n /** Utility function to just wait for the specified time\r\n * @param ms Duration in milliseconds to wait\r\n * @return Promise that resolves after the specified wait period\r\n */\r\n public static async wait(ms: number): Promise<void> {\r\n return new Promise<void>((resolve: any) => setTimeout(resolve, ms));\r\n }\r\n\r\n /** Utility function to wait for either the specified time or a promise, whichever resolves first\r\n * @param ms Maximum duration in milliseconds to wait\r\n * @param promise A pending promise to wait for\r\n * @return Promise that resolves after the specified wait period or the provided promise resolves, whichever comes first\r\n */\r\n public static async race<T>(ms: number, promise: PromiseLike<T>): Promise<T | void> {\r\n let timeout: any;\r\n const waitPromise = new Promise<void>((resolve) => {\r\n timeout = setTimeout(resolve, ms);\r\n });\r\n return Promise.race([waitPromise, promise]).finally(() => {\r\n if (timeout)\r\n clearTimeout(timeout);\r\n });\r\n }\r\n\r\n /** Utility function to just wait for the specified time\r\n * @return Promise that resolves after the specified wait period\r\n */\r\n public async wait(): Promise<void> {\r\n return new Promise<void>((resolve: any) => setTimeout(resolve, this._milliseconds));\r\n }\r\n\r\n /** Execute a function after delaying by this duration.\r\n * @param fn the function to execute after the delay\r\n * @param scope An optional object scope to serve as the 'this' pointer when `fn` is invoked.\r\n * @param args optional arguments to `fn`\r\n * @return Promise resolved by `fn`\r\n */\r\n public async executeAfter<T>(fn: (...args: any[]) => T, scope?: any, ...args: any[]): Promise<T> {\r\n return new Promise<T>((resolve: any) => setTimeout(() => resolve(fn.apply(scope, args)), this._milliseconds));\r\n }\r\n}\r\n\r\n/** A specific point in time relative to the current time.\r\n * BeTimePoints are used for timing operations. They are created from a BeDuration relative to the \"now\".\r\n * BeTimePoints are immutable.\r\n * @public\r\n */\r\nexport class BeTimePoint {\r\n private readonly _milliseconds: number;\r\n /** the time in milliseconds, of this BeTimePoint (relative to January 1, 1970 00:00:00 UTC.) */\r\n public get milliseconds() { return this._milliseconds; }\r\n private constructor(milliseconds: number) { this._milliseconds = milliseconds; }\r\n\r\n /** Create a BeTimePoint from Date.now() */\r\n public static now() { return new BeTimePoint(Date.now()); }\r\n\r\n /** Create a BeTimePoint at a specified duration in the future from now\r\n * @param val the duration from now\r\n */\r\n public static fromNow(val: BeDuration) { return new BeTimePoint(Date.now() + val.milliseconds); }\r\n\r\n /** Create a BeTimePoint at a specified duration in the past before now\r\n * @param val the duration before now\r\n */\r\n public static beforeNow(val: BeDuration) { return new BeTimePoint(Date.now() - val.milliseconds); }\r\n\r\n /** Determine whether this BeTimePoint is a time in the future from the time this method is called (it calls now()!) */\r\n public get isInFuture(): boolean { return Date.now() < this._milliseconds; }\r\n\r\n /** Determine whether this BeTimePoint is a time that has already passed before the time this method is called (it calls now()!) */\r\n public get isInPast(): boolean { return Date.now() > this._milliseconds; }\r\n\r\n /** Determine whether this BeTimePoint happens before another one.\r\n * @param other the other BeTimePoint.\r\n */\r\n public before(other: BeTimePoint): boolean { return this._milliseconds < other._milliseconds; }\r\n\r\n /** Determine whether this BeTimePoint happens after another one.\r\n * @param other the other BeTimePoint.\r\n */\r\n public after(other: BeTimePoint): boolean { return this._milliseconds > other._milliseconds; }\r\n\r\n /** Subtract a BeDuration from this BeTimePoint, returning a new BeTimePoint. This moves this BeTimePoint backwards in time if BeDuration.isTowardsFuture() === true\r\n * @param duration the duration to subtract.\r\n */\r\n public minus(duration: BeDuration): BeTimePoint { return new BeTimePoint(this._milliseconds - duration.milliseconds); }\r\n\r\n /** Subtract a BeDuration from this BeTimePoint, returning a new BeTimePoint. This moves this BeTimePoint backwards in time if BeDuration.isTowardsFuture() === true\r\n * @param duration the duration to subtract.\r\n */\r\n public plus(duration: BeDuration) { return new BeTimePoint(this._milliseconds + duration.milliseconds); }\r\n}\r\n\r\n/** A StopWatch for timing operations.\r\n * @public\r\n */\r\nexport class StopWatch {\r\n private _start?: BeTimePoint;\r\n private _stop?: BeTimePoint;\r\n /** Get the elapsed time since start() on a running timer. */\r\n public get current(): BeDuration { return BeDuration.fromMilliseconds(BeTimePoint.now().milliseconds - (!!this._start ? this._start.milliseconds : 0)); }\r\n /** Get the elapsed time, in seconds, since start() on a running timer. */\r\n public get currentSeconds(): number { return this.current.seconds; }\r\n /** Get the elapsed time between start() and stop() on this timer in milliseconds. */\r\n public get elapsed(): BeDuration { return BeDuration.fromMilliseconds((!!this._stop ? this._stop.milliseconds : BeTimePoint.now().milliseconds) - (!!this._start ? this._start.milliseconds : 0)); }\r\n /** Get the elapsed time, in seconds, between start() and stop() on this timer. */\r\n public get elapsedSeconds(): number { return this.elapsed.seconds; }\r\n /** ctor for StopWatch\r\n * @param description optional string stored with the StopWatch\r\n * @param startImmediately if true, StopWatch is started when created. Otherwise, call start() explicitly.\r\n */\r\n constructor(public description?: string, startImmediately = false) {\r\n if (startImmediately)\r\n this.start();\r\n }\r\n\r\n /** Start the stopwatch. Any future time measurements will be based on this new value. */\r\n public start(): void {\r\n this.reset();\r\n this._start = BeTimePoint.now();\r\n }\r\n\r\n /** Stop the stopwatch so that the duration can be viewed later. */\r\n public stop(): BeDuration {\r\n this._stop = BeTimePoint.now();\r\n return this.elapsed;\r\n }\r\n\r\n /** Clear the StopWatch */\r\n public reset(): void { this._start = this._stop = undefined; }\r\n}\r\n"]}