@itwin/core-bentley 4.0.0-dev.8 → 4.0.0-dev.81

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 (254) hide show
  1. package/CHANGELOG.md +50 -1
  2. package/lib/cjs/AccessToken.d.ts +10 -10
  3. package/lib/cjs/AccessToken.d.ts.map +1 -1
  4. package/lib/cjs/AccessToken.js +9 -9
  5. package/lib/cjs/AccessToken.js.map +1 -1
  6. package/lib/cjs/Assert.d.ts +25 -25
  7. package/lib/cjs/Assert.js +45 -45
  8. package/lib/cjs/Assert.js.map +1 -1
  9. package/lib/cjs/BeEvent.d.ts +81 -81
  10. package/lib/cjs/BeEvent.d.ts.map +1 -1
  11. package/lib/cjs/BeEvent.js +156 -156
  12. package/lib/cjs/BeEvent.js.map +1 -1
  13. package/lib/cjs/BeSQLite.d.ts +172 -170
  14. package/lib/cjs/BeSQLite.d.ts.map +1 -1
  15. package/lib/cjs/BeSQLite.js +185 -183
  16. package/lib/cjs/BeSQLite.js.map +1 -1
  17. package/lib/cjs/BentleyError.d.ts +378 -378
  18. package/lib/cjs/BentleyError.d.ts.map +1 -1
  19. package/lib/cjs/BentleyError.js +703 -702
  20. package/lib/cjs/BentleyError.js.map +1 -1
  21. package/lib/cjs/BentleyLoggerCategory.d.ts +11 -11
  22. package/lib/cjs/BentleyLoggerCategory.js +19 -19
  23. package/lib/cjs/BentleyLoggerCategory.js.map +1 -1
  24. package/lib/cjs/ByteStream.d.ts +110 -110
  25. package/lib/cjs/ByteStream.js +159 -159
  26. package/lib/cjs/ByteStream.js.map +1 -1
  27. package/lib/cjs/ClassUtils.d.ts +14 -14
  28. package/lib/cjs/ClassUtils.js +27 -27
  29. package/lib/cjs/ClassUtils.js.map +1 -1
  30. package/lib/cjs/Compare.d.ts +47 -47
  31. package/lib/cjs/Compare.d.ts.map +1 -1
  32. package/lib/cjs/Compare.js +75 -75
  33. package/lib/cjs/Compare.js.map +1 -1
  34. package/lib/cjs/CompressedId64Set.d.ts +134 -134
  35. package/lib/cjs/CompressedId64Set.d.ts.map +1 -1
  36. package/lib/cjs/CompressedId64Set.js +428 -428
  37. package/lib/cjs/CompressedId64Set.js.map +1 -1
  38. package/lib/cjs/Dictionary.d.ts +125 -125
  39. package/lib/cjs/Dictionary.js +203 -203
  40. package/lib/cjs/Dictionary.js.map +1 -1
  41. package/lib/cjs/Disposable.d.ts +80 -80
  42. package/lib/cjs/Disposable.d.ts.map +1 -1
  43. package/lib/cjs/Disposable.js +120 -120
  44. package/lib/cjs/Disposable.js.map +1 -1
  45. package/lib/cjs/Id.d.ts +285 -285
  46. package/lib/cjs/Id.d.ts.map +1 -1
  47. package/lib/cjs/Id.js +643 -643
  48. package/lib/cjs/Id.js.map +1 -1
  49. package/lib/cjs/IndexMap.d.ts +65 -65
  50. package/lib/cjs/IndexMap.js +91 -91
  51. package/lib/cjs/IndexMap.js.map +1 -1
  52. package/lib/cjs/JsonSchema.d.ts +77 -77
  53. package/lib/cjs/JsonSchema.d.ts.map +1 -1
  54. package/lib/cjs/JsonSchema.js +9 -9
  55. package/lib/cjs/JsonSchema.js.map +1 -1
  56. package/lib/cjs/JsonUtils.d.ts +78 -78
  57. package/lib/cjs/JsonUtils.js +151 -151
  58. package/lib/cjs/JsonUtils.js.map +1 -1
  59. package/lib/cjs/LRUMap.d.ts +129 -129
  60. package/lib/cjs/LRUMap.js +333 -333
  61. package/lib/cjs/LRUMap.js.map +1 -1
  62. package/lib/cjs/Logger.d.ts +143 -143
  63. package/lib/cjs/Logger.d.ts.map +1 -1
  64. package/lib/cjs/Logger.js +256 -258
  65. package/lib/cjs/Logger.js.map +1 -1
  66. package/lib/cjs/ObservableSet.d.ts +23 -23
  67. package/lib/cjs/ObservableSet.js +51 -51
  68. package/lib/cjs/ObservableSet.js.map +1 -1
  69. package/lib/cjs/OneAtATimeAction.d.ts +31 -31
  70. package/lib/cjs/OneAtATimeAction.js +94 -94
  71. package/lib/cjs/OneAtATimeAction.js.map +1 -1
  72. package/lib/cjs/OrderedId64Iterable.d.ts +74 -74
  73. package/lib/cjs/OrderedId64Iterable.d.ts.map +1 -1
  74. package/lib/cjs/OrderedId64Iterable.js +235 -235
  75. package/lib/cjs/OrderedId64Iterable.js.map +1 -1
  76. package/lib/cjs/OrderedSet.d.ts +40 -40
  77. package/lib/cjs/OrderedSet.js +64 -64
  78. package/lib/cjs/OrderedSet.js.map +1 -1
  79. package/lib/cjs/PriorityQueue.d.ts +70 -70
  80. package/lib/cjs/PriorityQueue.d.ts.map +1 -1
  81. package/lib/cjs/PriorityQueue.js +140 -140
  82. package/lib/cjs/PriorityQueue.js.map +1 -1
  83. package/lib/cjs/ProcessDetector.d.ts +59 -59
  84. package/lib/cjs/ProcessDetector.js +71 -71
  85. package/lib/cjs/ProcessDetector.js.map +1 -1
  86. package/lib/cjs/SortedArray.d.ts +236 -232
  87. package/lib/cjs/SortedArray.d.ts.map +1 -1
  88. package/lib/cjs/SortedArray.js +315 -303
  89. package/lib/cjs/SortedArray.js.map +1 -1
  90. package/lib/cjs/StatusCategory.d.ts +30 -30
  91. package/lib/cjs/StatusCategory.d.ts.map +1 -1
  92. package/lib/cjs/StatusCategory.js +460 -460
  93. package/lib/cjs/StatusCategory.js.map +1 -1
  94. package/lib/cjs/StringUtils.d.ts +22 -22
  95. package/lib/cjs/StringUtils.js +148 -148
  96. package/lib/cjs/StringUtils.js.map +1 -1
  97. package/lib/cjs/Time.d.ts +122 -122
  98. package/lib/cjs/Time.js +152 -152
  99. package/lib/cjs/Time.js.map +1 -1
  100. package/lib/cjs/Tracing.d.ts +43 -40
  101. package/lib/cjs/Tracing.d.ts.map +1 -1
  102. package/lib/cjs/Tracing.js +134 -130
  103. package/lib/cjs/Tracing.js.map +1 -1
  104. package/lib/cjs/TupleKeyedMap.d.ts +36 -36
  105. package/lib/cjs/TupleKeyedMap.js +102 -102
  106. package/lib/cjs/TupleKeyedMap.js.map +1 -1
  107. package/lib/cjs/TypedArrayBuilder.d.ts +155 -155
  108. package/lib/cjs/TypedArrayBuilder.d.ts.map +1 -1
  109. package/lib/cjs/TypedArrayBuilder.js +206 -208
  110. package/lib/cjs/TypedArrayBuilder.js.map +1 -1
  111. package/lib/cjs/UnexpectedErrors.d.ts +43 -43
  112. package/lib/cjs/UnexpectedErrors.d.ts.map +1 -1
  113. package/lib/cjs/UnexpectedErrors.js +68 -68
  114. package/lib/cjs/UnexpectedErrors.js.map +1 -1
  115. package/lib/cjs/UtilityTypes.d.ts +112 -96
  116. package/lib/cjs/UtilityTypes.d.ts.map +1 -1
  117. package/lib/cjs/UtilityTypes.js +40 -40
  118. package/lib/cjs/UtilityTypes.js.map +1 -1
  119. package/lib/cjs/YieldManager.d.ts +18 -18
  120. package/lib/cjs/YieldManager.js +34 -34
  121. package/lib/cjs/YieldManager.js.map +1 -1
  122. package/lib/cjs/core-bentley.d.ts +74 -74
  123. package/lib/cjs/core-bentley.js +94 -90
  124. package/lib/cjs/core-bentley.js.map +1 -1
  125. package/lib/cjs/partitionArray.d.ts +21 -21
  126. package/lib/cjs/partitionArray.js +43 -43
  127. package/lib/cjs/partitionArray.js.map +1 -1
  128. package/lib/esm/AccessToken.d.ts +10 -10
  129. package/lib/esm/AccessToken.d.ts.map +1 -1
  130. package/lib/esm/AccessToken.js +8 -8
  131. package/lib/esm/AccessToken.js.map +1 -1
  132. package/lib/esm/Assert.d.ts +25 -25
  133. package/lib/esm/Assert.js +41 -41
  134. package/lib/esm/Assert.js.map +1 -1
  135. package/lib/esm/BeEvent.d.ts +81 -81
  136. package/lib/esm/BeEvent.d.ts.map +1 -1
  137. package/lib/esm/BeEvent.js +150 -150
  138. package/lib/esm/BeEvent.js.map +1 -1
  139. package/lib/esm/BeSQLite.d.ts +172 -170
  140. package/lib/esm/BeSQLite.d.ts.map +1 -1
  141. package/lib/esm/BeSQLite.js +182 -180
  142. package/lib/esm/BeSQLite.js.map +1 -1
  143. package/lib/esm/BentleyError.d.ts +378 -378
  144. package/lib/esm/BentleyError.d.ts.map +1 -1
  145. package/lib/esm/BentleyError.js +699 -698
  146. package/lib/esm/BentleyError.js.map +1 -1
  147. package/lib/esm/BentleyLoggerCategory.d.ts +11 -11
  148. package/lib/esm/BentleyLoggerCategory.js +16 -16
  149. package/lib/esm/BentleyLoggerCategory.js.map +1 -1
  150. package/lib/esm/ByteStream.d.ts +110 -110
  151. package/lib/esm/ByteStream.js +155 -155
  152. package/lib/esm/ByteStream.js.map +1 -1
  153. package/lib/esm/ClassUtils.d.ts +14 -14
  154. package/lib/esm/ClassUtils.js +22 -22
  155. package/lib/esm/ClassUtils.js.map +1 -1
  156. package/lib/esm/Compare.d.ts +47 -47
  157. package/lib/esm/Compare.d.ts.map +1 -1
  158. package/lib/esm/Compare.js +63 -63
  159. package/lib/esm/Compare.js.map +1 -1
  160. package/lib/esm/CompressedId64Set.d.ts +134 -134
  161. package/lib/esm/CompressedId64Set.d.ts.map +1 -1
  162. package/lib/esm/CompressedId64Set.js +423 -423
  163. package/lib/esm/CompressedId64Set.js.map +1 -1
  164. package/lib/esm/Dictionary.d.ts +125 -125
  165. package/lib/esm/Dictionary.js +199 -199
  166. package/lib/esm/Dictionary.js.map +1 -1
  167. package/lib/esm/Disposable.d.ts +80 -80
  168. package/lib/esm/Disposable.d.ts.map +1 -1
  169. package/lib/esm/Disposable.js +112 -112
  170. package/lib/esm/Disposable.js.map +1 -1
  171. package/lib/esm/Id.d.ts +285 -285
  172. package/lib/esm/Id.d.ts.map +1 -1
  173. package/lib/esm/Id.js +639 -639
  174. package/lib/esm/Id.js.map +1 -1
  175. package/lib/esm/IndexMap.d.ts +65 -65
  176. package/lib/esm/IndexMap.js +86 -86
  177. package/lib/esm/IndexMap.js.map +1 -1
  178. package/lib/esm/JsonSchema.d.ts +77 -77
  179. package/lib/esm/JsonSchema.d.ts.map +1 -1
  180. package/lib/esm/JsonSchema.js +8 -8
  181. package/lib/esm/JsonSchema.js.map +1 -1
  182. package/lib/esm/JsonUtils.d.ts +78 -78
  183. package/lib/esm/JsonUtils.js +148 -148
  184. package/lib/esm/JsonUtils.js.map +1 -1
  185. package/lib/esm/LRUMap.d.ts +129 -129
  186. package/lib/esm/LRUMap.js +326 -326
  187. package/lib/esm/LRUMap.js.map +1 -1
  188. package/lib/esm/Logger.d.ts +143 -143
  189. package/lib/esm/Logger.d.ts.map +1 -1
  190. package/lib/esm/Logger.js +253 -253
  191. package/lib/esm/Logger.js.map +1 -1
  192. package/lib/esm/ObservableSet.d.ts +23 -23
  193. package/lib/esm/ObservableSet.js +47 -47
  194. package/lib/esm/ObservableSet.js.map +1 -1
  195. package/lib/esm/OneAtATimeAction.d.ts +31 -31
  196. package/lib/esm/OneAtATimeAction.js +89 -89
  197. package/lib/esm/OneAtATimeAction.js.map +1 -1
  198. package/lib/esm/OrderedId64Iterable.d.ts +74 -74
  199. package/lib/esm/OrderedId64Iterable.d.ts.map +1 -1
  200. package/lib/esm/OrderedId64Iterable.js +232 -232
  201. package/lib/esm/OrderedId64Iterable.js.map +1 -1
  202. package/lib/esm/OrderedSet.d.ts +40 -40
  203. package/lib/esm/OrderedSet.js +59 -59
  204. package/lib/esm/OrderedSet.js.map +1 -1
  205. package/lib/esm/PriorityQueue.d.ts +70 -70
  206. package/lib/esm/PriorityQueue.d.ts.map +1 -1
  207. package/lib/esm/PriorityQueue.js +136 -136
  208. package/lib/esm/PriorityQueue.js.map +1 -1
  209. package/lib/esm/ProcessDetector.d.ts +59 -59
  210. package/lib/esm/ProcessDetector.js +67 -67
  211. package/lib/esm/ProcessDetector.js.map +1 -1
  212. package/lib/esm/SortedArray.d.ts +236 -232
  213. package/lib/esm/SortedArray.d.ts.map +1 -1
  214. package/lib/esm/SortedArray.js +308 -296
  215. package/lib/esm/SortedArray.js.map +1 -1
  216. package/lib/esm/StatusCategory.d.ts +30 -30
  217. package/lib/esm/StatusCategory.d.ts.map +1 -1
  218. package/lib/esm/StatusCategory.js +455 -454
  219. package/lib/esm/StatusCategory.js.map +1 -1
  220. package/lib/esm/StringUtils.d.ts +22 -22
  221. package/lib/esm/StringUtils.js +142 -142
  222. package/lib/esm/StringUtils.js.map +1 -1
  223. package/lib/esm/Time.d.ts +122 -122
  224. package/lib/esm/Time.js +146 -146
  225. package/lib/esm/Time.js.map +1 -1
  226. package/lib/esm/Tracing.d.ts +43 -40
  227. package/lib/esm/Tracing.d.ts.map +1 -1
  228. package/lib/esm/Tracing.js +130 -126
  229. package/lib/esm/Tracing.js.map +1 -1
  230. package/lib/esm/TupleKeyedMap.d.ts +36 -36
  231. package/lib/esm/TupleKeyedMap.js +98 -98
  232. package/lib/esm/TupleKeyedMap.js.map +1 -1
  233. package/lib/esm/TypedArrayBuilder.d.ts +155 -155
  234. package/lib/esm/TypedArrayBuilder.d.ts.map +1 -1
  235. package/lib/esm/TypedArrayBuilder.js +198 -200
  236. package/lib/esm/TypedArrayBuilder.js.map +1 -1
  237. package/lib/esm/UnexpectedErrors.d.ts +43 -43
  238. package/lib/esm/UnexpectedErrors.d.ts.map +1 -1
  239. package/lib/esm/UnexpectedErrors.js +65 -64
  240. package/lib/esm/UnexpectedErrors.js.map +1 -1
  241. package/lib/esm/UtilityTypes.d.ts +112 -96
  242. package/lib/esm/UtilityTypes.d.ts.map +1 -1
  243. package/lib/esm/UtilityTypes.js +34 -34
  244. package/lib/esm/UtilityTypes.js.map +1 -1
  245. package/lib/esm/YieldManager.d.ts +18 -18
  246. package/lib/esm/YieldManager.js +30 -30
  247. package/lib/esm/YieldManager.js.map +1 -1
  248. package/lib/esm/core-bentley.d.ts +74 -74
  249. package/lib/esm/core-bentley.js +78 -78
  250. package/lib/esm/core-bentley.js.map +1 -1
  251. package/lib/esm/partitionArray.d.ts +21 -21
  252. package/lib/esm/partitionArray.js +39 -39
  253. package/lib/esm/partitionArray.js.map +1 -1
  254. package/package.json +9 -9
