@itwin/core-bentley 3.4.0-dev.9 → 3.5.0-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/CHANGELOG.md +25 -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 +376 -376
  18. package/lib/cjs/BentleyError.js +699 -699
  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 +92 -92
  24. package/lib/cjs/ByteStream.d.ts.map +1 -1
  25. package/lib/cjs/ByteStream.js +133 -123
  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 -63
  33. package/lib/cjs/Compare.js.map +1 -1
  34. package/lib/cjs/CompressedId64Set.d.ts +134 -134
  35. package/lib/cjs/CompressedId64Set.js +428 -428
  36. package/lib/cjs/CompressedId64Set.js.map +1 -1
  37. package/lib/cjs/Dictionary.d.ts +125 -125
  38. package/lib/cjs/Dictionary.d.ts.map +1 -1
  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.js +120 -120
  43. package/lib/cjs/Disposable.js.map +1 -1
  44. package/lib/cjs/Id.d.ts +277 -277
  45. package/lib/cjs/Id.d.ts.map +1 -1
  46. package/lib/cjs/Id.js +629 -619
  47. package/lib/cjs/Id.js.map +1 -1
  48. package/lib/cjs/IndexMap.d.ts +65 -65
  49. package/lib/cjs/IndexMap.js +91 -91
  50. package/lib/cjs/IndexMap.js.map +1 -1
  51. package/lib/cjs/JsonSchema.d.ts +77 -77
  52. package/lib/cjs/JsonSchema.js +9 -9
  53. package/lib/cjs/JsonSchema.js.map +1 -1
  54. package/lib/cjs/JsonUtils.d.ts +78 -78
  55. package/lib/cjs/JsonUtils.d.ts.map +1 -1
  56. package/lib/cjs/JsonUtils.js +151 -133
  57. package/lib/cjs/JsonUtils.js.map +1 -1
  58. package/lib/cjs/LRUMap.d.ts +129 -129
  59. package/lib/cjs/LRUMap.d.ts.map +1 -1
  60. package/lib/cjs/LRUMap.js +333 -333
  61. package/lib/cjs/LRUMap.js.map +1 -1
  62. package/lib/cjs/Logger.d.ts +141 -141
  63. package/lib/cjs/Logger.js +254 -254
  64. package/lib/cjs/Logger.js.map +1 -1
  65. package/lib/cjs/ObservableSet.d.ts +23 -23
  66. package/lib/cjs/ObservableSet.js +51 -51
  67. package/lib/cjs/ObservableSet.js.map +1 -1
  68. package/lib/cjs/OneAtATimeAction.d.ts +31 -31
  69. package/lib/cjs/OneAtATimeAction.d.ts.map +1 -1
  70. package/lib/cjs/OneAtATimeAction.js +94 -91
  71. package/lib/cjs/OneAtATimeAction.js.map +1 -1
  72. package/lib/cjs/OrderedId64Iterable.d.ts +74 -74
  73. package/lib/cjs/OrderedId64Iterable.js +235 -235
  74. package/lib/cjs/OrderedId64Iterable.js.map +1 -1
  75. package/lib/cjs/OrderedSet.d.ts +40 -40
  76. package/lib/cjs/OrderedSet.js +64 -64
  77. package/lib/cjs/OrderedSet.js.map +1 -1
  78. package/lib/cjs/PriorityQueue.d.ts +70 -70
  79. package/lib/cjs/PriorityQueue.js +140 -140
  80. package/lib/cjs/PriorityQueue.js.map +1 -1
  81. package/lib/cjs/ProcessDetector.d.ts +59 -59
  82. package/lib/cjs/ProcessDetector.js +71 -71
  83. package/lib/cjs/ProcessDetector.js.map +1 -1
  84. package/lib/cjs/SortedArray.d.ts +232 -232
  85. package/lib/cjs/SortedArray.d.ts.map +1 -1
  86. package/lib/cjs/SortedArray.js +303 -301
  87. package/lib/cjs/SortedArray.js.map +1 -1
  88. package/lib/cjs/StatusCategory.d.ts +30 -30
  89. package/lib/cjs/StatusCategory.js +460 -460
  90. package/lib/cjs/StatusCategory.js.map +1 -1
  91. package/lib/cjs/StringUtils.d.ts +22 -22
  92. package/lib/cjs/StringUtils.d.ts.map +1 -1
  93. package/lib/cjs/StringUtils.js +148 -146
  94. package/lib/cjs/StringUtils.js.map +1 -1
  95. package/lib/cjs/Time.d.ts +122 -122
  96. package/lib/cjs/Time.d.ts.map +1 -1
  97. package/lib/cjs/Time.js +152 -146
  98. package/lib/cjs/Time.js.map +1 -1
  99. package/lib/cjs/Tracing.d.ts +40 -40
  100. package/lib/cjs/Tracing.d.ts.map +1 -1
  101. package/lib/cjs/Tracing.js +130 -127
  102. package/lib/cjs/Tracing.js.map +1 -1
  103. package/lib/cjs/TypedArrayBuilder.d.ts +98 -0
  104. package/lib/cjs/TypedArrayBuilder.d.ts.map +1 -0
  105. package/lib/cjs/TypedArrayBuilder.js +135 -0
  106. package/lib/cjs/TypedArrayBuilder.js.map +1 -0
  107. package/lib/cjs/UnexpectedErrors.d.ts +43 -43
  108. package/lib/cjs/UnexpectedErrors.d.ts.map +1 -1
  109. package/lib/cjs/UnexpectedErrors.js +68 -65
  110. package/lib/cjs/UnexpectedErrors.js.map +1 -1
  111. package/lib/cjs/UtilityTypes.d.ts +86 -86
  112. package/lib/cjs/UtilityTypes.js +26 -26
  113. package/lib/cjs/UtilityTypes.js.map +1 -1
  114. package/lib/cjs/YieldManager.d.ts +18 -18
  115. package/lib/cjs/YieldManager.js +34 -34
  116. package/lib/cjs/YieldManager.js.map +1 -1
  117. package/lib/cjs/core-bentley.d.ts +74 -73
  118. package/lib/cjs/core-bentley.d.ts.map +1 -1
  119. package/lib/cjs/core-bentley.js +90 -89
  120. package/lib/cjs/core-bentley.js.map +1 -1
  121. package/lib/cjs/partitionArray.d.ts +21 -21
  122. package/lib/cjs/partitionArray.js +43 -43
  123. package/lib/cjs/partitionArray.js.map +1 -1
  124. package/lib/esm/AccessToken.d.ts +8 -8
  125. package/lib/esm/AccessToken.js +8 -8
  126. package/lib/esm/AccessToken.js.map +1 -1
  127. package/lib/esm/Assert.d.ts +25 -25
  128. package/lib/esm/Assert.js +41 -41
  129. package/lib/esm/Assert.js.map +1 -1
  130. package/lib/esm/AsyncMutex.d.ts +26 -26
  131. package/lib/esm/AsyncMutex.js +39 -39
  132. package/lib/esm/AsyncMutex.js.map +1 -1
  133. package/lib/esm/BeEvent.d.ts +81 -81
  134. package/lib/esm/BeEvent.js +150 -150
  135. package/lib/esm/BeEvent.js.map +1 -1
  136. package/lib/esm/BeSQLite.d.ts +170 -170
  137. package/lib/esm/BeSQLite.js +180 -180
  138. package/lib/esm/BeSQLite.js.map +1 -1
  139. package/lib/esm/BentleyError.d.ts +376 -376
  140. package/lib/esm/BentleyError.js +695 -695
  141. package/lib/esm/BentleyError.js.map +1 -1
  142. package/lib/esm/BentleyLoggerCategory.d.ts +11 -11
  143. package/lib/esm/BentleyLoggerCategory.js +16 -16
  144. package/lib/esm/BentleyLoggerCategory.js.map +1 -1
  145. package/lib/esm/ByteStream.d.ts +92 -92
  146. package/lib/esm/ByteStream.d.ts.map +1 -1
  147. package/lib/esm/ByteStream.js +129 -119
  148. package/lib/esm/ByteStream.js.map +1 -1
  149. package/lib/esm/ClassUtils.d.ts +14 -14
  150. package/lib/esm/ClassUtils.js +22 -22
  151. package/lib/esm/ClassUtils.js.map +1 -1
  152. package/lib/esm/Compare.d.ts +47 -47
  153. package/lib/esm/Compare.d.ts.map +1 -1
  154. package/lib/esm/Compare.js +63 -51
  155. package/lib/esm/Compare.js.map +1 -1
  156. package/lib/esm/CompressedId64Set.d.ts +134 -134
  157. package/lib/esm/CompressedId64Set.js +423 -423
  158. package/lib/esm/CompressedId64Set.js.map +1 -1
  159. package/lib/esm/Dictionary.d.ts +125 -125
  160. package/lib/esm/Dictionary.d.ts.map +1 -1
  161. package/lib/esm/Dictionary.js +199 -199
  162. package/lib/esm/Dictionary.js.map +1 -1
  163. package/lib/esm/Disposable.d.ts +80 -80
  164. package/lib/esm/Disposable.js +112 -112
  165. package/lib/esm/Disposable.js.map +1 -1
  166. package/lib/esm/Id.d.ts +277 -277
  167. package/lib/esm/Id.d.ts.map +1 -1
  168. package/lib/esm/Id.js +625 -615
  169. package/lib/esm/Id.js.map +1 -1
  170. package/lib/esm/IndexMap.d.ts +65 -65
  171. package/lib/esm/IndexMap.js +86 -86
  172. package/lib/esm/IndexMap.js.map +1 -1
  173. package/lib/esm/JsonSchema.d.ts +77 -77
  174. package/lib/esm/JsonSchema.js +8 -8
  175. package/lib/esm/JsonSchema.js.map +1 -1
  176. package/lib/esm/JsonUtils.d.ts +78 -78
  177. package/lib/esm/JsonUtils.d.ts.map +1 -1
  178. package/lib/esm/JsonUtils.js +148 -130
  179. package/lib/esm/JsonUtils.js.map +1 -1
  180. package/lib/esm/LRUMap.d.ts +129 -129
  181. package/lib/esm/LRUMap.d.ts.map +1 -1
  182. package/lib/esm/LRUMap.js +326 -326
  183. package/lib/esm/LRUMap.js.map +1 -1
  184. package/lib/esm/Logger.d.ts +141 -141
  185. package/lib/esm/Logger.js +249 -249
  186. package/lib/esm/Logger.js.map +1 -1
  187. package/lib/esm/ObservableSet.d.ts +23 -23
  188. package/lib/esm/ObservableSet.js +47 -47
  189. package/lib/esm/ObservableSet.js.map +1 -1
  190. package/lib/esm/OneAtATimeAction.d.ts +31 -31
  191. package/lib/esm/OneAtATimeAction.d.ts.map +1 -1
  192. package/lib/esm/OneAtATimeAction.js +89 -86
  193. package/lib/esm/OneAtATimeAction.js.map +1 -1
  194. package/lib/esm/OrderedId64Iterable.d.ts +74 -74
  195. package/lib/esm/OrderedId64Iterable.js +232 -232
  196. package/lib/esm/OrderedId64Iterable.js.map +1 -1
  197. package/lib/esm/OrderedSet.d.ts +40 -40
  198. package/lib/esm/OrderedSet.js +59 -59
  199. package/lib/esm/OrderedSet.js.map +1 -1
  200. package/lib/esm/PriorityQueue.d.ts +70 -70
  201. package/lib/esm/PriorityQueue.js +136 -136
  202. package/lib/esm/PriorityQueue.js.map +1 -1
  203. package/lib/esm/ProcessDetector.d.ts +59 -59
  204. package/lib/esm/ProcessDetector.js +67 -67
  205. package/lib/esm/ProcessDetector.js.map +1 -1
  206. package/lib/esm/SortedArray.d.ts +232 -232
  207. package/lib/esm/SortedArray.d.ts.map +1 -1
  208. package/lib/esm/SortedArray.js +296 -294
  209. package/lib/esm/SortedArray.js.map +1 -1
  210. package/lib/esm/StatusCategory.d.ts +30 -30
  211. package/lib/esm/StatusCategory.js +454 -454
  212. package/lib/esm/StatusCategory.js.map +1 -1
  213. package/lib/esm/StringUtils.d.ts +22 -22
  214. package/lib/esm/StringUtils.d.ts.map +1 -1
  215. package/lib/esm/StringUtils.js +142 -140
  216. package/lib/esm/StringUtils.js.map +1 -1
  217. package/lib/esm/Time.d.ts +122 -122
  218. package/lib/esm/Time.d.ts.map +1 -1
  219. package/lib/esm/Time.js +146 -140
  220. package/lib/esm/Time.js.map +1 -1
  221. package/lib/esm/Tracing.d.ts +40 -40
  222. package/lib/esm/Tracing.d.ts.map +1 -1
  223. package/lib/esm/Tracing.js +126 -123
  224. package/lib/esm/Tracing.js.map +1 -1
  225. package/lib/esm/TypedArrayBuilder.d.ts +98 -0
  226. package/lib/esm/TypedArrayBuilder.d.ts.map +1 -0
  227. package/lib/esm/TypedArrayBuilder.js +128 -0
  228. package/lib/esm/TypedArrayBuilder.js.map +1 -0
  229. package/lib/esm/UnexpectedErrors.d.ts +43 -43
  230. package/lib/esm/UnexpectedErrors.d.ts.map +1 -1
  231. package/lib/esm/UnexpectedErrors.js +64 -61
  232. package/lib/esm/UnexpectedErrors.js.map +1 -1
  233. package/lib/esm/UtilityTypes.d.ts +86 -86
  234. package/lib/esm/UtilityTypes.js +21 -21
  235. package/lib/esm/UtilityTypes.js.map +1 -1
  236. package/lib/esm/YieldManager.d.ts +18 -18
  237. package/lib/esm/YieldManager.js +30 -30
  238. package/lib/esm/YieldManager.js.map +1 -1
  239. package/lib/esm/core-bentley.d.ts +74 -73
  240. package/lib/esm/core-bentley.d.ts.map +1 -1
  241. package/lib/esm/core-bentley.js +78 -77
  242. package/lib/esm/core-bentley.js.map +1 -1
  243. package/lib/esm/partitionArray.d.ts +21 -21
  244. package/lib/esm/partitionArray.js +39 -39
  245. package/lib/esm/partitionArray.js.map +1 -1
  246. package/package.json +5 -5
