@itwin/core-bentley 3.6.0-dev.36 → 3.6.0-dev.40

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 (223) hide show
  1. package/lib/cjs/AccessToken.d.ts +8 -8
  2. package/lib/cjs/AccessToken.js +9 -9
  3. package/lib/cjs/AccessToken.js.map +1 -1
  4. package/lib/cjs/Assert.d.ts +25 -25
  5. package/lib/cjs/Assert.js +45 -45
  6. package/lib/cjs/Assert.js.map +1 -1
  7. package/lib/cjs/AsyncMutex.d.ts +26 -26
  8. package/lib/cjs/AsyncMutex.js +43 -43
  9. package/lib/cjs/AsyncMutex.js.map +1 -1
  10. package/lib/cjs/BeEvent.d.ts +81 -81
  11. package/lib/cjs/BeEvent.js +156 -156
  12. package/lib/cjs/BeEvent.js.map +1 -1
  13. package/lib/cjs/BeSQLite.d.ts +170 -170
  14. package/lib/cjs/BeSQLite.js +183 -183
  15. package/lib/cjs/BeSQLite.js.map +1 -1
  16. package/lib/cjs/BentleyError.d.ts +378 -378
  17. package/lib/cjs/BentleyError.js +702 -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/BentleyLoggerCategory.js.map +1 -1
  22. package/lib/cjs/ByteStream.d.ts +110 -110
  23. package/lib/cjs/ByteStream.js +159 -159
  24. package/lib/cjs/ByteStream.js.map +1 -1
  25. package/lib/cjs/ClassUtils.d.ts +14 -14
  26. package/lib/cjs/ClassUtils.js +27 -27
  27. package/lib/cjs/ClassUtils.js.map +1 -1
  28. package/lib/cjs/Compare.d.ts +47 -47
  29. package/lib/cjs/Compare.js +75 -75
  30. package/lib/cjs/Compare.js.map +1 -1
  31. package/lib/cjs/CompressedId64Set.d.ts +134 -134
  32. package/lib/cjs/CompressedId64Set.js +428 -428
  33. package/lib/cjs/CompressedId64Set.js.map +1 -1
  34. package/lib/cjs/Dictionary.d.ts +125 -125
  35. package/lib/cjs/Dictionary.js +203 -203
  36. package/lib/cjs/Dictionary.js.map +1 -1
  37. package/lib/cjs/Disposable.d.ts +80 -80
  38. package/lib/cjs/Disposable.js +120 -120
  39. package/lib/cjs/Disposable.js.map +1 -1
  40. package/lib/cjs/Id.d.ts +281 -281
  41. package/lib/cjs/Id.js +637 -637
  42. package/lib/cjs/Id.js.map +1 -1
  43. package/lib/cjs/IndexMap.d.ts +65 -65
  44. package/lib/cjs/IndexMap.js +91 -91
  45. package/lib/cjs/IndexMap.js.map +1 -1
  46. package/lib/cjs/JsonSchema.d.ts +77 -77
  47. package/lib/cjs/JsonSchema.js +9 -9
  48. package/lib/cjs/JsonSchema.js.map +1 -1
  49. package/lib/cjs/JsonUtils.d.ts +78 -78
  50. package/lib/cjs/JsonUtils.js +151 -151
  51. package/lib/cjs/JsonUtils.js.map +1 -1
  52. package/lib/cjs/LRUMap.d.ts +129 -129
  53. package/lib/cjs/LRUMap.js +333 -333
  54. package/lib/cjs/LRUMap.js.map +1 -1
  55. package/lib/cjs/Logger.d.ts +143 -143
  56. package/lib/cjs/Logger.js +258 -258
  57. package/lib/cjs/Logger.js.map +1 -1
  58. package/lib/cjs/ObservableSet.d.ts +23 -23
  59. package/lib/cjs/ObservableSet.js +51 -51
  60. package/lib/cjs/ObservableSet.js.map +1 -1
  61. package/lib/cjs/OneAtATimeAction.d.ts +31 -31
  62. package/lib/cjs/OneAtATimeAction.js +94 -94
  63. package/lib/cjs/OneAtATimeAction.js.map +1 -1
  64. package/lib/cjs/OrderedId64Iterable.d.ts +74 -74
  65. package/lib/cjs/OrderedId64Iterable.js +235 -235
  66. package/lib/cjs/OrderedId64Iterable.js.map +1 -1
  67. package/lib/cjs/OrderedSet.d.ts +40 -40
  68. package/lib/cjs/OrderedSet.js +64 -64
  69. package/lib/cjs/OrderedSet.js.map +1 -1
  70. package/lib/cjs/PriorityQueue.d.ts +70 -70
  71. package/lib/cjs/PriorityQueue.js +140 -140
  72. package/lib/cjs/PriorityQueue.js.map +1 -1
  73. package/lib/cjs/ProcessDetector.d.ts +59 -59
  74. package/lib/cjs/ProcessDetector.js +71 -71
  75. package/lib/cjs/ProcessDetector.js.map +1 -1
  76. package/lib/cjs/SortedArray.d.ts +232 -232
  77. package/lib/cjs/SortedArray.js +303 -303
  78. package/lib/cjs/SortedArray.js.map +1 -1
  79. package/lib/cjs/StatusCategory.d.ts +30 -30
  80. package/lib/cjs/StatusCategory.js +460 -460
  81. package/lib/cjs/StatusCategory.js.map +1 -1
  82. package/lib/cjs/StringUtils.d.ts +22 -22
  83. package/lib/cjs/StringUtils.js +148 -148
  84. package/lib/cjs/StringUtils.js.map +1 -1
  85. package/lib/cjs/Time.d.ts +122 -122
  86. package/lib/cjs/Time.js +152 -152
  87. package/lib/cjs/Time.js.map +1 -1
  88. package/lib/cjs/Tracing.d.ts +40 -40
  89. package/lib/cjs/Tracing.js +130 -130
  90. package/lib/cjs/Tracing.js.map +1 -1
  91. package/lib/cjs/TupleKeyedMap.d.ts +36 -36
  92. package/lib/cjs/TupleKeyedMap.js +102 -102
  93. package/lib/cjs/TupleKeyedMap.js.map +1 -1
  94. package/lib/cjs/TypedArrayBuilder.d.ts +155 -155
  95. package/lib/cjs/TypedArrayBuilder.js +208 -208
  96. package/lib/cjs/TypedArrayBuilder.js.map +1 -1
  97. package/lib/cjs/UnexpectedErrors.d.ts +43 -43
  98. package/lib/cjs/UnexpectedErrors.js +68 -68
  99. package/lib/cjs/UnexpectedErrors.js.map +1 -1
  100. package/lib/cjs/UtilityTypes.d.ts +100 -100
  101. package/lib/cjs/UtilityTypes.js +40 -40
  102. package/lib/cjs/UtilityTypes.js.map +1 -1
  103. package/lib/cjs/YieldManager.d.ts +18 -18
  104. package/lib/cjs/YieldManager.js +34 -34
  105. package/lib/cjs/YieldManager.js.map +1 -1
  106. package/lib/cjs/core-bentley.d.ts +75 -75
  107. package/lib/cjs/core-bentley.js +91 -91
  108. package/lib/cjs/core-bentley.js.map +1 -1
  109. package/lib/cjs/partitionArray.d.ts +21 -21
  110. package/lib/cjs/partitionArray.js +43 -43
  111. package/lib/cjs/partitionArray.js.map +1 -1
  112. package/lib/esm/AccessToken.d.ts +8 -8
  113. package/lib/esm/AccessToken.js +8 -8
  114. package/lib/esm/AccessToken.js.map +1 -1
  115. package/lib/esm/Assert.d.ts +25 -25
  116. package/lib/esm/Assert.js +41 -41
  117. package/lib/esm/Assert.js.map +1 -1
  118. package/lib/esm/AsyncMutex.d.ts +26 -26
  119. package/lib/esm/AsyncMutex.js +39 -39
  120. package/lib/esm/AsyncMutex.js.map +1 -1
  121. package/lib/esm/BeEvent.d.ts +81 -81
  122. package/lib/esm/BeEvent.js +150 -150
  123. package/lib/esm/BeEvent.js.map +1 -1
  124. package/lib/esm/BeSQLite.d.ts +170 -170
  125. package/lib/esm/BeSQLite.js +180 -180
  126. package/lib/esm/BeSQLite.js.map +1 -1
  127. package/lib/esm/BentleyError.d.ts +378 -378
  128. package/lib/esm/BentleyError.js +698 -698
  129. package/lib/esm/BentleyError.js.map +1 -1
  130. package/lib/esm/BentleyLoggerCategory.d.ts +11 -11
  131. package/lib/esm/BentleyLoggerCategory.js +16 -16
  132. package/lib/esm/BentleyLoggerCategory.js.map +1 -1
  133. package/lib/esm/ByteStream.d.ts +110 -110
  134. package/lib/esm/ByteStream.js +155 -155
  135. package/lib/esm/ByteStream.js.map +1 -1
  136. package/lib/esm/ClassUtils.d.ts +14 -14
  137. package/lib/esm/ClassUtils.js +22 -22
  138. package/lib/esm/ClassUtils.js.map +1 -1
  139. package/lib/esm/Compare.d.ts +47 -47
  140. package/lib/esm/Compare.js +63 -63
  141. package/lib/esm/Compare.js.map +1 -1
  142. package/lib/esm/CompressedId64Set.d.ts +134 -134
  143. package/lib/esm/CompressedId64Set.js +423 -423
  144. package/lib/esm/CompressedId64Set.js.map +1 -1
  145. package/lib/esm/Dictionary.d.ts +125 -125
  146. package/lib/esm/Dictionary.js +199 -199
  147. package/lib/esm/Dictionary.js.map +1 -1
  148. package/lib/esm/Disposable.d.ts +80 -80
  149. package/lib/esm/Disposable.js +112 -112
  150. package/lib/esm/Disposable.js.map +1 -1
  151. package/lib/esm/Id.d.ts +281 -281
  152. package/lib/esm/Id.js +633 -633
  153. package/lib/esm/Id.js.map +1 -1
  154. package/lib/esm/IndexMap.d.ts +65 -65
  155. package/lib/esm/IndexMap.js +86 -86
  156. package/lib/esm/IndexMap.js.map +1 -1
  157. package/lib/esm/JsonSchema.d.ts +77 -77
  158. package/lib/esm/JsonSchema.js +8 -8
  159. package/lib/esm/JsonSchema.js.map +1 -1
  160. package/lib/esm/JsonUtils.d.ts +78 -78
  161. package/lib/esm/JsonUtils.js +148 -148
  162. package/lib/esm/JsonUtils.js.map +1 -1
  163. package/lib/esm/LRUMap.d.ts +129 -129
  164. package/lib/esm/LRUMap.js +326 -326
  165. package/lib/esm/LRUMap.js.map +1 -1
  166. package/lib/esm/Logger.d.ts +143 -143
  167. package/lib/esm/Logger.js +253 -253
  168. package/lib/esm/Logger.js.map +1 -1
  169. package/lib/esm/ObservableSet.d.ts +23 -23
  170. package/lib/esm/ObservableSet.js +47 -47
  171. package/lib/esm/ObservableSet.js.map +1 -1
  172. package/lib/esm/OneAtATimeAction.d.ts +31 -31
  173. package/lib/esm/OneAtATimeAction.js +89 -89
  174. package/lib/esm/OneAtATimeAction.js.map +1 -1
  175. package/lib/esm/OrderedId64Iterable.d.ts +74 -74
  176. package/lib/esm/OrderedId64Iterable.js +232 -232
  177. package/lib/esm/OrderedId64Iterable.js.map +1 -1
  178. package/lib/esm/OrderedSet.d.ts +40 -40
  179. package/lib/esm/OrderedSet.js +59 -59
  180. package/lib/esm/OrderedSet.js.map +1 -1
  181. package/lib/esm/PriorityQueue.d.ts +70 -70
  182. package/lib/esm/PriorityQueue.js +136 -136
  183. package/lib/esm/PriorityQueue.js.map +1 -1
  184. package/lib/esm/ProcessDetector.d.ts +59 -59
  185. package/lib/esm/ProcessDetector.js +67 -67
  186. package/lib/esm/ProcessDetector.js.map +1 -1
  187. package/lib/esm/SortedArray.d.ts +232 -232
  188. package/lib/esm/SortedArray.js +296 -296
  189. package/lib/esm/SortedArray.js.map +1 -1
  190. package/lib/esm/StatusCategory.d.ts +30 -30
  191. package/lib/esm/StatusCategory.js +454 -454
  192. package/lib/esm/StatusCategory.js.map +1 -1
  193. package/lib/esm/StringUtils.d.ts +22 -22
  194. package/lib/esm/StringUtils.js +142 -142
  195. package/lib/esm/StringUtils.js.map +1 -1
  196. package/lib/esm/Time.d.ts +122 -122
  197. package/lib/esm/Time.js +146 -146
  198. package/lib/esm/Time.js.map +1 -1
  199. package/lib/esm/Tracing.d.ts +40 -40
  200. package/lib/esm/Tracing.js +126 -126
  201. package/lib/esm/Tracing.js.map +1 -1
  202. package/lib/esm/TupleKeyedMap.d.ts +36 -36
  203. package/lib/esm/TupleKeyedMap.js +98 -98
  204. package/lib/esm/TupleKeyedMap.js.map +1 -1
  205. package/lib/esm/TypedArrayBuilder.d.ts +155 -155
  206. package/lib/esm/TypedArrayBuilder.js +200 -200
  207. package/lib/esm/TypedArrayBuilder.js.map +1 -1
  208. package/lib/esm/UnexpectedErrors.d.ts +43 -43
  209. package/lib/esm/UnexpectedErrors.js +64 -64
  210. package/lib/esm/UnexpectedErrors.js.map +1 -1
  211. package/lib/esm/UtilityTypes.d.ts +100 -100
  212. package/lib/esm/UtilityTypes.js +34 -34
  213. package/lib/esm/UtilityTypes.js.map +1 -1
  214. package/lib/esm/YieldManager.d.ts +18 -18
  215. package/lib/esm/YieldManager.js +30 -30
  216. package/lib/esm/YieldManager.js.map +1 -1
  217. package/lib/esm/core-bentley.d.ts +75 -75
  218. package/lib/esm/core-bentley.js +79 -79
  219. package/lib/esm/core-bentley.js.map +1 -1
  220. package/lib/esm/partitionArray.d.ts +21 -21
  221. package/lib/esm/partitionArray.js +39 -39
  222. package/lib/esm/partitionArray.js.map +1 -1
  223. package/package.json +3 -3
