@loaders.gl/parquet 4.4.5 → 5.0.0-alpha.2

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 (674) hide show
  1. package/LICENSE +14 -3
  2. package/dist/bundled.d.ts +9 -0
  3. package/dist/bundled.d.ts.map +1 -0
  4. package/dist/bundled.js +10 -0
  5. package/dist/bundled.js.map +1 -0
  6. package/dist/geoparquet-loader-with-parser.d.ts +33 -0
  7. package/dist/geoparquet-loader-with-parser.d.ts.map +1 -0
  8. package/dist/geoparquet-loader-with-parser.js +52 -0
  9. package/dist/geoparquet-loader-with-parser.js.map +1 -0
  10. package/dist/geoparquet-loader.d.ts +59 -0
  11. package/dist/geoparquet-loader.d.ts.map +1 -0
  12. package/dist/geoparquet-loader.js +30 -0
  13. package/dist/geoparquet-loader.js.map +1 -0
  14. package/dist/index.cjs +25873 -4776
  15. package/dist/index.cjs.map +3 -4
  16. package/dist/index.d.ts +10 -7
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +7 -11
  19. package/dist/index.js.map +1 -1
  20. package/dist/lib/arrow/convert-columns-to-row-group.js +3 -0
  21. package/dist/lib/arrow/convert-columns-to-row-group.js.map +1 -1
  22. package/dist/lib/arrow/convert-schema-from-parquet.d.ts.map +1 -1
  23. package/dist/lib/arrow/convert-schema-from-parquet.js +86 -26
  24. package/dist/lib/arrow/convert-schema-from-parquet.js.map +1 -1
  25. package/dist/lib/arrow/convert-schema-to-parquet.d.ts.map +1 -1
  26. package/dist/lib/arrow/convert-schema-to-parquet.js +16 -7
  27. package/dist/lib/arrow/convert-schema-to-parquet.js.map +1 -1
  28. package/dist/lib/arrow/create-nested-arrow-vector.d.ts +8 -0
  29. package/dist/lib/arrow/create-nested-arrow-vector.d.ts.map +1 -0
  30. package/dist/lib/arrow/create-nested-arrow-vector.js +396 -0
  31. package/dist/lib/arrow/create-nested-arrow-vector.js.map +1 -0
  32. package/dist/lib/constants.d.ts +0 -1
  33. package/dist/lib/constants.d.ts.map +1 -1
  34. package/dist/lib/constants.js +1 -2
  35. package/dist/lib/constants.js.map +1 -1
  36. package/dist/lib/encoders/encode-arrow-to-parquet.d.ts +2 -2
  37. package/dist/lib/encoders/encode-arrow-to-parquet.d.ts.map +1 -1
  38. package/dist/lib/encoders/encode-arrow-to-parquet.js +3 -10
  39. package/dist/lib/encoders/encode-arrow-to-parquet.js.map +1 -1
  40. package/dist/lib/encoders/encode-table-to-parquet-js.d.ts +5 -0
  41. package/dist/lib/encoders/encode-table-to-parquet-js.d.ts.map +1 -0
  42. package/dist/lib/encoders/encode-table-to-parquet-js.js +199 -0
  43. package/dist/lib/encoders/encode-table-to-parquet-js.js.map +1 -0
  44. package/dist/lib/geo/geospatial-metadata.d.ts +67 -0
  45. package/dist/lib/geo/geospatial-metadata.d.ts.map +1 -0
  46. package/dist/lib/geo/geospatial-metadata.js +338 -0
  47. package/dist/lib/geo/geospatial-metadata.js.map +1 -0
  48. package/dist/lib/parquet-page-index.d.ts +62 -0
  49. package/dist/lib/parquet-page-index.d.ts.map +1 -0
  50. package/dist/lib/parquet-page-index.js +377 -0
  51. package/dist/lib/parquet-page-index.js.map +1 -0
  52. package/dist/lib/parquet-predicate.d.ts +17 -0
  53. package/dist/lib/parquet-predicate.d.ts.map +1 -0
  54. package/dist/lib/parquet-predicate.js +300 -0
  55. package/dist/lib/parquet-predicate.js.map +1 -0
  56. package/dist/lib/parquet-source-worker-client.d.ts +6 -0
  57. package/dist/lib/parquet-source-worker-client.d.ts.map +1 -0
  58. package/dist/lib/parquet-source-worker-client.js +22 -0
  59. package/dist/lib/parquet-source-worker-client.js.map +1 -0
  60. package/dist/lib/parquet-source-worker-decoder.d.ts +4 -0
  61. package/dist/lib/parquet-source-worker-decoder.d.ts.map +1 -0
  62. package/dist/lib/parquet-source-worker-decoder.js +115 -0
  63. package/dist/lib/parquet-source-worker-decoder.js.map +1 -0
  64. package/dist/lib/parquet-source-worker-file.d.ts +24 -0
  65. package/dist/lib/parquet-source-worker-file.d.ts.map +1 -0
  66. package/dist/lib/parquet-source-worker-file.js +40 -0
  67. package/dist/lib/parquet-source-worker-file.js.map +1 -0
  68. package/dist/lib/parquet-source-worker-types.d.ts +97 -0
  69. package/dist/lib/parquet-source-worker-types.d.ts.map +1 -0
  70. package/dist/lib/parquet-source-worker-types.js +5 -0
  71. package/dist/lib/parquet-source-worker-types.js.map +1 -0
  72. package/dist/lib/parquet-worker-transport.d.ts +8 -0
  73. package/dist/lib/parquet-worker-transport.d.ts.map +1 -0
  74. package/dist/lib/parquet-worker-transport.js +40 -0
  75. package/dist/lib/parquet-worker-transport.js.map +1 -0
  76. package/dist/lib/parsers/convert-parquet-tables.d.ts +16 -0
  77. package/dist/lib/parsers/convert-parquet-tables.d.ts.map +1 -0
  78. package/dist/lib/parsers/convert-parquet-tables.js +30 -0
  79. package/dist/lib/parsers/convert-parquet-tables.js.map +1 -0
  80. package/dist/lib/parsers/get-parquet-schema.d.ts.map +1 -1
  81. package/dist/lib/parsers/get-parquet-schema.js +3 -1
  82. package/dist/lib/parsers/get-parquet-schema.js.map +1 -1
  83. package/dist/lib/parsers/parse-geoparquet-to-geojson.d.ts +4 -4
  84. package/dist/lib/parsers/parse-geoparquet-to-geojson.d.ts.map +1 -1
  85. package/dist/lib/parsers/parse-geoparquet-to-geojson.js +19 -6
  86. package/dist/lib/parsers/parse-geoparquet-to-geojson.js.map +1 -1
  87. package/dist/lib/parsers/parse-parquet-tables.d.ts +37 -0
  88. package/dist/lib/parsers/parse-parquet-tables.d.ts.map +1 -0
  89. package/dist/lib/parsers/parse-parquet-tables.js +50 -0
  90. package/dist/lib/parsers/parse-parquet-tables.js.map +1 -0
  91. package/dist/lib/parsers/parse-parquet-to-arrow-js.d.ts +19 -0
  92. package/dist/lib/parsers/parse-parquet-to-arrow-js.d.ts.map +1 -0
  93. package/dist/lib/parsers/parse-parquet-to-arrow-js.js +608 -0
  94. package/dist/lib/parsers/parse-parquet-to-arrow-js.js.map +1 -0
  95. package/dist/lib/parsers/parse-parquet-to-arrow.d.ts +7 -7
  96. package/dist/lib/parsers/parse-parquet-to-arrow.d.ts.map +1 -1
  97. package/dist/lib/parsers/parse-parquet-to-arrow.js +45 -32
  98. package/dist/lib/parsers/parse-parquet-to-arrow.js.map +1 -1
  99. package/dist/lib/parsers/parse-parquet-to-columns.d.ts +3 -3
  100. package/dist/lib/parsers/parse-parquet-to-columns.d.ts.map +1 -1
  101. package/dist/lib/parsers/parse-parquet-to-columns.js +1 -4
  102. package/dist/lib/parsers/parse-parquet-to-columns.js.map +1 -1
  103. package/dist/lib/parsers/parse-parquet-to-json.d.ts +3 -3
  104. package/dist/lib/parsers/parse-parquet-to-json.d.ts.map +1 -1
  105. package/dist/lib/parsers/parse-parquet-to-json.js +77 -26
  106. package/dist/lib/parsers/parse-parquet-to-json.js.map +1 -1
  107. package/dist/lib/sources/parquet-range-file.d.ts +80 -0
  108. package/dist/lib/sources/parquet-range-file.d.ts.map +1 -0
  109. package/dist/lib/sources/parquet-range-file.js +261 -0
  110. package/dist/lib/sources/parquet-range-file.js.map +1 -0
  111. package/dist/lib/sources/single-batch-queue.d.ts +24 -0
  112. package/dist/lib/sources/single-batch-queue.d.ts.map +1 -0
  113. package/dist/lib/sources/single-batch-queue.js +91 -0
  114. package/dist/lib/sources/single-batch-queue.js.map +1 -0
  115. package/dist/lib/utils/load-wasm-node.d.ts +3 -0
  116. package/dist/lib/utils/load-wasm-node.d.ts.map +1 -0
  117. package/dist/lib/utils/load-wasm-node.js +23 -0
  118. package/dist/lib/utils/load-wasm-node.js.map +1 -0
  119. package/dist/lib/utils/load-wasm.d.ts +2 -2
  120. package/dist/lib/utils/load-wasm.d.ts.map +1 -1
  121. package/dist/lib/utils/load-wasm.js +28 -12
  122. package/dist/lib/utils/load-wasm.js.map +1 -1
  123. package/dist/lib/utils/make-stream-iterator.d.ts +2 -0
  124. package/dist/lib/utils/make-stream-iterator.d.ts.map +1 -1
  125. package/dist/lib/utils/make-stream-iterator.js +123 -14
  126. package/dist/lib/utils/make-stream-iterator.js.map +1 -1
  127. package/dist/lib/utils/normalize-parquet-options.d.ts +5 -0
  128. package/dist/lib/utils/normalize-parquet-options.d.ts.map +1 -0
  129. package/dist/lib/utils/normalize-parquet-options.js +11 -0
  130. package/dist/lib/utils/normalize-parquet-options.js.map +1 -0
  131. package/dist/parquet-dataset-source.cjs +26413 -0
  132. package/dist/parquet-dataset-source.cjs.map +6 -0
  133. package/dist/parquet-dataset-source.d.ts +54 -0
  134. package/dist/parquet-dataset-source.d.ts.map +1 -0
  135. package/dist/parquet-dataset-source.js +380 -0
  136. package/dist/parquet-dataset-source.js.map +1 -0
  137. package/dist/parquet-format.d.ts +2 -0
  138. package/dist/parquet-format.d.ts.map +1 -1
  139. package/dist/parquet-format.js +2 -0
  140. package/dist/parquet-format.js.map +1 -1
  141. package/dist/parquet-js-loader-types.d.ts +57 -0
  142. package/dist/parquet-js-loader-types.d.ts.map +1 -0
  143. package/dist/parquet-js-loader-types.js +33 -0
  144. package/dist/parquet-js-loader-types.js.map +1 -0
  145. package/dist/parquet-js-loader.d.ts +32 -0
  146. package/dist/parquet-js-loader.d.ts.map +1 -0
  147. package/dist/parquet-js-loader.js +58 -0
  148. package/dist/parquet-js-loader.js.map +1 -0
  149. package/dist/parquet-js-writer.d.ts +44 -0
  150. package/dist/parquet-js-writer.d.ts.map +1 -0
  151. package/dist/parquet-js-writer.js +28 -0
  152. package/dist/parquet-js-writer.js.map +1 -0
  153. package/dist/parquet-loader-base.d.ts +25 -0
  154. package/dist/parquet-loader-base.d.ts.map +1 -0
  155. package/dist/parquet-loader-base.js +23 -0
  156. package/dist/parquet-loader-base.js.map +1 -0
  157. package/dist/parquet-loader-options.d.ts +44 -0
  158. package/dist/parquet-loader-options.d.ts.map +1 -0
  159. package/dist/parquet-loader-options.js +10 -0
  160. package/dist/parquet-loader-options.js.map +1 -0
  161. package/dist/parquet-loader-types.d.ts +61 -0
  162. package/dist/parquet-loader-types.d.ts.map +1 -0
  163. package/dist/parquet-loader-types.js +17 -0
  164. package/dist/parquet-loader-types.js.map +1 -0
  165. package/dist/parquet-loader.d.ts +42 -0
  166. package/dist/parquet-loader.d.ts.map +1 -0
  167. package/dist/parquet-loader.js +68 -0
  168. package/dist/parquet-loader.js.map +1 -0
  169. package/dist/parquet-source-capabilities.d.ts +36 -0
  170. package/dist/parquet-source-capabilities.d.ts.map +1 -0
  171. package/dist/parquet-source-capabilities.js +22 -0
  172. package/dist/parquet-source-capabilities.js.map +1 -0
  173. package/dist/parquet-source-loader-types.d.ts +72 -0
  174. package/dist/parquet-source-loader-types.d.ts.map +1 -0
  175. package/dist/parquet-source-loader-types.js +74 -0
  176. package/dist/parquet-source-loader-types.js.map +1 -0
  177. package/dist/parquet-source-loader.cjs +25975 -0
  178. package/dist/parquet-source-loader.cjs.map +6 -0
  179. package/dist/parquet-source-loader.d.ts +120 -0
  180. package/dist/parquet-source-loader.d.ts.map +1 -0
  181. package/dist/parquet-source-loader.js +812 -0
  182. package/dist/parquet-source-loader.js.map +1 -0
  183. package/dist/parquet-source-types.d.ts +384 -0
  184. package/dist/parquet-source-types.d.ts.map +1 -0
  185. package/dist/parquet-source-types.js +5 -0
  186. package/dist/parquet-source-types.js.map +1 -0
  187. package/dist/parquet-source-worker-url.d.ts +3 -0
  188. package/dist/parquet-source-worker-url.d.ts.map +1 -0
  189. package/dist/parquet-source-worker-url.js +22 -0
  190. package/dist/parquet-source-worker-url.js.map +1 -0
  191. package/dist/parquet-source-worker.js +38491 -0
  192. package/dist/parquet-source-worker.js.map +7 -0
  193. package/dist/parquet-worker-node.cjs +54779 -0
  194. package/dist/parquet-worker-node.cjs.map +7 -0
  195. package/dist/parquet-worker-url.d.ts +3 -0
  196. package/dist/parquet-worker-url.d.ts.map +1 -0
  197. package/dist/parquet-worker-url.js +15 -0
  198. package/dist/parquet-worker-url.js.map +1 -0
  199. package/dist/parquet-worker.js +19920 -0
  200. package/dist/parquet-worker.js.map +7 -0
  201. package/dist/parquet-writer.d.ts +10 -0
  202. package/dist/parquet-writer.d.ts.map +1 -0
  203. package/dist/parquet-writer.js +27 -0
  204. package/dist/parquet-writer.js.map +1 -0
  205. package/dist/parquet_wasm_bg.wasm +0 -0
  206. package/dist/parquetjs/codecs/byte-stream-split.d.ts +9 -0
  207. package/dist/parquetjs/codecs/byte-stream-split.d.ts.map +1 -0
  208. package/dist/parquetjs/codecs/byte-stream-split.js +159 -0
  209. package/dist/parquetjs/codecs/byte-stream-split.js.map +1 -0
  210. package/dist/parquetjs/codecs/declare.d.ts +20 -3
  211. package/dist/parquetjs/codecs/declare.d.ts.map +1 -1
  212. package/dist/parquetjs/codecs/declare.js +7 -1
  213. package/dist/parquetjs/codecs/declare.js.map +1 -1
  214. package/dist/parquetjs/codecs/delta.d.ts +17 -0
  215. package/dist/parquetjs/codecs/delta.d.ts.map +1 -0
  216. package/dist/parquetjs/codecs/delta.js +439 -0
  217. package/dist/parquetjs/codecs/delta.js.map +1 -0
  218. package/dist/parquetjs/codecs/dictionary.d.ts +5 -2
  219. package/dist/parquetjs/codecs/dictionary.d.ts.map +1 -1
  220. package/dist/parquetjs/codecs/dictionary.js +16 -4
  221. package/dist/parquetjs/codecs/dictionary.js.map +1 -1
  222. package/dist/parquetjs/codecs/index.d.ts.map +1 -1
  223. package/dist/parquetjs/codecs/index.js +18 -0
  224. package/dist/parquetjs/codecs/index.js.map +1 -1
  225. package/dist/parquetjs/codecs/plain.d.ts +3 -3
  226. package/dist/parquetjs/codecs/plain.d.ts.map +1 -1
  227. package/dist/parquetjs/codecs/plain.js +88 -76
  228. package/dist/parquetjs/codecs/plain.js.map +1 -1
  229. package/dist/parquetjs/codecs/rle.d.ts +3 -3
  230. package/dist/parquetjs/codecs/rle.d.ts.map +1 -1
  231. package/dist/parquetjs/codecs/rle.js +196 -68
  232. package/dist/parquetjs/codecs/rle.js.map +1 -1
  233. package/dist/parquetjs/compression.d.ts +7 -8
  234. package/dist/parquetjs/compression.d.ts.map +1 -1
  235. package/dist/parquetjs/compression.js +95 -141
  236. package/dist/parquetjs/compression.js.map +1 -1
  237. package/dist/parquetjs/encoder/dictionary-planner.d.ts +17 -0
  238. package/dist/parquetjs/encoder/dictionary-planner.d.ts.map +1 -0
  239. package/dist/parquetjs/encoder/dictionary-planner.js +64 -0
  240. package/dist/parquetjs/encoder/dictionary-planner.js.map +1 -0
  241. package/dist/parquetjs/encoder/page-planner.d.ts +11 -0
  242. package/dist/parquetjs/encoder/page-planner.d.ts.map +1 -0
  243. package/dist/parquetjs/encoder/page-planner.js +60 -0
  244. package/dist/parquetjs/encoder/page-planner.js.map +1 -0
  245. package/dist/parquetjs/encoder/parquet-encoder.d.ts +11 -4
  246. package/dist/parquetjs/encoder/parquet-encoder.d.ts.map +1 -1
  247. package/dist/parquetjs/encoder/parquet-encoder.js +259 -52
  248. package/dist/parquetjs/encoder/parquet-encoder.js.map +1 -1
  249. package/dist/parquetjs/parquet-thrift/BsonType.d.ts +1 -1
  250. package/dist/parquetjs/parquet-thrift/BsonType.d.ts.map +1 -1
  251. package/dist/parquetjs/parquet-thrift/BsonType.js +1 -1
  252. package/dist/parquetjs/parquet-thrift/BsonType.js.map +1 -1
  253. package/dist/parquetjs/parquet-thrift/ColumnChunk.d.ts +2 -2
  254. package/dist/parquetjs/parquet-thrift/ColumnChunk.d.ts.map +1 -1
  255. package/dist/parquetjs/parquet-thrift/ColumnChunk.js +2 -2
  256. package/dist/parquetjs/parquet-thrift/ColumnChunk.js.map +1 -1
  257. package/dist/parquetjs/parquet-thrift/ColumnIndex.d.ts +6 -6
  258. package/dist/parquetjs/parquet-thrift/ColumnIndex.d.ts.map +1 -1
  259. package/dist/parquetjs/parquet-thrift/ColumnIndex.js +3 -3
  260. package/dist/parquetjs/parquet-thrift/ColumnIndex.js.map +1 -1
  261. package/dist/parquetjs/parquet-thrift/ColumnMetaData.d.ts +2 -2
  262. package/dist/parquetjs/parquet-thrift/ColumnMetaData.d.ts.map +1 -1
  263. package/dist/parquetjs/parquet-thrift/ColumnMetaData.js +2 -2
  264. package/dist/parquetjs/parquet-thrift/ColumnMetaData.js.map +1 -1
  265. package/dist/parquetjs/parquet-thrift/ColumnOrder.d.ts +1 -1
  266. package/dist/parquetjs/parquet-thrift/ColumnOrder.d.ts.map +1 -1
  267. package/dist/parquetjs/parquet-thrift/ColumnOrder.js +1 -1
  268. package/dist/parquetjs/parquet-thrift/ColumnOrder.js.map +1 -1
  269. package/dist/parquetjs/parquet-thrift/DataPageHeader.d.ts +1 -1
  270. package/dist/parquetjs/parquet-thrift/DataPageHeader.d.ts.map +1 -1
  271. package/dist/parquetjs/parquet-thrift/DataPageHeader.js +1 -1
  272. package/dist/parquetjs/parquet-thrift/DataPageHeader.js.map +1 -1
  273. package/dist/parquetjs/parquet-thrift/DataPageHeaderV2.d.ts +1 -1
  274. package/dist/parquetjs/parquet-thrift/DataPageHeaderV2.d.ts.map +1 -1
  275. package/dist/parquetjs/parquet-thrift/DataPageHeaderV2.js +1 -1
  276. package/dist/parquetjs/parquet-thrift/DataPageHeaderV2.js.map +1 -1
  277. package/dist/parquetjs/parquet-thrift/DateType.d.ts +1 -1
  278. package/dist/parquetjs/parquet-thrift/DateType.d.ts.map +1 -1
  279. package/dist/parquetjs/parquet-thrift/DateType.js +1 -1
  280. package/dist/parquetjs/parquet-thrift/DateType.js.map +1 -1
  281. package/dist/parquetjs/parquet-thrift/DecimalType.d.ts +1 -1
  282. package/dist/parquetjs/parquet-thrift/DecimalType.d.ts.map +1 -1
  283. package/dist/parquetjs/parquet-thrift/DecimalType.js +1 -1
  284. package/dist/parquetjs/parquet-thrift/DecimalType.js.map +1 -1
  285. package/dist/parquetjs/parquet-thrift/DictionaryPageHeader.d.ts +1 -1
  286. package/dist/parquetjs/parquet-thrift/DictionaryPageHeader.d.ts.map +1 -1
  287. package/dist/parquetjs/parquet-thrift/DictionaryPageHeader.js +1 -1
  288. package/dist/parquetjs/parquet-thrift/DictionaryPageHeader.js.map +1 -1
  289. package/dist/parquetjs/parquet-thrift/EdgeInterpolationAlgorithm.d.ts +8 -0
  290. package/dist/parquetjs/parquet-thrift/EdgeInterpolationAlgorithm.d.ts.map +1 -0
  291. package/dist/parquetjs/parquet-thrift/EdgeInterpolationAlgorithm.js +14 -0
  292. package/dist/parquetjs/parquet-thrift/EdgeInterpolationAlgorithm.js.map +1 -0
  293. package/dist/parquetjs/parquet-thrift/Encoding.d.ts +2 -1
  294. package/dist/parquetjs/parquet-thrift/Encoding.d.ts.map +1 -1
  295. package/dist/parquetjs/parquet-thrift/Encoding.js +1 -0
  296. package/dist/parquetjs/parquet-thrift/Encoding.js.map +1 -1
  297. package/dist/parquetjs/parquet-thrift/EnumType.d.ts +1 -1
  298. package/dist/parquetjs/parquet-thrift/EnumType.d.ts.map +1 -1
  299. package/dist/parquetjs/parquet-thrift/EnumType.js +1 -1
  300. package/dist/parquetjs/parquet-thrift/EnumType.js.map +1 -1
  301. package/dist/parquetjs/parquet-thrift/FileMetaData.d.ts +2 -2
  302. package/dist/parquetjs/parquet-thrift/FileMetaData.d.ts.map +1 -1
  303. package/dist/parquetjs/parquet-thrift/FileMetaData.js +2 -2
  304. package/dist/parquetjs/parquet-thrift/FileMetaData.js.map +1 -1
  305. package/dist/parquetjs/parquet-thrift/Float16Type.d.ts +9 -0
  306. package/dist/parquetjs/parquet-thrift/Float16Type.d.ts.map +1 -0
  307. package/dist/parquetjs/parquet-thrift/Float16Type.js +27 -0
  308. package/dist/parquetjs/parquet-thrift/Float16Type.js.map +1 -0
  309. package/dist/parquetjs/parquet-thrift/GeographyType.d.ts +14 -0
  310. package/dist/parquetjs/parquet-thrift/GeographyType.d.ts.map +1 -0
  311. package/dist/parquetjs/parquet-thrift/GeographyType.js +51 -0
  312. package/dist/parquetjs/parquet-thrift/GeographyType.js.map +1 -0
  313. package/dist/parquetjs/parquet-thrift/GeometryType.d.ts +11 -0
  314. package/dist/parquetjs/parquet-thrift/GeometryType.d.ts.map +1 -0
  315. package/dist/parquetjs/parquet-thrift/GeometryType.js +41 -0
  316. package/dist/parquetjs/parquet-thrift/GeometryType.js.map +1 -0
  317. package/dist/parquetjs/parquet-thrift/IndexPageHeader.d.ts +1 -1
  318. package/dist/parquetjs/parquet-thrift/IndexPageHeader.d.ts.map +1 -1
  319. package/dist/parquetjs/parquet-thrift/IndexPageHeader.js +1 -1
  320. package/dist/parquetjs/parquet-thrift/IndexPageHeader.js.map +1 -1
  321. package/dist/parquetjs/parquet-thrift/IntType.d.ts +1 -1
  322. package/dist/parquetjs/parquet-thrift/IntType.d.ts.map +1 -1
  323. package/dist/parquetjs/parquet-thrift/IntType.js +1 -1
  324. package/dist/parquetjs/parquet-thrift/IntType.js.map +1 -1
  325. package/dist/parquetjs/parquet-thrift/JsonType.d.ts +1 -1
  326. package/dist/parquetjs/parquet-thrift/JsonType.d.ts.map +1 -1
  327. package/dist/parquetjs/parquet-thrift/JsonType.js +1 -1
  328. package/dist/parquetjs/parquet-thrift/JsonType.js.map +1 -1
  329. package/dist/parquetjs/parquet-thrift/KeyValue.d.ts +1 -1
  330. package/dist/parquetjs/parquet-thrift/KeyValue.d.ts.map +1 -1
  331. package/dist/parquetjs/parquet-thrift/KeyValue.js +1 -1
  332. package/dist/parquetjs/parquet-thrift/KeyValue.js.map +1 -1
  333. package/dist/parquetjs/parquet-thrift/ListType.d.ts +1 -1
  334. package/dist/parquetjs/parquet-thrift/ListType.d.ts.map +1 -1
  335. package/dist/parquetjs/parquet-thrift/ListType.js +1 -1
  336. package/dist/parquetjs/parquet-thrift/ListType.js.map +1 -1
  337. package/dist/parquetjs/parquet-thrift/LogicalType.d.ts +17 -1
  338. package/dist/parquetjs/parquet-thrift/LogicalType.d.ts.map +1 -1
  339. package/dist/parquetjs/parquet-thrift/LogicalType.js +97 -1
  340. package/dist/parquetjs/parquet-thrift/LogicalType.js.map +1 -1
  341. package/dist/parquetjs/parquet-thrift/MapType.d.ts +1 -1
  342. package/dist/parquetjs/parquet-thrift/MapType.d.ts.map +1 -1
  343. package/dist/parquetjs/parquet-thrift/MapType.js +1 -1
  344. package/dist/parquetjs/parquet-thrift/MapType.js.map +1 -1
  345. package/dist/parquetjs/parquet-thrift/MicroSeconds.d.ts +1 -1
  346. package/dist/parquetjs/parquet-thrift/MicroSeconds.d.ts.map +1 -1
  347. package/dist/parquetjs/parquet-thrift/MicroSeconds.js +1 -1
  348. package/dist/parquetjs/parquet-thrift/MicroSeconds.js.map +1 -1
  349. package/dist/parquetjs/parquet-thrift/MilliSeconds.d.ts +1 -1
  350. package/dist/parquetjs/parquet-thrift/MilliSeconds.d.ts.map +1 -1
  351. package/dist/parquetjs/parquet-thrift/MilliSeconds.js +1 -1
  352. package/dist/parquetjs/parquet-thrift/MilliSeconds.js.map +1 -1
  353. package/dist/parquetjs/parquet-thrift/NanoSeconds.d.ts +9 -0
  354. package/dist/parquetjs/parquet-thrift/NanoSeconds.d.ts.map +1 -0
  355. package/dist/parquetjs/parquet-thrift/NanoSeconds.js +27 -0
  356. package/dist/parquetjs/parquet-thrift/NanoSeconds.js.map +1 -0
  357. package/dist/parquetjs/parquet-thrift/NullType.d.ts +1 -1
  358. package/dist/parquetjs/parquet-thrift/NullType.d.ts.map +1 -1
  359. package/dist/parquetjs/parquet-thrift/NullType.js +1 -1
  360. package/dist/parquetjs/parquet-thrift/NullType.js.map +1 -1
  361. package/dist/parquetjs/parquet-thrift/OffsetIndex.d.ts +1 -1
  362. package/dist/parquetjs/parquet-thrift/OffsetIndex.d.ts.map +1 -1
  363. package/dist/parquetjs/parquet-thrift/OffsetIndex.js +1 -1
  364. package/dist/parquetjs/parquet-thrift/OffsetIndex.js.map +1 -1
  365. package/dist/parquetjs/parquet-thrift/PageEncodingStats.d.ts +1 -1
  366. package/dist/parquetjs/parquet-thrift/PageEncodingStats.d.ts.map +1 -1
  367. package/dist/parquetjs/parquet-thrift/PageEncodingStats.js +1 -1
  368. package/dist/parquetjs/parquet-thrift/PageEncodingStats.js.map +1 -1
  369. package/dist/parquetjs/parquet-thrift/PageHeader.d.ts +1 -1
  370. package/dist/parquetjs/parquet-thrift/PageHeader.d.ts.map +1 -1
  371. package/dist/parquetjs/parquet-thrift/PageHeader.js +1 -1
  372. package/dist/parquetjs/parquet-thrift/PageHeader.js.map +1 -1
  373. package/dist/parquetjs/parquet-thrift/PageLocation.d.ts +2 -2
  374. package/dist/parquetjs/parquet-thrift/PageLocation.d.ts.map +1 -1
  375. package/dist/parquetjs/parquet-thrift/PageLocation.js +2 -2
  376. package/dist/parquetjs/parquet-thrift/PageLocation.js.map +1 -1
  377. package/dist/parquetjs/parquet-thrift/RowGroup.d.ts +2 -2
  378. package/dist/parquetjs/parquet-thrift/RowGroup.d.ts.map +1 -1
  379. package/dist/parquetjs/parquet-thrift/RowGroup.js +2 -2
  380. package/dist/parquetjs/parquet-thrift/RowGroup.js.map +1 -1
  381. package/dist/parquetjs/parquet-thrift/SchemaElement.d.ts +1 -1
  382. package/dist/parquetjs/parquet-thrift/SchemaElement.d.ts.map +1 -1
  383. package/dist/parquetjs/parquet-thrift/SchemaElement.js +1 -1
  384. package/dist/parquetjs/parquet-thrift/SchemaElement.js.map +1 -1
  385. package/dist/parquetjs/parquet-thrift/SortingColumn.d.ts +1 -1
  386. package/dist/parquetjs/parquet-thrift/SortingColumn.d.ts.map +1 -1
  387. package/dist/parquetjs/parquet-thrift/SortingColumn.js +1 -1
  388. package/dist/parquetjs/parquet-thrift/SortingColumn.js.map +1 -1
  389. package/dist/parquetjs/parquet-thrift/Statistics.d.ts +14 -10
  390. package/dist/parquetjs/parquet-thrift/Statistics.d.ts.map +1 -1
  391. package/dist/parquetjs/parquet-thrift/Statistics.js +38 -2
  392. package/dist/parquetjs/parquet-thrift/Statistics.js.map +1 -1
  393. package/dist/parquetjs/parquet-thrift/StringType.d.ts +1 -1
  394. package/dist/parquetjs/parquet-thrift/StringType.d.ts.map +1 -1
  395. package/dist/parquetjs/parquet-thrift/StringType.js +1 -1
  396. package/dist/parquetjs/parquet-thrift/StringType.js.map +1 -1
  397. package/dist/parquetjs/parquet-thrift/TimeType.d.ts +1 -1
  398. package/dist/parquetjs/parquet-thrift/TimeType.d.ts.map +1 -1
  399. package/dist/parquetjs/parquet-thrift/TimeType.js +1 -1
  400. package/dist/parquetjs/parquet-thrift/TimeType.js.map +1 -1
  401. package/dist/parquetjs/parquet-thrift/TimeUnit.d.ts +5 -1
  402. package/dist/parquetjs/parquet-thrift/TimeUnit.d.ts.map +1 -1
  403. package/dist/parquetjs/parquet-thrift/TimeUnit.js +25 -1
  404. package/dist/parquetjs/parquet-thrift/TimeUnit.js.map +1 -1
  405. package/dist/parquetjs/parquet-thrift/TimestampType.d.ts +1 -1
  406. package/dist/parquetjs/parquet-thrift/TimestampType.d.ts.map +1 -1
  407. package/dist/parquetjs/parquet-thrift/TimestampType.js +1 -1
  408. package/dist/parquetjs/parquet-thrift/TimestampType.js.map +1 -1
  409. package/dist/parquetjs/parquet-thrift/TypeDefinedOrder.d.ts +1 -1
  410. package/dist/parquetjs/parquet-thrift/TypeDefinedOrder.d.ts.map +1 -1
  411. package/dist/parquetjs/parquet-thrift/TypeDefinedOrder.js +1 -1
  412. package/dist/parquetjs/parquet-thrift/TypeDefinedOrder.js.map +1 -1
  413. package/dist/parquetjs/parquet-thrift/UUIDType.d.ts +1 -1
  414. package/dist/parquetjs/parquet-thrift/UUIDType.d.ts.map +1 -1
  415. package/dist/parquetjs/parquet-thrift/UUIDType.js +1 -1
  416. package/dist/parquetjs/parquet-thrift/UUIDType.js.map +1 -1
  417. package/dist/parquetjs/parquet-thrift/VariantType.d.ts +11 -0
  418. package/dist/parquetjs/parquet-thrift/VariantType.d.ts.map +1 -0
  419. package/dist/parquetjs/parquet-thrift/VariantType.js +41 -0
  420. package/dist/parquetjs/parquet-thrift/VariantType.js.map +1 -0
  421. package/dist/parquetjs/parquet-thrift/index.d.ts +6 -2
  422. package/dist/parquetjs/parquet-thrift/index.d.ts.map +1 -1
  423. package/dist/parquetjs/parquet-thrift/index.js +6 -2
  424. package/dist/parquetjs/parquet-thrift/index.js.map +1 -1
  425. package/dist/parquetjs/parser/decoders.d.ts +14 -3
  426. package/dist/parquetjs/parser/decoders.d.ts.map +1 -1
  427. package/dist/parquetjs/parser/decoders.js +381 -117
  428. package/dist/parquetjs/parser/decoders.js.map +1 -1
  429. package/dist/parquetjs/parser/parquet-reader.d.ts +35 -10
  430. package/dist/parquetjs/parser/parquet-reader.d.ts.map +1 -1
  431. package/dist/parquetjs/parser/parquet-reader.js +179 -59
  432. package/dist/parquetjs/parser/parquet-reader.js.map +1 -1
  433. package/dist/parquetjs/schema/declare.d.ts +62 -8
  434. package/dist/parquetjs/schema/declare.d.ts.map +1 -1
  435. package/dist/parquetjs/schema/declare.js.map +1 -1
  436. package/dist/parquetjs/schema/schema.d.ts +3 -0
  437. package/dist/parquetjs/schema/schema.d.ts.map +1 -1
  438. package/dist/parquetjs/schema/schema.js +21 -3
  439. package/dist/parquetjs/schema/schema.js.map +1 -1
  440. package/dist/parquetjs/schema/shred.d.ts +2 -0
  441. package/dist/parquetjs/schema/shred.d.ts.map +1 -1
  442. package/dist/parquetjs/schema/shred.js +71 -23
  443. package/dist/parquetjs/schema/shred.js.map +1 -1
  444. package/dist/parquetjs/schema/types.d.ts.map +1 -1
  445. package/dist/parquetjs/schema/types.js +272 -51
  446. package/dist/parquetjs/schema/types.js.map +1 -1
  447. package/dist/parquetjs/utils/binary-utils.d.ts +41 -0
  448. package/dist/parquetjs/utils/binary-utils.d.ts.map +1 -0
  449. package/dist/parquetjs/utils/binary-utils.js +106 -0
  450. package/dist/parquetjs/utils/binary-utils.js.map +1 -0
  451. package/dist/parquetjs/utils/file-utils.d.ts +1 -1
  452. package/dist/parquetjs/utils/file-utils.d.ts.map +1 -1
  453. package/dist/parquetjs/utils/file-utils.js +3 -3
  454. package/dist/parquetjs/utils/file-utils.js.map +1 -1
  455. package/dist/parquetjs/utils/read-utils.d.ts +14 -6
  456. package/dist/parquetjs/utils/read-utils.d.ts.map +1 -1
  457. package/dist/parquetjs/utils/read-utils.js +46 -39
  458. package/dist/parquetjs/utils/read-utils.js.map +1 -1
  459. package/dist/parquetjs/utils/thrift-runtime.d.ts +106 -0
  460. package/dist/parquetjs/utils/thrift-runtime.d.ts.map +1 -0
  461. package/dist/parquetjs/utils/thrift-runtime.js +50 -0
  462. package/dist/parquetjs/utils/thrift-runtime.js.map +1 -0
  463. package/dist/parquetjs/utils/uint8-array-compact-protocol-writer.d.ts +78 -0
  464. package/dist/parquetjs/utils/uint8-array-compact-protocol-writer.d.ts.map +1 -0
  465. package/dist/parquetjs/utils/uint8-array-compact-protocol-writer.js +213 -0
  466. package/dist/parquetjs/utils/uint8-array-compact-protocol-writer.js.map +1 -0
  467. package/dist/parquetjs/utils/uint8-array-compact-protocol.d.ts +80 -0
  468. package/dist/parquetjs/utils/uint8-array-compact-protocol.d.ts.map +1 -0
  469. package/dist/parquetjs/utils/uint8-array-compact-protocol.js +276 -0
  470. package/dist/parquetjs/utils/uint8-array-compact-protocol.js.map +1 -0
  471. package/dist/parquetjs/utils/uint8-array-transport.d.ts +25 -0
  472. package/dist/parquetjs/utils/uint8-array-transport.d.ts.map +1 -0
  473. package/dist/parquetjs/utils/uint8-array-transport.js +62 -0
  474. package/dist/parquetjs/utils/uint8-array-transport.js.map +1 -0
  475. package/dist/polyfills/process.d.ts +12 -0
  476. package/dist/polyfills/process.d.ts.map +1 -0
  477. package/dist/polyfills/process.js +17 -0
  478. package/dist/polyfills/process.js.map +1 -0
  479. package/dist/unbundled.d.ts +9 -0
  480. package/dist/unbundled.d.ts.map +1 -0
  481. package/dist/unbundled.js +10 -0
  482. package/dist/unbundled.js.map +1 -0
  483. package/dist/wasm.d.ts +3 -0
  484. package/dist/wasm.d.ts.map +1 -0
  485. package/dist/wasm.js +6 -0
  486. package/dist/wasm.js.map +1 -0
  487. package/dist/workers/parquet-source-worker.d.ts +2 -0
  488. package/dist/workers/parquet-source-worker.d.ts.map +1 -0
  489. package/dist/workers/parquet-source-worker.js +17 -0
  490. package/dist/workers/parquet-source-worker.js.map +1 -0
  491. package/dist/workers/parquet-worker-node.d.ts +2 -0
  492. package/dist/workers/parquet-worker-node.d.ts.map +1 -0
  493. package/dist/workers/parquet-worker-node.js +5 -0
  494. package/dist/workers/parquet-worker-node.js.map +1 -0
  495. package/dist/workers/parquet-worker.d.ts +2 -0
  496. package/dist/workers/parquet-worker.d.ts.map +1 -0
  497. package/dist/workers/parquet-worker.js +27 -0
  498. package/dist/workers/parquet-worker.js.map +1 -0
  499. package/package.json +63 -33
  500. package/src/bundled.ts +33 -0
  501. package/src/geoparquet-loader-with-parser.ts +95 -0
  502. package/src/geoparquet-loader.ts +54 -0
  503. package/src/index.ts +49 -23
  504. package/src/lib/arrow/convert-columns-to-row-group.ts +3 -0
  505. package/src/lib/arrow/convert-schema-from-parquet.ts +97 -30
  506. package/src/lib/arrow/convert-schema-to-parquet.ts +16 -7
  507. package/src/lib/arrow/create-nested-arrow-vector.ts +589 -0
  508. package/src/lib/constants.ts +0 -2
  509. package/src/lib/encoders/encode-arrow-to-parquet.ts +10 -16
  510. package/src/lib/encoders/encode-table-to-parquet-js.ts +261 -0
  511. package/src/lib/geo/geospatial-metadata.ts +457 -0
  512. package/src/lib/parquet-page-index.ts +581 -0
  513. package/src/lib/parquet-predicate.ts +374 -0
  514. package/src/lib/parquet-source-worker-client.ts +39 -0
  515. package/src/lib/parquet-source-worker-decoder.ts +156 -0
  516. package/src/lib/parquet-source-worker-file.ts +56 -0
  517. package/src/lib/parquet-source-worker-types.ts +107 -0
  518. package/src/lib/parquet-worker-transport.ts +57 -0
  519. package/src/lib/parsers/convert-parquet-tables.ts +39 -0
  520. package/src/lib/parsers/get-parquet-schema.ts +3 -1
  521. package/src/lib/parsers/parse-geoparquet-to-geojson.ts +27 -14
  522. package/src/lib/parsers/parse-parquet-tables.ts +82 -0
  523. package/src/lib/parsers/parse-parquet-to-arrow-js.ts +829 -0
  524. package/src/lib/parsers/parse-parquet-to-arrow.ts +63 -36
  525. package/src/lib/parsers/parse-parquet-to-columns.ts +6 -7
  526. package/src/lib/parsers/parse-parquet-to-json.ts +101 -33
  527. package/src/lib/sources/parquet-range-file.ts +359 -0
  528. package/src/lib/sources/single-batch-queue.ts +95 -0
  529. package/src/lib/utils/load-wasm-node.ts +25 -0
  530. package/src/lib/utils/load-wasm.ts +36 -13
  531. package/src/lib/utils/make-stream-iterator.ts +126 -14
  532. package/src/lib/utils/normalize-parquet-options.ts +14 -0
  533. package/src/parquet-dataset-source.ts +488 -0
  534. package/src/parquet-format.ts +2 -0
  535. package/src/parquet-js-loader-types.ts +52 -0
  536. package/src/parquet-js-loader.ts +83 -0
  537. package/src/parquet-js-writer.ts +68 -0
  538. package/src/parquet-loader-base.ts +34 -0
  539. package/src/parquet-loader-options.ts +51 -0
  540. package/src/parquet-loader-types.ts +35 -0
  541. package/src/parquet-loader.ts +115 -0
  542. package/src/parquet-source-capabilities.ts +56 -0
  543. package/src/parquet-source-loader-types.ts +87 -0
  544. package/src/parquet-source-loader.ts +1265 -0
  545. package/src/parquet-source-types.ts +458 -0
  546. package/src/parquet-source-worker-url.ts +23 -0
  547. package/src/parquet-worker-url.ts +18 -0
  548. package/src/parquet-writer.ts +42 -0
  549. package/src/parquetjs/LICENSE +23 -1
  550. package/src/parquetjs/codecs/byte-stream-split.ts +221 -0
  551. package/src/parquetjs/codecs/declare.ts +35 -3
  552. package/src/parquetjs/codecs/delta.ts +587 -0
  553. package/src/parquetjs/codecs/dictionary.ts +22 -4
  554. package/src/parquetjs/codecs/index.ts +18 -0
  555. package/src/parquetjs/codecs/plain.ts +149 -87
  556. package/src/parquetjs/codecs/rle.ts +268 -82
  557. package/src/parquetjs/compression.ts +110 -155
  558. package/src/parquetjs/encoder/dictionary-planner.ts +99 -0
  559. package/src/parquetjs/encoder/page-planner.ts +83 -0
  560. package/src/parquetjs/encoder/parquet-encoder.ts +378 -77
  561. package/src/parquetjs/parquet-thrift/BsonType.ts +1 -1
  562. package/src/parquetjs/parquet-thrift/ColumnChunk.ts +2 -2
  563. package/src/parquetjs/parquet-thrift/ColumnIndex.ts +13 -13
  564. package/src/parquetjs/parquet-thrift/ColumnMetaData.ts +2 -2
  565. package/src/parquetjs/parquet-thrift/ColumnOrder.ts +1 -1
  566. package/src/parquetjs/parquet-thrift/DataPageHeader.ts +1 -1
  567. package/src/parquetjs/parquet-thrift/DataPageHeaderV2.ts +1 -1
  568. package/src/parquetjs/parquet-thrift/DateType.ts +1 -1
  569. package/src/parquetjs/parquet-thrift/DecimalType.ts +1 -1
  570. package/src/parquetjs/parquet-thrift/DictionaryPageHeader.ts +1 -1
  571. package/src/parquetjs/parquet-thrift/EdgeInterpolationAlgorithm.ts +13 -0
  572. package/src/parquetjs/parquet-thrift/Encoding.ts +2 -1
  573. package/src/parquetjs/parquet-thrift/EnumType.ts +1 -1
  574. package/src/parquetjs/parquet-thrift/FileMetaData.ts +2 -2
  575. package/src/parquetjs/parquet-thrift/Float16Type.ts +28 -0
  576. package/src/parquetjs/parquet-thrift/GeographyType.ts +54 -0
  577. package/src/parquetjs/parquet-thrift/GeometryType.ts +43 -0
  578. package/src/parquetjs/parquet-thrift/IndexPageHeader.ts +1 -1
  579. package/src/parquetjs/parquet-thrift/IntType.ts +1 -1
  580. package/src/parquetjs/parquet-thrift/JsonType.ts +1 -1
  581. package/src/parquetjs/parquet-thrift/KeyValue.ts +1 -1
  582. package/src/parquetjs/parquet-thrift/ListType.ts +1 -1
  583. package/src/parquetjs/parquet-thrift/LogicalType.ts +97 -1
  584. package/src/parquetjs/parquet-thrift/MapType.ts +1 -1
  585. package/src/parquetjs/parquet-thrift/MicroSeconds.ts +1 -1
  586. package/src/parquetjs/parquet-thrift/MilliSeconds.ts +1 -1
  587. package/src/parquetjs/parquet-thrift/NanoSeconds.ts +28 -0
  588. package/src/parquetjs/parquet-thrift/NullType.ts +1 -1
  589. package/src/parquetjs/parquet-thrift/OffsetIndex.ts +1 -1
  590. package/src/parquetjs/parquet-thrift/PageEncodingStats.ts +1 -1
  591. package/src/parquetjs/parquet-thrift/PageHeader.ts +1 -1
  592. package/src/parquetjs/parquet-thrift/PageLocation.ts +2 -2
  593. package/src/parquetjs/parquet-thrift/RowGroup.ts +2 -2
  594. package/src/parquetjs/parquet-thrift/SchemaElement.ts +1 -1
  595. package/src/parquetjs/parquet-thrift/SortingColumn.ts +1 -1
  596. package/src/parquetjs/parquet-thrift/Statistics.ts +50 -14
  597. package/src/parquetjs/parquet-thrift/StringType.ts +1 -1
  598. package/src/parquetjs/parquet-thrift/TimeType.ts +1 -1
  599. package/src/parquetjs/parquet-thrift/TimeUnit.ts +25 -1
  600. package/src/parquetjs/parquet-thrift/TimestampType.ts +1 -1
  601. package/src/parquetjs/parquet-thrift/TypeDefinedOrder.ts +1 -1
  602. package/src/parquetjs/parquet-thrift/UUIDType.ts +1 -1
  603. package/src/parquetjs/parquet-thrift/VariantType.ts +43 -0
  604. package/src/parquetjs/parquet-thrift/index.ts +6 -4
  605. package/src/parquetjs/parser/decoders.ts +487 -133
  606. package/src/parquetjs/parser/parquet-reader.ts +297 -71
  607. package/src/parquetjs/schema/declare.ts +99 -7
  608. package/src/parquetjs/schema/schema.ts +23 -3
  609. package/src/parquetjs/schema/shred.ts +112 -35
  610. package/src/parquetjs/schema/types.ts +294 -61
  611. package/src/parquetjs/utils/binary-utils.ts +132 -0
  612. package/src/parquetjs/utils/file-utils.ts +4 -4
  613. package/src/parquetjs/utils/read-utils.ts +56 -55
  614. package/src/parquetjs/utils/thrift-runtime.ts +109 -0
  615. package/src/parquetjs/utils/uint8-array-compact-protocol-writer.ts +254 -0
  616. package/src/parquetjs/utils/uint8-array-compact-protocol.ts +322 -0
  617. package/src/parquetjs/utils/uint8-array-transport.ts +79 -0
  618. package/src/polyfills/process.ts +17 -0
  619. package/src/unbundled.ts +33 -0
  620. package/src/wasm.ts +6 -0
  621. package/src/workers/parquet-source-worker.ts +21 -0
  622. package/src/workers/parquet-worker-node.ts +5 -0
  623. package/src/workers/parquet-worker.ts +31 -0
  624. package/dist/parquet-arrow-loader.d.ts +0 -43
  625. package/dist/parquet-arrow-loader.d.ts.map +0 -1
  626. package/dist/parquet-arrow-loader.js +0 -49
  627. package/dist/parquet-arrow-loader.js.map +0 -1
  628. package/dist/parquet-arrow-writer.d.ts +0 -9
  629. package/dist/parquet-arrow-writer.d.ts.map +0 -1
  630. package/dist/parquet-arrow-writer.js +0 -23
  631. package/dist/parquet-arrow-writer.js.map +0 -1
  632. package/dist/parquet-json-loader.d.ts +0 -148
  633. package/dist/parquet-json-loader.d.ts.map +0 -1
  634. package/dist/parquet-json-loader.js +0 -106
  635. package/dist/parquet-json-loader.js.map +0 -1
  636. package/dist/parquet-json-writer.d.ts +0 -19
  637. package/dist/parquet-json-writer.d.ts.map +0 -1
  638. package/dist/parquet-json-writer.js +0 -20
  639. package/dist/parquet-json-writer.js.map +0 -1
  640. package/dist/polyfills/buffer/buffer-polyfill.browser.d.ts +0 -3
  641. package/dist/polyfills/buffer/buffer-polyfill.browser.d.ts.map +0 -1
  642. package/dist/polyfills/buffer/buffer-polyfill.browser.js +0 -12
  643. package/dist/polyfills/buffer/buffer-polyfill.browser.js.map +0 -1
  644. package/dist/polyfills/buffer/buffer-polyfill.node.d.ts +0 -3
  645. package/dist/polyfills/buffer/buffer-polyfill.node.d.ts.map +0 -1
  646. package/dist/polyfills/buffer/buffer-polyfill.node.js +0 -17
  647. package/dist/polyfills/buffer/buffer-polyfill.node.js.map +0 -1
  648. package/dist/polyfills/buffer/buffer.d.ts +0 -222
  649. package/dist/polyfills/buffer/buffer.d.ts.map +0 -1
  650. package/dist/polyfills/buffer/buffer.js +0 -1868
  651. package/dist/polyfills/buffer/buffer.js.map +0 -1
  652. package/dist/polyfills/buffer/index.d.ts +0 -4
  653. package/dist/polyfills/buffer/index.d.ts.map +0 -1
  654. package/dist/polyfills/buffer/index.js +0 -9
  655. package/dist/polyfills/buffer/index.js.map +0 -1
  656. package/dist/polyfills/buffer/install-buffer-polyfill.d.ts +0 -2
  657. package/dist/polyfills/buffer/install-buffer-polyfill.d.ts.map +0 -1
  658. package/dist/polyfills/buffer/install-buffer-polyfill.js +0 -10
  659. package/dist/polyfills/buffer/install-buffer-polyfill.js.map +0 -1
  660. package/dist/workers/parquet-json-worker.d.ts +0 -2
  661. package/dist/workers/parquet-json-worker.d.ts.map +0 -1
  662. package/dist/workers/parquet-json-worker.js +0 -7
  663. package/dist/workers/parquet-json-worker.js.map +0 -1
  664. package/src/parquet-arrow-loader.ts +0 -74
  665. package/src/parquet-arrow-writer.ts +0 -33
  666. package/src/parquet-json-loader.ts +0 -160
  667. package/src/parquet-json-writer.ts +0 -27
  668. package/src/parquetjs/modules.d.ts +0 -25
  669. package/src/polyfills/buffer/buffer-polyfill.browser.ts +0 -14
  670. package/src/polyfills/buffer/buffer-polyfill.node.ts +0 -19
  671. package/src/polyfills/buffer/buffer.ts +0 -2205
  672. package/src/polyfills/buffer/index.ts +0 -11
  673. package/src/polyfills/buffer/install-buffer-polyfill.ts +0 -12
  674. package/src/workers/parquet-json-worker.ts +0 -8
