@itwin/core-bentley 3.6.0-dev.11 → 3.6.0-dev.21

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 (228) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/lib/cjs/AccessToken.d.ts +8 -8
  3. package/lib/cjs/AccessToken.js +9 -9
  4. package/lib/cjs/AccessToken.js.map +1 -1
  5. package/lib/cjs/Assert.d.ts +25 -25
  6. package/lib/cjs/Assert.js +45 -45
  7. package/lib/cjs/Assert.js.map +1 -1
  8. package/lib/cjs/AsyncMutex.d.ts +26 -26
  9. package/lib/cjs/AsyncMutex.js +43 -43
  10. package/lib/cjs/AsyncMutex.js.map +1 -1
  11. package/lib/cjs/BeEvent.d.ts +81 -81
  12. package/lib/cjs/BeEvent.js +156 -156
  13. package/lib/cjs/BeEvent.js.map +1 -1
  14. package/lib/cjs/BeSQLite.d.ts +170 -170
  15. package/lib/cjs/BeSQLite.js +183 -183
  16. package/lib/cjs/BeSQLite.js.map +1 -1
  17. package/lib/cjs/BentleyError.d.ts +378 -378
  18. package/lib/cjs/BentleyError.js +702 -702
  19. package/lib/cjs/BentleyError.js.map +1 -1
  20. package/lib/cjs/BentleyLoggerCategory.d.ts +11 -11
  21. package/lib/cjs/BentleyLoggerCategory.js +19 -19
  22. package/lib/cjs/BentleyLoggerCategory.js.map +1 -1
  23. package/lib/cjs/ByteStream.d.ts +110 -94
  24. package/lib/cjs/ByteStream.d.ts.map +1 -1
  25. package/lib/cjs/ByteStream.js +159 -143
  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.js +75 -75
  32. package/lib/cjs/Compare.js.map +1 -1
  33. package/lib/cjs/CompressedId64Set.d.ts +134 -134
  34. package/lib/cjs/CompressedId64Set.js +428 -428
  35. package/lib/cjs/CompressedId64Set.js.map +1 -1
  36. package/lib/cjs/Dictionary.d.ts +125 -125
  37. package/lib/cjs/Dictionary.js +203 -203
  38. package/lib/cjs/Dictionary.js.map +1 -1
  39. package/lib/cjs/Disposable.d.ts +80 -80
  40. package/lib/cjs/Disposable.js +120 -120
  41. package/lib/cjs/Disposable.js.map +1 -1
  42. package/lib/cjs/Id.d.ts +277 -277
  43. package/lib/cjs/Id.js +629 -629
  44. package/lib/cjs/Id.js.map +1 -1
  45. package/lib/cjs/IndexMap.d.ts +65 -65
  46. package/lib/cjs/IndexMap.js +91 -91
  47. package/lib/cjs/IndexMap.js.map +1 -1
  48. package/lib/cjs/JsonSchema.d.ts +77 -77
  49. package/lib/cjs/JsonSchema.js +9 -9
  50. package/lib/cjs/JsonSchema.js.map +1 -1
  51. package/lib/cjs/JsonUtils.d.ts +78 -78
  52. package/lib/cjs/JsonUtils.js +151 -151
  53. package/lib/cjs/JsonUtils.js.map +1 -1
  54. package/lib/cjs/LRUMap.d.ts +129 -129
  55. package/lib/cjs/LRUMap.js +333 -333
  56. package/lib/cjs/LRUMap.js.map +1 -1
  57. package/lib/cjs/Logger.d.ts +143 -143
  58. package/lib/cjs/Logger.js +258 -258
  59. package/lib/cjs/Logger.js.map +1 -1
  60. package/lib/cjs/ObservableSet.d.ts +23 -23
  61. package/lib/cjs/ObservableSet.js +51 -51
  62. package/lib/cjs/ObservableSet.js.map +1 -1
  63. package/lib/cjs/OneAtATimeAction.d.ts +31 -31
  64. package/lib/cjs/OneAtATimeAction.js +94 -94
  65. package/lib/cjs/OneAtATimeAction.js.map +1 -1
  66. package/lib/cjs/OrderedId64Iterable.d.ts +74 -74
  67. package/lib/cjs/OrderedId64Iterable.js +235 -235
  68. package/lib/cjs/OrderedId64Iterable.js.map +1 -1
  69. package/lib/cjs/OrderedSet.d.ts +40 -40
  70. package/lib/cjs/OrderedSet.js +64 -64
  71. package/lib/cjs/OrderedSet.js.map +1 -1
  72. package/lib/cjs/PriorityQueue.d.ts +70 -70
  73. package/lib/cjs/PriorityQueue.js +140 -140
  74. package/lib/cjs/PriorityQueue.js.map +1 -1
  75. package/lib/cjs/ProcessDetector.d.ts +59 -59
  76. package/lib/cjs/ProcessDetector.js +71 -71
  77. package/lib/cjs/ProcessDetector.js.map +1 -1
  78. package/lib/cjs/SortedArray.d.ts +232 -232
  79. package/lib/cjs/SortedArray.js +303 -303
  80. package/lib/cjs/SortedArray.js.map +1 -1
  81. package/lib/cjs/StatusCategory.d.ts +30 -30
  82. package/lib/cjs/StatusCategory.js +460 -460
  83. package/lib/cjs/StatusCategory.js.map +1 -1
  84. package/lib/cjs/StringUtils.d.ts +22 -22
  85. package/lib/cjs/StringUtils.js +148 -148
  86. package/lib/cjs/StringUtils.js.map +1 -1
  87. package/lib/cjs/Time.d.ts +122 -122
  88. package/lib/cjs/Time.js +152 -152
  89. package/lib/cjs/Time.js.map +1 -1
  90. package/lib/cjs/Tracing.d.ts +40 -40
  91. package/lib/cjs/Tracing.js +130 -130
  92. package/lib/cjs/Tracing.js.map +1 -1
  93. package/lib/cjs/TupleKeyedMap.d.ts +36 -36
  94. package/lib/cjs/TupleKeyedMap.js +102 -102
  95. package/lib/cjs/TupleKeyedMap.js.map +1 -1
  96. package/lib/cjs/TypedArrayBuilder.d.ts +155 -97
  97. package/lib/cjs/TypedArrayBuilder.d.ts.map +1 -1
  98. package/lib/cjs/TypedArrayBuilder.js +208 -134
  99. package/lib/cjs/TypedArrayBuilder.js.map +1 -1
  100. package/lib/cjs/UnexpectedErrors.d.ts +43 -43
  101. package/lib/cjs/UnexpectedErrors.js +68 -68
  102. package/lib/cjs/UnexpectedErrors.js.map +1 -1
  103. package/lib/cjs/UtilityTypes.d.ts +100 -100
  104. package/lib/cjs/UtilityTypes.js +40 -40
  105. package/lib/cjs/UtilityTypes.js.map +1 -1
  106. package/lib/cjs/YieldManager.d.ts +18 -18
  107. package/lib/cjs/YieldManager.js +34 -34
  108. package/lib/cjs/YieldManager.js.map +1 -1
  109. package/lib/cjs/core-bentley.d.ts +75 -75
  110. package/lib/cjs/core-bentley.js +91 -91
  111. package/lib/cjs/core-bentley.js.map +1 -1
  112. package/lib/cjs/partitionArray.d.ts +21 -21
  113. package/lib/cjs/partitionArray.js +43 -43
  114. package/lib/cjs/partitionArray.js.map +1 -1
  115. package/lib/esm/AccessToken.d.ts +8 -8
  116. package/lib/esm/AccessToken.js +8 -8
  117. package/lib/esm/AccessToken.js.map +1 -1
  118. package/lib/esm/Assert.d.ts +25 -25
  119. package/lib/esm/Assert.js +41 -41
  120. package/lib/esm/Assert.js.map +1 -1
  121. package/lib/esm/AsyncMutex.d.ts +26 -26
  122. package/lib/esm/AsyncMutex.js +39 -39
  123. package/lib/esm/AsyncMutex.js.map +1 -1
  124. package/lib/esm/BeEvent.d.ts +81 -81
  125. package/lib/esm/BeEvent.js +150 -150
  126. package/lib/esm/BeEvent.js.map +1 -1
  127. package/lib/esm/BeSQLite.d.ts +170 -170
  128. package/lib/esm/BeSQLite.js +180 -180
  129. package/lib/esm/BeSQLite.js.map +1 -1
  130. package/lib/esm/BentleyError.d.ts +378 -378
  131. package/lib/esm/BentleyError.js +698 -698
  132. package/lib/esm/BentleyError.js.map +1 -1
  133. package/lib/esm/BentleyLoggerCategory.d.ts +11 -11
  134. package/lib/esm/BentleyLoggerCategory.js +16 -16
  135. package/lib/esm/BentleyLoggerCategory.js.map +1 -1
  136. package/lib/esm/ByteStream.d.ts +110 -94
  137. package/lib/esm/ByteStream.d.ts.map +1 -1
  138. package/lib/esm/ByteStream.js +155 -139
  139. package/lib/esm/ByteStream.js.map +1 -1
  140. package/lib/esm/ClassUtils.d.ts +14 -14
  141. package/lib/esm/ClassUtils.js +22 -22
  142. package/lib/esm/ClassUtils.js.map +1 -1
  143. package/lib/esm/Compare.d.ts +47 -47
  144. package/lib/esm/Compare.js +63 -63
  145. package/lib/esm/Compare.js.map +1 -1
  146. package/lib/esm/CompressedId64Set.d.ts +134 -134
  147. package/lib/esm/CompressedId64Set.js +423 -423
  148. package/lib/esm/CompressedId64Set.js.map +1 -1
  149. package/lib/esm/Dictionary.d.ts +125 -125
  150. package/lib/esm/Dictionary.js +199 -199
  151. package/lib/esm/Dictionary.js.map +1 -1
  152. package/lib/esm/Disposable.d.ts +80 -80
  153. package/lib/esm/Disposable.js +112 -112
  154. package/lib/esm/Disposable.js.map +1 -1
  155. package/lib/esm/Id.d.ts +277 -277
  156. package/lib/esm/Id.js +625 -625
  157. package/lib/esm/Id.js.map +1 -1
  158. package/lib/esm/IndexMap.d.ts +65 -65
  159. package/lib/esm/IndexMap.js +86 -86
  160. package/lib/esm/IndexMap.js.map +1 -1
  161. package/lib/esm/JsonSchema.d.ts +77 -77
  162. package/lib/esm/JsonSchema.js +8 -8
  163. package/lib/esm/JsonSchema.js.map +1 -1
  164. package/lib/esm/JsonUtils.d.ts +78 -78
  165. package/lib/esm/JsonUtils.js +148 -148
  166. package/lib/esm/JsonUtils.js.map +1 -1
  167. package/lib/esm/LRUMap.d.ts +129 -129
  168. package/lib/esm/LRUMap.js +326 -326
  169. package/lib/esm/LRUMap.js.map +1 -1
  170. package/lib/esm/Logger.d.ts +143 -143
  171. package/lib/esm/Logger.js +253 -253
  172. package/lib/esm/Logger.js.map +1 -1
  173. package/lib/esm/ObservableSet.d.ts +23 -23
  174. package/lib/esm/ObservableSet.js +47 -47
  175. package/lib/esm/ObservableSet.js.map +1 -1
  176. package/lib/esm/OneAtATimeAction.d.ts +31 -31
  177. package/lib/esm/OneAtATimeAction.js +89 -89
  178. package/lib/esm/OneAtATimeAction.js.map +1 -1
  179. package/lib/esm/OrderedId64Iterable.d.ts +74 -74
  180. package/lib/esm/OrderedId64Iterable.js +232 -232
  181. package/lib/esm/OrderedId64Iterable.js.map +1 -1
  182. package/lib/esm/OrderedSet.d.ts +40 -40
  183. package/lib/esm/OrderedSet.js +59 -59
  184. package/lib/esm/OrderedSet.js.map +1 -1
  185. package/lib/esm/PriorityQueue.d.ts +70 -70
  186. package/lib/esm/PriorityQueue.js +136 -136
  187. package/lib/esm/PriorityQueue.js.map +1 -1
  188. package/lib/esm/ProcessDetector.d.ts +59 -59
  189. package/lib/esm/ProcessDetector.js +67 -67
  190. package/lib/esm/ProcessDetector.js.map +1 -1
  191. package/lib/esm/SortedArray.d.ts +232 -232
  192. package/lib/esm/SortedArray.js +296 -296
  193. package/lib/esm/SortedArray.js.map +1 -1
  194. package/lib/esm/StatusCategory.d.ts +30 -30
  195. package/lib/esm/StatusCategory.js +454 -454
  196. package/lib/esm/StatusCategory.js.map +1 -1
  197. package/lib/esm/StringUtils.d.ts +22 -22
  198. package/lib/esm/StringUtils.js +142 -142
  199. package/lib/esm/StringUtils.js.map +1 -1
  200. package/lib/esm/Time.d.ts +122 -122
  201. package/lib/esm/Time.js +146 -146
  202. package/lib/esm/Time.js.map +1 -1
  203. package/lib/esm/Tracing.d.ts +40 -40
  204. package/lib/esm/Tracing.js +126 -126
  205. package/lib/esm/Tracing.js.map +1 -1
  206. package/lib/esm/TupleKeyedMap.d.ts +36 -36
  207. package/lib/esm/TupleKeyedMap.js +98 -98
  208. package/lib/esm/TupleKeyedMap.js.map +1 -1
  209. package/lib/esm/TypedArrayBuilder.d.ts +155 -97
  210. package/lib/esm/TypedArrayBuilder.d.ts.map +1 -1
  211. package/lib/esm/TypedArrayBuilder.js +200 -127
  212. package/lib/esm/TypedArrayBuilder.js.map +1 -1
  213. package/lib/esm/UnexpectedErrors.d.ts +43 -43
  214. package/lib/esm/UnexpectedErrors.js +64 -64
  215. package/lib/esm/UnexpectedErrors.js.map +1 -1
  216. package/lib/esm/UtilityTypes.d.ts +100 -100
  217. package/lib/esm/UtilityTypes.js +34 -34
  218. package/lib/esm/UtilityTypes.js.map +1 -1
  219. package/lib/esm/YieldManager.d.ts +18 -18
  220. package/lib/esm/YieldManager.js +30 -30
  221. package/lib/esm/YieldManager.js.map +1 -1
  222. package/lib/esm/core-bentley.d.ts +75 -75
  223. package/lib/esm/core-bentley.js +79 -79
  224. package/lib/esm/core-bentley.js.map +1 -1
  225. package/lib/esm/partitionArray.d.ts +21 -21
  226. package/lib/esm/partitionArray.js +39 -39
  227. package/lib/esm/partitionArray.js.map +1 -1
  228. package/package.json +3 -3
