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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/CHANGELOG.md +50 -1
  2. package/lib/cjs/AccessToken.d.ts +10 -10
  3. package/lib/cjs/AccessToken.d.ts.map +1 -1
  4. package/lib/cjs/AccessToken.js +9 -9
  5. package/lib/cjs/AccessToken.js.map +1 -1
  6. package/lib/cjs/Assert.d.ts +25 -25
  7. package/lib/cjs/Assert.js +45 -45
  8. package/lib/cjs/Assert.js.map +1 -1
  9. package/lib/cjs/BeEvent.d.ts +81 -81
  10. package/lib/cjs/BeEvent.d.ts.map +1 -1
  11. package/lib/cjs/BeEvent.js +156 -156
  12. package/lib/cjs/BeEvent.js.map +1 -1
  13. package/lib/cjs/BeSQLite.d.ts +172 -170
  14. package/lib/cjs/BeSQLite.d.ts.map +1 -1
  15. package/lib/cjs/BeSQLite.js +185 -183
  16. package/lib/cjs/BeSQLite.js.map +1 -1
  17. package/lib/cjs/BentleyError.d.ts +378 -378
  18. package/lib/cjs/BentleyError.d.ts.map +1 -1
  19. package/lib/cjs/BentleyError.js +703 -702
  20. package/lib/cjs/BentleyError.js.map +1 -1
  21. package/lib/cjs/BentleyLoggerCategory.d.ts +11 -11
  22. package/lib/cjs/BentleyLoggerCategory.js +19 -19
  23. package/lib/cjs/BentleyLoggerCategory.js.map +1 -1
  24. package/lib/cjs/ByteStream.d.ts +110 -110
  25. package/lib/cjs/ByteStream.js +159 -159
  26. package/lib/cjs/ByteStream.js.map +1 -1
  27. package/lib/cjs/ClassUtils.d.ts +14 -14
  28. package/lib/cjs/ClassUtils.js +27 -27
  29. package/lib/cjs/ClassUtils.js.map +1 -1
  30. package/lib/cjs/Compare.d.ts +47 -47
  31. package/lib/cjs/Compare.d.ts.map +1 -1
  32. package/lib/cjs/Compare.js +75 -75
  33. package/lib/cjs/Compare.js.map +1 -1
  34. package/lib/cjs/CompressedId64Set.d.ts +134 -134
  35. package/lib/cjs/CompressedId64Set.d.ts.map +1 -1
  36. package/lib/cjs/CompressedId64Set.js +428 -428
  37. package/lib/cjs/CompressedId64Set.js.map +1 -1
  38. package/lib/cjs/Dictionary.d.ts +125 -125
  39. package/lib/cjs/Dictionary.js +203 -203
  40. package/lib/cjs/Dictionary.js.map +1 -1
  41. package/lib/cjs/Disposable.d.ts +80 -80
  42. package/lib/cjs/Disposable.d.ts.map +1 -1
  43. package/lib/cjs/Disposable.js +120 -120
  44. package/lib/cjs/Disposable.js.map +1 -1
  45. package/lib/cjs/Id.d.ts +285 -285
  46. package/lib/cjs/Id.d.ts.map +1 -1
  47. package/lib/cjs/Id.js +643 -643
  48. package/lib/cjs/Id.js.map +1 -1
  49. package/lib/cjs/IndexMap.d.ts +65 -65
  50. package/lib/cjs/IndexMap.js +91 -91
  51. package/lib/cjs/IndexMap.js.map +1 -1
  52. package/lib/cjs/JsonSchema.d.ts +77 -77
  53. package/lib/cjs/JsonSchema.d.ts.map +1 -1
  54. package/lib/cjs/JsonSchema.js +9 -9
  55. package/lib/cjs/JsonSchema.js.map +1 -1
  56. package/lib/cjs/JsonUtils.d.ts +78 -78
  57. package/lib/cjs/JsonUtils.js +151 -151
  58. package/lib/cjs/JsonUtils.js.map +1 -1
  59. package/lib/cjs/LRUMap.d.ts +129 -129
  60. package/lib/cjs/LRUMap.js +333 -333
  61. package/lib/cjs/LRUMap.js.map +1 -1
  62. package/lib/cjs/Logger.d.ts +143 -143
  63. package/lib/cjs/Logger.d.ts.map +1 -1
  64. package/lib/cjs/Logger.js +256 -258
  65. package/lib/cjs/Logger.js.map +1 -1
  66. package/lib/cjs/ObservableSet.d.ts +23 -23
  67. package/lib/cjs/ObservableSet.js +51 -51
  68. package/lib/cjs/ObservableSet.js.map +1 -1
  69. package/lib/cjs/OneAtATimeAction.d.ts +31 -31
  70. package/lib/cjs/OneAtATimeAction.js +94 -94
  71. package/lib/cjs/OneAtATimeAction.js.map +1 -1
  72. package/lib/cjs/OrderedId64Iterable.d.ts +74 -74
  73. package/lib/cjs/OrderedId64Iterable.d.ts.map +1 -1
  74. package/lib/cjs/OrderedId64Iterable.js +235 -235
  75. package/lib/cjs/OrderedId64Iterable.js.map +1 -1
  76. package/lib/cjs/OrderedSet.d.ts +40 -40
  77. package/lib/cjs/OrderedSet.js +64 -64
  78. package/lib/cjs/OrderedSet.js.map +1 -1
  79. package/lib/cjs/PriorityQueue.d.ts +70 -70
  80. package/lib/cjs/PriorityQueue.d.ts.map +1 -1
  81. package/lib/cjs/PriorityQueue.js +140 -140
  82. package/lib/cjs/PriorityQueue.js.map +1 -1
  83. package/lib/cjs/ProcessDetector.d.ts +59 -59
  84. package/lib/cjs/ProcessDetector.js +71 -71
  85. package/lib/cjs/ProcessDetector.js.map +1 -1
  86. package/lib/cjs/SortedArray.d.ts +236 -232
  87. package/lib/cjs/SortedArray.d.ts.map +1 -1
  88. package/lib/cjs/SortedArray.js +315 -303
  89. package/lib/cjs/SortedArray.js.map +1 -1
  90. package/lib/cjs/StatusCategory.d.ts +30 -30
  91. package/lib/cjs/StatusCategory.d.ts.map +1 -1
  92. package/lib/cjs/StatusCategory.js +460 -460
  93. package/lib/cjs/StatusCategory.js.map +1 -1
  94. package/lib/cjs/StringUtils.d.ts +22 -22
  95. package/lib/cjs/StringUtils.js +148 -148
  96. package/lib/cjs/StringUtils.js.map +1 -1
  97. package/lib/cjs/Time.d.ts +122 -122
  98. package/lib/cjs/Time.js +152 -152
  99. package/lib/cjs/Time.js.map +1 -1
  100. package/lib/cjs/Tracing.d.ts +43 -40
  101. package/lib/cjs/Tracing.d.ts.map +1 -1
  102. package/lib/cjs/Tracing.js +134 -130
  103. package/lib/cjs/Tracing.js.map +1 -1
  104. package/lib/cjs/TupleKeyedMap.d.ts +36 -36
  105. package/lib/cjs/TupleKeyedMap.js +102 -102
  106. package/lib/cjs/TupleKeyedMap.js.map +1 -1
  107. package/lib/cjs/TypedArrayBuilder.d.ts +155 -155
  108. package/lib/cjs/TypedArrayBuilder.d.ts.map +1 -1
  109. package/lib/cjs/TypedArrayBuilder.js +206 -208
  110. package/lib/cjs/TypedArrayBuilder.js.map +1 -1
  111. package/lib/cjs/UnexpectedErrors.d.ts +43 -43
  112. package/lib/cjs/UnexpectedErrors.d.ts.map +1 -1
  113. package/lib/cjs/UnexpectedErrors.js +68 -68
  114. package/lib/cjs/UnexpectedErrors.js.map +1 -1
  115. package/lib/cjs/UtilityTypes.d.ts +112 -96
  116. package/lib/cjs/UtilityTypes.d.ts.map +1 -1
  117. package/lib/cjs/UtilityTypes.js +40 -40
  118. package/lib/cjs/UtilityTypes.js.map +1 -1
  119. package/lib/cjs/YieldManager.d.ts +18 -18
  120. package/lib/cjs/YieldManager.js +34 -34
  121. package/lib/cjs/YieldManager.js.map +1 -1
  122. package/lib/cjs/core-bentley.d.ts +74 -74
  123. package/lib/cjs/core-bentley.js +94 -90
  124. package/lib/cjs/core-bentley.js.map +1 -1
  125. package/lib/cjs/partitionArray.d.ts +21 -21
  126. package/lib/cjs/partitionArray.js +43 -43
  127. package/lib/cjs/partitionArray.js.map +1 -1
  128. package/lib/esm/AccessToken.d.ts +10 -10
  129. package/lib/esm/AccessToken.d.ts.map +1 -1
  130. package/lib/esm/AccessToken.js +8 -8
  131. package/lib/esm/AccessToken.js.map +1 -1
  132. package/lib/esm/Assert.d.ts +25 -25
  133. package/lib/esm/Assert.js +41 -41
  134. package/lib/esm/Assert.js.map +1 -1
  135. package/lib/esm/BeEvent.d.ts +81 -81
  136. package/lib/esm/BeEvent.d.ts.map +1 -1
  137. package/lib/esm/BeEvent.js +150 -150
  138. package/lib/esm/BeEvent.js.map +1 -1
  139. package/lib/esm/BeSQLite.d.ts +172 -170
  140. package/lib/esm/BeSQLite.d.ts.map +1 -1
  141. package/lib/esm/BeSQLite.js +182 -180
  142. package/lib/esm/BeSQLite.js.map +1 -1
  143. package/lib/esm/BentleyError.d.ts +378 -378
  144. package/lib/esm/BentleyError.d.ts.map +1 -1
  145. package/lib/esm/BentleyError.js +699 -698
  146. package/lib/esm/BentleyError.js.map +1 -1
  147. package/lib/esm/BentleyLoggerCategory.d.ts +11 -11
  148. package/lib/esm/BentleyLoggerCategory.js +16 -16
  149. package/lib/esm/BentleyLoggerCategory.js.map +1 -1
  150. package/lib/esm/ByteStream.d.ts +110 -110
  151. package/lib/esm/ByteStream.js +155 -155
  152. package/lib/esm/ByteStream.js.map +1 -1
  153. package/lib/esm/ClassUtils.d.ts +14 -14
  154. package/lib/esm/ClassUtils.js +22 -22
  155. package/lib/esm/ClassUtils.js.map +1 -1
  156. package/lib/esm/Compare.d.ts +47 -47
  157. package/lib/esm/Compare.d.ts.map +1 -1
  158. package/lib/esm/Compare.js +63 -63
  159. package/lib/esm/Compare.js.map +1 -1
  160. package/lib/esm/CompressedId64Set.d.ts +134 -134
  161. package/lib/esm/CompressedId64Set.d.ts.map +1 -1
  162. package/lib/esm/CompressedId64Set.js +423 -423
  163. package/lib/esm/CompressedId64Set.js.map +1 -1
  164. package/lib/esm/Dictionary.d.ts +125 -125
  165. package/lib/esm/Dictionary.js +199 -199
  166. package/lib/esm/Dictionary.js.map +1 -1
  167. package/lib/esm/Disposable.d.ts +80 -80
  168. package/lib/esm/Disposable.d.ts.map +1 -1
  169. package/lib/esm/Disposable.js +112 -112
  170. package/lib/esm/Disposable.js.map +1 -1
  171. package/lib/esm/Id.d.ts +285 -285
  172. package/lib/esm/Id.d.ts.map +1 -1
  173. package/lib/esm/Id.js +639 -639
  174. package/lib/esm/Id.js.map +1 -1
  175. package/lib/esm/IndexMap.d.ts +65 -65
  176. package/lib/esm/IndexMap.js +86 -86
  177. package/lib/esm/IndexMap.js.map +1 -1
  178. package/lib/esm/JsonSchema.d.ts +77 -77
  179. package/lib/esm/JsonSchema.d.ts.map +1 -1
  180. package/lib/esm/JsonSchema.js +8 -8
  181. package/lib/esm/JsonSchema.js.map +1 -1
  182. package/lib/esm/JsonUtils.d.ts +78 -78
  183. package/lib/esm/JsonUtils.js +148 -148
  184. package/lib/esm/JsonUtils.js.map +1 -1
  185. package/lib/esm/LRUMap.d.ts +129 -129
  186. package/lib/esm/LRUMap.js +326 -326
  187. package/lib/esm/LRUMap.js.map +1 -1
  188. package/lib/esm/Logger.d.ts +143 -143
  189. package/lib/esm/Logger.d.ts.map +1 -1
  190. package/lib/esm/Logger.js +253 -253
  191. package/lib/esm/Logger.js.map +1 -1
  192. package/lib/esm/ObservableSet.d.ts +23 -23
  193. package/lib/esm/ObservableSet.js +47 -47
  194. package/lib/esm/ObservableSet.js.map +1 -1
  195. package/lib/esm/OneAtATimeAction.d.ts +31 -31
  196. package/lib/esm/OneAtATimeAction.js +89 -89
  197. package/lib/esm/OneAtATimeAction.js.map +1 -1
  198. package/lib/esm/OrderedId64Iterable.d.ts +74 -74
  199. package/lib/esm/OrderedId64Iterable.d.ts.map +1 -1
  200. package/lib/esm/OrderedId64Iterable.js +232 -232
  201. package/lib/esm/OrderedId64Iterable.js.map +1 -1
  202. package/lib/esm/OrderedSet.d.ts +40 -40
  203. package/lib/esm/OrderedSet.js +59 -59
  204. package/lib/esm/OrderedSet.js.map +1 -1
  205. package/lib/esm/PriorityQueue.d.ts +70 -70
  206. package/lib/esm/PriorityQueue.d.ts.map +1 -1
  207. package/lib/esm/PriorityQueue.js +136 -136
  208. package/lib/esm/PriorityQueue.js.map +1 -1
  209. package/lib/esm/ProcessDetector.d.ts +59 -59
  210. package/lib/esm/ProcessDetector.js +67 -67
  211. package/lib/esm/ProcessDetector.js.map +1 -1
  212. package/lib/esm/SortedArray.d.ts +236 -232
  213. package/lib/esm/SortedArray.d.ts.map +1 -1
  214. package/lib/esm/SortedArray.js +308 -296
  215. package/lib/esm/SortedArray.js.map +1 -1
  216. package/lib/esm/StatusCategory.d.ts +30 -30
  217. package/lib/esm/StatusCategory.d.ts.map +1 -1
  218. package/lib/esm/StatusCategory.js +455 -454
  219. package/lib/esm/StatusCategory.js.map +1 -1
  220. package/lib/esm/StringUtils.d.ts +22 -22
  221. package/lib/esm/StringUtils.js +142 -142
  222. package/lib/esm/StringUtils.js.map +1 -1
  223. package/lib/esm/Time.d.ts +122 -122
  224. package/lib/esm/Time.js +146 -146
  225. package/lib/esm/Time.js.map +1 -1
  226. package/lib/esm/Tracing.d.ts +43 -40
  227. package/lib/esm/Tracing.d.ts.map +1 -1
  228. package/lib/esm/Tracing.js +130 -126
  229. package/lib/esm/Tracing.js.map +1 -1
  230. package/lib/esm/TupleKeyedMap.d.ts +36 -36
  231. package/lib/esm/TupleKeyedMap.js +98 -98
  232. package/lib/esm/TupleKeyedMap.js.map +1 -1
  233. package/lib/esm/TypedArrayBuilder.d.ts +155 -155
  234. package/lib/esm/TypedArrayBuilder.d.ts.map +1 -1
  235. package/lib/esm/TypedArrayBuilder.js +198 -200
  236. package/lib/esm/TypedArrayBuilder.js.map +1 -1
  237. package/lib/esm/UnexpectedErrors.d.ts +43 -43
  238. package/lib/esm/UnexpectedErrors.d.ts.map +1 -1
  239. package/lib/esm/UnexpectedErrors.js +65 -64
  240. package/lib/esm/UnexpectedErrors.js.map +1 -1
  241. package/lib/esm/UtilityTypes.d.ts +112 -96
  242. package/lib/esm/UtilityTypes.d.ts.map +1 -1
  243. package/lib/esm/UtilityTypes.js +34 -34
  244. package/lib/esm/UtilityTypes.js.map +1 -1
  245. package/lib/esm/YieldManager.d.ts +18 -18
  246. package/lib/esm/YieldManager.js +30 -30
  247. package/lib/esm/YieldManager.js.map +1 -1
  248. package/lib/esm/core-bentley.d.ts +74 -74
  249. package/lib/esm/core-bentley.js +78 -78
  250. package/lib/esm/core-bentley.js.map +1 -1
  251. package/lib/esm/partitionArray.d.ts +21 -21
  252. package/lib/esm/partitionArray.js +39 -39
  253. package/lib/esm/partitionArray.js.map +1 -1
  254. package/package.json +9 -9