@@ -1,121 +1,121 @@
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.DisposableList = exports.using = exports.disposeArray = exports.dispose = exports.isIDisposable = void 0;
11
- /**
12
- * A type guard that checks whether the given argument implements `IDisposable` interface
13
- * @public
14
- */
15
- function isIDisposable(obj) {
16
- // eslint-disable-next-line @typescript-eslint/unbound-method
17
- return !!obj && (obj instanceof Object) && !!obj.dispose && (typeof obj.dispose === "function");
18
- }
19
- exports.isIDisposable = isIDisposable;
20
- /** Convenience function for disposing of a disposable object that may be undefined.
21
- * This is primarily used to simplify implementations of [[IDisposable.dispose]].
22
- * As a simple example:
23
- * ```ts
24
- * class Disposable implements IDisposable {
25
- * public member1?: DisposableType1;
26
- * public member2?: DisposableType2;
27
- *
28
- * public dispose() {
29
- * this.member1 = dispose(this.member1); // If member1 is defined, dispose of it and set it to undefined.
30
- * this.member2 = dispose(this.member2); // Likewise for member2.
31
- * }
32
- * }
33
- * ```
34
- * @param disposable The object to be disposed of.
35
- * @returns undefined
36
- * @public
37
- */
38
- function dispose(disposable) {
39
- if (undefined !== disposable)
40
- disposable.dispose();
41
- return undefined;
42
- }
43
- exports.dispose = dispose;
44
- /** Disposes of and empties a list of disposable objects.
45
- * @param list The list of disposable objects.
46
- * @returns undefined
47
- * @public
48
- */
49
- function disposeArray(list) {
50
- if (undefined === list)
51
- return undefined;
52
- for (const entry of list)
53
- dispose(entry);
54
- list.length = 0;
55
- return undefined;
56
- }
57
- exports.disposeArray = disposeArray;
58
- /** A 'using' function which is a substitution for .NET's using statement. It makes sure that 'dispose'
59
- * is called on the resource no matter if the func returns or throws. If func returns, the return value
60
- * of this function is equal to return value of func. If func throws, this function also throws (after
61
- * disposing the resource).
62
- * @public
63
- */
64
- function using(resources, func) {
65
- if (!Array.isArray(resources))
66
- return using([resources], func);
67
- const doDispose = () => resources.forEach((disposable) => disposable.dispose());
68
- let shouldDisposeImmediately = true;
69
- try {
70
- const result = func(...resources);
71
- if (result instanceof Promise) {
72
- shouldDisposeImmediately = false;
73
- result.then(doDispose, doDispose);
74
- }
75
- return result;
76
- }
77
- finally {
78
- if (shouldDisposeImmediately)
79
- doDispose();
80
- }
81
- }
82
- exports.using = using;
83
- class FuncDisposable {
84
- constructor(disposeFunc) { this._disposeFunc = disposeFunc; }
85
- dispose() { this._disposeFunc(); }
86
- }
87
- /** A disposable container of disposable objects.
88
- * @public
89
- */
90
- class DisposableList {
91
- /** Creates a disposable list. */
92
- constructor(disposables = []) {
93
- this._disposables = [];
94
- disposables.forEach((disposable) => {
95
- this.add(disposable);
96
- });
97
- }
98
- isDisposable(x) {
99
- return x.dispose !== undefined;
100
- }
101
- /** Register an object for disposal. */
102
- add(disposable) {
103
- if (this.isDisposable(disposable))
104
- this._disposables.push(disposable);
105
- else
106
- this._disposables.push(new FuncDisposable(disposable));
107
- }
108
- /** Unregister disposable object. */
109
- remove(disposable) {
110
- const idx = this._disposables.indexOf(disposable);
111
- if (-1 !== idx)
112
- this._disposables.splice(idx, 1);
113
- }
114
- /** Disposes all registered objects. */
115
- dispose() {
116
- for (const disposable of this._disposables)
117
- disposable.dispose();
118
- }
119
- }
120
- exports.DisposableList = DisposableList;
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.DisposableList = exports.using = exports.disposeArray = exports.dispose = exports.isIDisposable = void 0;
11
+ /**
12
+ * A type guard that checks whether the given argument implements `IDisposable` interface
13
+ * @public
14
+ */
15
+ function isIDisposable(obj) {
16
+ // eslint-disable-next-line @typescript-eslint/unbound-method
17
+ return !!obj && (obj instanceof Object) && !!obj.dispose && (typeof obj.dispose === "function");
18
+ }
19
+ exports.isIDisposable = isIDisposable;
20
+ /** Convenience function for disposing of a disposable object that may be undefined.
21
+ * This is primarily used to simplify implementations of [[IDisposable.dispose]].
22
+ * As a simple example:
23
+ * ```ts
24
+ * class Disposable implements IDisposable {
25
+ * public member1?: DisposableType1;
26
+ * public member2?: DisposableType2;
27
+ *
28
+ * public dispose() {
29
+ * this.member1 = dispose(this.member1); // If member1 is defined, dispose of it and set it to undefined.
30
+ * this.member2 = dispose(this.member2); // Likewise for member2.
31
+ * }
32
+ * }
33
+ * ```
34
+ * @param disposable The object to be disposed of.
35
+ * @returns undefined
36
+ * @public
37
+ */
38
+ function dispose(disposable) {
39
+ if (undefined !== disposable)
40
+ disposable.dispose();
41
+ return undefined;
42
+ }
43
+ exports.dispose = dispose;
44
+ /** Disposes of and empties a list of disposable objects.
45
+ * @param list The list of disposable objects.
46
+ * @returns undefined
47
+ * @public
48
+ */
49
+ function disposeArray(list) {
50
+ if (undefined === list)
51
+ return undefined;
52
+ for (const entry of list)
53
+ dispose(entry);
54
+ list.length = 0;
55
+ return undefined;
56
+ }
57
+ exports.disposeArray = disposeArray;
58
+ /** A 'using' function which is a substitution for .NET's using statement. It makes sure that 'dispose'
59
+ * is called on the resource no matter if the func returns or throws. If func returns, the return value
60
+ * of this function is equal to return value of func. If func throws, this function also throws (after
61
+ * disposing the resource).
62
+ * @public
63
+ */
64
+ function using(resources, func) {
65
+ if (!Array.isArray(resources))
66
+ return using([resources], func);
67
+ const doDispose = () => resources.forEach((disposable) => disposable.dispose());
68
+ let shouldDisposeImmediately = true;
69
+ try {
70
+ const result = func(...resources);
71
+ if (result instanceof Promise) {
72
+ shouldDisposeImmediately = false;
73
+ result.then(doDispose, doDispose);
74
+ }
75
+ return result;
76
+ }
77
+ finally {
78
+ if (shouldDisposeImmediately)
79
+ doDispose();
80
+ }
81
+ }
82
+ exports.using = using;
83
+ class FuncDisposable {
84
+ constructor(disposeFunc) { this._disposeFunc = disposeFunc; }
85
+ dispose() { this._disposeFunc(); }
86
+ }
87
+ /** A disposable container of disposable objects.
88
+ * @public
89
+ */
90
+ class DisposableList {
91
+ /** Creates a disposable list. */
92
+ constructor(disposables = []) {
93
+ this._disposables = [];
94
+ disposables.forEach((disposable) => {
95
+ this.add(disposable);
96
+ });
97
+ }
98
+ isDisposable(x) {
99
+ return x.dispose !== undefined;
100
+ }
101
+ /** Register an object for disposal. */
102
+ add(disposable) {
103
+ if (this.isDisposable(disposable))
104
+ this._disposables.push(disposable);
105
+ else
106
+ this._disposables.push(new FuncDisposable(disposable));
107
+ }
108
+ /** Unregister disposable object. */
109
+ remove(disposable) {
110
+ const idx = this._disposables.indexOf(disposable);
111
+ if (-1 !== idx)
112
+ this._disposables.splice(idx, 1);
113
+ }
114
+ /** Disposes all registered objects. */
115
+ dispose() {
116
+ for (const disposable of this._disposables)
117
+ disposable.dispose();
118
+ }
119
+ }
120
+ exports.DisposableList = DisposableList;
121
121
  //# sourceMappingURL=Disposable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Disposable.js","sourceRoot":"","sources":["../../src/Disposable.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAwBH;;;GAGG;AACH,SAAgB,aAAa,CAAC,GAAY;IACxC,6DAA6D;IAC7D,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,YAAY,MAAM,CAAC,IAAI,CAAC,CAAE,GAAmB,CAAC,OAAO,IAAI,CAAC,OAAQ,GAAmB,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC;AACpI,CAAC;AAHD,sCAGC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,OAAO,CAAC,UAAwB;IAC9C,IAAI,SAAS,KAAK,UAAU;QAC1B,UAAU,CAAC,OAAO,EAAE,CAAC;IACvB,OAAO,SAAS,CAAC;AACnB,CAAC;AAJD,0BAIC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAoB;IAC/C,IAAI,SAAS,KAAK,IAAI;QACpB,OAAO,SAAS,CAAC;IAEnB,KAAK,MAAM,KAAK,IAAI,IAAI;QACtB,OAAO,CAAC,KAAK,CAAC,CAAC;IAEjB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAChB,OAAO,SAAS,CAAC;AACnB,CAAC;AATD,oCASC;AAED;;;;;GAKG;AACH,SAAgB,KAAK,CAAiC,SAAkB,EAAE,IAA4B;IACpG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;QAC3B,OAAO,KAAK,C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,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,oCAAoC;IAC7B,MAAM,CAAC,UAAuB;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAClD,IAAI,CAAC,CAAC,KAAK,GAAG;YACZ,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,uCAAuC;IAChC,OAAO;QACZ,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,YAAY;YACxC,UAAU,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACF;AAnCD,wCAmCC","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/** Interface adopted by a type which has deterministic cleanup logic.\r\n * For example:\r\n * - Most rendering-related types, such as [[RenderGraphic]] and [[Viewport]], own WebGL resources which must be explicitly released when no longer needed.\r\n * - Some low-level objects like [[ECDb]] own native types defined in C++ code which must be explicitly released when no longer needed.\r\n *\r\n * A similar concept exists in languages like C++ (implemented as \"destructors\") and C# (\"IDisposable\").\r\n * However, because TypeScript and Javascript lack any built-in support for deterministic destruction, it is up to the programmer to ensure dispose() is called appropriately.\r\n * Failure to do so may result in memory leaks or leaking of other resources.\r\n *\r\n * IDisposable tends to be contagious; that is, if a type has members which implement IDisposable, that type should also implement IDisposable to dispose of those members.\r\n *\r\n * Implementations of IDisposable tend to be more \"low-level\" types. The disposal of such types is often handled on your behalf.\r\n * However, always consult the documentation for an IDisposable type to determine under what circumstances you are expected to explicitly dispose of it.\r\n * @public\r\n */\r\nexport interface IDisposable {\r\n /** Disposes of any resources owned by this object.\r\n * @note The object is generally considered unusable after it has been disposed of.\r\n */\r\n dispose(): void;\r\n}\r\n\r\n/**\r\n * A type guard that checks whether the given argument implements `IDisposable` interface\r\n * @public\r\n */\r\nexport function isIDisposable(obj: unknown): obj is IDisposable {\r\n // eslint-disable-next-line @typescript-eslint/unbound-method\r\n return !!obj && (obj instanceof Object) && !!(obj as IDisposable).dispose && (typeof (obj as IDisposable).dispose === \"function\");\r\n}\r\n\r\n/** Convenience function for disposing of a disposable object that may be undefined.\r\n * This is primarily used to simplify implementations of [[IDisposable.dispose]].\r\n * As a simple example:\r\n * ```ts\r\n * class Disposable implements IDisposable {\r\n * public member1?: DisposableType1;\r\n * public member2?: DisposableType2;\r\n *\r\n * public dispose() {\r\n * this.member1 = dispose(this.member1); // If member1 is defined, dispose of it and set it to undefined.\r\n * this.member2 = dispose(this.member2); // Likewise for member2.\r\n * }\r\n * }\r\n * ```\r\n * @param disposable The object to be disposed of.\r\n * @returns undefined\r\n * @public\r\n */\r\nexport function dispose(disposable?: IDisposable): undefined {\r\n if (undefined !== disposable)\r\n disposable.dispose();\r\n return undefined;\r\n}\r\n\r\n/** Disposes of and empties a list of disposable objects.\r\n * @param list The list of disposable objects.\r\n * @returns undefined\r\n * @public\r\n */\r\nexport function disposeArray(list?: IDisposable[]): undefined {\r\n if (undefined === list)\r\n return undefined;\r\n\r\n for (const entry of list)\r\n dispose(entry);\r\n\r\n list.length = 0;\r\n return undefined;\r\n}\r\n\r\n/** A 'using' function which is a substitution for .NET's using statement. It makes sure that 'dispose'\r\n * is called on the resource no matter if the func returns or throws. If func returns, the return value\r\n * of this function is equal to return value of func. If func throws, this function also throws (after\r\n * disposing the resource).\r\n * @public\r\n */\r\nexport function using<T extends IDisposable, TResult>(resources: T | T[], func: (...r: T[]) => TResult): TResult {\r\n if (!Array.isArray(resources))\r\n return using([resources], func);\r\n\r\n const doDispose = () => resources.forEach((disposable) => disposable.dispose());\r\n let shouldDisposeImmediately = true;\r\n\r\n try {\r\n const result = func(...resources);\r\n if (result instanceof Promise) {\r\n shouldDisposeImmediately = false;\r\n result.then(doDispose, doDispose);\r\n }\r\n return result;\r\n } finally {\r\n if (shouldDisposeImmediately)\r\n doDispose();\r\n }\r\n}\r\n\r\n/** A definition of function which may be called to dispose an object\r\n * @public\r\n */\r\nexport type DisposeFunc = () => void;\r\n\r\nclass FuncDisposable implements IDisposable {\r\n private _disposeFunc: () => void;\r\n constructor(disposeFunc: () => void) { this._disposeFunc = disposeFunc; }\r\n public dispose() { this._disposeFunc(); }\r\n}\r\n\r\n/** A disposable container of disposable objects.\r\n * @public\r\n */\r\nexport class DisposableList implements IDisposable {\r\n private _disposables: IDisposable[];\r\n\r\n /** Creates a disposable list. */\r\n constructor(disposables: Array<IDisposable | DisposeFunc> = []) {\r\n this._disposables = [];\r\n disposables.forEach((disposable) => {\r\n this.add(disposable);\r\n });\r\n }\r\n\r\n private isDisposable(x: IDisposable | DisposeFunc): x is IDisposable {\r\n return (x as IDisposable).dispose !== undefined;\r\n }\r\n\r\n /** Register an object for disposal. */\r\n public add(disposable: IDisposable | DisposeFunc) {\r\n if (this.isDisposable(disposable))\r\n this._disposables.push(disposable);\r\n else\r\n this._disposables.push(new FuncDisposable(disposable));\r\n }\r\n\r\n /** Unregister disposable object. */\r\n public remove(disposable: IDisposable): void {\r\n const idx = this._disposables.indexOf(disposable);\r\n if (-1 !== idx)\r\n this._disposables.splice(idx, 1);\r\n }\r\n\r\n /** Disposes all registered objects. */\r\n public dispose(): void {\r\n for (const disposable of this._disposables)\r\n disposable.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Disposable.js","sourceRoot":"","sources":["../../src/Disposable.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAwBH;;;GAGG;AACH,SAAgB,aAAa,CAAC,GAAY;IACxC,6DAA6D;IAC7D,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,YAAY,MAAM,CAAC,IAAI,CAAC,CAAE,GAAmB,CAAC,OAAO,IAAI,CAAC,OAAQ,GAAmB,CAAC,OAAO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G,WAAW,CAAC,CAAC,CAAC;IAClE,OAAO,KAAK,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;CAC1C;AAED;;GAEG;AACH,MAAa,cAAc;IAGzB,iCAAiC;IACjC,YAAY,cAAgD,EAAE;QAC5D,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACjC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,YAAY,CAAC,CAA4B;QAC/C,OAAQ,CAAiB,CAAC,OAAO,KAAK,SAAS,CAAC;IAClD,CAAC;IAED,uCAAuC;IAChC,GAAG,CAAC,UAAqC;QAC9C,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;YAC/B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;;YAEnC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,oCAAoC;IAC7B,MAAM,CAAC,UAAuB;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAClD,IAAI,CAAC,CAAC,KAAK,GAAG;YACZ,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,uCAAuC;IAChC,OAAO;QACZ,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,YAAY;YACxC,UAAU,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACF;AAnCD,wCAmCC","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/** Interface adopted by a type which has deterministic cleanup logic.\n * For example:\n * - Most rendering-related types, such as [[RenderGraphic]] and [[Viewport]], own WebGL resources which must be explicitly released when no longer needed.\n * - Some low-level objects like [[ECDb]] own native types defined in C++ code which must be explicitly released when no longer needed.\n *\n * A similar concept exists in languages like C++ (implemented as \"destructors\") and C# (\"IDisposable\").\n * However, because TypeScript and Javascript lack any built-in support for deterministic destruction, it is up to the programmer to ensure dispose() is called appropriately.\n * Failure to do so may result in memory leaks or leaking of other resources.\n *\n * IDisposable tends to be contagious; that is, if a type has members which implement IDisposable, that type should also implement IDisposable to dispose of those members.\n *\n * Implementations of IDisposable tend to be more \"low-level\" types. The disposal of such types is often handled on your behalf.\n * However, always consult the documentation for an IDisposable type to determine under what circumstances you are expected to explicitly dispose of it.\n * @public\n */\nexport interface IDisposable {\n /** Disposes of any resources owned by this object.\n * @note The object is generally considered unusable after it has been disposed of.\n */\n dispose(): void;\n}\n\n/**\n * A type guard that checks whether the given argument implements `IDisposable` interface\n * @public\n */\nexport function isIDisposable(obj: unknown): obj is IDisposable {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n return !!obj && (obj instanceof Object) && !!(obj as IDisposable).dispose && (typeof (obj as IDisposable).dispose === \"function\");\n}\n\n/** Convenience function for disposing of a disposable object that may be undefined.\n * This is primarily used to simplify implementations of [[IDisposable.dispose]].\n * As a simple example:\n * ```ts\n * class Disposable implements IDisposable {\n * public member1?: DisposableType1;\n * public member2?: DisposableType2;\n *\n * public dispose() {\n * this.member1 = dispose(this.member1); // If member1 is defined, dispose of it and set it to undefined.\n * this.member2 = dispose(this.member2); // Likewise for member2.\n * }\n * }\n * ```\n * @param disposable The object to be disposed of.\n * @returns undefined\n * @public\n */\nexport function dispose(disposable?: IDisposable): undefined {\n if (undefined !== disposable)\n disposable.dispose();\n return undefined;\n}\n\n/** Disposes of and empties a list of disposable objects.\n * @param list The list of disposable objects.\n * @returns undefined\n * @public\n */\nexport function disposeArray(list?: IDisposable[]): undefined {\n if (undefined === list)\n return undefined;\n\n for (const entry of list)\n dispose(entry);\n\n list.length = 0;\n return undefined;\n}\n\n/** A 'using' function which is a substitution for .NET's using statement. It makes sure that 'dispose'\n * is called on the resource no matter if the func returns or throws. If func returns, the return value\n * of this function is equal to return value of func. If func throws, this function also throws (after\n * disposing the resource).\n * @public\n */\nexport function using<T extends IDisposable, TResult>(resources: T | T[], func: (...r: T[]) => TResult): TResult {\n if (!Array.isArray(resources))\n return using([resources], func);\n\n const doDispose = () => resources.forEach((disposable) => disposable.dispose());\n let shouldDisposeImmediately = true;\n\n try {\n const result = func(...resources);\n if (result instanceof Promise) {\n shouldDisposeImmediately = false;\n result.then(doDispose, doDispose);\n }\n return result;\n } finally {\n if (shouldDisposeImmediately)\n doDispose();\n }\n}\n\n/** A definition of function which may be called to dispose an object\n * @public\n */\nexport type DisposeFunc = () => void;\n\nclass FuncDisposable implements IDisposable {\n private _disposeFunc: () => void;\n constructor(disposeFunc: () => void) { this._disposeFunc = disposeFunc; }\n public dispose() { this._disposeFunc(); }\n}\n\n/** A disposable container of disposable objects.\n * @public\n */\nexport class DisposableList implements IDisposable {\n private _disposables: IDisposable[];\n\n /** Creates a disposable list. */\n constructor(disposables: Array<IDisposable | DisposeFunc> = []) {\n this._disposables = [];\n disposables.forEach((disposable) => {\n this.add(disposable);\n });\n }\n\n private isDisposable(x: IDisposable | DisposeFunc): x is IDisposable {\n return (x as IDisposable).dispose !== undefined;\n }\n\n /** Register an object for disposal. */\n public add(disposable: IDisposable | DisposeFunc) {\n if (this.isDisposable(disposable))\n this._disposables.push(disposable);\n else\n this._disposables.push(new FuncDisposable(disposable));\n }\n\n /** Unregister disposable object. */\n public remove(disposable: IDisposable): void {\n const idx = this._disposables.indexOf(disposable);\n if (-1 !== idx)\n this._disposables.splice(idx, 1);\n }\n\n /** Disposes all registered objects. */\n public dispose(): void {\n for (const disposable of this._disposables)\n disposable.dispose();\n }\n}\n"]}