@@ -1,24 +1,24 @@
1
- /** @packageDocumentation
2
- * @module Collections
3
- */
4
- import { BeEvent } from "./BeEvent";
5
- /** A standard [Set<T>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) that emits events when its contents change.
6
- * @public
7
- */
8
- export declare class ObservableSet<T> extends Set<T> {
9
- /** Emitted after `item` is added to this set. */
10
- readonly onAdded: BeEvent<(item: T) => void>;
11
- /** Emitted after `item` is deleted from this set. */
12
- readonly onDeleted: BeEvent<(item: T) => void>;
13
- /** Emitted after this set's contents are cleared. */
14
- readonly onCleared: BeEvent<() => void>;
15
- /** Construct a new ObservableSet.
16
- * @param elements Optional elements with which to populate the new set.
17
- */
18
- constructor(elements?: Iterable<T> | undefined);
19
- /** @internal */
20
- delete(item: T): boolean;
21
- /** @internal */
22
- clear(): void;
23
- }
1
+ /** @packageDocumentation
2
+ * @module Collections
3
+ */
4
+ import { BeEvent } from "./BeEvent";
5
+ /** A standard [Set<T>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) that emits events when its contents change.
6
+ * @public
7
+ */
8
+ export declare class ObservableSet<T> extends Set<T> {
9
+ /** Emitted after `item` is added to this set. */
10
+ readonly onAdded: BeEvent<(item: T) => void>;
11
+ /** Emitted after `item` is deleted from this set. */
12
+ readonly onDeleted: BeEvent<(item: T) => void>;
13
+ /** Emitted after this set's contents are cleared. */
14
+ readonly onCleared: BeEvent<() => void>;
15
+ /** Construct a new ObservableSet.
16
+ * @param elements Optional elements with which to populate the new set.
17
+ */
18
+ constructor(elements?: Iterable<T> | undefined);
19
+ /** @internal */
20
+ delete(item: T): boolean;
21
+ /** @internal */
22
+ clear(): void;
23
+ }
24
24
  //# sourceMappingURL=ObservableSet.d.ts.map
