@itwin/core-bentley 4.0.0-dev.7 → 4.0.0-dev.72

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 (211) hide show
  1. package/CHANGELOG.md +50 -1
  2. package/lib/cjs/AccessToken.d.ts +10 -10
  3. package/lib/cjs/AccessToken.d.ts.map +1 -1
  4. package/lib/cjs/AccessToken.js +9 -9
  5. package/lib/cjs/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/BeEvent.d.ts +81 -81
  9. package/lib/cjs/BeEvent.d.ts.map +1 -1
  10. package/lib/cjs/BeEvent.js +156 -156
  11. package/lib/cjs/BeSQLite.d.ts +172 -170
  12. package/lib/cjs/BeSQLite.d.ts.map +1 -1
  13. package/lib/cjs/BeSQLite.js +185 -183
  14. package/lib/cjs/BeSQLite.js.map +1 -1
  15. package/lib/cjs/BentleyError.d.ts +378 -378
  16. package/lib/cjs/BentleyError.d.ts.map +1 -1
  17. package/lib/cjs/BentleyError.js +703 -702
  18. package/lib/cjs/BentleyError.js.map +1 -1
  19. package/lib/cjs/BentleyLoggerCategory.d.ts +11 -11
  20. package/lib/cjs/BentleyLoggerCategory.js +19 -19
  21. package/lib/cjs/ByteStream.d.ts +110 -110
  22. package/lib/cjs/ByteStream.js +159 -159
  23. package/lib/cjs/ClassUtils.d.ts +14 -14
  24. package/lib/cjs/ClassUtils.js +27 -27
  25. package/lib/cjs/Compare.d.ts +47 -47
  26. package/lib/cjs/Compare.d.ts.map +1 -1
  27. package/lib/cjs/Compare.js +75 -75
  28. package/lib/cjs/CompressedId64Set.d.ts +134 -134
  29. package/lib/cjs/CompressedId64Set.d.ts.map +1 -1
  30. package/lib/cjs/CompressedId64Set.js +428 -428
  31. package/lib/cjs/CompressedId64Set.js.map +1 -1
  32. package/lib/cjs/Dictionary.d.ts +125 -125
  33. package/lib/cjs/Dictionary.js +203 -203
  34. package/lib/cjs/Disposable.d.ts +80 -80
  35. package/lib/cjs/Disposable.d.ts.map +1 -1
  36. package/lib/cjs/Disposable.js +120 -120
  37. package/lib/cjs/Id.d.ts +285 -285
  38. package/lib/cjs/Id.d.ts.map +1 -1
  39. package/lib/cjs/Id.js +643 -643
  40. package/lib/cjs/IndexMap.d.ts +65 -65
  41. package/lib/cjs/IndexMap.js +91 -91
  42. package/lib/cjs/JsonSchema.d.ts +77 -77
  43. package/lib/cjs/JsonSchema.d.ts.map +1 -1
  44. package/lib/cjs/JsonSchema.js +9 -9
  45. package/lib/cjs/JsonUtils.d.ts +78 -78
  46. package/lib/cjs/JsonUtils.js +151 -151
  47. package/lib/cjs/LRUMap.d.ts +129 -129
  48. package/lib/cjs/LRUMap.js +333 -333
  49. package/lib/cjs/LRUMap.js.map +1 -1
  50. package/lib/cjs/Logger.d.ts +143 -143
  51. package/lib/cjs/Logger.d.ts.map +1 -1
  52. package/lib/cjs/Logger.js +256 -258
  53. package/lib/cjs/Logger.js.map +1 -1
  54. package/lib/cjs/ObservableSet.d.ts +23 -23
  55. package/lib/cjs/ObservableSet.js +51 -51
  56. package/lib/cjs/OneAtATimeAction.d.ts +31 -31
  57. package/lib/cjs/OneAtATimeAction.js +94 -94
  58. package/lib/cjs/OneAtATimeAction.js.map +1 -1
  59. package/lib/cjs/OrderedId64Iterable.d.ts +74 -74
  60. package/lib/cjs/OrderedId64Iterable.d.ts.map +1 -1
  61. package/lib/cjs/OrderedId64Iterable.js +235 -235
  62. package/lib/cjs/OrderedSet.d.ts +40 -40
  63. package/lib/cjs/OrderedSet.js +64 -64
  64. package/lib/cjs/PriorityQueue.d.ts +70 -70
  65. package/lib/cjs/PriorityQueue.d.ts.map +1 -1
  66. package/lib/cjs/PriorityQueue.js +140 -140
  67. package/lib/cjs/ProcessDetector.d.ts +59 -59
  68. package/lib/cjs/ProcessDetector.js +71 -71
  69. package/lib/cjs/SortedArray.d.ts +236 -232
  70. package/lib/cjs/SortedArray.d.ts.map +1 -1
  71. package/lib/cjs/SortedArray.js +315 -303
  72. package/lib/cjs/SortedArray.js.map +1 -1
  73. package/lib/cjs/StatusCategory.d.ts +30 -30
  74. package/lib/cjs/StatusCategory.d.ts.map +1 -1
  75. package/lib/cjs/StatusCategory.js +460 -460
  76. package/lib/cjs/StatusCategory.js.map +1 -1
  77. package/lib/cjs/StringUtils.d.ts +22 -22
  78. package/lib/cjs/StringUtils.js +148 -148
  79. package/lib/cjs/Time.d.ts +122 -122
  80. package/lib/cjs/Time.js +152 -152
  81. package/lib/cjs/Time.js.map +1 -1
  82. package/lib/cjs/Tracing.d.ts +43 -40
  83. package/lib/cjs/Tracing.d.ts.map +1 -1
  84. package/lib/cjs/Tracing.js +134 -130
  85. package/lib/cjs/Tracing.js.map +1 -1
  86. package/lib/cjs/TupleKeyedMap.d.ts +36 -36
  87. package/lib/cjs/TupleKeyedMap.js +102 -102
  88. package/lib/cjs/TypedArrayBuilder.d.ts +155 -155
  89. package/lib/cjs/TypedArrayBuilder.d.ts.map +1 -1
  90. package/lib/cjs/TypedArrayBuilder.js +206 -208
  91. package/lib/cjs/TypedArrayBuilder.js.map +1 -1
  92. package/lib/cjs/UnexpectedErrors.d.ts +43 -43
  93. package/lib/cjs/UnexpectedErrors.d.ts.map +1 -1
  94. package/lib/cjs/UnexpectedErrors.js +68 -68
  95. package/lib/cjs/UnexpectedErrors.js.map +1 -1
  96. package/lib/cjs/UtilityTypes.d.ts +112 -96
  97. package/lib/cjs/UtilityTypes.d.ts.map +1 -1
  98. package/lib/cjs/UtilityTypes.js +40 -40
  99. package/lib/cjs/UtilityTypes.js.map +1 -1
  100. package/lib/cjs/YieldManager.d.ts +18 -18
  101. package/lib/cjs/YieldManager.js +34 -34
  102. package/lib/cjs/core-bentley.d.ts +74 -74
  103. package/lib/cjs/core-bentley.js +94 -90
  104. package/lib/cjs/core-bentley.js.map +1 -1
  105. package/lib/cjs/partitionArray.d.ts +21 -21
  106. package/lib/cjs/partitionArray.js +43 -43
  107. package/lib/esm/AccessToken.d.ts +10 -10
  108. package/lib/esm/AccessToken.d.ts.map +1 -1
  109. package/lib/esm/AccessToken.js +8 -8
  110. package/lib/esm/Assert.d.ts +25 -25
  111. package/lib/esm/Assert.js +41 -41
  112. package/lib/esm/Assert.js.map +1 -1
  113. package/lib/esm/BeEvent.d.ts +81 -81
  114. package/lib/esm/BeEvent.d.ts.map +1 -1
  115. package/lib/esm/BeEvent.js +150 -150
  116. package/lib/esm/BeSQLite.d.ts +172 -170
  117. package/lib/esm/BeSQLite.d.ts.map +1 -1
  118. package/lib/esm/BeSQLite.js +182 -180
  119. package/lib/esm/BeSQLite.js.map +1 -1
  120. package/lib/esm/BentleyError.d.ts +378 -378
  121. package/lib/esm/BentleyError.d.ts.map +1 -1
  122. package/lib/esm/BentleyError.js +699 -698
  123. package/lib/esm/BentleyError.js.map +1 -1
  124. package/lib/esm/BentleyLoggerCategory.d.ts +11 -11
  125. package/lib/esm/BentleyLoggerCategory.js +16 -16
  126. package/lib/esm/ByteStream.d.ts +110 -110
  127. package/lib/esm/ByteStream.js +155 -155
  128. package/lib/esm/ClassUtils.d.ts +14 -14
  129. package/lib/esm/ClassUtils.js +22 -22
  130. package/lib/esm/Compare.d.ts +47 -47
  131. package/lib/esm/Compare.d.ts.map +1 -1
  132. package/lib/esm/Compare.js +63 -63
  133. package/lib/esm/CompressedId64Set.d.ts +134 -134
  134. package/lib/esm/CompressedId64Set.d.ts.map +1 -1
  135. package/lib/esm/CompressedId64Set.js +423 -423
  136. package/lib/esm/CompressedId64Set.js.map +1 -1
  137. package/lib/esm/Dictionary.d.ts +125 -125
  138. package/lib/esm/Dictionary.js +199 -199
  139. package/lib/esm/Disposable.d.ts +80 -80
  140. package/lib/esm/Disposable.d.ts.map +1 -1
  141. package/lib/esm/Disposable.js +112 -112
  142. package/lib/esm/Id.d.ts +285 -285
  143. package/lib/esm/Id.d.ts.map +1 -1
  144. package/lib/esm/Id.js +639 -639
  145. package/lib/esm/IndexMap.d.ts +65 -65
  146. package/lib/esm/IndexMap.js +86 -86
  147. package/lib/esm/JsonSchema.d.ts +77 -77
  148. package/lib/esm/JsonSchema.d.ts.map +1 -1
  149. package/lib/esm/JsonSchema.js +8 -8
  150. package/lib/esm/JsonUtils.d.ts +78 -78
  151. package/lib/esm/JsonUtils.js +148 -148
  152. package/lib/esm/LRUMap.d.ts +129 -129
  153. package/lib/esm/LRUMap.js +326 -326
  154. package/lib/esm/LRUMap.js.map +1 -1
  155. package/lib/esm/Logger.d.ts +143 -143
  156. package/lib/esm/Logger.d.ts.map +1 -1
  157. package/lib/esm/Logger.js +253 -253
  158. package/lib/esm/Logger.js.map +1 -1
  159. package/lib/esm/ObservableSet.d.ts +23 -23
  160. package/lib/esm/ObservableSet.js +47 -47
  161. package/lib/esm/OneAtATimeAction.d.ts +31 -31
  162. package/lib/esm/OneAtATimeAction.js +89 -89
  163. package/lib/esm/OneAtATimeAction.js.map +1 -1
  164. package/lib/esm/OrderedId64Iterable.d.ts +74 -74
  165. package/lib/esm/OrderedId64Iterable.d.ts.map +1 -1
  166. package/lib/esm/OrderedId64Iterable.js +232 -232
  167. package/lib/esm/OrderedSet.d.ts +40 -40
  168. package/lib/esm/OrderedSet.js +59 -59
  169. package/lib/esm/PriorityQueue.d.ts +70 -70
  170. package/lib/esm/PriorityQueue.d.ts.map +1 -1
  171. package/lib/esm/PriorityQueue.js +136 -136
  172. package/lib/esm/ProcessDetector.d.ts +59 -59
  173. package/lib/esm/ProcessDetector.js +67 -67
  174. package/lib/esm/SortedArray.d.ts +236 -232
  175. package/lib/esm/SortedArray.d.ts.map +1 -1
  176. package/lib/esm/SortedArray.js +308 -296
  177. package/lib/esm/SortedArray.js.map +1 -1
  178. package/lib/esm/StatusCategory.d.ts +30 -30
  179. package/lib/esm/StatusCategory.d.ts.map +1 -1
  180. package/lib/esm/StatusCategory.js +455 -454
  181. package/lib/esm/StatusCategory.js.map +1 -1
  182. package/lib/esm/StringUtils.d.ts +22 -22
  183. package/lib/esm/StringUtils.js +142 -142
  184. package/lib/esm/Time.d.ts +122 -122
  185. package/lib/esm/Time.js +146 -146
  186. package/lib/esm/Time.js.map +1 -1
  187. package/lib/esm/Tracing.d.ts +43 -40
  188. package/lib/esm/Tracing.d.ts.map +1 -1
  189. package/lib/esm/Tracing.js +130 -126
  190. package/lib/esm/Tracing.js.map +1 -1
  191. package/lib/esm/TupleKeyedMap.d.ts +36 -36
  192. package/lib/esm/TupleKeyedMap.js +98 -98
  193. package/lib/esm/TypedArrayBuilder.d.ts +155 -155
  194. package/lib/esm/TypedArrayBuilder.d.ts.map +1 -1
  195. package/lib/esm/TypedArrayBuilder.js +198 -200
  196. package/lib/esm/TypedArrayBuilder.js.map +1 -1
  197. package/lib/esm/UnexpectedErrors.d.ts +43 -43
  198. package/lib/esm/UnexpectedErrors.d.ts.map +1 -1
  199. package/lib/esm/UnexpectedErrors.js +65 -64
  200. package/lib/esm/UnexpectedErrors.js.map +1 -1
  201. package/lib/esm/UtilityTypes.d.ts +112 -96
  202. package/lib/esm/UtilityTypes.d.ts.map +1 -1
  203. package/lib/esm/UtilityTypes.js +34 -34
  204. package/lib/esm/UtilityTypes.js.map +1 -1
  205. package/lib/esm/YieldManager.d.ts +18 -18
  206. package/lib/esm/YieldManager.js +30 -30
  207. package/lib/esm/core-bentley.d.ts +74 -74
  208. package/lib/esm/core-bentley.js +78 -78
  209. package/lib/esm/partitionArray.d.ts +21 -21
  210. package/lib/esm/partitionArray.js +39 -39
  211. package/package.json +9 -9