@@ -1,69 +1,69 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module Errors
8
- */
9
- var _a;
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.UnexpectedErrors = void 0;
12
- const Logger_1 = require("./Logger");
13
- /**
14
- * Utility for handling/reporting unexpected runtime errors. This class establishes a global handler for
15
- * unexpected errors, and programmers should use its `handle` method when they occur. Generally, unexpected
16
- * errors should not cause program termination, and should instead be logged and swallowed. However, for
17
- * development/debugging, it can be helpful to re-throw exceptions so they are not missed.
18
- * @public
19
- */
20
- class UnexpectedErrors {
21
- constructor() { } // this is a singleton
22
- /** Add a "telemetry tracker" for unexpected errors. Useful for tracking/reporting errors without changing handler.
23
- * @returns a method to remove the tracker
24
- */
25
- static addTelemetry(tracker) {
26
- this._telemetry.push(tracker);
27
- return () => this._telemetry.splice(this._telemetry.indexOf(tracker), 1);
28
- }
29
- /** call this method when an unexpected error happens so the global handler can process it.
30
- * @param error the unexpected error
31
- * @param notifyTelemetry if false, don't notify telemetry trackers. Use this for exceptions from third-party code, for example.
32
- */
33
- static handle(error, notifyTelemetry = true) {
34
- this._handler(error);
35
- if (notifyTelemetry) {
36
- this._telemetry.forEach((telemetry) => {
37
- try {
38
- telemetry(error);
39
- }
40
- catch (_) {
41
- // ignore errors from telemetry trackers
42
- }
43
- });
44
- }
45
- }
46
- /** establish a new global *unexpected error* handler.
47
- * @param handler the new global handler. You may provide your own function or use one of the static members of this class.
48
- * The default is [[errorLog]].
49
- * @returns the previous handler. Useful to temporarily change the handler.
50
- */
51
- static setHandler(handler) {
52
- const oldHandler = this._handler;
53
- this._handler = handler;
54
- return oldHandler;
55
- }
56
- }
57
- exports.UnexpectedErrors = UnexpectedErrors;
58
- _a = UnexpectedErrors;
59
- /** handler for re-throwing exceptions directly */
60
- UnexpectedErrors.reThrowImmediate = (e) => { throw e; };
61
- /** handler for re-throwing exceptions from an asynchronous interval (so the current call stack is not aborted) */
62
- UnexpectedErrors.reThrowDeferred = (e) => setTimeout(() => { throw e; }, 0);
63
- /** handler for logging exception to console */
64
- UnexpectedErrors.consoleLog = (e) => console.error(e); // eslint-disable-line no-console
65
- /** handler for logging exception with [[Logger]] */
66
- UnexpectedErrors.errorLog = (e) => Logger_1.Logger.logException("unhandled", e);
67
- UnexpectedErrors._telemetry = [];
68
- UnexpectedErrors._handler = _a.errorLog; // default to error logging
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Errors
8
+ */
9
+ var _a;
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.UnexpectedErrors = void 0;
12
+ const Logger_1 = require("./Logger");
13
+ /**
14
+ * Utility for handling/reporting unexpected runtime errors. This class establishes a global handler for
15
+ * unexpected errors, and programmers should use its `handle` method when they occur. Generally, unexpected
16
+ * errors should not cause program termination, and should instead be logged and swallowed. However, for
17
+ * development/debugging, it can be helpful to re-throw exceptions so they are not missed.
18
+ * @public
19
+ */
20
+ class UnexpectedErrors {
21
+ constructor() { } // this is a singleton
22
+ /** Add a "telemetry tracker" for unexpected errors. Useful for tracking/reporting errors without changing handler.
23
+ * @returns a method to remove the tracker
24
+ */
25
+ static addTelemetry(tracker) {
26
+ this._telemetry.push(tracker);
27
+ return () => this._telemetry.splice(this._telemetry.indexOf(tracker), 1);
28
+ }
29
+ /** call this method when an unexpected error happens so the global handler can process it.
30
+ * @param error the unexpected error
31
+ * @param notifyTelemetry if false, don't notify telemetry trackers. Use this for exceptions from third-party code, for example.
32
+ */
33
+ static handle(error, notifyTelemetry = true) {
34
+ this._handler(error);
35
+ if (notifyTelemetry) {
36
+ this._telemetry.forEach((telemetry) => {
37
+ try {
38
+ telemetry(error);
39
+ }
40
+ catch (_) {
41
+ // ignore errors from telemetry trackers
42
+ }
43
+ });
44
+ }
45
+ }
46
+ /** establish a new global *unexpected error* handler.
47
+ * @param handler the new global handler. You may provide your own function or use one of the static members of this class.
48
+ * The default is [[errorLog]].
49
+ * @returns the previous handler. Useful to temporarily change the handler.
50
+ */
51
+ static setHandler(handler) {
52
+ const oldHandler = this._handler;
53
+ this._handler = handler;
54
+ return oldHandler;
55
+ }
56
+ }
57
+ _a = UnexpectedErrors;
58
+ /** handler for re-throwing exceptions directly */
59
+ UnexpectedErrors.reThrowImmediate = (e) => { throw e; };
60
+ /** handler for re-throwing exceptions from an asynchronous interval (so the current call stack is not aborted) */
61
+ UnexpectedErrors.reThrowDeferred = (e) => setTimeout(() => { throw e; }, 0);
62
+ /** handler for logging exception to console */
63
+ UnexpectedErrors.consoleLog = (e) => console.error(e); // eslint-disable-line no-console
64
+ /** handler for logging exception with [[Logger]] */
65
+ UnexpectedErrors.errorLog = (e) => Logger_1.Logger.logException("unhandled", e);
66
+ UnexpectedErrors._telemetry = [];
67
+ UnexpectedErrors._handler = _a.errorLog; // default to error logging
68
+ exports.UnexpectedErrors = UnexpectedErrors;
69
69
  //# sourceMappingURL=UnexpectedErrors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UnexpectedErrors.js","sourceRoot":"","sources":["../../src/UnexpectedErrors.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,qCAAkC;AAOlC;;;;;;GAMG;AACH,MAAa,gBAAgB;IAY3B,gBAAwB,CAAC,CAAC,sBAAsB;IAEhD;;OAEG;IACI,MAAM,CAAC,YAAY,CAAC,OAA0B;QACnD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,MAAM,CAAC,KAAU,EAAE,eAAe,GAAG,IAAI;QACrD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrB,IAAI,eAAe,EAAE;YACnB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;gBACpC,IAAI;oBACF,SAAS,CAAC,KAAK,CAAC,CAAC;iBAClB;gBAAC,OAAO,CAAC,EAAE;oBACV,wCAAwC;iBACzC;YACH,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,OAA0B;QACjD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,OAAO,UAAU,CAAC;IACpB,CAAC;;AAhDH,4CAiDC;;AAhDC,kDAAkD;AAC3B,iCAAgB,GAAG,CAAC,CAAM,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAE,CAAA;AACnE,kHAAkH;AAC3F,gCAAe,GAAG,CAAC,CAAM,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAE,CAAA;AACvF,+CAA+C;AACxB,2BAAU,GAAG,CAAC,CAAM,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAE,CAAA,CAAC,iCAAiC;AACnG,oDAAoD;AAC7B,yBAAQ,GAAG,CAAC,CAAM,EAAE,EAAE,CAAC,eAAM,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAE,CAAA;AAEnE,2BAAU,GAAwB,EAAG,CAAA;AACrC,yBAAQ,GAAG,EAAI,CAAC,QAAS,CAAA,CAAC,2BAA2B","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 Errors\r\n */\r\n\r\nimport { Logger } from \"./Logger\";\r\n\r\n/** A function to be notified when an unexpected error happens\r\n * @public\r\n */\r\nexport type OnUnexpectedError = (error: any) => void;\r\n\r\n/**\r\n * Utility for handling/reporting unexpected runtime errors. This class establishes a global handler for\r\n * unexpected errors, and programmers should use its `handle` method when they occur. Generally, unexpected\r\n * errors should not cause program termination, and should instead be logged and swallowed. However, for\r\n * development/debugging, it can be helpful to re-throw exceptions so they are not missed.\r\n * @public\r\n */\r\nexport class UnexpectedErrors {\r\n /** handler for re-throwing exceptions directly */\r\n public static readonly reThrowImmediate = (e: any) => { throw e; };\r\n /** handler for re-throwing exceptions from an asynchronous interval (so the current call stack is not aborted) */\r\n public static readonly reThrowDeferred = (e: any) => setTimeout(() => { throw e; }, 0);\r\n /** handler for logging exception to console */\r\n public static readonly consoleLog = (e: any) => console.error(e); // eslint-disable-line no-console\r\n /** handler for logging exception with [[Logger]] */\r\n public static readonly errorLog = (e: any) => Logger.logException(\"unhandled\", e);\r\n\r\n private static _telemetry: OnUnexpectedError[] = [];\r\n private static _handler = this.errorLog; // default to error logging\r\n private constructor() { } // this is a singleton\r\n\r\n /** Add a \"telemetry tracker\" for unexpected errors. Useful for tracking/reporting errors without changing handler.\r\n * @returns a method to remove the tracker\r\n */\r\n public static addTelemetry(tracker: OnUnexpectedError): () => void {\r\n this._telemetry.push(tracker);\r\n return () => this._telemetry.splice(this._telemetry.indexOf(tracker), 1);\r\n }\r\n\r\n /** call this method when an unexpected error happens so the global handler can process it.\r\n * @param error the unexpected error\r\n * @param notifyTelemetry if false, don't notify telemetry trackers. Use this for exceptions from third-party code, for example.\r\n */\r\n public static handle(error: any, notifyTelemetry = true): void {\r\n this._handler(error);\r\n if (notifyTelemetry) {\r\n this._telemetry.forEach((telemetry) => {\r\n try {\r\n telemetry(error);\r\n } catch (_) {\r\n // ignore errors from telemetry trackers\r\n }\r\n });\r\n }\r\n }\r\n\r\n /** establish a new global *unexpected error* handler.\r\n * @param handler the new global handler. You may provide your own function or use one of the static members of this class.\r\n * The default is [[errorLog]].\r\n * @returns the previous handler. Useful to temporarily change the handler.\r\n */\r\n public static setHandler(handler: OnUnexpectedError): OnUnexpectedError {\r\n const oldHandler = this._handler;\r\n this._handler = handler;\r\n return oldHandler;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"UnexpectedErrors.js","sourceRoot":"","sources":["../../src/UnexpectedErrors.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;AAEH,qCAAkC;AAOlC;;;;;;GAMG;AACH,MAAa,gBAAgB;IAY3B,gBAAwB,CAAC,CAAC,sBAAsB;IAEhD;;OAEG;IACI,MAAM,CAAC,YAAY,CAAC,OAA0B;QACnD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,MAAM,CAAC,KAAU,EAAE,eAAe,GAAG,IAAI;QACrD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrB,IAAI,eAAe,EAAE;YACnB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;gBACpC,IAAI;oBACF,SAAS,CAAC,KAAK,CAAC,CAAC;iBAClB;gBAAC,OAAO,CAAC,EAAE;oBACV,wCAAwC;iBACzC;YACH,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,OAA0B;QACjD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,OAAO,UAAU,CAAC;IACpB,CAAC;;;AA/CD,kDAAkD;AAC3B,iCAAgB,GAAG,CAAC,CAAM,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,AAA3B,CAA4B;AACnE,kHAAkH;AAC3F,gCAAe,GAAG,CAAC,CAAM,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,AAAhD,CAAiD;AACvF,+CAA+C;AACxB,2BAAU,GAAG,CAAC,CAAM,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,AAA/B,CAAgC,CAAC,iCAAiC;AACnG,oDAAoD;AAC7B,yBAAQ,GAAG,CAAC,CAAM,EAAE,EAAE,CAAC,eAAM,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC,AAAlD,CAAmD;AAEnE,2BAAU,GAAwB,EAAE,AAA1B,CAA2B;AACrC,yBAAQ,GAAG,EAAI,CAAC,QAAQ,AAAhB,CAAiB,CAAC,2BAA2B;AAXzD,4CAAgB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Errors\n */\n\nimport { Logger } from \"./Logger\";\n\n/** A function to be notified when an unexpected error happens\n * @public\n */\nexport type OnUnexpectedError = (error: any) => void;\n\n/**\n * Utility for handling/reporting unexpected runtime errors. This class establishes a global handler for\n * unexpected errors, and programmers should use its `handle` method when they occur. Generally, unexpected\n * errors should not cause program termination, and should instead be logged and swallowed. However, for\n * development/debugging, it can be helpful to re-throw exceptions so they are not missed.\n * @public\n */\nexport class UnexpectedErrors {\n /** handler for re-throwing exceptions directly */\n public static readonly reThrowImmediate = (e: any) => { throw e; };\n /** handler for re-throwing exceptions from an asynchronous interval (so the current call stack is not aborted) */\n public static readonly reThrowDeferred = (e: any) => setTimeout(() => { throw e; }, 0);\n /** handler for logging exception to console */\n public static readonly consoleLog = (e: any) => console.error(e); // eslint-disable-line no-console\n /** handler for logging exception with [[Logger]] */\n public static readonly errorLog = (e: any) => Logger.logException(\"unhandled\", e);\n\n private static _telemetry: OnUnexpectedError[] = [];\n private static _handler = this.errorLog; // default to error logging\n private constructor() { } // this is a singleton\n\n /** Add a \"telemetry tracker\" for unexpected errors. Useful for tracking/reporting errors without changing handler.\n * @returns a method to remove the tracker\n */\n public static addTelemetry(tracker: OnUnexpectedError): () => void {\n this._telemetry.push(tracker);\n return () => this._telemetry.splice(this._telemetry.indexOf(tracker), 1);\n }\n\n /** call this method when an unexpected error happens so the global handler can process it.\n * @param error the unexpected error\n * @param notifyTelemetry if false, don't notify telemetry trackers. Use this for exceptions from third-party code, for example.\n */\n public static handle(error: any, notifyTelemetry = true): void {\n this._handler(error);\n if (notifyTelemetry) {\n this._telemetry.forEach((telemetry) => {\n try {\n telemetry(error);\n } catch (_) {\n // ignore errors from telemetry trackers\n }\n });\n }\n }\n\n /** establish a new global *unexpected error* handler.\n * @param handler the new global handler. You may provide your own function or use one of the static members of this class.\n * The default is [[errorLog]].\n * @returns the previous handler. Useful to temporarily change the handler.\n */\n public static setHandler(handler: OnUnexpectedError): OnUnexpectedError {\n const oldHandler = this._handler;\n this._handler = handler;\n return oldHandler;\n }\n}\n"]}