@@ -1,52 +1,52 @@
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 Collections
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ObservableSet = void 0;
11
- const BeEvent_1 = require("./BeEvent");
12
- /** A standard [Set<T>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) that emits events when its contents change.
13
- * @public
14
- */
15
- class ObservableSet extends Set {
16
- /** Construct a new ObservableSet.
17
- * @param elements Optional elements with which to populate the new set.
18
- */
19
- constructor(elements) {
20
- // NB: Set constructor will invoke add(). Do not override until initialized.
21
- super(elements);
22
- /** Emitted after `item` is added to this set. */
23
- this.onAdded = new BeEvent_1.BeEvent();
24
- /** Emitted after `item` is deleted from this set. */
25
- this.onDeleted = new BeEvent_1.BeEvent();
26
- /** Emitted after this set's contents are cleared. */
27
- this.onCleared = new BeEvent_1.BeEvent();
28
- this.add = (item) => {
29
- const prevSize = this.size;
30
- const ret = super.add(item);
31
- if (this.size !== prevSize)
32
- this.onAdded.raiseEvent(item);
33
- return ret;
34
- };
35
- }
36
- /** @internal */
37
- delete(item) {
38
- const ret = super.delete(item);
39
- if (ret)
40
- this.onDeleted.raiseEvent(item);
41
- return ret;
42
- }
43
- /** @internal */
44
- clear() {
45
- if (0 !== this.size) {
46
- super.clear();
47
- this.onCleared.raiseEvent();
48
- }
49
- }
50
- }
51
- exports.ObservableSet = ObservableSet;
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 Collections
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ObservableSet = void 0;
11
+ const BeEvent_1 = require("./BeEvent");
12
+ /** A standard [Set<T>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) that emits events when its contents change.
13
+ * @public
14
+ */
15
+ class ObservableSet extends Set {
16
+ /** Construct a new ObservableSet.
17
+ * @param elements Optional elements with which to populate the new set.
18
+ */
19
+ constructor(elements) {
20
+ // NB: Set constructor will invoke add(). Do not override until initialized.
21
+ super(elements);
22
+ /** Emitted after `item` is added to this set. */
23
+ this.onAdded = new BeEvent_1.BeEvent();
24
+ /** Emitted after `item` is deleted from this set. */
25
+ this.onDeleted = new BeEvent_1.BeEvent();
26
+ /** Emitted after this set's contents are cleared. */
27
+ this.onCleared = new BeEvent_1.BeEvent();
28
+ this.add = (item) => {
29
+ const prevSize = this.size;
30
+ const ret = super.add(item);
31
+ if (this.size !== prevSize)
32
+ this.onAdded.raiseEvent(item);
33
+ return ret;
34
+ };
35
+ }
36
+ /** @internal */
37
+ delete(item) {
38
+ const ret = super.delete(item);
39
+ if (ret)
40
+ this.onDeleted.raiseEvent(item);
41
+ return ret;
42
+ }
43
+ /** @internal */
44
+ clear() {
45
+ if (0 !== this.size) {
46
+ super.clear();
47
+ this.onCleared.raiseEvent();
48
+ }
49
+ }
50
+ }
51
+ exports.ObservableSet = ObservableSet;
52
52
  //# sourceMappingURL=ObservableSet.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObservableSet.js","sourceRoot":"","sources":["../../src/ObservableSet.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uCAAoC;AAEpC;;GAEG;AACH,MAAa,aAAiB,SAAQ,GAAM;IAQ1C;;OAEG;IACH,YAAmB,QAAkC;QACnD,4EAA4E;QAC5E,KAAK,CAAC,QAAQ,CAAC,CAAC;QAZlB,iDAAiD;QACjC,YAAO,GAAG,IAAI,iBAAO,EAAqB,CAAC;QAC3D,qDAAqD;QACrC,cAAS,GAAG,IAAI,iBAAO,EAAqB,CAAC;QAC7D,qDAAqD;QACrC,cAAS,GAAG,IAAI,iBAAO,EAAc,CAAC;QASpD,IAAI,CAAC,GAAG,GAAG,CAAC,IAAO,EAAE,EAAE;YACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;YAC3B,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5B,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;gBACxB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAEhC,OAAO,GAAG,CAAC;QACb,CAAC,CAAC;IACJ,CAAC;IAED,gBAAgB;IACA,MAAM,CAAC,IAAO;QAC5B,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,GAAG;YACL,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAElC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,gBAAgB;IACA,KAAK;QACnB,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE;YACnB,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;SAC7B;IACH,CAAC;CACF;AAzCD,sCAyCC","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 Collections\r\n */\r\n\r\nimport { BeEvent } from \"./BeEvent\";\r\n\r\n/** A standard [Set<T>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) that emits events when its contents change.\r\n * @public\r\n */\r\nexport class ObservableSet<T> extends Set<T> {\r\n /** Emitted after `item` is added to this set. */\r\n public readonly onAdded = new BeEvent<(item: T) => void>();\r\n /** Emitted after `item` is deleted from this set. */\r\n public readonly onDeleted = new BeEvent<(item: T) => void>();\r\n /** Emitted after this set's contents are cleared. */\r\n public readonly onCleared = new BeEvent<() => void>();\r\n\r\n /** Construct a new ObservableSet.\r\n * @param elements Optional elements with which to populate the new set.\r\n */\r\n public constructor(elements?: Iterable<T> | undefined) {\r\n // NB: Set constructor will invoke add(). Do not override until initialized.\r\n super(elements);\r\n\r\n this.add = (item: T) => { // eslint-disable-line @typescript-eslint/unbound-method\r\n const prevSize = this.size;\r\n const ret = super.add(item);\r\n if (this.size !== prevSize)\r\n this.onAdded.raiseEvent(item);\r\n\r\n return ret;\r\n };\r\n }\r\n\r\n /** @internal */\r\n public override delete(item: T): boolean {\r\n const ret = super.delete(item);\r\n if (ret)\r\n this.onDeleted.raiseEvent(item);\r\n\r\n return ret;\r\n }\r\n\r\n /** @internal */\r\n public override clear(): void {\r\n if (0 !== this.size) {\r\n super.clear();\r\n this.onCleared.raiseEvent();\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ObservableSet.js","sourceRoot":"","sources":["../../src/ObservableSet.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uCAAoC;AAEpC;;GAEG;AACH,MAAa,aAAiB,SAAQ,GAAM;IAQ1C;;OAEG;IACH,YAAmB,QAAkC;QACnD,4EAA4E;QAC5E,KAAK,CAAC,QAAQ,CAAC,CAAC;QAZlB,iDAAiD;QACjC,YAAO,GAAG,IAAI,iBAAO,EAAqB,CAAC;QAC3D,qDAAqD;QACrC,cAAS,GAAG,IAAI,iBAAO,EAAqB,CAAC;QAC7D,qDAAqD;QACrC,cAAS,GAAG,IAAI,iBAAO,EAAc,CAAC;QASpD,IAAI,CAAC,GAAG,GAAG,CAAC,IAAO,EAAE,EAAE;YACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;YAC3B,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5B,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;gBACxB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAEhC,OAAO,GAAG,CAAC;QACb,CAAC,CAAC;IACJ,CAAC;IAED,gBAAgB;IACA,MAAM,CAAC,IAAO;QAC5B,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,GAAG;YACL,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAElC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,gBAAgB;IACA,KAAK;QACnB,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE;YACnB,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;SAC7B;IACH,CAAC;CACF;AAzCD,sCAyCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Collections\n */\n\nimport { BeEvent } from \"./BeEvent\";\n\n/** A standard [Set<T>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) that emits events when its contents change.\n * @public\n */\nexport class ObservableSet<T> extends Set<T> {\n /** Emitted after `item` is added to this set. */\n public readonly onAdded = new BeEvent<(item: T) => void>();\n /** Emitted after `item` is deleted from this set. */\n public readonly onDeleted = new BeEvent<(item: T) => void>();\n /** Emitted after this set's contents are cleared. */\n public readonly onCleared = new BeEvent<() => void>();\n\n /** Construct a new ObservableSet.\n * @param elements Optional elements with which to populate the new set.\n */\n public constructor(elements?: Iterable<T> | undefined) {\n // NB: Set constructor will invoke add(). Do not override until initialized.\n super(elements);\n\n this.add = (item: T) => { // eslint-disable-line @typescript-eslint/unbound-method\n const prevSize = this.size;\n const ret = super.add(item);\n if (this.size !== prevSize)\n this.onAdded.raiseEvent(item);\n\n return ret;\n };\n }\n\n /** @internal */\n public override delete(item: T): boolean {\n const ret = super.delete(item);\n if (ret)\n this.onDeleted.raiseEvent(item);\n\n return ret;\n }\n\n /** @internal */\n public override clear(): void {\n if (0 !== this.size) {\n super.clear();\n this.onCleared.raiseEvent();\n }\n }\n}\n"]}