@@ -1,99 +1,99 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- /** @packageDocumentation
6
- * @module Collections
7
- */
8
- /** A map similar to the standard JavaScript Map collection except that the keys must be a tuple
9
- * (javascript array), and two keys are considered equal if their elements in order are strict-equal,
10
- * and the tuples have the same amount of elements
11
- *
12
- * This means you can use array literals to key data in Maps that would otherwise be reference-compared
13
- * if using JavaScript's built in Map
14
- *
15
- * Note that JavaScript's Map type, unlike this one that uses strict equality, uses instead
16
- * SameValueZero equality comparison
17
- * @see https://262.ecma-international.org/6.0/#sec-samevaluezero
18
- *
19
- * ```js
20
- * const map = new TupleKeyedMap([[1,"y"], "value"]);
21
- * const value = map.get([1, "y"]); // a normal map would identify these keys as different because they are independent objects
22
- * ```
23
- *
24
- * It is implemented by each index of the tuple key being used as a singular key into a submap
25
- * @note this only implements a subset of the Map interface
26
- * @public
27
- */
28
- export class TupleKeyedMap {
29
- // argument types match those of Map
30
- constructor(entries) {
31
- this._map = new Map();
32
- this._size = 0;
33
- if (entries)
34
- for (const [k, v] of entries) {
35
- this.set(k, v);
36
- }
37
- }
38
- clear() {
39
- return this._map.clear();
40
- }
41
- makeKeyError() {
42
- return Error("A Bad key was used, it didn't match the key type of the the map.");
43
- }
44
- get(key) {
45
- let cursor = this._map;
46
- for (const subkey of key) {
47
- if (!(cursor instanceof Map))
48
- throw this.makeKeyError();
49
- cursor = cursor.get(subkey);
50
- if (cursor === undefined)
51
- return undefined;
52
- }
53
- if (cursor instanceof Map)
54
- throw this.makeKeyError();
55
- return cursor;
56
- }
57
- has(key) {
58
- return this.get(key) !== undefined;
59
- }
60
- set(key, value) {
61
- let cursor = this._map;
62
- for (let i = 0; i < key.length - 1; ++i) {
63
- const subkey = key[i];
64
- let next = cursor.get(subkey);
65
- if (next === undefined) {
66
- next = new Map();
67
- cursor.set(subkey, next);
68
- }
69
- cursor = next;
70
- }
71
- const finalSubkey = key[key.length - 1];
72
- if (!(cursor instanceof Map))
73
- throw this.makeKeyError();
74
- cursor.set(finalSubkey, value);
75
- this._size++;
76
- return this;
77
- }
78
- *[Symbol.iterator]() {
79
- function* impl(map, keyPrefix) {
80
- for (const [k, v] of map) {
81
- const nextKey = [...keyPrefix, k];
82
- if (v instanceof Map) {
83
- yield* impl(v, nextKey);
84
- }
85
- else {
86
- yield [nextKey, v];
87
- }
88
- }
89
- }
90
- yield* impl(this._map, []);
91
- }
92
- get size() {
93
- return this._size;
94
- }
95
- get [Symbol.toStringTag]() {
96
- return this.constructor.name;
97
- }
98
- }
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module Collections
7
+ */
8
+ /** A map similar to the standard JavaScript Map collection except that the keys must be a tuple
9
+ * (javascript array), and two keys are considered equal if their elements in order are strict-equal,
10
+ * and the tuples have the same amount of elements
11
+ *
12
+ * This means you can use array literals to key data in Maps that would otherwise be reference-compared
13
+ * if using JavaScript's built in Map
14
+ *
15
+ * Note that JavaScript's Map type, unlike this one that uses strict equality, uses instead
16
+ * SameValueZero equality comparison
17
+ * @see https://262.ecma-international.org/6.0/#sec-samevaluezero
18
+ *
19
+ * ```js
20
+ * const map = new TupleKeyedMap([[1,"y"], "value"]);
21
+ * const value = map.get([1, "y"]); // a normal map would identify these keys as different because they are independent objects
22
+ * ```
23
+ *
24
+ * It is implemented by each index of the tuple key being used as a singular key into a submap
25
+ * @note this only implements a subset of the Map interface
26
+ * @public
27
+ */
28
+ export class TupleKeyedMap {
29
+ // argument types match those of Map
30
+ constructor(entries) {
31
+ this._map = new Map();
32
+ this._size = 0;
33
+ if (entries)
34
+ for (const [k, v] of entries) {
35
+ this.set(k, v);
36
+ }
37
+ }
38
+ clear() {
39
+ return this._map.clear();
40
+ }
41
+ makeKeyError() {
42
+ return Error("A Bad key was used, it didn't match the key type of the the map.");
43
+ }
44
+ get(key) {
45
+ let cursor = this._map;
46
+ for (const subkey of key) {
47
+ if (!(cursor instanceof Map))
48
+ throw this.makeKeyError();
49
+ cursor = cursor.get(subkey);
50
+ if (cursor === undefined)
51
+ return undefined;
52
+ }
53
+ if (cursor instanceof Map)
54
+ throw this.makeKeyError();
55
+ return cursor;
56
+ }
57
+ has(key) {
58
+ return this.get(key) !== undefined;
59
+ }
60
+ set(key, value) {
61
+ let cursor = this._map;
62
+ for (let i = 0; i < key.length - 1; ++i) {
63
+ const subkey = key[i];
64
+ let next = cursor.get(subkey);
65
+ if (next === undefined) {
66
+ next = new Map();
67
+ cursor.set(subkey, next);
68
+ }
69
+ cursor = next;
70
+ }
71
+ const finalSubkey = key[key.length - 1];
72
+ if (!(cursor instanceof Map))
73
+ throw this.makeKeyError();
74
+ cursor.set(finalSubkey, value);
75
+ this._size++;
76
+ return this;
77
+ }
78
+ *[Symbol.iterator]() {
79
+ function* impl(map, keyPrefix) {
80
+ for (const [k, v] of map) {
81
+ const nextKey = [...keyPrefix, k];
82
+ if (v instanceof Map) {
83
+ yield* impl(v, nextKey);
84
+ }
85
+ else {
86
+ yield [nextKey, v];
87
+ }
88
+ }
89
+ }
90
+ yield* impl(this._map, []);
91
+ }
92
+ get size() {
93
+ return this._size;
94
+ }
95
+ get [Symbol.toStringTag]() {
96
+ return this.constructor.name;
97
+ }
98
+ }
99
99
  //# sourceMappingURL=TupleKeyedMap.js.map