@@ -1,97 +1,113 @@
1
- /** @packageDocumentation
2
- * @module Utils
3
- */
4
- /** The inverse of TypeScript's Readonly<T> type, producing a type that has all the properties of `T` with any `readonly` modifiers removed.
5
- * @public
6
- */
7
- export declare type Mutable<T> = {
8
- -readonly [K in keyof T]: T[K];
9
- };
10
- /** Make a new type from an existing type `T`, with set of required properties `K` optional.
11
- * @public
12
- */
13
- export declare type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
14
- /** Make a new type from an existing type `T`, with set of optional properties `K` required.
15
- * @public
16
- */
17
- export declare type MarkRequired<T, K extends keyof T> = Pick<Required<T>, K> & Omit<T, K>;
18
- /** Generically represents a class `T`, for use in type annotations.
19
- * @note A variable of type `Constructor<T>` matches a class `T` only if `T` has a **public** constructor.
20
- * @see [[asInstanceOf]] to attempt to cast an arbitrary value to class `T`.
21
- * @see [[isInstanceOf]] to determine if an arbitrary value is an instance of class `T`.
22
- * @public
23
- */
24
- export declare type Constructor<T> = new (...args: any[]) => T;
25
- /** Returns true if `obj` is an object of class `T`.
26
- * @see [[asInstanceOf]] to cast `obj` to class `T`.
27
- * @public
28
- */
29
- export declare function isInstanceOf<T>(obj: any, constructor: Constructor<T>): boolean;
30
- /** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.
31
- * @see [[isInstanceOf]] to query whether `obj` is of class `T`.
32
- * @public
33
- */
34
- export declare function asInstanceOf<T>(obj: any, constructor: Constructor<T>): T | undefined;
35
- /** Extracts the names of all public properties of `T` that are not of type `function`.
36
- * This includes properties defined using `get` syntax. Care should be used when using this type in conjunction with
37
- * the object spread (`...`) operator, because the spread operator omits properties defined using `get` syntax and, therefore,
38
- * so too does the type that TypeScript infers from that operator.
39
- * `get` syntax. For example:
40
- * ```ts
41
- * class Thing {
42
- * private _a = "a"; // a private variable
43
- * public b = "b"; // a public variable
44
- * public get c() { return "c"; } // a public property
45
- * public d() { return "d"; } // a public method
46
- * public e = () => "e"; // a public variable of type `function`
47
- * }
48
- *
49
- * // The following can have the values "b" or "c" - those are the public, non-function properties of Thing.
50
- * let nonFunctionProperty: NonFunctionPropertyNamesOf<Thing> = "c";
51
- *
52
- * // The following produces an error: "Property 'c' is missing in type '{ b: string; e: () => string; }' but required in type 'NonFunctionPropertiesOf<Thing>'"
53
- * const thing1 = new Thing();
54
- * const thing2: NonFunctionPropertiesOf<Thing> = { ...thing1 };
55
- * ```
56
- * @see [[NonFunctionPropertiesOf]] to obtain a type that includes only these properties.
57
- * @public
58
- */
59
- export declare type NonFunctionPropertyNamesOf<T> = {
60
- [K in keyof T]: T[K] extends Function ? never : K;
61
- }[keyof T];
62
- /** Produces a type consisting of all of the public properties of `T` except for those of type `function`.
63
- * @see [[NonFunctionPropertyNamesOf]] for potential pitfalls when used in conjunction with the object spread operator.
64
- * @public
65
- */
66
- export declare type NonFunctionPropertiesOf<T> = Pick<T, NonFunctionPropertyNamesOf<T>>;
67
- /** Any function returning a Promise.
68
- * @see [[AsyncMethodsOf]] to extract all async methods from a type.
69
- * @see [[PromiseReturnType]] to extract the type to which the Promise resolves.
70
- * @public
71
- */
72
- export declare type AsyncFunction = (...args: any) => Promise<any>;
73
- /** The members of `T` that are async functions (functions that return a promise), and no other properties
74
- * @public
75
- */
76
- export declare type PickAsyncMethods<T> = {
77
- [P in keyof T]: T[P] extends AsyncFunction ? T[P] : never;
78
- };
79
- /** Extracts the names of all function properties of `T` that return a Promise.
80
- * @public
81
- */
82
- export declare type AsyncMethodsOf<T> = {
83
- [P in keyof T]: T[P] extends AsyncFunction ? P : never;
84
- }[keyof T];
85
- /** Extracts the type to which the Promise returned by an async function resolves.
86
- * @public
87
- */
88
- export declare type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;
89
- /** A runtime property omitter, makes a shallow copy of the given object without the specified properties
90
- * Compatible with the typescript `Omit` mapped type:
91
- * ```js
92
- * const testvar: Omit<{x: string, y: object}, "y"> = omit({x: "hello", y: {}}, ["y"]);
93
- * ```
94
- * @public
95
- */
96
- export declare function omit<T extends {}, K extends readonly (keyof T)[]>(t: T, keys: K): Omit<T, K[number]>;
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 type Mutable<T> = {
8
+ -readonly [K in keyof T]: T[K];
9
+ };
10
+ /** Make a new type from an existing type `T`, with set of required properties `K` optional.
11
+ * @public
12
+ */
13
+ export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
14
+ /** Make a new type from an existing type `T`, with set of optional properties `K` required.
15
+ * @public
16
+ */
17
+ export type MarkRequired<T, K extends keyof T> = Pick<Required<T>, K> & Omit<T, K>;
18
+ /** Generically represents a class `T`, for use in type annotations.
19
+ * @note A variable of type `Constructor<T>` matches a class `T` only if `T` has a **public** constructor.
20
+ * @see [[asInstanceOf]] to attempt to cast an arbitrary value to class `T`.
21
+ * @see [[isInstanceOf]] to determine if an arbitrary value is an instance of class `T`.
22
+ * @public
23
+ */
24
+ export type Constructor<T> = new (...args: any[]) => T;
25
+ /** Returns true if `obj` is an object of class `T`.
26
+ * @see [[asInstanceOf]] to cast `obj` to class `T`.
27
+ * @public
28
+ */
29
+ export declare function isInstanceOf<T>(obj: any, constructor: Constructor<T>): boolean;
30
+ /** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.
31
+ * @see [[isInstanceOf]] to query whether `obj` is of class `T`.
32
+ * @public
33
+ */
34
+ export declare function asInstanceOf<T>(obj: any, constructor: Constructor<T>): T | undefined;
35
+ /** Extracts the names of all public properties of `T` that are not of type `function`.
36
+ * This includes properties defined using `get` syntax. Care should be used when using this type in conjunction with
37
+ * the object spread (`...`) operator, because the spread operator omits properties defined using `get` syntax and, therefore,
38
+ * so too does the type that TypeScript infers from that operator.
39
+ * `get` syntax. For example:
40
+ * ```ts
41
+ * class Thing {
42
+ * private _a = "a"; // a private variable
43
+ * public b = "b"; // a public variable
44
+ * public get c() { return "c"; } // a public property
45
+ * public d() { return "d"; } // a public method
46
+ * public e = () => "e"; // a public variable of type `function`
47
+ * }
48
+ *
49
+ * // The following can have the values "b" or "c" - those are the public, non-function properties of Thing.
50
+ * let nonFunctionProperty: NonFunctionPropertyNamesOf<Thing> = "c";
51
+ *
52
+ * // The following produces an error: "Property 'c' is missing in type '{ b: string; e: () => string; }' but required in type 'NonFunctionPropertiesOf<Thing>'"
53
+ * const thing1 = new Thing();
54
+ * const thing2: NonFunctionPropertiesOf<Thing> = { ...thing1 };
55
+ * ```
56
+ * @see [[NonFunctionPropertiesOf]] to obtain a type that includes only these properties.
57
+ * @public
58
+ */
59
+ export type NonFunctionPropertyNamesOf<T> = {
60
+ [K in keyof T]: T[K] extends Function ? never : K;
61
+ }[keyof T];
62
+ /** Produces a type consisting of all of the public properties of `T` except for those of type `function`.
63
+ * @see [[NonFunctionPropertyNamesOf]] for potential pitfalls when used in conjunction with the object spread operator.
64
+ * @public
65
+ */
66
+ export type NonFunctionPropertiesOf<T> = Pick<T, NonFunctionPropertyNamesOf<T>>;
67
+ /** Any function returning a Promise.
68
+ * @see [[AsyncMethodsOf]] to extract all async methods from a type.
69
+ * @see [[PromiseReturnType]] to extract the type to which the Promise resolves.
70
+ * @public
71
+ */
72
+ export type AsyncFunction = (...args: any) => Promise<any>;
73
+ /** The members of `T` that are async functions (functions that return a promise), and no other properties
74
+ * @public
75
+ */
76
+ export type PickAsyncMethods<T> = {
77
+ [P in keyof T]: T[P] extends AsyncFunction ? T[P] : never;
78
+ };
79
+ /** Extracts the names of all function properties of `T` that return a Promise.
80
+ * @public
81
+ */
82
+ export type AsyncMethodsOf<T> = {
83
+ [P in keyof T]: T[P] extends AsyncFunction ? P : never;
84
+ }[keyof T];
85
+ /** Extracts the type to which the Promise returned by an async function resolves.
86
+ * @public
87
+ */
88
+ export type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;
89
+ /** A runtime property omitter, makes a shallow copy of the given object without the specified properties
90
+ * Compatible with the typescript `Omit` mapped type:
91
+ * ```js
92
+ * const testvar: Omit<{x: string, y: object}, "y"> = omit({x: "hello", y: {}}, ["y"]);
93
+ * ```
94
+ * @public
95
+ */
96
+ export declare function omit<T extends {}, K extends readonly (keyof T)[]>(t: T, keys: K): Omit<T, K[number]>;
97
+ /** Defines a type wherein at least one of the properties of T is required to exist.
98
+ * In the following example, paying for a coffee requires a customer to have either a credit card, some cash, or both in their wallet.
99
+ * ```ts
100
+ * interface Wallet {
101
+ * cash?: number;
102
+ * card?: CreditCard;
103
+ * }
104
+ *
105
+ * function payForCoffee(wallet: RequireAtLeastOne<Wallet>) { ... }
106
+ * ```
107
+ * Source: [@azure/keyvault-certificates](https://learn.microsoft.com/en-us/javascript/api/@azure/keyvault-certificates/requireatleastone?view=azure-node-latest).
108
+ * @public
109
+ */
110
+ export type RequireAtLeastOne<T> = {
111
+ [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
112
+ }[keyof T];
97
113
  //# sourceMappingURL=UtilityTypes.d.ts.map
@@ -1 +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;;GAEG;AACH,oBAAY,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE9E;;GAEG;AACH,oBAAY,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEnF;;;;;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,gBAAgB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK;CAAG,CAAC;AAEjG;;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;AAEhH;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAKpG"}
1
+ {"version":3,"file":"UtilityTypes.d.ts","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IACvB,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC/B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEnF;;;;;GAKG;AACH,MAAM,MAAM,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,MAAM,MAAM,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,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhF;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,aAAa,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK;CAAG,CAAC;AAEjG;;GAEG;AACH,MAAM,MAAM,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,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,aAAa,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;AAEhH;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAKpG;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;KAChC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CAC/E,CAAC,MAAM,CAAC,CAAC,CAAC"}
@@ -1,41 +1,41 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module Utils
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.omit = exports.asInstanceOf = exports.isInstanceOf = void 0;
11
- /** Returns true if `obj` is an object of class `T`.
12
- * @see [[asInstanceOf]] to cast `obj` to class `T`.
13
- * @public
14
- */
15
- function isInstanceOf(obj, constructor) {
16
- return "object" === typeof obj && obj instanceof constructor;
17
- }
18
- exports.isInstanceOf = isInstanceOf;
19
- /** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.
20
- * @see [[isInstanceOf]] to query whether `obj` is of class `T`.
21
- * @public
22
- */
23
- function asInstanceOf(obj, constructor) {
24
- return isInstanceOf(obj, constructor) ? obj : undefined;
25
- }
26
- exports.asInstanceOf = asInstanceOf;
27
- /** A runtime property omitter, makes a shallow copy of the given object without the specified properties
28
- * Compatible with the typescript `Omit` mapped type:
29
- * ```js
30
- * const testvar: Omit<{x: string, y: object}, "y"> = omit({x: "hello", y: {}}, ["y"]);
31
- * ```
32
- * @public
33
- */
34
- function omit(t, keys) {
35
- const clone = { ...t };
36
- for (const key of keys)
37
- delete clone[key];
38
- return clone;
39
- }
40
- exports.omit = omit;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Utils
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.omit = exports.asInstanceOf = exports.isInstanceOf = void 0;
11
+ /** Returns true if `obj` is an object of class `T`.
12
+ * @see [[asInstanceOf]] to cast `obj` to class `T`.
13
+ * @public
14
+ */
15
+ function isInstanceOf(obj, constructor) {
16
+ return "object" === typeof obj && obj instanceof constructor;
17
+ }
18
+ exports.isInstanceOf = isInstanceOf;
19
+ /** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.
20
+ * @see [[isInstanceOf]] to query whether `obj` is of class `T`.
21
+ * @public
22
+ */
23
+ function asInstanceOf(obj, constructor) {
24
+ return isInstanceOf(obj, constructor) ? obj : undefined;
25
+ }
26
+ exports.asInstanceOf = asInstanceOf;
27
+ /** A runtime property omitter, makes a shallow copy of the given object without the specified properties
28
+ * Compatible with the typescript `Omit` mapped type:
29
+ * ```js
30
+ * const testvar: Omit<{x: string, y: object}, "y"> = omit({x: "hello", y: {}}, ["y"]);
31
+ * ```
32
+ * @public
33
+ */
34
+ function omit(t, keys) {
35
+ const clone = { ...t };
36
+ for (const key of keys)
37
+ delete clone[key];
38
+ return clone;
39
+ }
40
+ exports.omit = omit;
41
41
  //# sourceMappingURL=UtilityTypes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UtilityTypes.js","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA2BH;;;GAGG;AACH,SAAgB,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,QAAQ,KAAK,OAAO,GAAG,IAAI,GAAG,YAAY,WAAW,CAAC;AAC/D,CAAC;AAFD,oCAEC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,YAAY,CAAI,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AAFD,oCAEC;AA0DD;;;;;;GAMG;AACH,SAAgB,IAAI,CAA+C,CAAI,EAAE,IAAO;IAC9E,MAAM,KAAK,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;IACvB,KAAK,MAAM,GAAG,IAAI,IAAI;QACpB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,OAAO,KAAK,CAAC;AACf,CAAC;AALD,oBAKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Utils\r\n */\r\n\r\n/** The inverse of TypeScript's Readonly<T> type, producing a type that has all the properties of `T` with any `readonly` modifiers removed.\r\n * @public\r\n */\r\nexport type Mutable<T> = {\r\n -readonly [K in keyof T]: T[K];\r\n};\r\n\r\n/** Make a new type from an existing type `T`, with set of required properties `K` optional.\r\n * @public\r\n */\r\nexport type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\r\n\r\n/** Make a new type from an existing type `T`, with set of optional properties `K` required.\r\n * @public\r\n */\r\nexport type MarkRequired<T, K extends keyof T> = Pick<Required<T>, K> & Omit<T, K>;\r\n\r\n/** Generically represents a class `T`, for use in type annotations.\r\n * @note A variable of type `Constructor<T>` matches a class `T` only if `T` has a **public** constructor.\r\n * @see [[asInstanceOf]] to attempt to cast an arbitrary value to class `T`.\r\n * @see [[isInstanceOf]] to determine if an arbitrary value is an instance of class `T`.\r\n * @public\r\n */\r\nexport type Constructor<T> = new (...args: any[]) => T;\r\n\r\n/** Returns true if `obj` is an object of class `T`.\r\n * @see [[asInstanceOf]] to cast `obj` to class `T`.\r\n * @public\r\n */\r\nexport function isInstanceOf<T>(obj: any, constructor: Constructor<T>): boolean {\r\n return \"object\" === typeof obj && obj instanceof constructor;\r\n}\r\n\r\n/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.\r\n * @see [[isInstanceOf]] to query whether `obj` is of class `T`.\r\n * @public\r\n */\r\nexport function asInstanceOf<T>(obj: any, constructor: Constructor<T>): T | undefined {\r\n return isInstanceOf<T>(obj, constructor) ? obj as T : undefined;\r\n}\r\n\r\n/** Extracts the names of all public properties of `T` that are not of type `function`.\r\n * This includes properties defined using `get` syntax. Care should be used when using this type in conjunction with\r\n * the object spread (`...`) operator, because the spread operator omits properties defined using `get` syntax and, therefore,\r\n * so too does the type that TypeScript infers from that operator.\r\n * `get` syntax. For example:\r\n * ```ts\r\n * class Thing {\r\n * private _a = \"a\"; // a private variable\r\n * public b = \"b\"; // a public variable\r\n * public get c() { return \"c\"; } // a public property\r\n * public d() { return \"d\"; } // a public method\r\n * public e = () => \"e\"; // a public variable of type `function`\r\n * }\r\n *\r\n * // The following can have the values \"b\" or \"c\" - those are the public, non-function properties of Thing.\r\n * let nonFunctionProperty: NonFunctionPropertyNamesOf<Thing> = \"c\";\r\n *\r\n * // The following produces an error: \"Property 'c' is missing in type '{ b: string; e: () => string; }' but required in type 'NonFunctionPropertiesOf<Thing>'\"\r\n * const thing1 = new Thing();\r\n * const thing2: NonFunctionPropertiesOf<Thing> = { ...thing1 };\r\n * ```\r\n * @see [[NonFunctionPropertiesOf]] to obtain a type that includes only these properties.\r\n * @public\r\n */\r\nexport type NonFunctionPropertyNamesOf<T> = {\r\n [K in keyof T]: T[K] extends Function ? never : K;\r\n}[keyof T];\r\n\r\n/** Produces a type consisting of all of the public properties of `T` except for those of type `function`.\r\n * @see [[NonFunctionPropertyNamesOf]] for potential pitfalls when used in conjunction with the object spread operator.\r\n * @public\r\n */\r\nexport type NonFunctionPropertiesOf<T> = Pick<T, NonFunctionPropertyNamesOf<T>>;\r\n\r\n/** Any function returning a Promise.\r\n * @see [[AsyncMethodsOf]] to extract all async methods from a type.\r\n * @see [[PromiseReturnType]] to extract the type to which the Promise resolves.\r\n * @public\r\n */\r\nexport type AsyncFunction = (...args: any) => Promise<any>;\r\n\r\n/** The members of `T` that are async functions (functions that return a promise), and no other properties\r\n * @public\r\n */\r\nexport type PickAsyncMethods<T> = { [P in keyof T]: T[P] extends AsyncFunction ? T[P] : never; };\r\n\r\n/** Extracts the names of all function properties of `T` that return a Promise.\r\n * @public\r\n */\r\nexport type AsyncMethodsOf<T> = { [P in keyof T]: T[P] extends AsyncFunction ? P : never }[keyof T];\r\n\r\n/** Extracts the type to which the Promise returned by an async function resolves.\r\n * @public\r\n */\r\nexport type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;\r\n\r\n/** A runtime property omitter, makes a shallow copy of the given object without the specified properties\r\n * Compatible with the typescript `Omit` mapped type:\r\n * ```js\r\n * const testvar: Omit<{x: string, y: object}, \"y\"> = omit({x: \"hello\", y: {}}, [\"y\"]);\r\n * ```\r\n * @public\r\n */\r\nexport function omit<T extends {}, K extends readonly (keyof T)[]>(t: T, keys: K): Omit<T, K[number]> {\r\n const clone = { ...t };\r\n for (const key of keys)\r\n delete clone[key];\r\n return clone;\r\n}\r\n"]}
1
+ {"version":3,"file":"UtilityTypes.js","sourceRoot":"","sources":["../../src/UtilityTypes.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA2BH;;;GAGG;AACH,SAAgB,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,QAAQ,KAAK,OAAO,GAAG,IAAI,GAAG,YAAY,WAAW,CAAC;AAC/D,CAAC;AAFD,oCAEC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAI,GAAQ,EAAE,WAA2B;IACnE,OAAO,YAAY,CAAI,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAClE,CAAC;AAFD,oCAEC;AA0DD;;;;;;GAMG;AACH,SAAgB,IAAI,CAA+C,CAAI,EAAE,IAAO;IAC9E,MAAM,KAAK,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;IACvB,KAAK,MAAM,GAAG,IAAI,IAAI;QACpB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,OAAO,KAAK,CAAC;AACf,CAAC;AALD,oBAKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utils\n */\n\n/** The inverse of TypeScript's Readonly<T> type, producing a type that has all the properties of `T` with any `readonly` modifiers removed.\n * @public\n */\nexport type Mutable<T> = {\n -readonly [K in keyof T]: T[K];\n};\n\n/** Make a new type from an existing type `T`, with set of required properties `K` optional.\n * @public\n */\nexport type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\n\n/** Make a new type from an existing type `T`, with set of optional properties `K` required.\n * @public\n */\nexport type MarkRequired<T, K extends keyof T> = Pick<Required<T>, K> & Omit<T, K>;\n\n/** Generically represents a class `T`, for use in type annotations.\n * @note A variable of type `Constructor<T>` matches a class `T` only if `T` has a **public** constructor.\n * @see [[asInstanceOf]] to attempt to cast an arbitrary value to class `T`.\n * @see [[isInstanceOf]] to determine if an arbitrary value is an instance of class `T`.\n * @public\n */\nexport type Constructor<T> = new (...args: any[]) => T;\n\n/** Returns true if `obj` is an object of class `T`.\n * @see [[asInstanceOf]] to cast `obj` to class `T`.\n * @public\n */\nexport function isInstanceOf<T>(obj: any, constructor: Constructor<T>): boolean {\n return \"object\" === typeof obj && obj instanceof constructor;\n}\n\n/** Cast `obj` to an instance of class `T`, or return undefined if `obj` is not an instance of class `T`.\n * @see [[isInstanceOf]] to query whether `obj` is of class `T`.\n * @public\n */\nexport function asInstanceOf<T>(obj: any, constructor: Constructor<T>): T | undefined {\n return isInstanceOf<T>(obj, constructor) ? obj as T : undefined;\n}\n\n/** Extracts the names of all public properties of `T` that are not of type `function`.\n * This includes properties defined using `get` syntax. Care should be used when using this type in conjunction with\n * the object spread (`...`) operator, because the spread operator omits properties defined using `get` syntax and, therefore,\n * so too does the type that TypeScript infers from that operator.\n * `get` syntax. For example:\n * ```ts\n * class Thing {\n * private _a = \"a\"; // a private variable\n * public b = \"b\"; // a public variable\n * public get c() { return \"c\"; } // a public property\n * public d() { return \"d\"; } // a public method\n * public e = () => \"e\"; // a public variable of type `function`\n * }\n *\n * // The following can have the values \"b\" or \"c\" - those are the public, non-function properties of Thing.\n * let nonFunctionProperty: NonFunctionPropertyNamesOf<Thing> = \"c\";\n *\n * // The following produces an error: \"Property 'c' is missing in type '{ b: string; e: () => string; }' but required in type 'NonFunctionPropertiesOf<Thing>'\"\n * const thing1 = new Thing();\n * const thing2: NonFunctionPropertiesOf<Thing> = { ...thing1 };\n * ```\n * @see [[NonFunctionPropertiesOf]] to obtain a type that includes only these properties.\n * @public\n */\nexport type NonFunctionPropertyNamesOf<T> = {\n [K in keyof T]: T[K] extends Function ? never : K;\n}[keyof T];\n\n/** Produces a type consisting of all of the public properties of `T` except for those of type `function`.\n * @see [[NonFunctionPropertyNamesOf]] for potential pitfalls when used in conjunction with the object spread operator.\n * @public\n */\nexport type NonFunctionPropertiesOf<T> = Pick<T, NonFunctionPropertyNamesOf<T>>;\n\n/** Any function returning a Promise.\n * @see [[AsyncMethodsOf]] to extract all async methods from a type.\n * @see [[PromiseReturnType]] to extract the type to which the Promise resolves.\n * @public\n */\nexport type AsyncFunction = (...args: any) => Promise<any>;\n\n/** The members of `T` that are async functions (functions that return a promise), and no other properties\n * @public\n */\nexport type PickAsyncMethods<T> = { [P in keyof T]: T[P] extends AsyncFunction ? T[P] : never; };\n\n/** Extracts the names of all function properties of `T` that return a Promise.\n * @public\n */\nexport type AsyncMethodsOf<T> = { [P in keyof T]: T[P] extends AsyncFunction ? P : never }[keyof T];\n\n/** Extracts the type to which the Promise returned by an async function resolves.\n * @public\n */\nexport type PromiseReturnType<T extends AsyncFunction> = T extends (...args: any) => Promise<infer R> ? R : any;\n\n/** A runtime property omitter, makes a shallow copy of the given object without the specified properties\n * Compatible with the typescript `Omit` mapped type:\n * ```js\n * const testvar: Omit<{x: string, y: object}, \"y\"> = omit({x: \"hello\", y: {}}, [\"y\"]);\n * ```\n * @public\n */\nexport function omit<T extends {}, K extends readonly (keyof T)[]>(t: T, keys: K): Omit<T, K[number]> {\n const clone = { ...t };\n for (const key of keys)\n delete clone[key];\n return clone;\n}\n\n/** Defines a type wherein at least one of the properties of T is required to exist.\n * In the following example, paying for a coffee requires a customer to have either a credit card, some cash, or both in their wallet.\n * ```ts\n * interface Wallet {\n * cash?: number;\n * card?: CreditCard;\n * }\n *\n * function payForCoffee(wallet: RequireAtLeastOne<Wallet>) { ... }\n * ```\n * Source: [@azure/keyvault-certificates](https://learn.microsoft.com/en-us/javascript/api/@azure/keyvault-certificates/requireatleastone?view=azure-node-latest).\n * @public\n */\nexport type RequireAtLeastOne<T> = {\n [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;\n}[keyof T];\n"]}
@@ -1,19 +1,19 @@
1
- /** @internal options for constructing yield managers */
2
- export interface YieldManagerOptions {
3
- iterationsBeforeYield?: number;
4
- }
5
- /**
6
- * @internal
7
- * An object allowing code to optionally yield with some frequency.
8
- * useful in some intense loops that make processes unresponsive.
9
- * primarily a workaround for: https://github.com/nodejs/node-addon-api/issues/1140
10
- * @note see [[defaultYieldManagerOptions]], the default amount of times it must be called to cause an actual yield is 1000
11
- */
12
- export declare class YieldManager {
13
- options: Readonly<Required<YieldManagerOptions>>;
14
- private _counter;
15
- constructor(options?: YieldManagerOptions);
16
- allowYield(): Promise<void>;
17
- protected actualYield(): Promise<void>;
18
- }
1
+ /** @internal options for constructing yield managers */
2
+ export interface YieldManagerOptions {
3
+ iterationsBeforeYield?: number;
4
+ }
5
+ /**
6
+ * @internal
7
+ * An object allowing code to optionally yield with some frequency.
8
+ * useful in some intense loops that make processes unresponsive.
9
+ * primarily a workaround for: https://github.com/nodejs/node-addon-api/issues/1140
10
+ * @note see [[defaultYieldManagerOptions]], the default amount of times it must be called to cause an actual yield is 1000
11
+ */
12
+ export declare class YieldManager {
13
+ options: Readonly<Required<YieldManagerOptions>>;
14
+ private _counter;
15
+ constructor(options?: YieldManagerOptions);
16
+ allowYield(): Promise<void>;
17
+ protected actualYield(): Promise<void>;
18
+ }
19
19
  //# sourceMappingURL=YieldManager.d.ts.map
@@ -1,35 +1,35 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.YieldManager = void 0;
8
- /** @internal the default options when constructing yield managers */
9
- const defaultYieldManagerOptions = {
10
- iterationsBeforeYield: 1000,
11
- };
12
- /**
13
- * @internal
14
- * An object allowing code to optionally yield with some frequency.
15
- * useful in some intense loops that make processes unresponsive.
16
- * primarily a workaround for: https://github.com/nodejs/node-addon-api/issues/1140
17
- * @note see [[defaultYieldManagerOptions]], the default amount of times it must be called to cause an actual yield is 1000
18
- */
19
- class YieldManager {
20
- constructor(options = {}) {
21
- this._counter = 0;
22
- this.options = { ...defaultYieldManagerOptions, ...options };
23
- }
24
- async allowYield() {
25
- this._counter = (this._counter + 1) % this.options.iterationsBeforeYield;
26
- if (this._counter === 0) {
27
- await this.actualYield();
28
- }
29
- }
30
- async actualYield() {
31
- await new Promise((r) => setTimeout(r, 0));
32
- }
33
- }
34
- exports.YieldManager = YieldManager;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.YieldManager = void 0;
8
+ /** @internal the default options when constructing yield managers */
9
+ const defaultYieldManagerOptions = {
10
+ iterationsBeforeYield: 1000,
11
+ };
12
+ /**
13
+ * @internal
14
+ * An object allowing code to optionally yield with some frequency.
15
+ * useful in some intense loops that make processes unresponsive.
16
+ * primarily a workaround for: https://github.com/nodejs/node-addon-api/issues/1140
17
+ * @note see [[defaultYieldManagerOptions]], the default amount of times it must be called to cause an actual yield is 1000
18
+ */
19
+ class YieldManager {
20
+ constructor(options = {}) {
21
+ this._counter = 0;
22
+ this.options = { ...defaultYieldManagerOptions, ...options };
23
+ }
24
+ async allowYield() {
25
+ this._counter = (this._counter + 1) % this.options.iterationsBeforeYield;
26
+ if (this._counter === 0) {
27
+ await this.actualYield();
28
+ }
29
+ }
30
+ async actualYield() {
31
+ await new Promise((r) => setTimeout(r, 0));
32
+ }
33
+ }
34
+ exports.YieldManager = YieldManager;
35
35
  //# sourceMappingURL=YieldManager.js.map