@@ -1,32 +1,32 @@
1
- /** @packageDocumentation
2
- * @module Utils
3
- */
4
- /** @beta */
5
- export declare class AbandonedError extends Error {
6
- }
7
- /**
8
- * Orchestrator of a one-at-a-time activity. This concept is useful only for *replaceable* operations (that is, operations where subsequent requests replace and obviate
9
- * the need for previous requests. E.g. over slow HTTP connections, without this class, the stream of requests can overwhelm the connection, and cause the HTTP
10
- * request queue to grow such that the delay to service new requests is unbounded.
11
- *
12
- * With this class, we issue the initial request immediately. When the second request arrives before the first one completes, it becomes *pending*. If subsequent
13
- * requests arrive with a pending request, the current pending request is *abandoned* (its Promise is rejected) and the new request becomes pending.
14
- * When the active request completes, the pending request (if present) is started. In this manner there will only ever be one outstanding HTTP request for this type
15
- * of operation, but the first and last request will always eventually complete.
16
- * @beta
17
- */
18
- export declare class OneAtATimeAction<T> {
19
- private _active?;
20
- private _pending?;
21
- private _run;
22
- msg: string;
23
- /** Ctor for OneAtATimePromise.
24
- * @param run The method that performs an action that creates the Promise.
25
- */
26
- constructor(run: (...args: any[]) => Promise<T>, msg?: string);
27
- /** Add a new request to this OneAtATimePromise. The request will only run when no other outstanding requests are active.
28
- * @note Callers of this method *must* handle AbandonedError rejections.
29
- */
30
- request(...args: any[]): Promise<T>;
31
- }
1
+ /** @packageDocumentation
2
+ * @module Utils
3
+ */
4
+ /** @beta */
5
+ export declare class AbandonedError extends Error {
6
+ }
7
+ /**
8
+ * Orchestrator of a one-at-a-time activity. This concept is useful only for *replaceable* operations (that is, operations where subsequent requests replace and obviate
9
+ * the need for previous requests. E.g. over slow HTTP connections, without this class, the stream of requests can overwhelm the connection, and cause the HTTP
10
+ * request queue to grow such that the delay to service new requests is unbounded.
11
+ *
12
+ * With this class, we issue the initial request immediately. When the second request arrives before the first one completes, it becomes *pending*. If subsequent
13
+ * requests arrive with a pending request, the current pending request is *abandoned* (its Promise is rejected) and the new request becomes pending.
14
+ * When the active request completes, the pending request (if present) is started. In this manner there will only ever be one outstanding HTTP request for this type
15
+ * of operation, but the first and last request will always eventually complete.
16
+ * @beta
17
+ */
18
+ export declare class OneAtATimeAction<T> {
19
+ private _active?;
20
+ private _pending?;
21
+ private _run;
22
+ msg: string;
23
+ /** Ctor for OneAtATimePromise.
24
+ * @param run The method that performs an action that creates the Promise.
25
+ */
26
+ constructor(run: (...args: any[]) => Promise<T>, msg?: string);
27
+ /** Add a new request to this OneAtATimePromise. The request will only run when no other outstanding requests are active.
28
+ * @note Callers of this method *must* handle AbandonedError rejections.
29
+ */
30
+ request(...args: any[]): Promise<T>;
31
+ }
32
32
  //# sourceMappingURL=OneAtATimeAction.d.ts.map