@@ -1,1868 +0,0 @@
1
- // loaders.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
- // This file is forked from https://github.com/feross/buffer under MIT license
5
- /* !
6
- * The buffer module from node.js, for the browser.
7
- * @author Feross Aboukhadijeh <https://feross.org>
8
- * @license MIT
9
- * https://github.com/feross/buffer/blob/master/AUTHORS.md
10
- */
11
- /**
12
- * The decision to include this polyfill in loaders.gl may seem controversial.
13
- *
14
- * It is based on the following reasoning:
15
- * - The Buffer API is used in the parquetjs library and likely other Node.js
16
- * libraries we will use in the future.
17
- * - While the goal is to convert code from Buffer to ArrayBuffer, the Thrift
18
- * code in Parquet may be autogenerated.
19
- * - Bundlers often require a polyfill to be included, this extra step is not
20
- * a great experience for loaders.gl users.
21
- * - The forked buffer polyfill module had old and generated some type errors.
22
- */
23
- /* eslint-disable */ // no-proto, max-statements, max-depth, complexity, no-continue, prefer-spread, no-constant-condition, consistent-return */
24
- // @ts-nocheck - this references don't work well in prototype assignment
25
- import base64 from 'base64-js';
26
- import ieee754 from 'ieee754';
27
- export const kMaxLength = 0x7fffffff;
28
- export const INSPECT_MAX_BYTES = 50;
29
- // const customInspectSymbol =
30
- // typeof Symbol === 'function' && typeof Symbol['for'] === 'function' // eslint-disable-line dot-notation
31
- // ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
32
- // : null;
33
- /**
34
- * The Buffer constructor returns instances of `Uint8Array` that have their
35
- * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
36
- * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
37
- * and the `Uint8Array` methods. Square bracket notation works as expected -- it
38
- * returns a single octet.
39
- *
40
- * The `Uint8Array` prototype remains unmodified.
41
- */
42
- export class Buffer extends Uint8Array {
43
- static poolSize = 8192; // not used by this implementation
44
- // length: number; inherited
45
- get parent() {
46
- if (!Buffer.isBuffer(this))
47
- return undefined;
48
- return this.buffer;
49
- }
50
- get offset() {
51
- if (!Buffer.isBuffer(this))
52
- return undefined;
53
- return this.byteOffset;
54
- }
55
- /** This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
56
- * to detect a Buffer instance. It's not possible to use `instanceof Buffer`
57
- * reliably in a browserify context because there could be multiple different
58
- * copies of the 'buffer' package in use. This method works even for Buffer
59
- * instances that were created from another copy of the `buffer` package.
60
- * @see: https://github.com/feross/buffer/issues/154
61
- */
62
- _isBuffer = true;
63
- constructor(arg, encodingOrOffset, length) {
64
- if (typeof arg !== 'number') {
65
- return Buffer.from(arg, encodingOrOffset, length);
66
- }
67
- // Basic case, just a length
68
- const size = arg;
69
- if (size > kMaxLength) {
70
- throw new RangeError(`The value "${size}" is invalid for option "size"`);
71
- }
72
- if (typeof encodingOrOffset === 'string') {
73
- throw new TypeError('The "string" argument must be of type string. Received type number');
74
- }
75
- super(size < 0 ? 0 : checked(size) | 0);
76
- return;
77
- }
78
- static from(value, encodingOrOffset, length) {
79
- if (typeof value === 'string') {
80
- return fromString(value, encodingOrOffset);
81
- }
82
- if (ArrayBuffer.isView(value)) {
83
- return fromArrayView(value);
84
- }
85
- if (value == null) {
86
- throw new TypeError(`${'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
87
- 'or Array-like Object. Received type '}${typeof value}`);
88
- }
89
- if (isInstance(value, ArrayBuffer) || (value && isInstance(value.buffer, ArrayBuffer))) {
90
- return fromArrayBuffer(value, encodingOrOffset, length);
91
- }
92
- if (typeof SharedArrayBuffer !== 'undefined' &&
93
- (isInstance(value, SharedArrayBuffer) ||
94
- (value && isInstance(value.buffer, SharedArrayBuffer)))) {
95
- return fromArrayBuffer(value, encodingOrOffset, length);
96
- }
97
- if (typeof value === 'number') {
98
- throw new TypeError('The "value" argument must not be of type number. Received type number');
99
- }
100
- const valueOf = value.valueOf && value.valueOf();
101
- if (valueOf != null && valueOf !== value) {
102
- return Buffer.from(valueOf, encodingOrOffset, length);
103
- }
104
- const b = fromObject(value);
105
- if (b)
106
- return b;
107
- if (typeof Symbol !== 'undefined' &&
108
- Symbol.toPrimitive != null &&
109
- typeof value[Symbol.toPrimitive] === 'function') {
110
- return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length);
111
- }
112
- throw new TypeError(`${'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
113
- 'or Array-like Object. Received type '}${typeof value}`);
114
- }
115
- /**
116
- * Returns true if {obj} is a Buffer
117
- *
118
- * @param obj object to test.
119
- */
120
- static isBuffer(b) {
121
- return b != null && b._isBuffer === true && b !== Buffer.prototype; // so Buffer.isBuffer(Buffer.prototype) will be false
122
- }
123
- /**
124
- * The same as buf1.compare(buf2).
125
- */
126
- static compare(a, b) {
127
- if (!Buffer.isBuffer(a) && isInstance(a, Uint8Array))
128
- a = Buffer.from(a, a.offset, a.byteLength);
129
- if (!Buffer.isBuffer(b) && isInstance(b, Uint8Array))
130
- b = Buffer.from(b, b.offset, b.byteLength);
131
- if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
132
- throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');
133
- }
134
- if (a === b)
135
- return 0;
136
- let x = a.length;
137
- let y = b.length;
138
- for (let i = 0, len = Math.min(x, y); i < len; ++i) {
139
- if (a[i] !== b[i]) {
140
- x = a[i];
141
- y = b[i];
142
- break;
143
- }
144
- }
145
- if (x < y)
146
- return -1;
147
- if (y < x)
148
- return 1;
149
- return 0;
150
- }
151
- /**
152
- * Returns true if {encoding} is a valid encoding argument.
153
- * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
154
- *
155
- * @param encoding string to test.
156
- */
157
- static isEncoding(encoding) {
158
- switch (String(encoding).toLowerCase()) {
159
- case 'hex':
160
- case 'utf8':
161
- case 'utf-8':
162
- case 'ascii':
163
- case 'latin1':
164
- case 'binary':
165
- case 'base64':
166
- case 'ucs2':
167
- case 'ucs-2':
168
- case 'utf16le':
169
- case 'utf-16le':
170
- return true;
171
- default:
172
- return false;
173
- }
174
- }
175
- /**
176
- * Returns a buffer which is the result of concatenating all the buffers in the list together.
177
- *
178
- * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
179
- * If the list has exactly one item, then the first item of the list is returned.
180
- * If the list has more than one item, then a new Buffer is created.
181
- *
182
- * @param list An array of Buffer objects to concatenate
183
- * @param totalLength Total length of the buffers when concatenated.
184
- * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
185
- */
186
- static concat(list, length) {
187
- if (!Array.isArray(list)) {
188
- throw new TypeError('"list" argument must be an Array of Buffers');
189
- }
190
- if (list.length === 0) {
191
- return Buffer.alloc(0);
192
- }
193
- let i;
194
- if (length === undefined) {
195
- length = 0;
196
- for (i = 0; i < list.length; ++i) {
197
- length += list[i].length;
198
- }
199
- }
200
- const buffer = Buffer.allocUnsafe(length);
201
- let pos = 0;
202
- for (i = 0; i < list.length; ++i) {
203
- let buf = list[i];
204
- if (isInstance(buf, Uint8Array)) {
205
- if (pos + buf.length > buffer.length) {
206
- if (!Buffer.isBuffer(buf)) {
207
- buf = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
208
- }
209
- buf.copy(buffer, pos);
210
- }
211
- else {
212
- Uint8Array.prototype.set.call(buffer, buf, pos);
213
- }
214
- }
215
- else if (!Buffer.isBuffer(buf)) {
216
- throw new TypeError('"list" argument must be an Array of Buffers');
217
- }
218
- else {
219
- buf.copy(buffer, pos);
220
- }
221
- pos += buf.length;
222
- }
223
- return buffer;
224
- }
225
- /**
226
- * Allocates a new buffer of {size} octets.
227
- *
228
- * @param size count of octets to allocate.
229
- * @param fill if specified, buffer will be initialized by calling buf.fill(fill).
230
- * If parameter is omitted, buffer will be filled with zeros.
231
- * @param encoding encoding used for call to buf.fill while initializing
232
- */
233
- static alloc(size, fill, encoding) {
234
- return alloc(size, fill, encoding);
235
- }
236
- /**
237
- * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
238
- * of the newly created Buffer are unknown and may contain sensitive data.
239
- *
240
- * @param size count of octets to allocate
241
- */
242
- static allocUnsafe(size) {
243
- assertSize(size);
244
- return new Buffer(size);
245
- }
246
- /**
247
- * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
248
- * of the newly created Buffer are unknown and may contain sensitive data.
249
- *
250
- * @param size count of octets to allocate
251
- */
252
- static allocUnsafeSlow(size) {
253
- return allocUnsafe(size);
254
- }
255
- includes(val, byteOffset, encoding) {
256
- return this.indexOf(val, byteOffset, encoding) !== -1;
257
- }
258
- indexOf(val, byteOffset, encoding) {
259
- return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
260
- }
261
- lastIndexOf(val, byteOffset, encoding) {
262
- return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
263
- }
264
- readInt8(offset, noAssert) {
265
- offset = offset >>> 0;
266
- if (!noAssert)
267
- checkOffset(offset, 1, this.length);
268
- if (!(this[offset] & 0x80))
269
- return this[offset];
270
- return (0xff - this[offset] + 1) * -1;
271
- }
272
- readInt16LE(offset, noAssert) {
273
- offset = offset >>> 0;
274
- if (!noAssert)
275
- checkOffset(offset, 2, this.length);
276
- const val = this[offset] | (this[offset + 1] << 8);
277
- return val & 0x8000 ? val | 0xffff0000 : val;
278
- }
279
- readInt16BE(offset, noAssert) {
280
- offset = offset >>> 0;
281
- if (!noAssert)
282
- checkOffset(offset, 2, this.length);
283
- const val = this[offset + 1] | (this[offset] << 8);
284
- return val & 0x8000 ? val | 0xffff0000 : val;
285
- }
286
- readInt32LE(offset, noAssert) {
287
- offset = offset >>> 0;
288
- if (!noAssert)
289
- checkOffset(offset, 4, this.length);
290
- return (this[offset] | (this[offset + 1] << 8) | (this[offset + 2] << 16) | (this[offset + 3] << 24));
291
- }
292
- readInt32BE(offset, noAssert) {
293
- offset = offset >>> 0;
294
- if (!noAssert)
295
- checkOffset(offset, 4, this.length);
296
- return ((this[offset] << 24) | (this[offset + 1] << 16) | (this[offset + 2] << 8) | this[offset + 3]);
297
- }
298
- readIntBE(offset, byteLength, noAssert) {
299
- offset = offset >>> 0;
300
- byteLength = byteLength >>> 0;
301
- if (!noAssert)
302
- checkOffset(offset, byteLength, this.length);
303
- let i = byteLength;
304
- let mul = 1;
305
- let val = this[offset + --i];
306
- while (i > 0 && (mul *= 0x100)) {
307
- val += this[offset + --i] * mul;
308
- }
309
- mul *= 0x80;
310
- if (val >= mul)
311
- val -= Math.pow(2, 8 * byteLength);
312
- return val;
313
- }
314
- readIntLE(offset, byteLength, noAssert) {
315
- offset = offset >>> 0;
316
- byteLength = byteLength >>> 0;
317
- if (!noAssert)
318
- checkOffset(offset, byteLength, this.length);
319
- let val = this[offset];
320
- let mul = 1;
321
- let i = 0;
322
- while (++i < byteLength && (mul *= 0x100)) {
323
- val += this[offset + i] * mul;
324
- }
325
- mul *= 0x80;
326
- if (val >= mul)
327
- val -= Math.pow(2, 8 * byteLength);
328
- return val;
329
- }
330
- readBigInt64LE(offset) {
331
- offset = offset >>> 0;
332
- validateNumber(offset, 'offset');
333
- const first = this[offset];
334
- const last = this[offset + 7];
335
- if (first === undefined || last === undefined) {
336
- boundsError(offset, this.length - 8);
337
- }
338
- const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24); // Overflow
339
- return ((BigInt(val) << BigInt(32)) +
340
- BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24));
341
- }
342
- readBigInt64BE(offset) {
343
- offset = offset >>> 0;
344
- validateNumber(offset, 'offset');
345
- const first = this[offset];
346
- const last = this[offset + 7];
347
- if (first === undefined || last === undefined) {
348
- boundsError(offset, this.length - 8);
349
- }
350
- const val = (first << 24) + // Overflow
351
- this[++offset] * 2 ** 16 +
352
- this[++offset] * 2 ** 8 +
353
- this[++offset];
354
- return ((BigInt(val) << BigInt(32)) +
355
- BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last));
356
- }
357
- readUInt8(offset, noAssert) {
358
- offset = offset >>> 0;
359
- if (!noAssert)
360
- checkOffset(offset, 1, this.length);
361
- return this[offset];
362
- }
363
- readUInt16LE(offset, noAssert) {
364
- offset = offset >>> 0;
365
- if (!noAssert)
366
- checkOffset(offset, 2, this.length);
367
- return this[offset] | (this[offset + 1] << 8);
368
- }
369
- readUInt16BE(offset, noAssert) {
370
- offset = offset >>> 0;
371
- if (!noAssert)
372
- checkOffset(offset, 2, this.length);
373
- return (this[offset] << 8) | this[offset + 1];
374
- }
375
- readUInt32LE(offset, noAssert) {
376
- offset = offset >>> 0;
377
- if (!noAssert)
378
- checkOffset(offset, 4, this.length);
379
- return ((this[offset] | (this[offset + 1] << 8) | (this[offset + 2] << 16)) +
380
- this[offset + 3] * 0x1000000);
381
- }
382
- readUInt32BE(offset, noAssert) {
383
- offset = offset >>> 0;
384
- if (!noAssert)
385
- checkOffset(offset, 4, this.length);
386
- return (this[offset] * 0x1000000 +
387
- ((this[offset + 1] << 16) | (this[offset + 2] << 8) | this[offset + 3]));
388
- }
389
- readUIntLE(offset, byteLength, noAssert) {
390
- offset = offset >>> 0;
391
- byteLength = byteLength >>> 0;
392
- if (!noAssert)
393
- checkOffset(offset, byteLength, this.length);
394
- let val = this[offset];
395
- let mul = 1;
396
- let i = 0;
397
- while (++i < byteLength && (mul *= 0x100)) {
398
- val += this[offset + i] * mul;
399
- }
400
- return val;
401
- }
402
- readUIntBE(offset, byteLength, noAssert) {
403
- offset = offset >>> 0;
404
- byteLength = byteLength >>> 0;
405
- if (!noAssert) {
406
- checkOffset(offset, byteLength, this.length);
407
- }
408
- let val = this[offset + --byteLength];
409
- let mul = 1;
410
- while (byteLength > 0 && (mul *= 0x100)) {
411
- val += this[offset + --byteLength] * mul;
412
- }
413
- return val;
414
- }
415
- readBigUInt64LE(offset) {
416
- offset = offset >>> 0;
417
- validateNumber(offset, 'offset');
418
- const first = this[offset];
419
- const last = this[offset + 7];
420
- if (first === undefined || last === undefined) {
421
- boundsError(offset, this.length - 8);
422
- }
423
- const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
424
- const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
425
- return BigInt(lo) + (BigInt(hi) << BigInt(32));
426
- }
427
- readBigUInt64BE(offset) {
428
- offset = offset >>> 0;
429
- validateNumber(offset, 'offset');
430
- const first = this[offset];
431
- const last = this[offset + 7];
432
- if (first === undefined || last === undefined) {
433
- boundsError(offset, this.length - 8);
434
- }
435
- const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
436
- const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
437
- return (BigInt(hi) << BigInt(32)) + BigInt(lo);
438
- }
439
- readFloatLE(offset, noAssert) {
440
- offset = offset >>> 0;
441
- if (!noAssert)
442
- checkOffset(offset, 4, this.length);
443
- return ieee754.read(this, offset, true, 23, 4);
444
- }
445
- readFloatBE(offset, noAssert) {
446
- offset = offset >>> 0;
447
- if (!noAssert)
448
- checkOffset(offset, 4, this.length);
449
- return ieee754.read(this, offset, false, 23, 4);
450
- }
451
- readDoubleLE(offset, noAssert) {
452
- offset = offset >>> 0;
453
- if (!noAssert)
454
- checkOffset(offset, 8, this.length);
455
- return ieee754.read(this, offset, true, 52, 8);
456
- }
457
- readDoubleBE(offset, noAssert) {
458
- offset = offset >>> 0;
459
- if (!noAssert)
460
- checkOffset(offset, 8, this.length);
461
- return ieee754.read(this, offset, false, 52, 8);
462
- }
463
- writeUInt8(value, offset, noAssert) {
464
- value = Number(value);
465
- offset = offset >>> 0;
466
- if (!noAssert)
467
- checkInt(this, value, offset, 1, 0xff, 0);
468
- this[offset] = value & 0xff;
469
- return offset + 1;
470
- }
471
- writeUInt16LE(value, offset, noAssert) {
472
- value = Number(value);
473
- offset = offset >>> 0;
474
- if (!noAssert)
475
- checkInt(this, value, offset, 2, 0xffff, 0);
476
- this[offset] = value & 0xff;
477
- this[offset + 1] = value >>> 8;
478
- return offset + 2;
479
- }
480
- writeUInt16BE(value, offset, noAssert) {
481
- value = Number(value);
482
- offset = offset >>> 0;
483
- if (!noAssert)
484
- checkInt(this, value, offset, 2, 0xffff, 0);
485
- this[offset] = value >>> 8;
486
- this[offset + 1] = value & 0xff;
487
- return offset + 2;
488
- }
489
- writeUInt32LE(value, offset, noAssert) {
490
- value = Number(value);
491
- offset = offset >>> 0;
492
- if (!noAssert)
493
- checkInt(this, value, offset, 4, 0xffffffff, 0);
494
- this[offset + 3] = value >>> 24;
495
- this[offset + 2] = value >>> 16;
496
- this[offset + 1] = value >>> 8;
497
- this[offset] = value & 0xff;
498
- return offset + 4;
499
- }
500
- writeUInt32BE(value, offset, noAssert) {
501
- value = Number(value);
502
- offset = offset >>> 0;
503
- if (!noAssert)
504
- checkInt(this, value, offset, 4, 0xffffffff, 0);
505
- this[offset] = value >>> 24;
506
- this[offset + 1] = value >>> 16;
507
- this[offset + 2] = value >>> 8;
508
- this[offset + 3] = value & 0xff;
509
- return offset + 4;
510
- }
511
- writeUIntLE(value, offset, byteLength, noAssert) {
512
- value = Number(value);
513
- offset = offset >>> 0;
514
- byteLength = byteLength >>> 0;
515
- if (!noAssert) {
516
- const maxBytes = Math.pow(2, 8 * byteLength) - 1;
517
- checkInt(this, value, offset, byteLength, maxBytes, 0);
518
- }
519
- let mul = 1;
520
- let i = 0;
521
- this[offset] = value & 0xff;
522
- while (++i < byteLength && (mul *= 0x100)) {
523
- this[offset + i] = (value / mul) & 0xff;
524
- }
525
- return offset + byteLength;
526
- }
527
- writeUIntBE(value, offset, byteLength, noAssert) {
528
- value = Number(value);
529
- offset = offset >>> 0;
530
- byteLength = byteLength >>> 0;
531
- if (!noAssert) {
532
- const maxBytes = Math.pow(2, 8 * byteLength) - 1;
533
- checkInt(this, value, offset, byteLength, maxBytes, 0);
534
- }
535
- let i = byteLength - 1;
536
- let mul = 1;
537
- this[offset + i] = value & 0xff;
538
- while (--i >= 0 && (mul *= 0x100)) {
539
- this[offset + i] = (value / mul) & 0xff;
540
- }
541
- return offset + byteLength;
542
- }
543
- writeBigUInt64LE(value, offset = 0) {
544
- return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'));
545
- }
546
- writeBigUInt64BE(value, offset = 0) {
547
- return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'));
548
- }
549
- writeIntLE(value, offset, byteLength, noAssert) {
550
- value = Number(value);
551
- offset = offset >>> 0;
552
- if (!noAssert) {
553
- const limit = Math.pow(2, 8 * byteLength - 1);
554
- checkInt(this, value, offset, byteLength, limit - 1, -limit);
555
- }
556
- let i = 0;
557
- let mul = 1;
558
- let sub = 0;
559
- this[offset] = value & 0xff;
560
- while (++i < byteLength && (mul *= 0x100)) {
561
- if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
562
- sub = 1;
563
- }
564
- this[offset + i] = (((value / mul) >> 0) - sub) & 0xff;
565
- }
566
- return offset + byteLength;
567
- }
568
- writeIntBE(value, offset, byteLength, noAssert) {
569
- value = Number(value);
570
- offset = offset >>> 0;
571
- if (!noAssert) {
572
- const limit = Math.pow(2, 8 * byteLength - 1);
573
- checkInt(this, value, offset, byteLength, limit - 1, -limit);
574
- }
575
- let i = byteLength - 1;
576
- let mul = 1;
577
- let sub = 0;
578
- this[offset + i] = value & 0xff;
579
- while (--i >= 0 && (mul *= 0x100)) {
580
- if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
581
- sub = 1;
582
- }
583
- this[offset + i] = (((value / mul) >> 0) - sub) & 0xff;
584
- }
585
- return offset + byteLength;
586
- }
587
- writeInt8(value, offset, noAssert) {
588
- value = Number(value);
589
- offset = offset >>> 0;
590
- if (!noAssert)
591
- checkInt(this, value, offset, 1, 0x7f, -0x80);
592
- if (value < 0)
593
- value = 0xff + value + 1;
594
- this[offset] = value & 0xff;
595
- return offset + 1;
596
- }
597
- writeInt16LE(value, offset, noAssert) {
598
- value = Number(value);
599
- offset = offset >>> 0;
600
- if (!noAssert)
601
- checkInt(this, value, offset, 2, 0x7fff, -0x8000);
602
- this[offset] = value & 0xff;
603
- this[offset + 1] = value >>> 8;
604
- return offset + 2;
605
- }
606
- writeInt16BE(value, offset, noAssert) {
607
- value = Number(value);
608
- offset = offset >>> 0;
609
- if (!noAssert)
610
- checkInt(this, value, offset, 2, 0x7fff, -0x8000);
611
- this[offset] = value >>> 8;
612
- this[offset + 1] = value & 0xff;
613
- return offset + 2;
614
- }
615
- writeInt32LE(value, offset, noAssert) {
616
- value = Number(value);
617
- offset = offset >>> 0;
618
- if (!noAssert)
619
- checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
620
- this[offset] = value & 0xff;
621
- this[offset + 1] = value >>> 8;
622
- this[offset + 2] = value >>> 16;
623
- this[offset + 3] = value >>> 24;
624
- return offset + 4;
625
- }
626
- writeInt32BE(value, offset, noAssert) {
627
- value = Number(value);
628
- offset = offset >>> 0;
629
- if (!noAssert)
630
- checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
631
- if (value < 0)
632
- value = 0xffffffff + value + 1;
633
- this[offset] = value >>> 24;
634
- this[offset + 1] = value >>> 16;
635
- this[offset + 2] = value >>> 8;
636
- this[offset + 3] = value & 0xff;
637
- return offset + 4;
638
- }
639
- writeBigInt64LE(value, offset = 0) {
640
- return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'));
641
- }
642
- writeBigInt64BE(value, offset = 0) {
643
- return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'));
644
- }
645
- writeFloatLE(value, offset, noAssert) {
646
- return writeFloat(this, value, offset, true, noAssert);
647
- }
648
- writeFloatBE(value, offset, noAssert) {
649
- return writeFloat(this, value, offset, false, noAssert);
650
- }
651
- writeDoubleLE(value, offset, noAssert) {
652
- return writeDouble(this, value, offset, true, noAssert);
653
- }
654
- writeDoubleBE(value, offset, noAssert) {
655
- return writeDouble(this, value, offset, false, noAssert);
656
- }
657
- write(string, offset, length, encoding) {
658
- // Buffer#write(string)
659
- if (offset === undefined) {
660
- encoding = 'utf8';
661
- length = this.length;
662
- offset = 0;
663
- // Buffer#write(string, encoding)
664
- }
665
- else if (length === undefined && typeof offset === 'string') {
666
- encoding = offset;
667
- length = this.length;
668
- offset = 0;
669
- // Buffer#write(string, offset[, length][, encoding])
670
- }
671
- else if (isFinite(offset)) {
672
- offset = offset >>> 0;
673
- if (isFinite(length)) {
674
- length = length >>> 0;
675
- if (encoding === undefined)
676
- encoding = 'utf8';
677
- }
678
- else {
679
- encoding = length;
680
- length = undefined;
681
- }
682
- }
683
- else {
684
- throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');
685
- }
686
- const remaining = this.length - offset;
687
- if (length === undefined || length > remaining)
688
- length = remaining;
689
- if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
690
- throw new RangeError('Attempt to write outside buffer bounds');
691
- }
692
- if (!encoding)
693
- encoding = 'utf8';
694
- let loweredCase = false;
695
- for (;;) {
696
- switch (encoding) {
697
- case 'hex':
698
- return hexWrite(this, string, offset, length);
699
- case 'utf8':
700
- case 'utf-8':
701
- return utf8Write(this, string, offset, length);
702
- case 'ascii':
703
- case 'latin1':
704
- case 'binary':
705
- return asciiWrite(this, string, offset, length);
706
- case 'base64':
707
- // Warning: maxLength not taken into account in base64Write
708
- return base64Write(this, string, offset, length);
709
- case 'ucs2':
710
- case 'ucs-2':
711
- case 'utf16le':
712
- case 'utf-16le':
713
- return ucs2Write(this, string, offset, length);
714
- default:
715
- if (loweredCase)
716
- throw new TypeError(`Unknown encoding: ${encoding}`);
717
- encoding = `${encoding}`.toLowerCase();
718
- loweredCase = true;
719
- }
720
- }
721
- }
722
- // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
723
- copy(target, targetStart, start, end) {
724
- if (!Buffer.isBuffer(target))
725
- throw new TypeError('argument should be a Buffer');
726
- if (!start)
727
- start = 0;
728
- if (!end && end !== 0)
729
- end = this.length;
730
- if (targetStart >= target.length)
731
- targetStart = target.length;
732
- if (!targetStart)
733
- targetStart = 0;
734
- if (end > 0 && end < start)
735
- end = start;
736
- // Copy 0 bytes; we're done
737
- if (end === start)
738
- return 0;
739
- if (target.length === 0 || this.length === 0)
740
- return 0;
741
- // Fatal error conditions
742
- if (targetStart < 0) {
743
- throw new RangeError('targetStart out of bounds');
744
- }
745
- if (start < 0 || start >= this.length)
746
- throw new RangeError('Index out of range');
747
- if (end < 0)
748
- throw new RangeError('sourceEnd out of bounds');
749
- // Are we oob?
750
- if (end > this.length)
751
- end = this.length;
752
- if (target.length - targetStart < end - start) {
753
- end = target.length - targetStart + start;
754
- }
755
- const len = end - start;
756
- if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
757
- // Use built-in when available, missing from IE11
758
- this.copyWithin(targetStart, start, end);
759
- }
760
- else {
761
- Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart);
762
- }
763
- return len;
764
- }
765
- // Usage:
766
- // buffer.fill(number[, offset[, end]])
767
- // buffer.fill(buffer[, offset[, end]])
768
- // buffer.fill(string[, offset[, end]][, encoding])
769
- fill(val, start, end, encoding) {
770
- // Handle string cases:
771
- if (typeof val === 'string') {
772
- if (typeof start === 'string') {
773
- encoding = start;
774
- start = 0;
775
- end = this.length;
776
- }
777
- else if (typeof end === 'string') {
778
- encoding = end;
779
- end = this.length;
780
- }
781
- if (encoding !== undefined && typeof encoding !== 'string') {
782
- throw new TypeError('encoding must be a string');
783
- }
784
- if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
785
- throw new TypeError(`Unknown encoding: ${encoding}`);
786
- }
787
- if (val.length === 1) {
788
- const code = val.charCodeAt(0);
789
- if ((encoding === 'utf8' && code < 128) || encoding === 'latin1') {
790
- // Fast path: If `val` fits into a single byte, use that numeric value.
791
- val = code;
792
- }
793
- }
794
- }
795
- else if (typeof val === 'number') {
796
- val = val & 255;
797
- }
798
- else if (typeof val === 'boolean') {
799
- val = Number(val);
800
- }
801
- // Invalid ranges are not set to a default, so can range check early.
802
- if (start < 0 || this.length < start || this.length < end) {
803
- throw new RangeError('Out of range index');
804
- }
805
- if (end <= start) {
806
- return this;
807
- }
808
- start = start >>> 0;
809
- end = end === undefined ? this.length : end >>> 0;
810
- if (!val)
811
- val = 0;
812
- let i;
813
- if (typeof val === 'number') {
814
- for (i = start; i < end; ++i) {
815
- this[i] = val;
816
- }
817
- }
818
- else {
819
- const bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding);
820
- const len = bytes.length;
821
- if (len === 0) {
822
- throw new TypeError(`The value "${val}" is invalid for argument "value"`);
823
- }
824
- for (i = 0; i < end - start; ++i) {
825
- this[i + start] = bytes[i % len];
826
- }
827
- }
828
- return this;
829
- }
830
- swap16() {
831
- const len = this.length;
832
- if (len % 2 !== 0) {
833
- throw new RangeError('Buffer size must be a multiple of 16-bits');
834
- }
835
- for (let i = 0; i < len; i += 2) {
836
- swap(this, i, i + 1);
837
- }
838
- return this;
839
- }
840
- swap32() {
841
- const len = this.length;
842
- if (len % 4 !== 0) {
843
- throw new RangeError('Buffer size must be a multiple of 32-bits');
844
- }
845
- for (let i = 0; i < len; i += 4) {
846
- swap(this, i, i + 3);
847
- swap(this, i + 1, i + 2);
848
- }
849
- return this;
850
- }
851
- swap64() {
852
- const len = this.length;
853
- if (len % 8 !== 0) {
854
- throw new RangeError('Buffer size must be a multiple of 64-bits');
855
- }
856
- for (let i = 0; i < len; i += 8) {
857
- swap(this, i, i + 7);
858
- swap(this, i + 1, i + 6);
859
- swap(this, i + 2, i + 5);
860
- swap(this, i + 3, i + 4);
861
- }
862
- return this;
863
- }
864
- toString(encoding, start, end) {
865
- const length = this.length;
866
- if (length === 0)
867
- return '';
868
- if (arguments.length === 0)
869
- return utf8Slice(this, 0, length);
870
- return this._slowToString(...arguments);
871
- }
872
- // toLocaleString(b) {
873
- // if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer');
874
- // if (this === b) return true;
875
- // return Buffer.compare(this, b) === 0;
876
- // }
877
- inspect() {
878
- let str = '';
879
- const max = INSPECT_MAX_BYTES;
880
- str = this.toString('hex', 0, max)
881
- .replace(/(.{2})/g, '$1 ')
882
- .trim();
883
- if (this.length > max)
884
- str += ' ... ';
885
- return `<Buffer ${str}>`;
886
- }
887
- // if (customInspectSymbol) {
888
- // Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
889
- // }
890
- // }
891
- equals(b) {
892
- if (!Buffer.isBuffer(b))
893
- throw new TypeError('Argument must be a Buffer');
894
- if (this === b)
895
- return true;
896
- return Buffer.compare(this, b) === 0;
897
- }
898
- compare(target, start, end, thisStart, thisEnd) {
899
- if (!Buffer.isBuffer(target) && isInstance(target, Uint8Array)) {
900
- target = Buffer.from(target, target.offset, target.byteLength);
901
- }
902
- if (!Buffer.isBuffer(target)) {
903
- throw new TypeError(`${'The "target" argument must be one of type Buffer or Uint8Array. ' + 'Received type '}${typeof target}`);
904
- }
905
- if (start === undefined) {
906
- start = 0;
907
- }
908
- if (end === undefined) {
909
- end = target ? target.length : 0;
910
- }
911
- if (thisStart === undefined) {
912
- thisStart = 0;
913
- }
914
- if (thisEnd === undefined) {
915
- thisEnd = this.length;
916
- }
917
- if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
918
- throw new RangeError('out of range index');
919
- }
920
- if (thisStart >= thisEnd && start >= end) {
921
- return 0;
922
- }
923
- if (thisStart >= thisEnd) {
924
- return -1;
925
- }
926
- if (start >= end) {
927
- return 1;
928
- }
929
- start >>>= 0;
930
- end >>>= 0;
931
- thisStart >>>= 0;
932
- thisEnd >>>= 0;
933
- if (this === target)
934
- return 0;
935
- let x = thisEnd - thisStart;
936
- let y = end - start;
937
- const len = Math.min(x, y);
938
- const thisCopy = this.slice(thisStart, thisEnd);
939
- const targetCopy = target.slice(start, end);
940
- for (let i = 0; i < len; ++i) {
941
- if (thisCopy[i] !== targetCopy[i]) {
942
- x = thisCopy[i];
943
- y = targetCopy[i];
944
- break;
945
- }
946
- }
947
- if (x < y)
948
- return -1;
949
- if (y < x)
950
- return 1;
951
- return 0;
952
- }
953
- toJSON() {
954
- return {
955
- type: 'Buffer',
956
- data: Array.prototype.slice.call(this._arr || this, 0)
957
- };
958
- }
959
- slice(start, end) {
960
- const len = this.length;
961
- start = ~~start;
962
- end = end === undefined ? len : ~~end;
963
- if (start < 0) {
964
- start += len;
965
- if (start < 0)
966
- start = 0;
967
- }
968
- else if (start > len) {
969
- start = len;
970
- }
971
- if (end < 0) {
972
- end += len;
973
- if (end < 0)
974
- end = 0;
975
- }
976
- else if (end > len) {
977
- end = len;
978
- }
979
- if (end < start)
980
- end = start;
981
- const newBuf = this.subarray(start, end);
982
- // Return an augmented `Uint8Array` instance
983
- Object.setPrototypeOf(newBuf, Buffer.prototype);
984
- return newBuf;
985
- }
986
- // Typo support?
987
- // readUint8(offset: number, noAssert?: boolean): number {
988
- // return this.readUInt8(...arguments);
989
- // }
990
- // readUint16LE(offset: number, noAssert?: boolean): number {
991
- // return this.readUInt16LE(...arguments);
992
- // }
993
- // readUint16BE(offset: number, noAssert?: boolean): number {
994
- // return this.readUInt16BE(...arguments);
995
- // }
996
- // readUint32LE(offset: number, noAssert?: boolean): number {
997
- // return this.readUInt32LE(...arguments);
998
- // }
999
- // readUint32BE(offset: number, noAssert?: boolean): number {
1000
- // return this.readUInt32BE(...arguments);
1001
- // }
1002
- // writeUint8() {
1003
- // return this.writeUInt8(...arguments);
1004
- // }
1005
- // writeUint16LE
1006
- // writeUint16LE
1007
- // writeUint32LE = Buffer.prototype.
1008
- // Buffer.prototype.writeUint32BE
1009
- _slowToString(encoding, start, end) {
1010
- let loweredCase = false;
1011
- // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
1012
- // property of a typed array.
1013
- // This behaves neither like String nor Uint8Array in that we set start/end
1014
- // to their upper/lower bounds if the value passed is out of range.
1015
- // undefined is handled specially as per ECMA-262 6th Edition,
1016
- // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
1017
- if (start === undefined || start < 0) {
1018
- start = 0;
1019
- }
1020
- // Return early if start > this.length. Done here to prevent potential uint32
1021
- // coercion fail below.
1022
- if (start > this.length) {
1023
- return '';
1024
- }
1025
- if (end === undefined || end > this.length) {
1026
- end = this.length;
1027
- }
1028
- if (end <= 0) {
1029
- return '';
1030
- }
1031
- // Force coercion to uint32. This will also coerce falsey/NaN values to 0.
1032
- end >>>= 0;
1033
- start >>>= 0;
1034
- if (end <= start) {
1035
- return '';
1036
- }
1037
- if (!encoding)
1038
- encoding = 'utf8';
1039
- while (true) {
1040
- switch (encoding) {
1041
- case 'hex':
1042
- return hexSlice(this, start, end);
1043
- case 'utf8':
1044
- case 'utf-8':
1045
- return utf8Slice(this, start, end);
1046
- case 'ascii':
1047
- return asciiSlice(this, start, end);
1048
- case 'latin1':
1049
- case 'binary':
1050
- return latin1Slice(this, start, end);
1051
- case 'base64':
1052
- return base64Slice(this, start, end);
1053
- case 'ucs2':
1054
- case 'ucs-2':
1055
- case 'utf16le':
1056
- case 'utf-16le':
1057
- return utf16leSlice(this, start, end);
1058
- default:
1059
- if (loweredCase)
1060
- throw new TypeError(`Unknown encoding: ${encoding}`);
1061
- encoding = `${encoding}`.toLowerCase();
1062
- loweredCase = true;
1063
- }
1064
- }
1065
- }
1066
- }
1067
- function checkInt(buf, value, offset, ext, max, min) {
1068
- if (!Buffer.isBuffer(buf))
1069
- throw new TypeError('"buffer" argument must be a Buffer instance');
1070
- if (value > max || value < min)
1071
- throw new RangeError('"value" argument is out of bounds');
1072
- if (offset + ext > buf.length)
1073
- throw new RangeError('Index out of range');
1074
- }
1075
- function wrtBigUInt64LE(buf, value, offset, min, max) {
1076
- checkIntBI(value, min, max, buf, offset, 7);
1077
- let lo = Number(value & BigInt(0xffffffff));
1078
- buf[offset++] = lo;
1079
- lo = lo >> 8;
1080
- buf[offset++] = lo;
1081
- lo = lo >> 8;
1082
- buf[offset++] = lo;
1083
- lo = lo >> 8;
1084
- buf[offset++] = lo;
1085
- let hi = Number((value >> BigInt(32)) & BigInt(0xffffffff));
1086
- buf[offset++] = hi;
1087
- hi = hi >> 8;
1088
- buf[offset++] = hi;
1089
- hi = hi >> 8;
1090
- buf[offset++] = hi;
1091
- hi = hi >> 8;
1092
- buf[offset++] = hi;
1093
- return offset;
1094
- }
1095
- function wrtBigUInt64BE(buf, value, offset, min, max) {
1096
- checkIntBI(value, min, max, buf, offset, 7);
1097
- let lo = Number(value & BigInt(0xffffffff));
1098
- buf[offset + 7] = lo;
1099
- lo = lo >> 8;
1100
- buf[offset + 6] = lo;
1101
- lo = lo >> 8;
1102
- buf[offset + 5] = lo;
1103
- lo = lo >> 8;
1104
- buf[offset + 4] = lo;
1105
- let hi = Number((value >> BigInt(32)) & BigInt(0xffffffff));
1106
- buf[offset + 3] = hi;
1107
- hi = hi >> 8;
1108
- buf[offset + 2] = hi;
1109
- hi = hi >> 8;
1110
- buf[offset + 1] = hi;
1111
- hi = hi >> 8;
1112
- buf[offset] = hi;
1113
- return offset + 8;
1114
- }
1115
- // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
1116
- // https://github.com/feross/buffer/pull/148
1117
- // Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
1118
- // Object.setPrototypeOf(Buffer, Uint8Array);
1119
- function assertSize(size) {
1120
- if (typeof size !== 'number') {
1121
- throw new TypeError('"size" argument must be of type number');
1122
- }
1123
- else if (size < 0) {
1124
- throw new RangeError(`The value "${size}" is invalid for option "size"`);
1125
- }
1126
- }
1127
- function alloc(size, fill, encoding) {
1128
- assertSize(size);
1129
- if (size <= 0) {
1130
- return new Buffer(size);
1131
- }
1132
- if (fill !== undefined) {
1133
- // Only pay attention to encoding if it's a string. This
1134
- // prevents accidentally sending in a number that would
1135
- // be interpreted as a start offset.
1136
- return typeof encoding === 'string'
1137
- ? new Buffer(size).fill(fill, encoding)
1138
- : new Buffer(size).fill(fill);
1139
- }
1140
- return new Buffer(size);
1141
- }
1142
- function fromString(string, encoding) {
1143
- if (typeof encoding !== 'string' || encoding === '') {
1144
- encoding = 'utf8';
1145
- }
1146
- if (!Buffer.isEncoding(encoding)) {
1147
- throw new TypeError(`Unknown encoding: ${encoding}`);
1148
- }
1149
- const length = byteLength(string, encoding) | 0;
1150
- let buf = new Buffer(length);
1151
- const actual = buf.write(string, encoding);
1152
- if (actual !== length) {
1153
- // Writing a hex string, for example, that contains invalid characters will
1154
- // cause everything after the first invalid character to be ignored. (e.g.
1155
- // 'abxxcd' will be treated as 'ab')
1156
- buf = buf.slice(0, actual);
1157
- }
1158
- return buf;
1159
- }
1160
- function fromArrayLike(array) {
1161
- const length = array.length < 0 ? 0 : checked(array.length) | 0;
1162
- const buf = new Buffer(length);
1163
- for (let i = 0; i < length; i += 1) {
1164
- buf[i] = array[i] & 255;
1165
- }
1166
- return buf;
1167
- }
1168
- function fromArrayView(arrayView) {
1169
- if (isInstance(arrayView, Uint8Array)) {
1170
- const copy = new Uint8Array(arrayView);
1171
- return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
1172
- }
1173
- return fromArrayLike(arrayView);
1174
- }
1175
- function fromArrayBuffer(array, byteOffset, length) {
1176
- if (byteOffset < 0 || array.byteLength < byteOffset) {
1177
- throw new RangeError('"offset" is outside of buffer bounds');
1178
- }
1179
- if (array.byteLength < byteOffset + (length || 0)) {
1180
- throw new RangeError('"length" is outside of buffer bounds');
1181
- }
1182
- let buf;
1183
- if (byteOffset === undefined && length === undefined) {
1184
- buf = new Uint8Array(array);
1185
- }
1186
- else if (length === undefined) {
1187
- buf = new Uint8Array(array, byteOffset);
1188
- }
1189
- else {
1190
- buf = new Uint8Array(array, byteOffset, length);
1191
- }
1192
- // Return an augmented `Uint8Array` instance
1193
- Object.setPrototypeOf(buf, Buffer.prototype);
1194
- return buf;
1195
- }
1196
- function fromObject(obj) {
1197
- if (Buffer.isBuffer(obj)) {
1198
- const len = checked(obj.length) | 0;
1199
- const buf = new Buffer(len);
1200
- if (buf.length === 0) {
1201
- return buf;
1202
- }
1203
- obj.copy(buf, 0, 0, len);
1204
- return buf;
1205
- }
1206
- if (obj.length !== undefined) {
1207
- if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
1208
- return new Buffer(0);
1209
- }
1210
- return fromArrayLike(obj);
1211
- }
1212
- if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
1213
- return fromArrayLike(obj.data);
1214
- }
1215
- }
1216
- function checked(length) {
1217
- // Note: cannot use `length < kMaxLength` here because that fails when
1218
- // length is NaN (which is otherwise coerced to zero.)
1219
- if (length >= kMaxLength) {
1220
- throw new RangeError(`${'Attempt to allocate Buffer larger than maximum ' + 'size: 0x'}${kMaxLength.toString(16)} bytes`);
1221
- }
1222
- return length | 0;
1223
- }
1224
- function byteLength(string, encoding) {
1225
- if (Buffer.isBuffer(string)) {
1226
- return string.length;
1227
- }
1228
- if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
1229
- return string.byteLength;
1230
- }
1231
- if (typeof string !== 'string') {
1232
- throw new TypeError(`${'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
1233
- 'Received type '}${typeof string}`);
1234
- }
1235
- const len = string.length;
1236
- const mustMatch = arguments.length > 2 && arguments[2] === true;
1237
- if (!mustMatch && len === 0)
1238
- return 0;
1239
- // Use a for loop to avoid recursion
1240
- let loweredCase = false;
1241
- for (;;) {
1242
- switch (encoding) {
1243
- case 'ascii':
1244
- case 'latin1':
1245
- case 'binary':
1246
- return len;
1247
- case 'utf8':
1248
- case 'utf-8':
1249
- return utf8ToBytes(string).length;
1250
- case 'ucs2':
1251
- case 'ucs-2':
1252
- case 'utf16le':
1253
- case 'utf-16le':
1254
- return len * 2;
1255
- case 'hex':
1256
- return len >>> 1;
1257
- case 'base64':
1258
- return base64ToBytes(string).length;
1259
- default:
1260
- if (loweredCase) {
1261
- return mustMatch ? -1 : utf8ToBytes(string).length; // assume utf8
1262
- }
1263
- encoding = `${encoding}`.toLowerCase();
1264
- loweredCase = true;
1265
- }
1266
- }
1267
- }
1268
- // Buffer.byteLength = byteLength;
1269
- function swap(b, n, m) {
1270
- const i = b[n];
1271
- b[n] = b[m];
1272
- b[m] = i;
1273
- }
1274
- // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
1275
- // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
1276
- //
1277
- // Arguments:
1278
- // - buffer - a Buffer to search
1279
- // - val - a string, Buffer, or number
1280
- // - byteOffset - an index into `buffer`; will be clamped to an int32
1281
- // - encoding - an optional encoding, relevant is val is a string
1282
- // - dir - true for indexOf, false for lastIndexOf
1283
- function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
1284
- // Empty buffer means no match
1285
- if (buffer.length === 0)
1286
- return -1;
1287
- // Normalize byteOffset
1288
- if (typeof byteOffset === 'string') {
1289
- encoding = byteOffset;
1290
- byteOffset = 0;
1291
- }
1292
- else if (byteOffset > 0x7fffffff) {
1293
- byteOffset = 0x7fffffff;
1294
- }
1295
- else if (byteOffset < -0x80000000) {
1296
- byteOffset = -0x80000000;
1297
- }
1298
- byteOffset = Number(byteOffset); // Coerce to Number.
1299
- if (numberIsNaN(byteOffset)) {
1300
- // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
1301
- byteOffset = dir ? 0 : buffer.length - 1;
1302
- }
1303
- // Normalize byteOffset: negative offsets start from the end of the buffer
1304
- if (byteOffset < 0)
1305
- byteOffset = buffer.length + byteOffset;
1306
- if (byteOffset >= buffer.length) {
1307
- if (dir)
1308
- return -1;
1309
- byteOffset = buffer.length - 1;
1310
- }
1311
- else if (byteOffset < 0) {
1312
- if (dir)
1313
- byteOffset = 0;
1314
- else
1315
- return -1;
1316
- }
1317
- // Normalize val
1318
- if (typeof val === 'string') {
1319
- val = Buffer.from(val, encoding);
1320
- }
1321
- // Finally, search either indexOf (if dir is true) or lastIndexOf
1322
- if (Buffer.isBuffer(val)) {
1323
- // Special case: looking for empty string/buffer always fails
1324
- if (val.length === 0) {
1325
- return -1;
1326
- }
1327
- return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
1328
- }
1329
- else if (typeof val === 'number') {
1330
- val = val & 0xff; // Search for a byte value [0-255]
1331
- if (typeof Uint8Array.prototype.indexOf === 'function') {
1332
- if (dir) {
1333
- return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
1334
- }
1335
- return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
1336
- }
1337
- return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
1338
- }
1339
- throw new TypeError('val must be string, number or Buffer');
1340
- }
1341
- function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
1342
- let indexSize = 1;
1343
- let arrLength = arr.length;
1344
- let valLength = val.length;
1345
- if (encoding !== undefined) {
1346
- encoding = String(encoding).toLowerCase();
1347
- if (encoding === 'ucs2' ||
1348
- encoding === 'ucs-2' ||
1349
- encoding === 'utf16le' ||
1350
- encoding === 'utf-16le') {
1351
- if (arr.length < 2 || val.length < 2) {
1352
- return -1;
1353
- }
1354
- indexSize = 2;
1355
- arrLength /= 2;
1356
- valLength /= 2;
1357
- byteOffset /= 2;
1358
- }
1359
- }
1360
- function read(buf, i) {
1361
- if (indexSize === 1) {
1362
- return buf[i];
1363
- }
1364
- return buf.readUInt16BE(i * indexSize);
1365
- }
1366
- let i;
1367
- if (dir) {
1368
- let foundIndex = -1;
1369
- for (i = byteOffset; i < arrLength; i++) {
1370
- if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
1371
- if (foundIndex === -1)
1372
- foundIndex = i;
1373
- if (i - foundIndex + 1 === valLength)
1374
- return foundIndex * indexSize;
1375
- }
1376
- else {
1377
- if (foundIndex !== -1)
1378
- i -= i - foundIndex;
1379
- foundIndex = -1;
1380
- }
1381
- }
1382
- }
1383
- else {
1384
- if (byteOffset + valLength > arrLength)
1385
- byteOffset = arrLength - valLength;
1386
- for (i = byteOffset; i >= 0; i--) {
1387
- let found = true;
1388
- for (let j = 0; j < valLength; j++) {
1389
- if (read(arr, i + j) !== read(val, j)) {
1390
- found = false;
1391
- break;
1392
- }
1393
- }
1394
- if (found)
1395
- return i;
1396
- }
1397
- }
1398
- return -1;
1399
- }
1400
- function hexWrite(buf, string, offset, length) {
1401
- offset = Number(offset) || 0;
1402
- const remaining = buf.length - offset;
1403
- if (!length) {
1404
- length = remaining;
1405
- }
1406
- else {
1407
- length = Number(length);
1408
- if (length > remaining) {
1409
- length = remaining;
1410
- }
1411
- }
1412
- const strLen = string.length;
1413
- if (length > strLen / 2) {
1414
- length = strLen / 2;
1415
- }
1416
- let i;
1417
- for (i = 0; i < length; ++i) {
1418
- const parsed = parseInt(string.substr(i * 2, 2), 16);
1419
- if (numberIsNaN(parsed))
1420
- return i;
1421
- buf[offset + i] = parsed;
1422
- }
1423
- return i;
1424
- }
1425
- function utf8Write(buf, string, offset, length) {
1426
- return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
1427
- }
1428
- function asciiWrite(buf, string, offset, length) {
1429
- return blitBuffer(asciiToBytes(string), buf, offset, length);
1430
- }
1431
- function base64Write(buf, string, offset, length) {
1432
- return blitBuffer(base64ToBytes(string), buf, offset, length);
1433
- }
1434
- function ucs2Write(buf, string, offset, length) {
1435
- return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
1436
- }
1437
- function base64Slice(buf, start, end) {
1438
- if (start === 0 && end === buf.length) {
1439
- return base64.fromByteArray(buf);
1440
- }
1441
- return base64.fromByteArray(buf.slice(start, end));
1442
- }
1443
- function utf8Slice(buf, start, end) {
1444
- end = Math.min(buf.length, end);
1445
- const res = [];
1446
- let i = start;
1447
- while (i < end) {
1448
- const firstByte = buf[i];
1449
- let codePoint = null;
1450
- let bytesPerSequence = firstByte > 0xef ? 4 : firstByte > 0xdf ? 3 : firstByte > 0xbf ? 2 : 1;
1451
- if (i + bytesPerSequence <= end) {
1452
- let fourthByte;
1453
- let secondByte;
1454
- let tempCodePoint;
1455
- let thirdByte;
1456
- switch (bytesPerSequence) {
1457
- case 1:
1458
- if (firstByte < 0x80) {
1459
- codePoint = firstByte;
1460
- }
1461
- break;
1462
- case 2:
1463
- secondByte = buf[i + 1];
1464
- if ((secondByte & 0xc0) === 0x80) {
1465
- tempCodePoint = ((firstByte & 0x1f) << 0x6) | (secondByte & 0x3f);
1466
- if (tempCodePoint > 0x7f) {
1467
- codePoint = tempCodePoint;
1468
- }
1469
- }
1470
- break;
1471
- case 3:
1472
- secondByte = buf[i + 1];
1473
- thirdByte = buf[i + 2];
1474
- if ((secondByte & 0xc0) === 0x80 && (thirdByte & 0xc0) === 0x80) {
1475
- tempCodePoint =
1476
- ((firstByte & 0xf) << 0xc) | ((secondByte & 0x3f) << 0x6) | (thirdByte & 0x3f);
1477
- if (tempCodePoint > 0x7ff && (tempCodePoint < 0xd800 || tempCodePoint > 0xdfff)) {
1478
- codePoint = tempCodePoint;
1479
- }
1480
- }
1481
- break;
1482
- case 4:
1483
- secondByte = buf[i + 1];
1484
- thirdByte = buf[i + 2];
1485
- fourthByte = buf[i + 3];
1486
- if ((secondByte & 0xc0) === 0x80 &&
1487
- (thirdByte & 0xc0) === 0x80 &&
1488
- (fourthByte & 0xc0) === 0x80) {
1489
- tempCodePoint =
1490
- ((firstByte & 0xf) << 0x12) |
1491
- ((secondByte & 0x3f) << 0xc) |
1492
- ((thirdByte & 0x3f) << 0x6) |
1493
- (fourthByte & 0x3f);
1494
- if (tempCodePoint > 0xffff && tempCodePoint < 0x110000) {
1495
- codePoint = tempCodePoint;
1496
- }
1497
- }
1498
- }
1499
- }
1500
- if (codePoint === null) {
1501
- // we did not generate a valid codePoint so insert a
1502
- // replacement char (U+FFFD) and advance only 1 byte
1503
- codePoint = 0xfffd;
1504
- bytesPerSequence = 1;
1505
- }
1506
- else if (codePoint > 0xffff) {
1507
- // encode to utf16 (surrogate pair dance)
1508
- codePoint -= 0x10000;
1509
- res.push(((codePoint >>> 10) & 0x3ff) | 0xd800);
1510
- codePoint = 0xdc00 | (codePoint & 0x3ff);
1511
- }
1512
- res.push(codePoint);
1513
- i += bytesPerSequence;
1514
- }
1515
- return decodeCodePointsArray(res);
1516
- }
1517
- // Based on http://stackoverflow.com/a/22747272/680742, the browser with
1518
- // the lowest limit is Chrome, with 0x10000 args.
1519
- // We go 1 magnitude less, for safety
1520
- const MAX_ARGUMENTS_LENGTH = 0x1000;
1521
- function decodeCodePointsArray(codePoints) {
1522
- const len = codePoints.length;
1523
- if (len <= MAX_ARGUMENTS_LENGTH) {
1524
- return String.fromCharCode.apply(String, codePoints); // avoid extra slice()
1525
- }
1526
- // Decode in chunks to avoid "call stack size exceeded".
1527
- let res = '';
1528
- let i = 0;
1529
- while (i < len) {
1530
- res += String.fromCharCode.apply(String, codePoints.slice(i, (i += MAX_ARGUMENTS_LENGTH)));
1531
- }
1532
- return res;
1533
- }
1534
- function asciiSlice(buf, start, end) {
1535
- let ret = '';
1536
- end = Math.min(buf.length, end);
1537
- for (let i = start; i < end; ++i) {
1538
- ret += String.fromCharCode(buf[i] & 0x7f);
1539
- }
1540
- return ret;
1541
- }
1542
- function latin1Slice(buf, start, end) {
1543
- let ret = '';
1544
- end = Math.min(buf.length, end);
1545
- for (let i = start; i < end; ++i) {
1546
- ret += String.fromCharCode(buf[i]);
1547
- }
1548
- return ret;
1549
- }
1550
- function hexSlice(buf, start, end) {
1551
- const len = buf.length;
1552
- if (!start || start < 0)
1553
- start = 0;
1554
- if (!end || end < 0 || end > len)
1555
- end = len;
1556
- let out = '';
1557
- for (let i = start; i < end; ++i) {
1558
- out += hexSliceLookupTable[buf[i]];
1559
- }
1560
- return out;
1561
- }
1562
- function utf16leSlice(buf, start, end) {
1563
- const bytes = buf.slice(start, end);
1564
- let res = '';
1565
- // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
1566
- for (let i = 0; i < bytes.length - 1; i += 2) {
1567
- res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
1568
- }
1569
- return res;
1570
- }
1571
- /*
1572
- * Need to make sure that buffer isn't trying to write out of bounds.
1573
- */
1574
- function checkOffset(offset, ext, length) {
1575
- if (offset % 1 !== 0 || offset < 0)
1576
- throw new RangeError('offset is not uint');
1577
- if (offset + ext > length)
1578
- throw new RangeError('Trying to access beyond buffer length');
1579
- }
1580
- function checkIEEE754(buf, value, offset, ext, max, min) {
1581
- if (offset + ext > buf.length)
1582
- throw new RangeError('Index out of range');
1583
- if (offset < 0)
1584
- throw new RangeError('Index out of range');
1585
- }
1586
- function writeFloat(buf, value, offset, littleEndian, noAssert) {
1587
- value = Number(value);
1588
- offset = offset >>> 0;
1589
- if (!noAssert) {
1590
- checkIEEE754(buf, value, offset, 4, 3.4028234663852886e38, -3.4028234663852886e38);
1591
- }
1592
- ieee754.write(buf, value, offset, littleEndian, 23, 4);
1593
- return offset + 4;
1594
- }
1595
- function writeDouble(buf, value, offset, littleEndian, noAssert) {
1596
- value = Number(value);
1597
- offset = offset >>> 0;
1598
- if (!noAssert) {
1599
- checkIEEE754(buf, value, offset, 8, 1.7976931348623157e308, -1.7976931348623157e308);
1600
- }
1601
- ieee754.write(buf, value, offset, littleEndian, 52, 8);
1602
- return offset + 8;
1603
- }
1604
- // CUSTOM ERRORS
1605
- // Simplified versions from Node, changed for Buffer-only usage
1606
- const errors = {};
1607
- function E(sym, getMessage, Base) {
1608
- errors[sym] = class NodeError extends Base {
1609
- constructor() {
1610
- super();
1611
- Object.defineProperty(this, 'message', {
1612
- value: getMessage.apply(this, arguments),
1613
- writable: true,
1614
- configurable: true
1615
- });
1616
- // Add the error code to the name to include it in the stack trace.
1617
- this.name = `${this.name} [${sym}]`;
1618
- // Access the stack to generate the error message including the error code
1619
- // from the name.
1620
- this.stack; // eslint-disable-line no-unused-expressions
1621
- // Reset the name to the actual name.
1622
- delete this.name;
1623
- }
1624
- get code() {
1625
- return sym;
1626
- }
1627
- set code(value) {
1628
- Object.defineProperty(this, 'code', {
1629
- configurable: true,
1630
- enumerable: true,
1631
- value,
1632
- writable: true
1633
- });
1634
- }
1635
- toString() {
1636
- return `${this.name} [${sym}]: ${this.message}`;
1637
- }
1638
- };
1639
- }
1640
- E('ERR_BUFFER_OUT_OF_BOUNDS', function (name) {
1641
- if (name) {
1642
- return `${name} is outside of buffer bounds`;
1643
- }
1644
- return 'Attempt to access memory outside buffer bounds';
1645
- }, RangeError);
1646
- E('ERR_INVALID_ARG_TYPE', function (name, actual) {
1647
- return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
1648
- }, TypeError);
1649
- E('ERR_OUT_OF_RANGE', function (str, range, input) {
1650
- let msg = `The value of "${str}" is out of range.`;
1651
- let received = input;
1652
- if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
1653
- received = addNumericalSeparator(String(input));
1654
- }
1655
- else if (typeof input === 'bigint') {
1656
- received = String(input);
1657
- if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
1658
- received = addNumericalSeparator(received);
1659
- }
1660
- received += 'n';
1661
- }
1662
- msg += ` It must be ${range}. Received ${received}`;
1663
- return msg;
1664
- }, RangeError);
1665
- function addNumericalSeparator(val) {
1666
- let res = '';
1667
- let i = val.length;
1668
- const start = val[0] === '-' ? 1 : 0;
1669
- for (; i >= start + 4; i -= 3) {
1670
- res = `_${val.slice(i - 3, i)}${res}`;
1671
- }
1672
- return `${val.slice(0, i)}${res}`;
1673
- }
1674
- // CHECK FUNCTIONS
1675
- function checkBounds(buf, offset, byteLength) {
1676
- validateNumber(offset, 'offset');
1677
- if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
1678
- boundsError(offset, buf.length - (byteLength + 1));
1679
- }
1680
- }
1681
- function checkIntBI(value, min, max, buf, offset, byteLength) {
1682
- if (value > max || value < min) {
1683
- const n = typeof min === 'bigint' ? 'n' : '';
1684
- let range;
1685
- if (byteLength > 3) {
1686
- if (min === 0 || min === BigInt(0)) {
1687
- range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
1688
- }
1689
- else {
1690
- range =
1691
- `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
1692
- `${(byteLength + 1) * 8 - 1}${n}`;
1693
- }
1694
- }
1695
- else {
1696
- range = `>= ${min}${n} and <= ${max}${n}`;
1697
- }
1698
- throw new errors.ERR_OUT_OF_RANGE('value', range, value);
1699
- }
1700
- checkBounds(buf, offset, byteLength);
1701
- }
1702
- function validateNumber(value, name) {
1703
- if (typeof value !== 'number') {
1704
- throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value);
1705
- }
1706
- }
1707
- function boundsError(value, length, type) {
1708
- if (Math.floor(value) !== value) {
1709
- validateNumber(value, type);
1710
- throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value);
1711
- }
1712
- if (length < 0) {
1713
- throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
1714
- }
1715
- throw new errors.ERR_OUT_OF_RANGE(type || 'offset', `>= ${type ? 1 : 0} and <= ${length}`, value);
1716
- }
1717
- // HELPER FUNCTIONS
1718
- const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
1719
- function base64clean(str) {
1720
- // Node takes equal signs as end of the Base64 encoding
1721
- str = str.split('=')[0];
1722
- // Node strips out invalid characters like \n and \t from the string, base64-js does not
1723
- str = str.trim().replace(INVALID_BASE64_RE, '');
1724
- // Node converts strings with length < 2 to ''
1725
- if (str.length < 2)
1726
- return '';
1727
- // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
1728
- while (str.length % 4 !== 0) {
1729
- str = `${str}=`;
1730
- }
1731
- return str;
1732
- }
1733
- function utf8ToBytes(string, units) {
1734
- units = units || Infinity;
1735
- let codePoint;
1736
- const length = string.length;
1737
- let leadSurrogate = null;
1738
- const bytes = [];
1739
- for (let i = 0; i < length; ++i) {
1740
- codePoint = string.charCodeAt(i);
1741
- // is surrogate component
1742
- if (codePoint > 0xd7ff && codePoint < 0xe000) {
1743
- // last char was a lead
1744
- if (!leadSurrogate) {
1745
- // no lead yet
1746
- if (codePoint > 0xdbff) {
1747
- // unexpected trail
1748
- if ((units -= 3) > -1)
1749
- bytes.push(0xef, 0xbf, 0xbd);
1750
- continue;
1751
- }
1752
- else if (i + 1 === length) {
1753
- // unpaired lead
1754
- if ((units -= 3) > -1)
1755
- bytes.push(0xef, 0xbf, 0xbd);
1756
- continue;
1757
- }
1758
- // valid lead
1759
- leadSurrogate = codePoint;
1760
- continue;
1761
- }
1762
- // 2 leads in a row
1763
- if (codePoint < 0xdc00) {
1764
- if ((units -= 3) > -1)
1765
- bytes.push(0xef, 0xbf, 0xbd);
1766
- leadSurrogate = codePoint;
1767
- continue;
1768
- }
1769
- // valid surrogate pair
1770
- codePoint = (((leadSurrogate - 0xd800) << 10) | (codePoint - 0xdc00)) + 0x10000;
1771
- }
1772
- else if (leadSurrogate) {
1773
- // valid bmp char, but last char was a lead
1774
- if ((units -= 3) > -1)
1775
- bytes.push(0xef, 0xbf, 0xbd);
1776
- }
1777
- leadSurrogate = null;
1778
- // encode utf8
1779
- if (codePoint < 0x80) {
1780
- if ((units -= 1) < 0)
1781
- break;
1782
- bytes.push(codePoint);
1783
- }
1784
- else if (codePoint < 0x800) {
1785
- if ((units -= 2) < 0)
1786
- break;
1787
- bytes.push((codePoint >> 0x6) | 0xc0, (codePoint & 0x3f) | 0x80);
1788
- }
1789
- else if (codePoint < 0x10000) {
1790
- if ((units -= 3) < 0)
1791
- break;
1792
- bytes.push((codePoint >> 0xc) | 0xe0, ((codePoint >> 0x6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80);
1793
- }
1794
- else if (codePoint < 0x110000) {
1795
- if ((units -= 4) < 0)
1796
- break;
1797
- bytes.push((codePoint >> 0x12) | 0xf0, ((codePoint >> 0xc) & 0x3f) | 0x80, ((codePoint >> 0x6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80);
1798
- }
1799
- else {
1800
- throw new Error('Invalid code point');
1801
- }
1802
- }
1803
- return bytes;
1804
- }
1805
- function asciiToBytes(str) {
1806
- const byteArray = [];
1807
- for (let i = 0; i < str.length; ++i) {
1808
- // Node's code seems to be doing this and not & 0x7F..
1809
- byteArray.push(str.charCodeAt(i) & 0xff);
1810
- }
1811
- return byteArray;
1812
- }
1813
- function utf16leToBytes(str, units) {
1814
- let c;
1815
- let hi;
1816
- let lo;
1817
- const byteArray = [];
1818
- for (let i = 0; i < str.length; ++i) {
1819
- if ((units -= 2) < 0)
1820
- break;
1821
- c = str.charCodeAt(i);
1822
- hi = c >> 8;
1823
- lo = c % 256;
1824
- byteArray.push(lo);
1825
- byteArray.push(hi);
1826
- }
1827
- return byteArray;
1828
- }
1829
- function base64ToBytes(str) {
1830
- return base64.toByteArray(base64clean(str));
1831
- }
1832
- function blitBuffer(src, dst, offset, length) {
1833
- let i;
1834
- for (i = 0; i < length; ++i) {
1835
- if (i + offset >= dst.length || i >= src.length)
1836
- break;
1837
- dst[i + offset] = src[i];
1838
- }
1839
- return i;
1840
- }
1841
- // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
1842
- // the `instanceof` check but they should be treated as of that type.
1843
- // See: https://github.com/feross/buffer/issues/166
1844
- function isInstance(obj, type) {
1845
- return (obj instanceof type ||
1846
- (obj != null &&
1847
- obj.constructor != null &&
1848
- obj.constructor.name != null &&
1849
- obj.constructor.name === type.name));
1850
- }
1851
- function numberIsNaN(obj) {
1852
- // For IE11 support
1853
- return obj !== obj; // eslint-disable-line no-self-compare
1854
- }
1855
- // Create lookup table for `toString('hex')`
1856
- // See: https://github.com/feross/buffer/issues/219
1857
- const hexSliceLookupTable = (function () {
1858
- const alphabet = '0123456789abcdef';
1859
- const table = new Array(256);
1860
- for (let i = 0; i < 16; ++i) {
1861
- const i16 = i * 16;
1862
- for (let j = 0; j < 16; ++j) {
1863
- table[i16 + j] = alphabet[i] + alphabet[j];
1864
- }
1865
- }
1866
- return table;
1867
- })();
1868
- //# sourceMappingURL=buffer.js.map