@@ -1,160 +1,160 @@
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.ByteStream = void 0;
11
- const Assert_1 = require("./Assert");
12
- const Id_1 = require("./Id");
13
- /** Allows the contents of an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
14
- * to be consumed sequentially using methods to extract
15
- * data of a particular type from the bytes beginning at the current read position.
16
- * Methods and properties beginning with 'read' and taking no arguments consume data at the current read position and advance it
17
- * by the size of the data read. The read position can also be directly adjusted by the caller.
18
- * @public
19
- */
20
- class ByteStream {
21
- /** Construct a new ByteStream with the read position set to the beginning.
22
- * @param buffer The underlying buffer from which data is to be extracted.
23
- * @param subView If defined, specifies the subset of the underlying buffer's data to use.
24
- * This constructor is subject to two common mistakes:
25
- *
26
- * 1. Given `bytes: Uint8Array`, `new ByteStream(bytes)` will compile but at run-time will produce an error asserting that
27
- * the DataView constructor requires an ArrayBuffer. The correct usage is `new ByteStream(bytes.buffer)`.
28
- * 2. Given `bytes: Uint8Array`, `new ByteStream(bytes.buffer)` creates a stream for the entire range of bytes represented by the underlying
29
- * ArrayBuffer. If `bytes` represents only a **sub-range** of the underlying buffer's data, the results will be unexpected unless the optional `subView`
30
- * argument is supplied, with correct offset and length.
31
- *
32
- * For both of the above reasons, prefer to use [[fromUint8Array]].
33
- * @deprecated Use [[fromUint8Array]] or [[fromArrayBuffer]].
34
- */
35
- constructor(buffer, subView) {
36
- this._curPos = 0;
37
- if (undefined !== subView) {
38
- this._view = new DataView(buffer, subView.byteOffset, subView.byteLength);
39
- this._byteOffset = subView.byteOffset;
40
- }
41
- else {
42
- this._view = new DataView(buffer);
43
- this._byteOffset = 0;
44
- }
45
- }
46
- /** Construct a new ByteStream for the range of bytes represented by `bytes`, which may be a subset of the range of bytes
47
- * represented by the underlying ArrayBuffer. The read position will be set to the beginning of the range of bytes.
48
- */
49
- static fromUint8Array(bytes) {
50
- const { byteOffset, byteLength } = bytes;
51
- return new ByteStream(bytes.buffer, { byteOffset, byteLength }); // eslint-disable-line deprecation/deprecation
52
- }
53
- /** Construct a new ByteStream with the read position set to the beginning.
54
- * @param buffer The underlying buffer from which data is to be extracted.
55
- * @param subView If defined, specifies the subset of the underlying buffer's data to use.
56
- */
57
- static fromArrayBuffer(buffer, subView) {
58
- return new ByteStream(buffer, subView); // eslint-disable-line deprecation/deprecation
59
- }
60
- /** The number of bytes in this stream */
61
- get length() {
62
- return this._view.byteLength;
63
- }
64
- /** The number of bytes remaining to be read, from [[curPos]] to the end of the stream. */
65
- get remainingLength() {
66
- return this.length - this.curPos;
67
- }
68
- /** Returns true if the current read position has been advanced past the end of the stream. This generally indicates that an attempt was made to read more data than is available.
69
- * @see [[isAtTheEnd]]
70
- */
71
- get isPastTheEnd() {
72
- return this.curPos > this.length;
73
- }
74
- /** Returns true if the current read position has advanced precisely to the end of the stream, indicating all of the data has been consumed.
75
- * @see [[isPastTheEnd]].
76
- */
77
- get isAtTheEnd() {
78
- return this.curPos === this.length;
79
- }
80
- /** The current read position as an index into the stream of bytes. */
81
- get curPos() { return this._curPos; }
82
- set curPos(pos) {
83
- this._curPos = pos;
84
- (0, Assert_1.assert)(!this.isPastTheEnd);
85
- }
86
- /** Adds the specified number of bytes to the current read position */
87
- advance(numBytes) {
88
- this.curPos = (this.curPos + numBytes);
89
- return !this.isPastTheEnd;
90
- }
91
- /** Subtracts the specified number of bytes from the current read position */
92
- rewind(numBytes) {
93
- if (this.curPos - numBytes < 0)
94
- return false;
95
- this.curPos = this.curPos - numBytes;
96
- return true;
97
- }
98
- /** Resets the current read position to the beginning of the stream */
99
- reset() { this.curPos = 0; }
100
- /** Read a unsigned 8-bit integer from the current read position and advance by 1 byte. */
101
- readUint8() { return this.read(1, (view) => view.getUint8(this.curPos)); }
102
- /** Read an unsigned 16-bit integer from the current read position and advance by 2 bytes. */
103
- readUint16() { return this.read(2, (view) => view.getUint16(this.curPos, true)); }
104
- /** Read an unsigned 32-bit integer from the current read position and advance by 4 bytes. */
105
- readUint32() { return this.read(4, (view) => view.getUint32(this.curPos, true)); }
106
- /** Read a signed 32-bit integer from the current read position and advance by 4 bytes. */
107
- readInt32() { return this.read(4, (view) => view.getInt32(this.curPos, true)); }
108
- /** Read a 32-bit floating point number from the current read position and advance by 4 bytes. */
109
- readFloat32() { return this.read(4, (view) => view.getFloat32(this.curPos, true)); }
110
- /** Read a 64-bit floating point number from the current read position and advance by 8 bytes. */
111
- readFloat64() { return this.read(8, (view) => view.getFloat64(this.curPos, true)); }
112
- /** Read an unsigned 64-bit integer from the current read position, advance by 8 bytes, and return the 64-bit value as an Id64String. */
113
- readId64() { return Id_1.Id64.fromUint32Pair(this.readUint32(), this.readUint32()); }
114
- /** Read an unsigned 24-bit integer from the current read position and advance by 3 bytes. */
115
- readUint24() { return this.readUint8() | (this.readUint8() << 8) | (this.readUint8() << 16); }
116
- /** @deprecated use [[readUint8]]. */
117
- get nextUint8() { return this.readUint8(); }
118
- /** @deprecated use [[readUint16]]. */
119
- get nextUint16() { return this.readUint16(); }
120
- /** @deprecated use [[readUint32]]. */
121
- get nextUint32() { return this.readUint32(); }
122
- /** @deprecated use [[readInt32]]. */
123
- get nextInt32() { return this.readInt32(); }
124
- /** @deprecated use [[readFloat32]]. */
125
- get nextFloat32() { return this.readFloat32(); }
126
- /** @deprecated use [[readFloat64]]. */
127
- get nextFloat64() { return this.readFloat64(); }
128
- /** @deprecated use [[readId64]]. */
129
- get nextId64() { return this.readId64(); }
130
- /** @deprecated use [[readUint32]]. */
131
- get nextUint24() { return this.readUint24(); }
132
- /** Read the specified number of bytes beginning at the current read position into a Uint8Array and advance by the specified number of byte.
133
- * @param numBytes The number of bytes to read.
134
- */
135
- nextBytes(numBytes) {
136
- const bytes = new Uint8Array(this.arrayBuffer, this.curPos + this._byteOffset, numBytes);
137
- this.advance(numBytes);
138
- return bytes;
139
- }
140
- /** Read the specified number of bytes at the specified offset without changing the read position. */
141
- readBytes(readPos, numBytes) {
142
- return new Uint8Array(this.arrayBuffer, readPos + this._byteOffset, numBytes);
143
- }
144
- /** Read the specified number of unsigned 32-bit integers from the current read position and advance the read position. */
145
- nextUint32s(numUint32s) {
146
- const numBytes = numUint32s * 4;
147
- const uint32s = new Uint32Array(this.arrayBuffer, this.curPos + this._byteOffset, numUint32s);
148
- this.advance(numBytes);
149
- return uint32s;
150
- }
151
- /** Returns the underlying array buffer */
152
- get arrayBuffer() { return this._view.buffer; }
153
- read(numBytes, read) {
154
- const result = read(this._view);
155
- this.advance(numBytes);
156
- return result;
157
- }
158
- }
159
- exports.ByteStream = ByteStream;
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.ByteStream = void 0;
11
+ const Assert_1 = require("./Assert");
12
+ const Id_1 = require("./Id");
13
+ /** Allows the contents of an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
14
+ * to be consumed sequentially using methods to extract
15
+ * data of a particular type from the bytes beginning at the current read position.
16
+ * Methods and properties beginning with 'read' and taking no arguments consume data at the current read position and advance it
17
+ * by the size of the data read. The read position can also be directly adjusted by the caller.
18
+ * @public
19
+ */
20
+ class ByteStream {
21
+ /** Construct a new ByteStream with the read position set to the beginning.
22
+ * @param buffer The underlying buffer from which data is to be extracted.
23
+ * @param subView If defined, specifies the subset of the underlying buffer's data to use.
24
+ * This constructor is subject to two common mistakes:
25
+ *
26
+ * 1. Given `bytes: Uint8Array`, `new ByteStream(bytes)` will compile but at run-time will produce an error asserting that
27
+ * the DataView constructor requires an ArrayBuffer. The correct usage is `new ByteStream(bytes.buffer)`.
28
+ * 2. Given `bytes: Uint8Array`, `new ByteStream(bytes.buffer)` creates a stream for the entire range of bytes represented by the underlying
29
+ * ArrayBuffer. If `bytes` represents only a **sub-range** of the underlying buffer's data, the results will be unexpected unless the optional `subView`
30
+ * argument is supplied, with correct offset and length.
31
+ *
32
+ * For both of the above reasons, prefer to use [[fromUint8Array]].
33
+ * @deprecated Use [[fromUint8Array]] or [[fromArrayBuffer]].
34
+ */
35
+ constructor(buffer, subView) {
36
+ this._curPos = 0;
37
+ if (undefined !== subView) {
38
+ this._view = new DataView(buffer, subView.byteOffset, subView.byteLength);
39
+ this._byteOffset = subView.byteOffset;
40
+ }
41
+ else {
42
+ this._view = new DataView(buffer);
43
+ this._byteOffset = 0;
44
+ }
45
+ }
46
+ /** Construct a new ByteStream for the range of bytes represented by `bytes`, which may be a subset of the range of bytes
47
+ * represented by the underlying ArrayBuffer. The read position will be set to the beginning of the range of bytes.
48
+ */
49
+ static fromUint8Array(bytes) {
50
+ const { byteOffset, byteLength } = bytes;
51
+ return new ByteStream(bytes.buffer, { byteOffset, byteLength }); // eslint-disable-line deprecation/deprecation
52
+ }
53
+ /** Construct a new ByteStream with the read position set to the beginning.
54
+ * @param buffer The underlying buffer from which data is to be extracted.
55
+ * @param subView If defined, specifies the subset of the underlying buffer's data to use.
56
+ */
57
+ static fromArrayBuffer(buffer, subView) {
58
+ return new ByteStream(buffer, subView); // eslint-disable-line deprecation/deprecation
59
+ }
60
+ /** The number of bytes in this stream */
61
+ get length() {
62
+ return this._view.byteLength;
63
+ }
64
+ /** The number of bytes remaining to be read, from [[curPos]] to the end of the stream. */
65
+ get remainingLength() {
66
+ return this.length - this.curPos;
67
+ }
68
+ /** Returns true if the current read position has been advanced past the end of the stream. This generally indicates that an attempt was made to read more data than is available.
69
+ * @see [[isAtTheEnd]]
70
+ */
71
+ get isPastTheEnd() {
72
+ return this.curPos > this.length;
73
+ }
74
+ /** Returns true if the current read position has advanced precisely to the end of the stream, indicating all of the data has been consumed.
75
+ * @see [[isPastTheEnd]].
76
+ */
77
+ get isAtTheEnd() {
78
+ return this.curPos === this.length;
79
+ }
80
+ /** The current read position as an index into the stream of bytes. */
81
+ get curPos() { return this._curPos; }
82
+ set curPos(pos) {
83
+ this._curPos = pos;
84
+ (0, Assert_1.assert)(!this.isPastTheEnd);
85
+ }
86
+ /** Adds the specified number of bytes to the current read position */
87
+ advance(numBytes) {
88
+ this.curPos = (this.curPos + numBytes);
89
+ return !this.isPastTheEnd;
90
+ }
91
+ /** Subtracts the specified number of bytes from the current read position */
92
+ rewind(numBytes) {
93
+ if (this.curPos - numBytes < 0)
94
+ return false;
95
+ this.curPos = this.curPos - numBytes;
96
+ return true;
97
+ }
98
+ /** Resets the current read position to the beginning of the stream */
99
+ reset() { this.curPos = 0; }
100
+ /** Read a unsigned 8-bit integer from the current read position and advance by 1 byte. */
101
+ readUint8() { return this.read(1, (view) => view.getUint8(this.curPos)); }
102
+ /** Read an unsigned 16-bit integer from the current read position and advance by 2 bytes. */
103
+ readUint16() { return this.read(2, (view) => view.getUint16(this.curPos, true)); }
104
+ /** Read an unsigned 32-bit integer from the current read position and advance by 4 bytes. */
105
+ readUint32() { return this.read(4, (view) => view.getUint32(this.curPos, true)); }
106
+ /** Read a signed 32-bit integer from the current read position and advance by 4 bytes. */
107
+ readInt32() { return this.read(4, (view) => view.getInt32(this.curPos, true)); }
108
+ /** Read a 32-bit floating point number from the current read position and advance by 4 bytes. */
109
+ readFloat32() { return this.read(4, (view) => view.getFloat32(this.curPos, true)); }
110
+ /** Read a 64-bit floating point number from the current read position and advance by 8 bytes. */
111
+ readFloat64() { return this.read(8, (view) => view.getFloat64(this.curPos, true)); }
112
+ /** Read an unsigned 64-bit integer from the current read position, advance by 8 bytes, and return the 64-bit value as an Id64String. */
113
+ readId64() { return Id_1.Id64.fromUint32Pair(this.readUint32(), this.readUint32()); }
114
+ /** Read an unsigned 24-bit integer from the current read position and advance by 3 bytes. */
115
+ readUint24() { return this.readUint8() | (this.readUint8() << 8) | (this.readUint8() << 16); }
116
+ /** @deprecated use [[readUint8]]. */
117
+ get nextUint8() { return this.readUint8(); }
118
+ /** @deprecated use [[readUint16]]. */
119
+ get nextUint16() { return this.readUint16(); }
120
+ /** @deprecated use [[readUint32]]. */
121
+ get nextUint32() { return this.readUint32(); }
122
+ /** @deprecated use [[readInt32]]. */
123
+ get nextInt32() { return this.readInt32(); }
124
+ /** @deprecated use [[readFloat32]]. */
125
+ get nextFloat32() { return this.readFloat32(); }
126
+ /** @deprecated use [[readFloat64]]. */
127
+ get nextFloat64() { return this.readFloat64(); }
128
+ /** @deprecated use [[readId64]]. */
129
+ get nextId64() { return this.readId64(); }
130
+ /** @deprecated use [[readUint32]]. */
131
+ get nextUint24() { return this.readUint24(); }
132
+ /** Read the specified number of bytes beginning at the current read position into a Uint8Array and advance by the specified number of byte.
133
+ * @param numBytes The number of bytes to read.
134
+ */
135
+ nextBytes(numBytes) {
136
+ const bytes = new Uint8Array(this.arrayBuffer, this.curPos + this._byteOffset, numBytes);
137
+ this.advance(numBytes);
138
+ return bytes;
139
+ }
140
+ /** Read the specified number of bytes at the specified offset without changing the read position. */
141
+ readBytes(readPos, numBytes) {
142
+ return new Uint8Array(this.arrayBuffer, readPos + this._byteOffset, numBytes);
143
+ }
144
+ /** Read the specified number of unsigned 32-bit integers from the current read position and advance the read position. */
145
+ nextUint32s(numUint32s) {
146
+ const numBytes = numUint32s * 4;
147
+ const uint32s = new Uint32Array(this.arrayBuffer, this.curPos + this._byteOffset, numUint32s);
148
+ this.advance(numBytes);
149
+ return uint32s;
150
+ }
151
+ /** Returns the underlying array buffer */
152
+ get arrayBuffer() { return this._view.buffer; }
153
+ read(numBytes, read) {
154
+ const result = read(this._view);
155
+ this.advance(numBytes);
156
+ return result;
157
+ }
158
+ }
159
+ exports.ByteStream = ByteStream;
160
160
  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AE,UAAU,CAAC,CAAC;QAC9F,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,0CAA0C;IAC1C,IAAW,WAAW,KAAsC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAE/E,IAAI,CAAC,QAAgB,EAAE,IAAgC;QAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA9JD,gCA8JC","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 { assert } from \"./Assert\";\nimport { Id64, Id64String } from \"./Id\";\n\n/** Allows the contents of an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)\n * to be consumed sequentially using methods to extract\n * data of a particular type from the bytes beginning at the current read position.\n * Methods and properties beginning with 'read' and taking no arguments consume data at the current read position and advance it\n * by the size of the data read. The read position can also be directly adjusted by the caller.\n * @public\n */\nexport class ByteStream {\n private readonly _view: DataView;\n private readonly _byteOffset: number;\n private _curPos: number = 0;\n\n /** Construct a new ByteStream with the read position set to the beginning.\n * @param buffer The underlying buffer from which data is to be extracted.\n * @param subView If defined, specifies the subset of the underlying buffer's data to use.\n * This constructor is subject to two common mistakes:\n *\n * 1. Given `bytes: Uint8Array`, `new ByteStream(bytes)` will compile but at run-time will produce an error asserting that\n * the DataView constructor requires an ArrayBuffer. The correct usage is `new ByteStream(bytes.buffer)`.\n * 2. Given `bytes: Uint8Array`, `new ByteStream(bytes.buffer)` creates a stream for the entire range of bytes represented by the underlying\n * ArrayBuffer. If `bytes` represents only a **sub-range** of the underlying buffer's data, the results will be unexpected unless the optional `subView`\n * argument is supplied, with correct offset and length.\n *\n * For both of the above reasons, prefer to use [[fromUint8Array]].\n * @deprecated Use [[fromUint8Array]] or [[fromArrayBuffer]].\n */\n public constructor(buffer: ArrayBuffer | SharedArrayBuffer, subView?: { byteOffset: number, byteLength: number }) {\n if (undefined !== subView) {\n this._view = new DataView(buffer, subView.byteOffset, subView.byteLength);\n this._byteOffset = subView.byteOffset;\n } else {\n this._view = new DataView(buffer);\n this._byteOffset = 0;\n }\n }\n\n /** Construct a new ByteStream for the range of bytes represented by `bytes`, which may be a subset of the range of bytes\n * represented by the underlying ArrayBuffer. The read position will be set to the beginning of the range of bytes.\n */\n public static fromUint8Array(bytes: Uint8Array): ByteStream {\n const { byteOffset, byteLength } = bytes;\n return new ByteStream(bytes.buffer, { byteOffset, byteLength }); // eslint-disable-line deprecation/deprecation\n }\n\n /** Construct a new ByteStream with the read position set to the beginning.\n * @param buffer The underlying buffer from which data is to be extracted.\n * @param subView If defined, specifies the subset of the underlying buffer's data to use.\n */\n public static fromArrayBuffer(buffer: ArrayBuffer | SharedArrayBuffer, subView?: { byteOffset: number, byteLength: number }): ByteStream {\n return new ByteStream(buffer, subView); // eslint-disable-line deprecation/deprecation\n }\n\n /** The number of bytes in this stream */\n public get length(): number {\n return this._view.byteLength;\n }\n\n /** The number of bytes remaining to be read, from [[curPos]] to the end of the stream. */\n public get remainingLength(): number {\n return this.length - this.curPos;\n }\n\n /** Returns true if the current read position has been advanced past the end of the stream. This generally indicates that an attempt was made to read more data than is available.\n * @see [[isAtTheEnd]]\n */\n public get isPastTheEnd(): boolean {\n return this.curPos > this.length;\n }\n\n /** Returns true if the current read position has advanced precisely to the end of the stream, indicating all of the data has been consumed.\n * @see [[isPastTheEnd]].\n */\n public get isAtTheEnd(): boolean {\n return this.curPos === this.length;\n }\n\n /** The current read position as an index into the stream of bytes. */\n public get curPos(): number { return this._curPos; }\n public set curPos(pos: number) {\n this._curPos = pos;\n assert(!this.isPastTheEnd);\n }\n\n /** Adds the specified number of bytes to the current read position */\n public advance(numBytes: number): boolean {\n this.curPos = (this.curPos + numBytes);\n return !this.isPastTheEnd;\n }\n\n /** Subtracts the specified number of bytes from the current read position */\n public rewind(numBytes: number): boolean {\n if (this.curPos - numBytes < 0)\n return false;\n\n this.curPos = this.curPos - numBytes;\n return true;\n }\n\n /** Resets the current read position to the beginning of the stream */\n public reset(): void { this.curPos = 0; }\n\n /** Read a unsigned 8-bit integer from the current read position and advance by 1 byte. */\n public readUint8(): number { return this.read(1, (view) => view.getUint8(this.curPos)); }\n /** Read an unsigned 16-bit integer from the current read position and advance by 2 bytes. */\n public readUint16(): number { return this.read(2, (view) => view.getUint16(this.curPos, true)); }\n /** Read an unsigned 32-bit integer from the current read position and advance by 4 bytes. */\n public readUint32(): number { return this.read(4, (view) => view.getUint32(this.curPos, true)); }\n /** Read a signed 32-bit integer from the current read position and advance by 4 bytes. */\n public readInt32(): number { return this.read(4, (view) => view.getInt32(this.curPos, true)); }\n /** Read a 32-bit floating point number from the current read position and advance by 4 bytes. */\n public readFloat32(): number { return this.read(4, (view) => view.getFloat32(this.curPos, true)); }\n /** Read a 64-bit floating point number from the current read position and advance by 8 bytes. */\n public readFloat64(): number { return this.read(8, (view) => view.getFloat64(this.curPos, true)); }\n /** Read an unsigned 64-bit integer from the current read position, advance by 8 bytes, and return the 64-bit value as an Id64String. */\n public readId64(): Id64String { return Id64.fromUint32Pair(this.readUint32(), this.readUint32()); }\n /** Read an unsigned 24-bit integer from the current read position and advance by 3 bytes. */\n public readUint24(): number { return this.readUint8() | (this.readUint8() << 8) | (this.readUint8() << 16); }\n\n /** @deprecated use [[readUint8]]. */\n public get nextUint8(): number { return this.readUint8(); }\n /** @deprecated use [[readUint16]]. */\n public get nextUint16(): number { return this.readUint16(); }\n /** @deprecated use [[readUint32]]. */\n public get nextUint32(): number { return this.readUint32(); }\n /** @deprecated use [[readInt32]]. */\n public get nextInt32(): number { return this.readInt32(); }\n /** @deprecated use [[readFloat32]]. */\n public get nextFloat32(): number { return this.readFloat32(); }\n /** @deprecated use [[readFloat64]]. */\n public get nextFloat64(): number { return this.readFloat64(); }\n /** @deprecated use [[readId64]]. */\n public get nextId64(): Id64String { return this.readId64(); }\n /** @deprecated use [[readUint32]]. */\n public get nextUint24(): number { return this.readUint24(); }\n\n /** Read the specified number of bytes beginning at the current read position into a Uint8Array and advance by the specified number of byte.\n * @param numBytes The number of bytes to read.\n */\n public nextBytes(numBytes: number): Uint8Array {\n const bytes = new Uint8Array(this.arrayBuffer, this.curPos + this._byteOffset, numBytes);\n this.advance(numBytes);\n return bytes;\n }\n\n /** Read the specified number of bytes at the specified offset without changing the read position. */\n public readBytes(readPos: number, numBytes: number): Uint8Array {\n return new Uint8Array(this.arrayBuffer, readPos + this._byteOffset, numBytes);\n }\n\n /** Read the specified number of unsigned 32-bit integers from the current read position and advance the read position. */\n public nextUint32s(numUint32s: number): Uint32Array {\n const numBytes = numUint32s * 4;\n const uint32s = new Uint32Array(this.arrayBuffer, this.curPos + this._byteOffset, numUint32s);\n this.advance(numBytes);\n return uint32s;\n }\n\n /** Returns the underlying array buffer */\n public get arrayBuffer(): ArrayBuffer | SharedArrayBuffer { return this._view.buffer; }\n\n private read(numBytes: number, read: (view: DataView) => number) {\n const result = read(this._view);\n this.advance(numBytes);\n return result;\n }\n}\n"]}