@@ -1,95 +1,95 @@
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.OneAtATimeAction = exports.AbandonedError = void 0;
11
- const BentleyError_1 = require("./BentleyError");
12
- /** @beta */
13
- class AbandonedError extends Error {
14
- }
15
- exports.AbandonedError = AbandonedError;
16
- /**
17
- * An object that returns a Promise when you call [[init]], but supplies a way to abandon the promise if it is no longer relevant.
18
- * When you call abandon, the promise will be rejected. You must supply a [[run]] method to the constructor that
19
- * creates the real Promise for the underlying action. Notice that to use this class there are really two
20
- * Promises involved that are chained together. That makes this class less efficient than just using a Promise directly.
21
- */
22
- class PromiseWithAbandon {
23
- /** Create a PromiseWithAbandon. After this call you must call [[init]] to create the underlying Promise.
24
- * @param _run The method that creates the underlying Promise.
25
- * @param _args An array of args to be passed to run when [[start]] is called.
26
- */
27
- constructor(_run, _args) {
28
- this._run = _run;
29
- this._args = _args;
30
- }
31
- /** Create a Promise that is chained to the underlying Promise, but is connected to the abandon method. */
32
- async init(msg) {
33
- return new Promise((resolve, reject) => {
34
- this.abandon = (message) => reject(new AbandonedError(message !== null && message !== void 0 ? message : msg));
35
- this._resolve = resolve;
36
- });
37
- }
38
- /** Call the [[run]] method supplied to the ctor to start the underlying Promise. */
39
- async start() {
40
- try {
41
- this._resolve(await this._run(...this._args));
42
- }
43
- catch (err) {
44
- this.abandon(BentleyError_1.BentleyError.getErrorMessage(err)); // turn all errors from execution into abandoned errors, but keep the message
45
- }
46
- }
47
- }
48
- /**
49
- * Orchestrator of a one-at-a-time activity. This concept is useful only for *replaceable* operations (that is, operations where subsequent requests replace and obviate
50
- * the need for previous requests. E.g. over slow HTTP connections, without this class, the stream of requests can overwhelm the connection, and cause the HTTP
51
- * request queue to grow such that the delay to service new requests is unbounded.
52
- *
53
- * With this class, we issue the initial request immediately. When the second request arrives before the first one completes, it becomes *pending*. If subsequent
54
- * requests arrive with a pending request, the current pending request is *abandoned* (its Promise is rejected) and the new request becomes pending.
55
- * When the active request completes, the pending request (if present) is started. In this manner there will only ever be one outstanding HTTP request for this type
56
- * of operation, but the first and last request will always eventually complete.
57
- * @beta
58
- */
59
- class OneAtATimeAction {
60
- /** Ctor for OneAtATimePromise.
61
- * @param run The method that performs an action that creates the Promise.
62
- */
63
- constructor(run, msg = "abandoned") {
64
- this._run = run;
65
- this.msg = msg;
66
- }
67
- /** Add a new request to this OneAtATimePromise. The request will only run when no other outstanding requests are active.
68
- * @note Callers of this method *must* handle AbandonedError rejections.
69
- */
70
- async request(...args) {
71
- const entry = new PromiseWithAbandon(this._run, args); // create an "abandon-able promise" object
72
- const promise = entry.init(this.msg); // create the Promise from PromiseWithAbandon. Note: this must be called before we call start.
73
- if (this._active !== undefined) { // is there an active request?
74
- if (this._pending) // yes. If there is also a pending request, this one replaces it and previous one is abandoned
75
- this._pending.abandon(); // rejects previous call to this method, throwing AbandonedError.
76
- this._pending = entry;
77
- }
78
- else {
79
- this._active = entry; // this is the first request, start it.
80
- entry.start(); // eslint-disable-line @typescript-eslint/no-floating-promises
81
- }
82
- try {
83
- return await promise;
84
- }
85
- finally {
86
- // do all of this whether promise was fulfilled or rejected
87
- this._active = this._pending; // see if there's a pending request waiting
88
- this._pending = undefined; // clear pending
89
- if (this._active)
90
- this._active.start(); // eslint-disable-line @typescript-eslint/no-floating-promises
91
- }
92
- }
93
- }
94
- exports.OneAtATimeAction = OneAtATimeAction;
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.OneAtATimeAction = exports.AbandonedError = void 0;
11
+ const BentleyError_1 = require("./BentleyError");
12
+ /** @beta */
13
+ class AbandonedError extends Error {
14
+ }
15
+ exports.AbandonedError = AbandonedError;
16
+ /**
17
+ * An object that returns a Promise when you call [[init]], but supplies a way to abandon the promise if it is no longer relevant.
18
+ * When you call abandon, the promise will be rejected. You must supply a [[run]] method to the constructor that
19
+ * creates the real Promise for the underlying action. Notice that to use this class there are really two
20
+ * Promises involved that are chained together. That makes this class less efficient than just using a Promise directly.
21
+ */
22
+ class PromiseWithAbandon {
23
+ /** Create a PromiseWithAbandon. After this call you must call [[init]] to create the underlying Promise.
24
+ * @param _run The method that creates the underlying Promise.
25
+ * @param _args An array of args to be passed to run when [[start]] is called.
26
+ */
27
+ constructor(_run, _args) {
28
+ this._run = _run;
29
+ this._args = _args;
30
+ }
31
+ /** Create a Promise that is chained to the underlying Promise, but is connected to the abandon method. */
32
+ async init(msg) {
33
+ return new Promise((resolve, reject) => {
34
+ this.abandon = (message) => reject(new AbandonedError(message !== null && message !== void 0 ? message : msg));
35
+ this._resolve = resolve;
36
+ });
37
+ }
38
+ /** Call the [[run]] method supplied to the ctor to start the underlying Promise. */
39
+ async start() {
40
+ try {
41
+ this._resolve(await this._run(...this._args));
42
+ }
43
+ catch (err) {
44
+ this.abandon(BentleyError_1.BentleyError.getErrorMessage(err)); // turn all errors from execution into abandoned errors, but keep the message
45
+ }
46
+ }
47
+ }
48
+ /**
49
+ * Orchestrator of a one-at-a-time activity. This concept is useful only for *replaceable* operations (that is, operations where subsequent requests replace and obviate
50
+ * the need for previous requests. E.g. over slow HTTP connections, without this class, the stream of requests can overwhelm the connection, and cause the HTTP
51
+ * request queue to grow such that the delay to service new requests is unbounded.
52
+ *
53
+ * With this class, we issue the initial request immediately. When the second request arrives before the first one completes, it becomes *pending*. If subsequent
54
+ * requests arrive with a pending request, the current pending request is *abandoned* (its Promise is rejected) and the new request becomes pending.
55
+ * When the active request completes, the pending request (if present) is started. In this manner there will only ever be one outstanding HTTP request for this type
56
+ * of operation, but the first and last request will always eventually complete.
57
+ * @beta
58
+ */
59
+ class OneAtATimeAction {
60
+ /** Ctor for OneAtATimePromise.
61
+ * @param run The method that performs an action that creates the Promise.
62
+ */
63
+ constructor(run, msg = "abandoned") {
64
+ this._run = run;
65
+ this.msg = msg;
66
+ }
67
+ /** Add a new request to this OneAtATimePromise. The request will only run when no other outstanding requests are active.
68
+ * @note Callers of this method *must* handle AbandonedError rejections.
69
+ */
70
+ async request(...args) {
71
+ const entry = new PromiseWithAbandon(this._run, args); // create an "abandon-able promise" object
72
+ const promise = entry.init(this.msg); // create the Promise from PromiseWithAbandon. Note: this must be called before we call start.
73
+ if (this._active !== undefined) { // is there an active request?
74
+ if (this._pending) // yes. If there is also a pending request, this one replaces it and previous one is abandoned
75
+ this._pending.abandon(); // rejects previous call to this method, throwing AbandonedError.
76
+ this._pending = entry;
77
+ }
78
+ else {
79
+ this._active = entry; // this is the first request, start it.
80
+ entry.start(); // eslint-disable-line @typescript-eslint/no-floating-promises
81
+ }
82
+ try {
83
+ return await promise;
84
+ }
85
+ finally {
86
+ // do all of this whether promise was fulfilled or rejected
87
+ this._active = this._pending; // see if there's a pending request waiting
88
+ this._pending = undefined; // clear pending
89
+ if (this._active)
90
+ this._active.start(); // eslint-disable-line @typescript-eslint/no-floating-promises
91
+ }
92
+ }
93
+ }
94
+ exports.OneAtATimeAction = OneAtATimeAction;
95
95
  //# sourceMappingURL=OneAtATimeAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OneAtATimeAction.js","sourceRoot":"","sources":["../../src/OneAtATimeAction.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,iDAA8C;AAE9C,YAAY;AACZ,MAAa,cAAe,SAAQ,KAAK;CAAI;AAA7C,wCAA6C;AAE7C;;;;;GAKG;AACH,MAAM,kBAAkB;IAKtB;;;OAGG;IACH,YAAoB,IAAoC,EAAU,KAAY;QAA1D,SAAI,GAAJ,IAAI,CAAgC;QAAU,UAAK,GAAL,KAAK,CAAO;IAAI,CAAC;IAEnF,0GAA0G;IACnG,KAAK,CAAC,IAAI,CAAC,GAAW;QAC3B,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACxC,IAAI,CAAC,OAAO,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,GAAG,CAAC,CAAC,CAAC;YAChF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,oFAAoF;IAC7E,KAAK,CAAC,KAAK;QAChB,IAAI;YACF,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;SAC/C;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,CAAC,OAAO,CAAC,2BAAY,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,6EAA6E;SAC/H;IACH,CAAC;CACF;AAED;;;;;;;;;;GAUG;AACH,MAAa,gBAAgB;IAM3B;;OAEG;IACH,YAAY,GAAmC,EAAE,GAAG,GAAG,WAAW;QAChE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAO,CAAC,GAAG,IAAW;QACjC,MAAM,KAAK,GAAG,IAAI,kBAAkB,CAAI,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,0CAA0C;QACpG,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,8FAA8F;QAEpI,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,EAAE,8BAA8B;YAC9D,IAAI,IAAI,CAAC,QAAQ,EAAE,8FAA8F;gBAC/G,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,iEAAiE;YAC5F,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;SACvB;aAAM;YACL,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,uCAAuC;YAC7D,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,8DAA8D;SAC9E;QAED,IAAI;YACF,OAAO,MAAM,OAAO,CAAC;SACtB;gBAAS;YACR,2DAA2D;YAC3D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,2CAA2C;YACzE,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,gBAAgB;YAC3C,IAAI,IAAI,CAAC,OAAO;gBACd,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,8DAA8D;SACvF;IACH,CAAC;CACF;AAxCD,4CAwCC","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\nimport { BentleyError } from \"./BentleyError\";\r\n\r\n/** @beta */\r\nexport class AbandonedError extends Error { }\r\n\r\n/**\r\n * An object that returns a Promise when you call [[init]], but supplies a way to abandon the promise if it is no longer relevant.\r\n * When you call abandon, the promise will be rejected. You must supply a [[run]] method to the constructor that\r\n * creates the real Promise for the underlying action. Notice that to use this class there are really two\r\n * Promises involved that are chained together. That makes this class less efficient than just using a Promise directly.\r\n */\r\nclass PromiseWithAbandon<T> {\r\n /** Method to abandon the Promise created by [[init]] while it is outstanding. The promise will be rejected. */\r\n public abandon!: (msg?: string) => void;\r\n private _resolve!: (val: any) => void;\r\n\r\n /** Create a PromiseWithAbandon. After this call you must call [[init]] to create the underlying Promise.\r\n * @param _run The method that creates the underlying Promise.\r\n * @param _args An array of args to be passed to run when [[start]] is called.\r\n */\r\n constructor(private _run: (...args: any[]) => Promise<T>, private _args: any[]) { }\r\n\r\n /** Create a Promise that is chained to the underlying Promise, but is connected to the abandon method. */\r\n public async init(msg: string): Promise<T> {\r\n return new Promise<T>((resolve, reject) => {\r\n this.abandon = (message?: string) => reject(new AbandonedError(message ?? msg));\r\n this._resolve = resolve;\r\n });\r\n }\r\n\r\n /** Call the [[run]] method supplied to the ctor to start the underlying Promise. */\r\n public async start() {\r\n try {\r\n this._resolve(await this._run(...this._args));\r\n } catch (err) {\r\n this.abandon(BentleyError.getErrorMessage(err)); // turn all errors from execution into abandoned errors, but keep the message\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Orchestrator of a one-at-a-time activity. This concept is useful only for *replaceable* operations (that is, operations where subsequent requests replace and obviate\r\n * the need for previous requests. E.g. over slow HTTP connections, without this class, the stream of requests can overwhelm the connection, and cause the HTTP\r\n * request queue to grow such that the delay to service new requests is unbounded.\r\n *\r\n * With this class, we issue the initial request immediately. When the second request arrives before the first one completes, it becomes *pending*. If subsequent\r\n * requests arrive with a pending request, the current pending request is *abandoned* (its Promise is rejected) and the new request becomes pending.\r\n * When the active request completes, the pending request (if present) is started. In this manner there will only ever be one outstanding HTTP request for this type\r\n * of operation, but the first and last request will always eventually complete.\r\n * @beta\r\n */\r\nexport class OneAtATimeAction<T> {\r\n private _active?: PromiseWithAbandon<T>;\r\n private _pending?: PromiseWithAbandon<T>;\r\n private _run: (...args: any[]) => Promise<T>;\r\n public msg: string;\r\n\r\n /** Ctor for OneAtATimePromise.\r\n * @param run The method that performs an action that creates the Promise.\r\n */\r\n constructor(run: (...args: any[]) => Promise<T>, msg = \"abandoned\") {\r\n this._run = run;\r\n this.msg = msg;\r\n }\r\n\r\n /** Add a new request to this OneAtATimePromise. The request will only run when no other outstanding requests are active.\r\n * @note Callers of this method *must* handle AbandonedError rejections.\r\n */\r\n public async request(...args: any[]): Promise<T> {\r\n const entry = new PromiseWithAbandon<T>(this._run, args); // create an \"abandon-able promise\" object\r\n const promise = entry.init(this.msg); // create the Promise from PromiseWithAbandon. Note: this must be called before we call start.\r\n\r\n if (this._active !== undefined) { // is there an active request?\r\n if (this._pending) // yes. If there is also a pending request, this one replaces it and previous one is abandoned\r\n this._pending.abandon(); // rejects previous call to this method, throwing AbandonedError.\r\n this._pending = entry;\r\n } else {\r\n this._active = entry; // this is the first request, start it.\r\n entry.start(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n\r\n try {\r\n return await promise;\r\n } finally {\r\n // do all of this whether promise was fulfilled or rejected\r\n this._active = this._pending; // see if there's a pending request waiting\r\n this._pending = undefined; // clear pending\r\n if (this._active)\r\n this._active.start(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"OneAtATimeAction.js","sourceRoot":"","sources":["../../src/OneAtATimeAction.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,iDAA8C;AAE9C,YAAY;AACZ,MAAa,cAAe,SAAQ,KAAK;CAAI;AAA7C,wCAA6C;AAE7C;;;;;GAKG;AACH,MAAM,kBAAkB;IAKtB;;;OAGG;IACH,YAAoB,IAAoC,EAAU,KAAY;QAA1D,SAAI,GAAJ,IAAI,CAAgC;QAAU,UAAK,GAAL,KAAK,CAAO;IAAI,CAAC;IAEnF,0GAA0G;IACnG,KAAK,CAAC,IAAI,CAAC,GAAW;QAC3B,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACxC,IAAI,CAAC,OAAO,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,GAAG,CAAC,CAAC,CAAC;YAChF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,oFAAoF;IAC7E,KAAK,CAAC,KAAK;QAChB,IAAI;YACF,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;SAC/C;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,CAAC,OAAO,CAAC,2BAAY,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,6EAA6E;SAC/H;IACH,CAAC;CACF;AAED;;;;;;;;;;GAUG;AACH,MAAa,gBAAgB;IAM3B;;OAEG;IACH,YAAY,GAAmC,EAAE,GAAG,GAAG,WAAW;QAChE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,OAAO,CAAC,GAAG,IAAW;QACjC,MAAM,KAAK,GAAG,IAAI,kBAAkB,CAAI,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,0CAA0C;QACpG,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,8FAA8F;QAEpI,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,EAAE,8BAA8B;YAC9D,IAAI,IAAI,CAAC,QAAQ,EAAE,8FAA8F;gBAC/G,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,iEAAiE;YAC5F,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;SACvB;aAAM;YACL,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,uCAAuC;YAC7D,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,8DAA8D;SAC9E;QAED,IAAI;YACF,OAAO,MAAM,OAAO,CAAC;SACtB;gBAAS;YACR,2DAA2D;YAC3D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,2CAA2C;YACzE,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,gBAAgB;YAC3C,IAAI,IAAI,CAAC,OAAO;gBACd,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,8DAA8D;SACvF;IACH,CAAC;CACF;AAxCD,4CAwCC","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\nimport { BentleyError } from \"./BentleyError\";\n\n/** @beta */\nexport class AbandonedError extends Error { }\n\n/**\n * An object that returns a Promise when you call [[init]], but supplies a way to abandon the promise if it is no longer relevant.\n * When you call abandon, the promise will be rejected. You must supply a [[run]] method to the constructor that\n * creates the real Promise for the underlying action. Notice that to use this class there are really two\n * Promises involved that are chained together. That makes this class less efficient than just using a Promise directly.\n */\nclass PromiseWithAbandon<T> {\n /** Method to abandon the Promise created by [[init]] while it is outstanding. The promise will be rejected. */\n public abandon!: (msg?: string) => void;\n private _resolve!: (val: any) => void;\n\n /** Create a PromiseWithAbandon. After this call you must call [[init]] to create the underlying Promise.\n * @param _run The method that creates the underlying Promise.\n * @param _args An array of args to be passed to run when [[start]] is called.\n */\n constructor(private _run: (...args: any[]) => Promise<T>, private _args: any[]) { }\n\n /** Create a Promise that is chained to the underlying Promise, but is connected to the abandon method. */\n public async init(msg: string): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n this.abandon = (message?: string) => reject(new AbandonedError(message ?? msg));\n this._resolve = resolve;\n });\n }\n\n /** Call the [[run]] method supplied to the ctor to start the underlying Promise. */\n public async start() {\n try {\n this._resolve(await this._run(...this._args));\n } catch (err) {\n this.abandon(BentleyError.getErrorMessage(err)); // turn all errors from execution into abandoned errors, but keep the message\n }\n }\n}\n\n/**\n * Orchestrator of a one-at-a-time activity. This concept is useful only for *replaceable* operations (that is, operations where subsequent requests replace and obviate\n * the need for previous requests. E.g. over slow HTTP connections, without this class, the stream of requests can overwhelm the connection, and cause the HTTP\n * request queue to grow such that the delay to service new requests is unbounded.\n *\n * With this class, we issue the initial request immediately. When the second request arrives before the first one completes, it becomes *pending*. If subsequent\n * requests arrive with a pending request, the current pending request is *abandoned* (its Promise is rejected) and the new request becomes pending.\n * When the active request completes, the pending request (if present) is started. In this manner there will only ever be one outstanding HTTP request for this type\n * of operation, but the first and last request will always eventually complete.\n * @beta\n */\nexport class OneAtATimeAction<T> {\n private _active?: PromiseWithAbandon<T>;\n private _pending?: PromiseWithAbandon<T>;\n private _run: (...args: any[]) => Promise<T>;\n public msg: string;\n\n /** Ctor for OneAtATimePromise.\n * @param run The method that performs an action that creates the Promise.\n */\n constructor(run: (...args: any[]) => Promise<T>, msg = \"abandoned\") {\n this._run = run;\n this.msg = msg;\n }\n\n /** Add a new request to this OneAtATimePromise. The request will only run when no other outstanding requests are active.\n * @note Callers of this method *must* handle AbandonedError rejections.\n */\n public async request(...args: any[]): Promise<T> {\n const entry = new PromiseWithAbandon<T>(this._run, args); // create an \"abandon-able promise\" object\n const promise = entry.init(this.msg); // create the Promise from PromiseWithAbandon. Note: this must be called before we call start.\n\n if (this._active !== undefined) { // is there an active request?\n if (this._pending) // yes. If there is also a pending request, this one replaces it and previous one is abandoned\n this._pending.abandon(); // rejects previous call to this method, throwing AbandonedError.\n this._pending = entry;\n } else {\n this._active = entry; // this is the first request, start it.\n entry.start(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n\n try {\n return await promise;\n } finally {\n // do all of this whether promise was fulfilled or rejected\n this._active = this._pending; // see if there's a pending request waiting\n this._pending = undefined; // clear pending\n if (this._active)\n this._active.start(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n }\n}\n"]}