@@ -1,156 +1,156 @@
1
- /** @packageDocumentation
2
- * @module Collections
3
- */
4
- import { Constructor } from "./UtilityTypes";
5
- /** Options used to construct a [[TypedArrayBuilder]].
6
- * @public
7
- */
8
- export interface TypedArrayBuilderOptions {
9
- /** Controls how much additional memory is allocated when the TypedArray needs to be resized to accomodate more elements.
10
- * [[TypedArrayBuilder.ensureCapacity]] multiplies the required capacity by this factor to determine the new capacity.
11
- * Default: 1.5
12
- * Minimum: 1.0, which causes the TypedArray to allocate exactly the space it needs each time it is resized.
13
- */
14
- growthFactor?: number;
15
- /** The number of elements to allocate memory for in the TypedArray when creating the builder.
16
- * If you know the minimum number of elements you intend to add to the builder, you should specify that as the
17
- * initial capacity to avoid reallocations when populating the array.
18
- * Default: 0.
19
- * Minimum: 0.
20
- */
21
- initialCapacity?: number;
22
- }
23
- /** A [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) containing unsigned 8-, 16-, or 32-bit integers.
24
- * @see [[UintArrayBuilder]] to construct such an array.
25
- * @public
26
- */
27
- export declare type UintArray = Uint8Array | Uint16Array | Uint32Array;
28
- /** Incrementally builds a [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) of unsigned 8-, 16-, or 32-bit integers.
29
- * Sometimes you wish to populate a `TypedArray`, but you don't know how many elements you will need.
30
- * `TypedArray` requires you to specify the size upon construction, and does not permit you to change the size later.
31
- *
32
- * `TypedArrayBuilder` manages a `TypedArray`, permitting you to [[push]] and [[append]] elements to it. It exposes two "size" properties":
33
- * - [[capacity]], the number of elements it has currently allocated space for - i.e., the length of the underlying TypedArray; and
34
- * - [[length]], the number of elements that have so far been added to it, which is never bigger than [[capacity]].
35
- * When [[capacity]] is exceeded, a new, bigger TypedArray is allocated and the contents of the previous array are copied over to it.
36
- *
37
- * Once you've finished adding elements, you can obtain the finished `TypedArray` via [[toTypedArray]].
38
- * @see [[Uint8ArrayBuilder]], [[Uint16ArrayBuilder]], and [[Uint32ArrayBuilder]] to build specific types of arrays.
39
- * @see [[UintArrayBuilder]] when you don't know the maximum number of bytes required for each element in the array.
40
- * @public
41
- */
42
- export declare class TypedArrayBuilder<T extends UintArray> {
43
- /** The constructor for the specific type of array being populated. */
44
- protected _constructor: Constructor<T>;
45
- /** The underlying typed array, to be reallocated and copied when its capacity is exceeded. */
46
- protected _data: T;
47
- /** The number of elements added to the array so far. */
48
- protected _length: number;
49
- /** Multiplier applied to required capacity by [[ensureCapacity]]. */
50
- readonly growthFactor: number;
51
- /** Constructs a new builder from the specified options, with a [[length]] of zero. */
52
- protected constructor(constructor: Constructor<T>, options?: TypedArrayBuilderOptions);
53
- /** The number of elements currently in the array. */
54
- get length(): number;
55
- /** The number of elements that can fit into the memory currently allocated for the array. */
56
- get capacity(): number;
57
- /** Like [TypedArray.at](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/at),
58
- * returns the element at the specified index, with negative integers counting back from the end of the array.
59
- * @note It is your responsibility to ensure the index falls within the bounds of the array.
60
- */
61
- at(index: number): number;
62
- /** Ensure that [[capacity]] is at least equal to `newCapacity`.
63
- * This is used internally by methods like [[push]] and [[append]] to ensure the array has room for the element(s) to be added.
64
- * It can also be useful when you know you intend to add some number of additional elements, to minimize reallocations.
65
- *
66
- * If `newCapacity` is not greater than the current [[capacity]], this function does nothing.
67
- * Otherwise, it allocates a new `TypedArray` with room for `newCapacity * growthFactor` elements, and copies the contents of the previous `TypedArray` into it.
68
- * [[length]] remains unchanged; [[capacity]] reflects the size of the new TypeArray.
69
- */
70
- ensureCapacity(newCapacity: number): number;
71
- /** Append the specified value, resizing if necessary. */
72
- push(value: number): void;
73
- /** Append an array of values, resizing (at most once) if necessary. */
74
- append(values: T): void;
75
- /** Obtain the finished array.
76
- * @param includeUnusedCapacity If true, the length of the returned array will be equal to [[capacity]], with extra bytes initialized to zero; otherwise, the
77
- * returned array's length will be equal to [[length]].
78
- */
79
- toTypedArray(includeUnusedCapacity?: boolean): T;
80
- }
81
- /** A [[TypedArrayBuilder]] for producing a [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).
82
- * @public
83
- */
84
- export declare class Uint8ArrayBuilder extends TypedArrayBuilder<Uint8Array> {
85
- /** See [[TypedArrayBuilder]] constructor. */
86
- constructor(options?: TypedArrayBuilderOptions);
87
- }
88
- /** A [[TypedArrayBuilder]] for producing a [Uint16Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array).
89
- * @public
90
- */
91
- export declare class Uint16ArrayBuilder extends TypedArrayBuilder<Uint16Array> {
92
- /** See [[TypedArrayBuilder]] constructor. */
93
- constructor(options?: TypedArrayBuilderOptions);
94
- }
95
- /** A [[TypedArrayBuilder]] for producing a [Uint32Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array).
96
- * @public
97
- */
98
- export declare class Uint32ArrayBuilder extends TypedArrayBuilder<Uint32Array> {
99
- /** See [[TypedArrayBuilder]] constructor. */
100
- constructor(options?: TypedArrayBuilderOptions);
101
- /** Obtain a view of the finished array as an array of bytes. */
102
- toUint8Array(includeUnusedCapacity?: boolean): Uint8Array;
103
- }
104
- /** Options used to construct a [[UintArrayBuilder]].
105
- * @public
106
- */
107
- export interface UintArrayBuilderOptions extends TypedArrayBuilderOptions {
108
- /** The type of the initial empty `TypedArray` created by the builder. For example, if you know that you will be adding values larger than
109
- * 255 to the array, specify `{ initialType: Uint16Array }` to avoid replacing the otherwise default `Uint8Array` when the first such value is added.
110
- * Default: `Uint8Array`.
111
- */
112
- initialType?: typeof Uint8Array | typeof Uint16Array | typeof Uint32Array;
113
- }
114
- /** A [[TypedArrayBuilder]] that can populate a [[UintArray]] with the minimum
115
- * [bytes per element](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT) required.
116
- *
117
- * By default, the underlying array is a `Uint8Array`, though this can be configured via [[UintArrayBuilderOptions.initialType]].
118
- * As values are added to the array, if the bytes per element supported by the underlying array is too small to hold one of the new values, the array is
119
- * reallocated to a type large enough to hold all of the new values. For example, the following produces a `Uint8Array` because all values are less than 256:
120
- *
121
- * ```ts
122
- * const builder = new UintArrayBuilder();
123
- * builder.append([1, 2, 254, 255]);
124
- * const array = builder.toTypedArray();
125
- * assert(array instanceof Uint8Array);
126
- * ```
127
- *
128
- * However, the following produces a `Uint16Array` because one of the values is larger than 255 but none are larger than 65,535:
129
- *
130
- * ```ts
131
- * const builder = new UintArrayBuilder();
132
- * builder.append([1, 255, 257, 65535]);
133
- * const array = builder.toTypedArray();
134
- * assert(array instanceof Uint16Array);
135
- * ```
136
- *
137
- * @see [[Uint8ArrayBuilder]], [[Uint16ArrayBuilder]], or [[Uint32ArrayBuilder]] if you know the number of bytes you want to allocate for each element in the array.
138
- * @public
139
- */
140
- export declare class UintArrayBuilder extends TypedArrayBuilder<UintArray> {
141
- constructor(options?: UintArrayBuilderOptions);
142
- /** The number of bytes (1, 2, or 4) currently allocated per element by the underlying array.
143
- * This may change as larger values are added to the array.
144
- */
145
- get bytesPerElement(): number;
146
- /** Ensures that the underlying array is of a type that can contain the largest value in `newValues`.
147
- * For example, if `_data` is a `Uint16Array` and `newValues` contains any value(s) larger than 65,535, it will be replaced with a `Uint32Array`.
148
- * This method is invoked by [[push]] and [[append]].
149
- */
150
- protected ensureBytesPerElement(newValues: Iterable<number>): void;
151
- /** See [[TypedArrayBuilder.push]]. */
152
- push(value: number): void;
153
- /** See [[TypedArrayBuilder.append]]. */
154
- append(values: UintArray): void;
155
- }
1
+ /** @packageDocumentation
2
+ * @module Collections
3
+ */
4
+ import { Constructor } from "./UtilityTypes";
5
+ /** Options used to construct a [[TypedArrayBuilder]].
6
+ * @public
7
+ */
8
+ export interface TypedArrayBuilderOptions {
9
+ /** Controls how much additional memory is allocated when the TypedArray needs to be resized to accomodate more elements.
10
+ * [[TypedArrayBuilder.ensureCapacity]] multiplies the required capacity by this factor to determine the new capacity.
11
+ * Default: 1.5
12
+ * Minimum: 1.0, which causes the TypedArray to allocate exactly the space it needs each time it is resized.
13
+ */
14
+ growthFactor?: number;
15
+ /** The number of elements to allocate memory for in the TypedArray when creating the builder.
16
+ * If you know the minimum number of elements you intend to add to the builder, you should specify that as the
17
+ * initial capacity to avoid reallocations when populating the array.
18
+ * Default: 0.
19
+ * Minimum: 0.
20
+ */
21
+ initialCapacity?: number;
22
+ }
23
+ /** A [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) containing unsigned 8-, 16-, or 32-bit integers.
24
+ * @see [[UintArrayBuilder]] to construct such an array.
25
+ * @public
26
+ */
27
+ export type UintArray = Uint8Array | Uint16Array | Uint32Array;
28
+ /** Incrementally builds a [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) of unsigned 8-, 16-, or 32-bit integers.
29
+ * Sometimes you wish to populate a `TypedArray`, but you don't know how many elements you will need.
30
+ * `TypedArray` requires you to specify the size upon construction, and does not permit you to change the size later.
31
+ *
32
+ * `TypedArrayBuilder` manages a `TypedArray`, permitting you to [[push]] and [[append]] elements to it. It exposes two "size" properties":
33
+ * - [[capacity]], the number of elements it has currently allocated space for - i.e., the length of the underlying TypedArray; and
34
+ * - [[length]], the number of elements that have so far been added to it, which is never bigger than [[capacity]].
35
+ * When [[capacity]] is exceeded, a new, bigger TypedArray is allocated and the contents of the previous array are copied over to it.
36
+ *
37
+ * Once you've finished adding elements, you can obtain the finished `TypedArray` via [[toTypedArray]].
38
+ * @see [[Uint8ArrayBuilder]], [[Uint16ArrayBuilder]], and [[Uint32ArrayBuilder]] to build specific types of arrays.
39
+ * @see [[UintArrayBuilder]] when you don't know the maximum number of bytes required for each element in the array.
40
+ * @public
41
+ */
42
+ export declare class TypedArrayBuilder<T extends UintArray> {
43
+ /** The constructor for the specific type of array being populated. */
44
+ protected _constructor: Constructor<T>;
45
+ /** The underlying typed array, to be reallocated and copied when its capacity is exceeded. */
46
+ protected _data: T;
47
+ /** The number of elements added to the array so far. */
48
+ protected _length: number;
49
+ /** Multiplier applied to required capacity by [[ensureCapacity]]. */
50
+ readonly growthFactor: number;
51
+ /** Constructs a new builder from the specified options, with a [[length]] of zero. */
52
+ protected constructor(constructor: Constructor<T>, options?: TypedArrayBuilderOptions);
53
+ /** The number of elements currently in the array. */
54
+ get length(): number;
55
+ /** The number of elements that can fit into the memory currently allocated for the array. */
56
+ get capacity(): number;
57
+ /** Like [TypedArray.at](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/at),
58
+ * returns the element at the specified index, with negative integers counting back from the end of the array.
59
+ * @note It is your responsibility to ensure the index falls within the bounds of the array.
60
+ */
61
+ at(index: number): number;
62
+ /** Ensure that [[capacity]] is at least equal to `newCapacity`.
63
+ * This is used internally by methods like [[push]] and [[append]] to ensure the array has room for the element(s) to be added.
64
+ * It can also be useful when you know you intend to add some number of additional elements, to minimize reallocations.
65
+ *
66
+ * If `newCapacity` is not greater than the current [[capacity]], this function does nothing.
67
+ * Otherwise, it allocates a new `TypedArray` with room for `newCapacity * growthFactor` elements, and copies the contents of the previous `TypedArray` into it.
68
+ * [[length]] remains unchanged; [[capacity]] reflects the size of the new TypeArray.
69
+ */
70
+ ensureCapacity(newCapacity: number): number;
71
+ /** Append the specified value, resizing if necessary. */
72
+ push(value: number): void;
73
+ /** Append an array of values, resizing (at most once) if necessary. */
74
+ append(values: T): void;
75
+ /** Obtain the finished array.
76
+ * @param includeUnusedCapacity If true, the length of the returned array will be equal to [[capacity]], with extra bytes initialized to zero; otherwise, the
77
+ * returned array's length will be equal to [[length]].
78
+ */
79
+ toTypedArray(includeUnusedCapacity?: boolean): T;
80
+ }
81
+ /** A [[TypedArrayBuilder]] for producing a [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).
82
+ * @public
83
+ */
84
+ export declare class Uint8ArrayBuilder extends TypedArrayBuilder<Uint8Array> {
85
+ /** See [[TypedArrayBuilder]] constructor. */
86
+ constructor(options?: TypedArrayBuilderOptions);
87
+ }
88
+ /** A [[TypedArrayBuilder]] for producing a [Uint16Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array).
89
+ * @public
90
+ */
91
+ export declare class Uint16ArrayBuilder extends TypedArrayBuilder<Uint16Array> {
92
+ /** See [[TypedArrayBuilder]] constructor. */
93
+ constructor(options?: TypedArrayBuilderOptions);
94
+ }
95
+ /** A [[TypedArrayBuilder]] for producing a [Uint32Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array).
96
+ * @public
97
+ */
98
+ export declare class Uint32ArrayBuilder extends TypedArrayBuilder<Uint32Array> {
99
+ /** See [[TypedArrayBuilder]] constructor. */
100
+ constructor(options?: TypedArrayBuilderOptions);
101
+ /** Obtain a view of the finished array as an array of bytes. */
102
+ toUint8Array(includeUnusedCapacity?: boolean): Uint8Array;
103
+ }
104
+ /** Options used to construct a [[UintArrayBuilder]].
105
+ * @public
106
+ */
107
+ export interface UintArrayBuilderOptions extends TypedArrayBuilderOptions {
108
+ /** The type of the initial empty `TypedArray` created by the builder. For example, if you know that you will be adding values larger than
109
+ * 255 to the array, specify `{ initialType: Uint16Array }` to avoid replacing the otherwise default `Uint8Array` when the first such value is added.
110
+ * Default: `Uint8Array`.
111
+ */
112
+ initialType?: typeof Uint8Array | typeof Uint16Array | typeof Uint32Array;
113
+ }
114
+ /** A [[TypedArrayBuilder]] that can populate a [[UintArray]] with the minimum
115
+ * [bytes per element](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT) required.
116
+ *
117
+ * By default, the underlying array is a `Uint8Array`, though this can be configured via [[UintArrayBuilderOptions.initialType]].
118
+ * As values are added to the array, if the bytes per element supported by the underlying array is too small to hold one of the new values, the array is
119
+ * reallocated to a type large enough to hold all of the new values. For example, the following produces a `Uint8Array` because all values are less than 256:
120
+ *
121
+ * ```ts
122
+ * const builder = new UintArrayBuilder();
123
+ * builder.append([1, 2, 254, 255]);
124
+ * const array = builder.toTypedArray();
125
+ * assert(array instanceof Uint8Array);
126
+ * ```
127
+ *
128
+ * However, the following produces a `Uint16Array` because one of the values is larger than 255 but none are larger than 65,535:
129
+ *
130
+ * ```ts
131
+ * const builder = new UintArrayBuilder();
132
+ * builder.append([1, 255, 257, 65535]);
133
+ * const array = builder.toTypedArray();
134
+ * assert(array instanceof Uint16Array);
135
+ * ```
136
+ *
137
+ * @see [[Uint8ArrayBuilder]], [[Uint16ArrayBuilder]], or [[Uint32ArrayBuilder]] if you know the number of bytes you want to allocate for each element in the array.
138
+ * @public
139
+ */
140
+ export declare class UintArrayBuilder extends TypedArrayBuilder<UintArray> {
141
+ constructor(options?: UintArrayBuilderOptions);
142
+ /** The number of bytes (1, 2, or 4) currently allocated per element by the underlying array.
143
+ * This may change as larger values are added to the array.
144
+ */
145
+ get bytesPerElement(): number;
146
+ /** Ensures that the underlying array is of a type that can contain the largest value in `newValues`.
147
+ * For example, if `_data` is a `Uint16Array` and `newValues` contains any value(s) larger than 65,535, it will be replaced with a `Uint32Array`.
148
+ * This method is invoked by [[push]] and [[append]].
149
+ */
150
+ protected ensureBytesPerElement(newValues: Iterable<number>): void;
151
+ /** See [[TypedArrayBuilder.push]]. */
152
+ push(value: number): void;
153
+ /** See [[TypedArrayBuilder.append]]. */
154
+ append(values: UintArray): void;
155
+ }
156
156
  //# sourceMappingURL=TypedArrayBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TypedArrayBuilder.d.ts","sourceRoot":"","sources":["../../src/TypedArrayBuilder.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,oBAAY,SAAS,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;AAE/D;;;;;;;;;;;;;GAaG;AACH,qBAAa,iBAAiB,CAAC,CAAC,SAAS,SAAS;IAChD,sEAAsE;IACtE,SAAS,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACvC,8FAA8F;IAC9F,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC;IACnB,wDAAwD;IACxD,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,qEAAqE;IACrE,SAAgB,YAAY,EAAE,MAAM,CAAC;IAErC,sFAAsF;IACtF,SAAS,aAAa,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,CAA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