1
+ {"version":3,"file":"ByteStream.js","sourceRoot":"","sources":["../../src/ByteStream.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,qCAAkC;AAClC,6BAAwC;AAExC;;;;;;GAMG;AACH,MAAa,UAAU;IAKrB;;;;;;;;;;;;;OAaG;IACH,YAAmB,MAAuC,EAAE,OAAoD;QAhBxG,YAAO,GAAW,CAAC,CAAC;QAiB1B,IAAI,SAAS,KAAK,OAAO,EAAE;YACzB,IAAI,CAAC,KAAK,GAAG,IAAI,QAAQ,CAAC,MAAM,EAAE,OAAO,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gCA8JC","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 { assert } from \"./Assert\";\r\nimport { Id64, Id64String } from \"./Id\";\r\n\r\n/** Allows the contents of an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)\r\n * to be consumed sequentially using methods to extract\r\n * data of a particular type from the bytes beginning at the current read position.\r\n * Methods and properties beginning with 'read' and taking no arguments consume data at the current read position and advance it\r\n * by the size of the data read. The read position can also be directly adjusted by the caller.\r\n * @public\r\n */\r\nexport class ByteStream {\r\n private readonly _view: DataView;\r\n private readonly _byteOffset: number;\r\n private _curPos: number = 0;\r\n\r\n /** Construct a new ByteStream with the read position set to the beginning.\r\n * @param buffer The underlying buffer from which data is to be extracted.\r\n * @param subView If defined, specifies the subset of the underlying buffer's data to use.\r\n * This constructor is subject to two common mistakes:\r\n *\r\n * 1. Given `bytes: Uint8Array`, `new ByteStream(bytes)` will compile but at run-time will produce an error asserting that\r\n * the DataView constructor requires an ArrayBuffer. The correct usage is `new ByteStream(bytes.buffer)`.\r\n * 2. Given `bytes: Uint8Array`, `new ByteStream(bytes.buffer)` creates a stream for the entire range of bytes represented by the underlying\r\n * ArrayBuffer. If `bytes` represents only a **sub-range** of the underlying buffer's data, the results will be unexpected unless the optional `subView`\r\n * argument is supplied, with correct offset and length.\r\n *\r\n * For both of the above reasons, prefer to use [[fromUint8Array]].\r\n * @deprecated Use [[fromUint8Array]] or [[fromArrayBuffer]].\r\n */\r\n public constructor(buffer: ArrayBuffer | SharedArrayBuffer, subView?: { byteOffset: number, byteLength: number }) {\r\n if (undefined !== subView) {\r\n this._view = new DataView(buffer, subView.byteOffset, subView.byteLength);\r\n this._byteOffset = subView.byteOffset;\r\n } else {\r\n this._view = new DataView(buffer);\r\n this._byteOffset = 0;\r\n }\r\n }\r\n\r\n /** Construct a new ByteStream for the range of bytes represented by `bytes`, which may be a subset of the range of bytes\r\n * represented by the underlying ArrayBuffer. The read position will be set to the beginning of the range of bytes.\r\n */\r\n public static fromUint8Array(bytes: Uint8Array): ByteStream {\r\n const { byteOffset, byteLength } = bytes;\r\n return new ByteStream(bytes.buffer, { byteOffset, byteLength }); // eslint-disable-line deprecation/deprecation\r\n }\r\n\r\n /** Construct a new ByteStream with the read position set to the beginning.\r\n * @param buffer The underlying buffer from which data is to be extracted.\r\n * @param subView If defined, specifies the subset of the underlying buffer's data to use.\r\n */\r\n public static fromArrayBuffer(buffer: ArrayBuffer | SharedArrayBuffer, subView?: { byteOffset: number, byteLength: number }): ByteStream {\r\n return new ByteStream(buffer, subView); // eslint-disable-line deprecation/deprecation\r\n }\r\n\r\n /** The number of bytes in this stream */\r\n public get length(): number {\r\n return this._view.byteLength;\r\n }\r\n\r\n /** The number of bytes remaining to be read, from [[curPos]] to the end of the stream. */\r\n public get remainingLength(): number {\r\n return this.length - this.curPos;\r\n }\r\n\r\n /** Returns true if the current read position has been advanced past the end of the stream. This generally indicates that an attempt was made to read more data than is available.\r\n * @see [[isAtTheEnd]]\r\n */\r\n public get isPastTheEnd(): boolean {\r\n return this.curPos > this.length;\r\n }\r\n\r\n /** Returns true if the current read position has advanced precisely to the end of the stream, indicating all of the data has been consumed.\r\n * @see [[isPastTheEnd]].\r\n */\r\n public get isAtTheEnd(): boolean {\r\n return this.curPos === this.length;\r\n }\r\n\r\n /** The current read position as an index into the stream of bytes. */\r\n public get curPos(): number { return this._curPos; }\r\n public set curPos(pos: number) {\r\n this._curPos = pos;\r\n assert(!this.isPastTheEnd);\r\n }\r\n\r\n /** Adds the specified number of bytes to the current read position */\r\n public advance(numBytes: number): boolean {\r\n this.curPos = (this.curPos + numBytes);\r\n return !this.isPastTheEnd;\r\n }\r\n\r\n /** Subtracts the specified number of bytes from the current read position */\r\n public rewind(numBytes: number): boolean {\r\n if (this.curPos - numBytes < 0)\r\n return false;\r\n\r\n this.curPos = this.curPos - numBytes;\r\n return true;\r\n }\r\n\r\n /** Resets the current read position to the beginning of the stream */\r\n public reset(): void { this.curPos = 0; }\r\n\r\n /** Read a unsigned 8-bit integer from the current read position and advance by 1 byte. */\r\n public readUint8(): number { return this.read(1, (view) => view.getUint8(this.curPos)); }\r\n /** Read an unsigned 16-bit integer from the current read position and advance by 2 bytes. */\r\n public readUint16(): number { return this.read(2, (view) => view.getUint16(this.curPos, true)); }\r\n /** Read an unsigned 32-bit integer from the current read position and advance by 4 bytes. */\r\n public readUint32(): number { return this.read(4, (view) => view.getUint32(this.curPos, true)); }\r\n /** Read a signed 32-bit integer from the current read position and advance by 4 bytes. */\r\n public readInt32(): number { return this.read(4, (view) => view.getInt32(this.curPos, true)); }\r\n /** Read a 32-bit floating point number from the current read position and advance by 4 bytes. */\r\n public readFloat32(): number { return this.read(4, (view) => view.getFloat32(this.curPos, true)); }\r\n /** Read a 64-bit floating point number from the current read position and advance by 8 bytes. */\r\n public readFloat64(): number { return this.read(8, (view) => view.getFloat64(this.curPos, true)); }\r\n /** Read an unsigned 64-bit integer from the current read position, advance by 8 bytes, and return the 64-bit value as an Id64String. */\r\n public readId64(): Id64String { return Id64.fromUint32Pair(this.readUint32(), this.readUint32()); }\r\n /** Read an unsigned 24-bit integer from the current read position and advance by 3 bytes. */\r\n public readUint24(): number { return this.readUint8() | (this.readUint8() << 8) | (this.readUint8() << 16); }\r\n\r\n /** @deprecated use [[readUint8]]. */\r\n public get nextUint8(): number { return this.readUint8(); }\r\n /** @deprecated use [[readUint16]]. */\r\n public get nextUint16(): number { return this.readUint16(); }\r\n /** @deprecated use [[readUint32]]. */\r\n public get nextUint32(): number { return this.readUint32(); }\r\n /** @deprecated use [[readInt32]]. */\r\n public get nextInt32(): number { return this.readInt32(); }\r\n /** @deprecated use [[readFloat32]]. */\r\n public get nextFloat32(): number { return this.readFloat32(); }\r\n /** @deprecated use [[readFloat64]]. */\r\n public get nextFloat64(): number { return this.readFloat64(); }\r\n /** @deprecated use [[readId64]]. */\r\n public get nextId64(): Id64String { return this.readId64(); }\r\n /** @deprecated use [[readUint32]]. */\r\n public get nextUint24(): number { return this.readUint24(); }\r\n\r\n /** Read the specified number of bytes beginning at the current read position into a Uint8Array and advance by the specified number of byte.\r\n * @param numBytes The number of bytes to read.\r\n */\r\n public nextBytes(numBytes: number): Uint8Array {\r\n const bytes = new Uint8Array(this.arrayBuffer, this.curPos + this._byteOffset, numBytes);\r\n this.advance(numBytes);\r\n return bytes;\r\n }\r\n\r\n /** Read the specified number of bytes at the specified offset without changing the read position. */\r\n public readBytes(readPos: number, numBytes: number): Uint8Array {\r\n return new Uint8Array(this.arrayBuffer, readPos + this._byteOffset, numBytes);\r\n }\r\n\r\n /** Read the specified number of unsigned 32-bit integers from the current read position and advance the read position. */\r\n public nextUint32s(numUint32s: number): Uint32Array {\r\n const numBytes = numUint32s * 4;\r\n const uint32s = new Uint32Array(this.arrayBuffer, this.curPos + this._byteOffset, numUint32s);\r\n this.advance(numBytes);\r\n return uint32s;\r\n }\r\n\r\n /** Returns the underlying array buffer */\r\n public get arrayBuffer(): ArrayBuffer | SharedArrayBuffer { return this._view.buffer; }\r\n\r\n private read(numBytes: number, read: (view: DataView) => number) {\r\n const result = read(this._view);\r\n this.advance(numBytes);\r\n return result;\r\n }\r\n}\r\n"]}
@@ -1,15 +1,15 @@
1
- /** Check if class `subclass` is a different class from `superclass` but extends from `superclass`
2
- * @internal
3
- * @param subclass the class that may be a subclass of `superclass`
4
- * @param superclass the class that may be a base class of `subclass`
5
- * @returns whether `subclass` is a proper subclass of `superclass`
6
- */
7
- export declare function isProperSubclassOf<SuperClass extends new (..._: any[]) => any, NonSubClass extends new (..._: any[]) => any, SubClass extends new (..._: any[]) => InstanceType<SuperClass>>(subclass: SubClass | NonSubClass, superclass: SuperClass): subclass is SubClass;
8
- /** Check if class `subclass` is `superclass` or extends from `superclass`
9
- * @internal
10
- * @param subclass the class that may be a subclass of `superclass`
11
- * @param superclass the class that may be a base class of `subclass`
12
- * @returns whether `subclass` is a subclass of `superclass`
13
- */
14
- export declare function isSubclassOf<SuperClass extends new (..._: any[]) => any, NonSubClass extends new (..._: any[]) => any, SubClass extends new (..._: any[]) => InstanceType<SuperClass>>(subclass: SuperClass | SubClass | NonSubClass, superclass: SuperClass): subclass is SubClass | SuperClass;
1
+ /** Check if class `subclass` is a different class from `superclass` but extends from `superclass`
2
+ * @internal
3
+ * @param subclass the class that may be a subclass of `superclass`
4
+ * @param superclass the class that may be a base class of `subclass`
5
+ * @returns whether `subclass` is a proper subclass of `superclass`
6
+ */
7
+ export declare function isProperSubclassOf<SuperClass extends new (..._: any[]) => any, NonSubClass extends new (..._: any[]) => any, SubClass extends new (..._: any[]) => InstanceType<SuperClass>>(subclass: SubClass | NonSubClass, superclass: SuperClass): subclass is SubClass;
8
+ /** Check if class `subclass` is `superclass` or extends from `superclass`
9
+ * @internal
10
+ * @param subclass the class that may be a subclass of `superclass`
11
+ * @param superclass the class that may be a base class of `subclass`
12
+ * @returns whether `subclass` is a subclass of `superclass`
13
+ */
14
+ export declare function isSubclassOf<SuperClass extends new (..._: any[]) => any, NonSubClass extends new (..._: any[]) => any, SubClass extends new (..._: any[]) => InstanceType<SuperClass>>(subclass: SuperClass | SubClass | NonSubClass, superclass: SuperClass): subclass is SubClass | SuperClass;
15
15
  //# sourceMappingURL=ClassUtils.d.ts.map