@@ -1,111 +1,111 @@
1
- /** @packageDocumentation
2
- * @module Utils
3
- */
4
- import { Id64String } from "./Id";
5
- /** Allows the contents of an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
6
- * to be consumed sequentially using methods to extract
7
- * data of a particular type from the bytes beginning at the current read position.
8
- * Methods and properties beginning with 'read' and taking no arguments consume data at the current read position and advance it
9
- * by the size of the data read. The read position can also be directly adjusted by the caller.
10
- * @public
11
- */
12
- export declare class ByteStream {
13
- private readonly _view;
14
- private readonly _byteOffset;
15
- private _curPos;
16
- /** Construct a new ByteStream with the read position set to the beginning.
17
- * @param buffer The underlying buffer from which data is to be extracted.
18
- * @param subView If defined, specifies the subset of the underlying buffer's data to use.
19
- * This constructor is subject to two common mistakes:
20
- *
21
- * 1. Given `bytes: Uint8Array`, `new ByteStream(bytes)` will compile but at run-time will produce an error asserting that
22
- * the DataView constructor requires an ArrayBuffer. The correct usage is `new ByteStream(bytes.buffer)`.
23
- * 2. Given `bytes: Uint8Array`, `new ByteStream(bytes.buffer)` creates a stream for the entire range of bytes represented by the underlying
24
- * ArrayBuffer. If `bytes` represents only a **sub-range** of the underlying buffer's data, the results will be unexpected unless the optional `subView`
25
- * argument is supplied, with correct offset and length.
26
- *
27
- * For both of the above reasons, prefer to use [[fromUint8Array]].
28
- * @deprecated in 3.x. Use [[fromUint8Array]] or [[fromArrayBuffer]].
29
- */
30
- constructor(buffer: ArrayBuffer | SharedArrayBuffer, subView?: {
31
- byteOffset: number;
32
- byteLength: number;
33
- });
34
- /** Construct a new ByteStream for the range of bytes represented by `bytes`, which may be a subset of the range of bytes
35
- * represented by the underlying ArrayBuffer. The read position will be set to the beginning of the range of bytes.
36
- */
37
- static fromUint8Array(bytes: Uint8Array): ByteStream;
38
- /** Construct a new ByteStream with the read position set to the beginning.
39
- * @param buffer The underlying buffer from which data is to be extracted.
40
- * @param subView If defined, specifies the subset of the underlying buffer's data to use.
41
- */
42
- static fromArrayBuffer(buffer: ArrayBuffer | SharedArrayBuffer, subView?: {
43
- byteOffset: number;
44
- byteLength: number;
45
- }): ByteStream;
46
- /** The number of bytes in this stream */
47
- get length(): number;
48
- /** The number of bytes remaining to be read, from [[curPos]] to the end of the stream. */
49
- get remainingLength(): number;
50
- /** 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.
51
- * @see [[isAtTheEnd]]
52
- */
53
- get isPastTheEnd(): boolean;
54
- /** Returns true if the current read position has advanced precisely to the end of the stream, indicating all of the data has been consumed.
55
- * @see [[isPastTheEnd]].
56
- */
57
- get isAtTheEnd(): boolean;
58
- /** The current read position as an index into the stream of bytes. */
59
- get curPos(): number;
60
- set curPos(pos: number);
61
- /** Adds the specified number of bytes to the current read position */
62
- advance(numBytes: number): boolean;
63
- /** Subtracts the specified number of bytes from the current read position */
64
- rewind(numBytes: number): boolean;
65
- /** Resets the current read position to the beginning of the stream */
66
- reset(): void;
67
- /** Read a unsigned 8-bit integer from the current read position and advance by 1 byte. */
68
- readUint8(): number;
69
- /** Read an unsigned 16-bit integer from the current read position and advance by 2 bytes. */
70
- readUint16(): number;
71
- /** Read an unsigned 32-bit integer from the current read position and advance by 4 bytes. */
72
- readUint32(): number;
73
- /** Read a signed 32-bit integer from the current read position and advance by 4 bytes. */
74
- readInt32(): number;
75
- /** Read a 32-bit floating point number from the current read position and advance by 4 bytes. */
76
- readFloat32(): number;
77
- /** Read a 64-bit floating point number from the current read position and advance by 8 bytes. */
78
- readFloat64(): number;
79
- /** Read an unsigned 64-bit integer from the current read position, advance by 8 bytes, and return the 64-bit value as an Id64String. */
80
- readId64(): Id64String;
81
- /** Read an unsigned 24-bit integer from the current read position and advance by 3 bytes. */
82
- readUint24(): number;
83
- /** @deprecated in 3.x. use [[readUint8]]. */
84
- get nextUint8(): number;
85
- /** @deprecated in 3.x. use [[readUint16]]. */
86
- get nextUint16(): number;
87
- /** @deprecated in 3.x. use [[readUint32]]. */
88
- get nextUint32(): number;
89
- /** @deprecated in 3.x. use [[readInt32]]. */
90
- get nextInt32(): number;
91
- /** @deprecated in 3.x. use [[readFloat32]]. */
92
- get nextFloat32(): number;
93
- /** @deprecated in 3.x. use [[readFloat64]]. */
94
- get nextFloat64(): number;
95
- /** @deprecated in 3.x. use [[readId64]]. */
96
- get nextId64(): Id64String;
97
- /** @deprecated in 3.x. use [[readUint32]]. */
98
- get nextUint24(): number;
99
- /** Read the specified number of bytes beginning at the current read position into a Uint8Array and advance by the specified number of byte.
100
- * @param numBytes The number of bytes to read.
101
- */
102
- nextBytes(numBytes: number): Uint8Array;
103
- /** Read the specified number of bytes at the specified offset without changing the read position. */
104
- readBytes(readPos: number, numBytes: number): Uint8Array;
105
- /** Read the specified number of unsigned 32-bit integers from the current read position and advance the read position. */
106
- nextUint32s(numUint32s: number): Uint32Array;
107
- /** Returns the underlying array buffer */
108
- get arrayBuffer(): ArrayBuffer | SharedArrayBuffer;
109
- private read;
110
- }
1
+ /** @packageDocumentation
2
+ * @module Utils
3
+ */
4
+ import { Id64String } from "./Id";
5
+ /** Allows the contents of an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)
6
+ * to be consumed sequentially using methods to extract
7
+ * data of a particular type from the bytes beginning at the current read position.
8
+ * Methods and properties beginning with 'read' and taking no arguments consume data at the current read position and advance it
9
+ * by the size of the data read. The read position can also be directly adjusted by the caller.
10
+ * @public
11
+ */
12
+ export declare class ByteStream {
13
+ private readonly _view;
14
+ private readonly _byteOffset;
15
+ private _curPos;
16
+ /** Construct a new ByteStream with the read position set to the beginning.
17
+ * @param buffer The underlying buffer from which data is to be extracted.
18
+ * @param subView If defined, specifies the subset of the underlying buffer's data to use.
19
+ * This constructor is subject to two common mistakes:
20
+ *
21
+ * 1. Given `bytes: Uint8Array`, `new ByteStream(bytes)` will compile but at run-time will produce an error asserting that
22
+ * the DataView constructor requires an ArrayBuffer. The correct usage is `new ByteStream(bytes.buffer)`.
23
+ * 2. Given `bytes: Uint8Array`, `new ByteStream(bytes.buffer)` creates a stream for the entire range of bytes represented by the underlying
24
+ * ArrayBuffer. If `bytes` represents only a **sub-range** of the underlying buffer's data, the results will be unexpected unless the optional `subView`
25
+ * argument is supplied, with correct offset and length.
26
+ *
27
+ * For both of the above reasons, prefer to use [[fromUint8Array]].
28
+ * @deprecated in 3.x. Use [[fromUint8Array]] or [[fromArrayBuffer]].
29
+ */
30
+ constructor(buffer: ArrayBuffer | SharedArrayBuffer, subView?: {
31
+ byteOffset: number;
32
+ byteLength: number;
33
+ });
34
+ /** Construct a new ByteStream for the range of bytes represented by `bytes`, which may be a subset of the range of bytes
35
+ * represented by the underlying ArrayBuffer. The read position will be set to the beginning of the range of bytes.
36
+ */
37
+ static fromUint8Array(bytes: Uint8Array): ByteStream;
38
+ /** Construct a new ByteStream with the read position set to the beginning.
39
+ * @param buffer The underlying buffer from which data is to be extracted.
40
+ * @param subView If defined, specifies the subset of the underlying buffer's data to use.
41
+ */
42
+ static fromArrayBuffer(buffer: ArrayBuffer | SharedArrayBuffer, subView?: {
43
+ byteOffset: number;
44
+ byteLength: number;
45
+ }): ByteStream;
46
+ /** The number of bytes in this stream */
47
+ get length(): number;
48
+ /** The number of bytes remaining to be read, from [[curPos]] to the end of the stream. */
49
+ get remainingLength(): number;
50
+ /** 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.
51
+ * @see [[isAtTheEnd]]
52
+ */
53
+ get isPastTheEnd(): boolean;
54
+ /** Returns true if the current read position has advanced precisely to the end of the stream, indicating all of the data has been consumed.
55
+ * @see [[isPastTheEnd]].
56
+ */
57
+ get isAtTheEnd(): boolean;
58
+ /** The current read position as an index into the stream of bytes. */
59
+ get curPos(): number;
60
+ set curPos(pos: number);
61
+ /** Adds the specified number of bytes to the current read position */
62
+ advance(numBytes: number): boolean;
63
+ /** Subtracts the specified number of bytes from the current read position */
64
+ rewind(numBytes: number): boolean;
65
+ /** Resets the current read position to the beginning of the stream */
66
+ reset(): void;
67
+ /** Read a unsigned 8-bit integer from the current read position and advance by 1 byte. */
68
+ readUint8(): number;
69
+ /** Read an unsigned 16-bit integer from the current read position and advance by 2 bytes. */
70
+ readUint16(): number;
71
+ /** Read an unsigned 32-bit integer from the current read position and advance by 4 bytes. */
72
+ readUint32(): number;
73
+ /** Read a signed 32-bit integer from the current read position and advance by 4 bytes. */
74
+ readInt32(): number;
75
+ /** Read a 32-bit floating point number from the current read position and advance by 4 bytes. */
76
+ readFloat32(): number;
77
+ /** Read a 64-bit floating point number from the current read position and advance by 8 bytes. */
78
+ readFloat64(): number;
79
+ /** Read an unsigned 64-bit integer from the current read position, advance by 8 bytes, and return the 64-bit value as an Id64String. */
80
+ readId64(): Id64String;
81
+ /** Read an unsigned 24-bit integer from the current read position and advance by 3 bytes. */
82
+ readUint24(): number;
83
+ /** @deprecated in 3.x. use [[readUint8]]. */
84
+ get nextUint8(): number;
85
+ /** @deprecated in 3.x. use [[readUint16]]. */
86
+ get nextUint16(): number;
87
+ /** @deprecated in 3.x. use [[readUint32]]. */
88
+ get nextUint32(): number;
89
+ /** @deprecated in 3.x. use [[readInt32]]. */
90
+ get nextInt32(): number;
91
+ /** @deprecated in 3.x. use [[readFloat32]]. */
92
+ get nextFloat32(): number;
93
+ /** @deprecated in 3.x. use [[readFloat64]]. */
94
+ get nextFloat64(): number;
95
+ /** @deprecated in 3.x. use [[readId64]]. */
96
+ get nextId64(): Id64String;
97
+ /** @deprecated in 3.x. use [[readUint32]]. */
98
+ get nextUint24(): number;
99
+ /** Read the specified number of bytes beginning at the current read position into a Uint8Array and advance by the specified number of byte.
100
+ * @param numBytes The number of bytes to read.
101
+ */
102
+ nextBytes(numBytes: number): Uint8Array;
103
+ /** Read the specified number of bytes at the specified offset without changing the read position. */
104
+ readBytes(readPos: number, numBytes: number): Uint8Array;
105
+ /** Read the specified number of unsigned 32-bit integers from the current read position and advance the read position. */
106
+ nextUint32s(numUint32s: number): Uint32Array;
107
+ /** Returns the underlying array buffer */
108
+ get arrayBuffer(): ArrayBuffer | SharedArrayBuffer;
109
+ private read;
110
+ }
111
111
  //# sourceMappingURL=ByteStream.d.ts.map