@@ -1,75 +1,75 @@
1
- /** @packageDocumentation
2
- * @module Ids
3
- */
4
- import { CompressedId64Set } from "./CompressedId64Set";
5
- import { Id64Array, Id64String } from "./Id";
6
- /** @public */
7
- export declare type OrderedId64Iterable = Iterable<Id64String>;
8
- /** A collection of **valid** [[Id64String]]s sorted in ascending order by the unsigned 64-bit integer value of the Ids.
9
- * This ordering is a requirement for several groups of APIs including [[CompressedId64Set]].
10
- * When used as input to a function, duplicate Ids are ignored; when returned as a function output, no duplicates are present.
11
- * @see [[CompressedId64Set]] for a compact string representation of such an ordered collection.
12
- * @see [[OrderedId64Iterable.compare]] for a function that compares Ids based on this criterion.
13
- * @see [[OrderedId64Array]] for a mutable implementation.
14
- * @public
15
- */
16
- export declare namespace OrderedId64Iterable {
17
- /** An ordered comparison of [[Id64String]]s suitable for use with sorting routines like
18
- * [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) and sorted containers
19
- * like [[SortedArray]] and [[Dictionary]]. The comparison compares the 64-bit numerical values of the two Ids, returning a negative number if lhs < rhs,
20
- * a positive number if lhs > rhs, or zero if lhs == rhs.
21
- * The default string comparison is fine (and more efficient) when numerical ordering is not required; use this instead if you want e.g., "0x100" to be greater than "0xf".
22
- * @see [[OrderedId64Iterable.sortArray]] for a convenient way to sort an array of Id64Strings.
23
- */
24
- function compare(lhs: Id64String, rhs: Id64String): number;
25
- /** Sort an array of [[Id64String]]s **in-place** in ascending order by their 64-bit numerical values.
26
- * @see [[OrderedId64Iterable.compare]] for the comparison routine used.
27
- * @returns the input array.
28
- * @note This function returns its input for consistency with Javascript's
29
- * [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) method.
30
- * It **does not** create a **new** array.
31
- */
32
- function sortArray(ids: Id64Array): Id64Array;
33
- /** Given two ordered collections of [[Id64String]]s, determine whether they are identical sets. Duplicate Ids are ignored.
34
- * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
35
- */
36
- function areEqualSets(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): boolean;
37
- /** Given an ordered collection of [[Id64String]]s, determine if it contains any Ids.
38
- * @param ids A well-formed, ordered collection of zero or more valid Ids.
39
- * @returns true if the input represents an empty set of Ids. The result is unspecified if the input does not meet the criteria for the input type.
40
- */
41
- function isEmptySet(ids: OrderedId64Iterable | CompressedId64Set): boolean;
42
- /** Given an ordered collection of [[Id64String]]s possibly containing duplicates, produce an ordered collection containing no duplicates.
43
- * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
44
- */
45
- function unique(ids: OrderedId64Iterable): OrderedId64Iterable;
46
- /** Given an ordered collection of [[Id64String]]s possibly containing duplicates, produce an ordered iterator over the distinct Ids, eliminating duplicates.
47
- * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
48
- */
49
- function uniqueIterator(ids: OrderedId64Iterable): Generator<string, void, unknown>;
50
- /** Given two ordered collections of [[Id64String]]s, produce a collection representing their union - i.e., the Ids that are present in either or both collections.
51
- * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
52
- */
53
- function union(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable;
54
- /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their intersection - i.e., the Ids that are present in both collections.
55
- * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
56
- */
57
- function intersection(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable;
58
- /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their difference - i.e., the Ids that are present in `ids1` but not present in `ids2`.
59
- * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
60
- */
61
- function difference(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable;
62
- /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their union - i.e., the Ids that are present in either or both collections.
63
- * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
64
- */
65
- function unionIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): Generator<string, void, unknown>;
66
- /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their intersection - i.e., the Ids that are present in both collections.
67
- * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
68
- */
69
- function intersectionIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): Generator<string, void, unknown>;
70
- /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their difference - i.e., the Ids that are present in `ids1` but not present in `ids2`.
71
- * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
72
- */
73
- function differenceIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): Generator<string, void, unknown>;
74
- }
1
+ /** @packageDocumentation
2
+ * @module Ids
3
+ */
4
+ import { CompressedId64Set } from "./CompressedId64Set";
5
+ import { Id64Array, Id64String } from "./Id";
6
+ /** @public */
7
+ export declare type OrderedId64Iterable = Iterable<Id64String>;
8
+ /** A collection of **valid** [[Id64String]]s sorted in ascending order by the unsigned 64-bit integer value of the Ids.
9
+ * This ordering is a requirement for several groups of APIs including [[CompressedId64Set]].
10
+ * When used as input to a function, duplicate Ids are ignored; when returned as a function output, no duplicates are present.
11
+ * @see [[CompressedId64Set]] for a compact string representation of such an ordered collection.
12
+ * @see [[OrderedId64Iterable.compare]] for a function that compares Ids based on this criterion.
13
+ * @see [[OrderedId64Array]] for a mutable implementation.
14
+ * @public
15
+ */
16
+ export declare namespace OrderedId64Iterable {
17
+ /** An ordered comparison of [[Id64String]]s suitable for use with sorting routines like
18
+ * [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) and sorted containers
19
+ * like [[SortedArray]] and [[Dictionary]]. The comparison compares the 64-bit numerical values of the two Ids, returning a negative number if lhs < rhs,
20
+ * a positive number if lhs > rhs, or zero if lhs == rhs.
21
+ * The default string comparison is fine (and more efficient) when numerical ordering is not required; use this instead if you want e.g., "0x100" to be greater than "0xf".
22
+ * @see [[OrderedId64Iterable.sortArray]] for a convenient way to sort an array of Id64Strings.
23
+ */
24
+ function compare(lhs: Id64String, rhs: Id64String): number;
25
+ /** Sort an array of [[Id64String]]s **in-place** in ascending order by their 64-bit numerical values.
26
+ * @see [[OrderedId64Iterable.compare]] for the comparison routine used.
27
+ * @returns the input array.
28
+ * @note This function returns its input for consistency with Javascript's
29
+ * [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) method.
30
+ * It **does not** create a **new** array.
31
+ */
32
+ function sortArray(ids: Id64Array): Id64Array;
33
+ /** Given two ordered collections of [[Id64String]]s, determine whether they are identical sets. Duplicate Ids are ignored.
34
+ * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
35
+ */
36
+ function areEqualSets(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): boolean;
37
+ /** Given an ordered collection of [[Id64String]]s, determine if it contains any Ids.
38
+ * @param ids A well-formed, ordered collection of zero or more valid Ids.
39
+ * @returns true if the input represents an empty set of Ids. The result is unspecified if the input does not meet the criteria for the input type.
40
+ */
41
+ function isEmptySet(ids: OrderedId64Iterable | CompressedId64Set): boolean;
42
+ /** Given an ordered collection of [[Id64String]]s possibly containing duplicates, produce an ordered collection containing no duplicates.
43
+ * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
44
+ */
45
+ function unique(ids: OrderedId64Iterable): OrderedId64Iterable;
46
+ /** Given an ordered collection of [[Id64String]]s possibly containing duplicates, produce an ordered iterator over the distinct Ids, eliminating duplicates.
47
+ * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
48
+ */
49
+ function uniqueIterator(ids: OrderedId64Iterable): Generator<string, void, unknown>;
50
+ /** Given two ordered collections of [[Id64String]]s, produce a collection representing their union - i.e., the Ids that are present in either or both collections.
51
+ * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
52
+ */
53
+ function union(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable;
54
+ /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their intersection - i.e., the Ids that are present in both collections.
55
+ * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
56
+ */
57
+ function intersection(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable;
58
+ /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their difference - i.e., the Ids that are present in `ids1` but not present in `ids2`.
59
+ * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
60
+ */
61
+ function difference(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable;
62
+ /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their union - i.e., the Ids that are present in either or both collections.
63
+ * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
64
+ */
65
+ function unionIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): Generator<string, void, unknown>;
66
+ /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their intersection - i.e., the Ids that are present in both collections.
67
+ * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
68
+ */
69
+ function intersectionIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): Generator<string, void, unknown>;
70
+ /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their difference - i.e., the Ids that are present in `ids1` but not present in `ids2`.
71
+ * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.
72
+ */
73
+ function differenceIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): Generator<string, void, unknown>;
74
+ }
75
75
  //# sourceMappingURL=OrderedId64Iterable.d.ts.map