@@ -1,28 +1,28 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.isSubclassOf = exports.isProperSubclassOf = void 0;
8
- /** Check if class `subclass` is a different class from `superclass` but extends from `superclass`
9
- * @internal
10
- * @param subclass the class that may be a subclass of `superclass`
11
- * @param superclass the class that may be a base class of `subclass`
12
- * @returns whether `subclass` is a proper subclass of `superclass`
13
- */
14
- function isProperSubclassOf(subclass, superclass) {
15
- return subclass.prototype instanceof superclass;
16
- }
17
- exports.isProperSubclassOf = isProperSubclassOf;
18
- /** Check if class `subclass` is `superclass` or extends from `superclass`
19
- * @internal
20
- * @param subclass the class that may be a subclass of `superclass`
21
- * @param superclass the class that may be a base class of `subclass`
22
- * @returns whether `subclass` is a subclass of `superclass`
23
- */
24
- function isSubclassOf(subclass, superclass) {
25
- return subclass === superclass || isProperSubclassOf(subclass, superclass);
26
- }
27
- exports.isSubclassOf = isSubclassOf;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.isSubclassOf = exports.isProperSubclassOf = void 0;
8
+ /** Check if class `subclass` is a different class from `superclass` but extends from `superclass`
9
+ * @internal
10
+ * @param subclass the class that may be a subclass of `superclass`
11
+ * @param superclass the class that may be a base class of `subclass`
12
+ * @returns whether `subclass` is a proper subclass of `superclass`
13
+ */
14
+ function isProperSubclassOf(subclass, superclass) {
15
+ return subclass.prototype instanceof superclass;
16
+ }
17
+ exports.isProperSubclassOf = isProperSubclassOf;
18
+ /** Check if class `subclass` is `superclass` or extends from `superclass`
19
+ * @internal
20
+ * @param subclass the class that may be a subclass of `superclass`
21
+ * @param superclass the class that may be a base class of `subclass`
22
+ * @returns whether `subclass` is a subclass of `superclass`
23
+ */
24
+ function isSubclassOf(subclass, superclass) {
25
+ return subclass === superclass || isProperSubclassOf(subclass, superclass);
26
+ }
27
+ exports.isSubclassOf = isSubclassOf;
28
28
  //# sourceMappingURL=ClassUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClassUtils.js","sourceRoot":"","sources":["../../src/ClassUtils.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;;;;GAKG;AACH,SAAgB,kBAAkB,CAIhC,QAAgC,EAAE,UAAsB;IACxD,OAAO,QAAQ,CAAC,SAAS,YAAY,UAAU,CAAC;AAClD,CAAC;AAND,gDAMC;AAED;;;;;GAKG;AACH,SAAgB,YAAY,CAI1B,QAA6C,EAAE,UAAsB;IACrE,OAAO,QAAQ,KAAK,UAAU,IAAI,kBAAkB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAC7E,CAAC;AAND,oCAMC","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\n/** Check if class `subclass` is a different class from `superclass` but extends from `superclass`\n * @internal\n * @param subclass the class that may be a subclass of `superclass`\n * @param superclass the class that may be a base class of `subclass`\n * @returns whether `subclass` is a proper subclass of `superclass`\n */\nexport function isProperSubclassOf<\n SuperClass extends new (..._: any[]) => any,\n NonSubClass extends new (..._: any[]) => any,\n SubClass extends new (..._: any[]) => InstanceType<SuperClass>,\n>(subclass: SubClass | NonSubClass, superclass: SuperClass): subclass is SubClass {\n return subclass.prototype instanceof superclass;\n}\n\n/** Check if class `subclass` is `superclass` or extends from `superclass`\n * @internal\n * @param subclass the class that may be a subclass of `superclass`\n * @param superclass the class that may be a base class of `subclass`\n * @returns whether `subclass` is a subclass of `superclass`\n */\nexport function isSubclassOf<\n SuperClass extends new (..._: any[]) => any,\n NonSubClass extends new (..._: any[]) => any,\n SubClass extends new (..._: any[]) => InstanceType<SuperClass>,\n>(subclass: SuperClass | SubClass | NonSubClass, superclass: SuperClass): subclass is SubClass | SuperClass {\n return subclass === superclass || isProperSubclassOf(subclass, superclass);\n}\n"]}