@@ -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 in 3.x. 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 in 3.x. use [[readUint8]]. */
117
- get nextUint8() { return this.readUint8(); }
118
- /** @deprecated in 3.x. use [[readUint16]]. */
119
- get nextUint16() { return this.readUint16(); }
120
- /** @deprecated in 3.x. use [[readUint32]]. */
121
- get nextUint32() { return this.readUint32(); }
122
- /** @deprecated in 3.x. use [[readInt32]]. */
123
- get nextInt32() { return this.readInt32(); }
124
- /** @deprecated in 3.x. use [[readFloat32]]. */
125
- get nextFloat32() { return this.readFloat32(); }
126
- /** @deprecated in 3.x. use [[readFloat64]]. */
127
- get nextFloat64() { return this.readFloat64(); }
128
- /** @deprecated in 3.x. use [[readId64]]. */
129
- get nextId64() { return this.readId64(); }
130
- /** @deprecated in 3.x. 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 in 3.x. 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 in 3.x. use [[readUint8]]. */
117
+ get nextUint8() { return this.readUint8(); }
118
+ /** @deprecated in 3.x. use [[readUint16]]. */
119
+ get nextUint16() { return this.readUint16(); }
120
+ /** @deprecated in 3.x. use [[readUint32]]. */
121
+ get nextUint32() { return this.readUint32(); }
122
+ /** @deprecated in 3.x. use [[readInt32]]. */
123
+ get nextInt32() { return this.readInt32(); }
124
+ /** @deprecated in 3.x. use [[readFloat32]]. */
125
+ get nextFloat32() { return this.readFloat32(); }
126
+ /** @deprecated in 3.x. use [[readFloat64]]. */
127
+ get nextFloat64() { return this.readFloat64(); }
128
+ /** @deprecated in 3.x. use [[readId64]]. */
129
+ get nextId64() { return this.readId64(); }
130
+ /** @deprecated in 3.x. 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
  //# sourceMappingURL=ByteStream.js.map
@@ -1 +1 @@
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,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;YAC1E,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;SACvC;aAAM;YACL,IAAI,CAAC,KAAK,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;YAClC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;SACtB;IACH,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,cAAc,CAAC,KAAiB;QAC5C,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;QACzC,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,8CAA8C;IACjH,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,eAAe,CAAC,MAAuC,EAAE,OAAoD;QACzH,OAAO,IAAI,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,8CAA8C;IACxF,CAAC;IAED,yCAAyC;IACzC,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,KAAK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MAAM,QAAQ,GAAG,UAAU,GAAG,CAAC,CAAC;QAChC,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,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":["/*---------------------------------------------------------------------------------------------\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 in 3.x. 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 in 3.x. use [[readUint8]]. */\r\n public get nextUint8(): number { return this.readUint8(); }\r\n /** @deprecated in 3.x. use [[readUint16]]. */\r\n public get nextUint16(): number { return this.readUint16(); }\r\n /** @deprecated in 3.x. use [[readUint32]]. */\r\n public get nextUint32(): number { return this.readUint32(); }\r\n /** @deprecated in 3.x. use [[readInt32]]. */\r\n public get nextInt32(): number { return this.readInt32(); }\r\n /** @deprecated in 3.x. use [[readFloat32]]. */\r\n public get nextFloat32(): number { return this.readFloat32(); }\r\n /** @deprecated in 3.x. use [[readFloat64]]. */\r\n public get nextFloat64(): number { return this.readFloat64(); }\r\n /** @deprecated in 3.x. use [[readId64]]. */\r\n public get nextId64(): Id64String { return this.readId64(); }\r\n /** @deprecated in 3.x. 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
+ {"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,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;YAC1E,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;SACvC;aAAM;YACL,IAAI,CAAC,KAAK,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;YAClC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;SACtB;IACH,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,cAAc,CAAC,KAAiB;QAC5C,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;QACzC,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,8CAA8C;IACjH,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,eAAe,CAAC,MAAuC,EAAE,OAAoD;QACzH,OAAO,IAAI,UAAU,CAAC,MAAM,EAAE,OAAO,CAA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CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAChF,CAAC;IAED,0HAA0H;IACnH,WAAW,CAAC,UAAkB;QACnC,MAAM,QAAQ,GAAG,UAAU,GAAG,CAAC,CAAC;QAChC,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,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 in 3.x. 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 in 3.x. use [[readUint8]]. */\n public get nextUint8(): number { return this.readUint8(); }\n /** @deprecated in 3.x. use [[readUint16]]. */\n public get nextUint16(): number { return this.readUint16(); }\n /** @deprecated in 3.x. use [[readUint32]]. */\n public get nextUint32(): number { return this.readUint32(); }\n /** @deprecated in 3.x. use [[readInt32]]. */\n public get nextInt32(): number { return this.readInt32(); }\n /** @deprecated in 3.x. use [[readFloat32]]. */\n public get nextFloat32(): number { return this.readFloat32(); }\n /** @deprecated in 3.x. use [[readFloat64]]. */\n public get nextFloat64(): number { return this.readFloat64(); }\n /** @deprecated in 3.x. use [[readId64]]. */\n public get nextId64(): Id64String { return this.readId64(); }\n /** @deprecated in 3.x. 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"]}