1
+ {"version":3,"file":"ClassUtils.js","sourceRoot":"","sources":["../../src/ClassUtils.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;;;;GAKG;AACH,SAAgB,kBAAkB,CAIhC,QAAgC,EAAE,UAAsB;IACxD,OAAO,QAAQ,CAAC,SAAS,YAAY,UAAU,CAAC;AAClD,CAAC;AAND,gDAMC;AAED;;;;;GAKG;AACH,SAAgB,YAAY,CAI1B,QAA6C,EAAE,UAAsB;IACrE,OAAO,QAAQ,KAAK,UAAU,IAAI,kBAAkB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAC7E,CAAC;AAND,oCAMC","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\r\n/** Check if class `subclass` is a different class from `superclass` but extends from `superclass`\r\n * @internal\r\n * @param subclass the class that may be a subclass of `superclass`\r\n * @param superclass the class that may be a base class of `subclass`\r\n * @returns whether `subclass` is a proper subclass of `superclass`\r\n */\r\nexport function isProperSubclassOf<\r\n SuperClass extends new (..._: any[]) => any,\r\n NonSubClass extends new (..._: any[]) => any,\r\n SubClass extends new (..._: any[]) => InstanceType<SuperClass>,\r\n>(subclass: SubClass | NonSubClass, superclass: SuperClass): subclass is SubClass {\r\n return subclass.prototype instanceof superclass;\r\n}\r\n\r\n/** Check if class `subclass` is `superclass` or extends from `superclass`\r\n * @internal\r\n * @param subclass the class that may be a subclass of `superclass`\r\n * @param superclass the class that may be a base class of `subclass`\r\n * @returns whether `subclass` is a subclass of `superclass`\r\n */\r\nexport function isSubclassOf<\r\n SuperClass extends new (..._: any[]) => any,\r\n NonSubClass extends new (..._: any[]) => any,\r\n SubClass extends new (..._: any[]) => InstanceType<SuperClass>,\r\n>(subclass: SuperClass | SubClass | NonSubClass, superclass: SuperClass): subclass is SubClass | SuperClass {\r\n return subclass === superclass || isProperSubclassOf(subclass, superclass);\r\n}\r\n"]}
@@ -1,48 +1,48 @@
1
- /** @packageDocumentation
2
- * @module Utils
3
- */
4
- /**
5
- * A function that returns a numerical value indicating how two objects are ordered in relation to one another.
6
- * Such functions are used by various collection classes throughout the library.
7
- * Given values `lhs` and `rhs`, the function returns:
8
- * - Zero if lhs == rhs
9
- * - A negative number if lhs < rhs
10
- * - A positive number if lhs > rhs
11
- *
12
- * An OrderedComparator `must` implement [strict weak ordering](https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings), which can be summarized by the following rules:
13
- * - `compare(x, x)` returns zero.
14
- * - If `compare(x, y)` returns zero, then so does `compare(y, x)` (i.e., `x == y` implies `y == x`).
15
- * - If `compare(x, y)` returns non-zero, then `compare(y, x)` returns a value with an opposite sign (i.e., `x < y` implies `y > x`).
16
- * - If `compare(x, y)` and `compare(y, z)` return non-zero values with the same sign, then `compare(x, z)` returns a value with the same sign (i.e., `x < y < z` implies `x < z`).
17
- *
18
- * @see SortedArray
19
- * @see Dictionary
20
- * @see IndexMap
21
- * @see PriorityQueue
22
- * @public
23
- */
24
- export declare type OrderedComparator<T, U = T> = (lhs: T, rhs: U) => number;
25
- /**
26
- * An [[OrderedComparator]] for numbers that treats two numbers as equal if the absolute value of their difference is less than a specified tolerance.
27
- * @public
28
- */
29
- export declare function compareWithTolerance(a: number, b: number, tolerance?: number): number;
30
- /** @public */
31
- export declare function compareNumbers(a: number, b: number): number;
32
- /** @public */
33
- export declare function compareBooleans(a: boolean, b: boolean): number;
34
- /** @public */
35
- export declare function compareStrings(a: string, b: string): number;
36
- /** @public */
37
- export declare function comparePossiblyUndefined<T>(compareDefined: (lhs: T, rhs: T) => number, lhs?: T, rhs?: T): number;
38
- /** @public */
39
- export declare function compareStringsOrUndefined(lhs?: string, rhs?: string): number;
40
- /** @public */
41
- export declare function compareNumbersOrUndefined(lhs?: number, rhs?: number): number;
42
- /** @public */
43
- export declare function compareBooleansOrUndefined(lhs?: boolean, rhs?: boolean): number;
44
- /** Compare two possibly-undefined values for equality. If both are undefined, the comparison is performed by the supplied `areEqual` function.
45
- * @public
46
- */
47
- export declare function areEqualPossiblyUndefined<T, U>(t: T | undefined, u: U | undefined, areEqual: (t: T, u: U) => boolean): boolean;
1
+ /** @packageDocumentation
2
+ * @module Utils
3
+ */
4
+ /**
5
+ * A function that returns a numerical value indicating how two objects are ordered in relation to one another.
6
+ * Such functions are used by various collection classes throughout the library.
7
+ * Given values `lhs` and `rhs`, the function returns:
8
+ * - Zero if lhs == rhs
9
+ * - A negative number if lhs < rhs
10
+ * - A positive number if lhs > rhs
11
+ *
12
+ * An OrderedComparator `must` implement [strict weak ordering](https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings), which can be summarized by the following rules:
13
+ * - `compare(x, x)` returns zero.
14
+ * - If `compare(x, y)` returns zero, then so does `compare(y, x)` (i.e., `x == y` implies `y == x`).
15
+ * - If `compare(x, y)` returns non-zero, then `compare(y, x)` returns a value with an opposite sign (i.e., `x < y` implies `y > x`).
16
+ * - If `compare(x, y)` and `compare(y, z)` return non-zero values with the same sign, then `compare(x, z)` returns a value with the same sign (i.e., `x < y < z` implies `x < z`).
17
+ *
18
+ * @see SortedArray
19
+ * @see Dictionary
20
+ * @see IndexMap
21
+ * @see PriorityQueue
22
+ * @public
23
+ */
24
+ export declare type OrderedComparator<T, U = T> = (lhs: T, rhs: U) => number;
25
+ /**
26
+ * An [[OrderedComparator]] for numbers that treats two numbers as equal if the absolute value of their difference is less than a specified tolerance.
27
+ * @public
28
+ */
29
+ export declare function compareWithTolerance(a: number, b: number, tolerance?: number): number;
30
+ /** @public */
31
+ export declare function compareNumbers(a: number, b: number): number;
32
+ /** @public */
33
+ export declare function compareBooleans(a: boolean, b: boolean): number;
34
+ /** @public */
35
+ export declare function compareStrings(a: string, b: string): number;
36
+ /** @public */
37
+ export declare function comparePossiblyUndefined<T>(compareDefined: (lhs: T, rhs: T) => number, lhs?: T, rhs?: T): number;
38
+ /** @public */
39
+ export declare function compareStringsOrUndefined(lhs?: string, rhs?: string): number;
40
+ /** @public */
41
+ export declare function compareNumbersOrUndefined(lhs?: number, rhs?: number): number;
42
+ /** @public */
43
+ export declare function compareBooleansOrUndefined(lhs?: boolean, rhs?: boolean): number;
44
+ /** Compare two possibly-undefined values for equality. If both are undefined, the comparison is performed by the supplied `areEqual` function.
45
+ * @public
46
+ */
47
+ export declare function areEqualPossiblyUndefined<T, U>(t: T | undefined, u: U | undefined, areEqual: (t: T, u: U) => boolean): boolean;
48
48
  //# sourceMappingURL=Compare.d.ts.map