@fireproof/vendor 1.0.3 → 1.1.0-dev

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 (299) hide show
  1. package/package.json +4 -97
  2. package/src/@web3-storage/pail/dist/src/batch/index.d.ts +1 -53
  3. package/src/@web3-storage/pail/dist/src/batch/index.d.ts.map +1 -1
  4. package/src/@web3-storage/pail/dist/src/batch/shard.d.ts +1 -1
  5. package/src/@web3-storage/pail/dist/src/batch/shard.d.ts.map +1 -1
  6. package/src/@web3-storage/pail/dist/src/block.d.ts +2 -2
  7. package/src/@web3-storage/pail/dist/src/block.d.ts.map +1 -1
  8. package/src/@web3-storage/pail/dist/src/clock/index.d.ts +2 -2
  9. package/src/@web3-storage/pail/dist/src/clock/index.d.ts.map +1 -1
  10. package/src/@web3-storage/pail/dist/src/crdt/batch/index.d.ts.map +1 -1
  11. package/src/@web3-storage/pail/dist/src/crdt/index.d.ts +2 -2
  12. package/src/@web3-storage/pail/dist/src/crdt/index.d.ts.map +1 -1
  13. package/src/@web3-storage/pail/dist/src/diff.d.ts +3 -3
  14. package/src/@web3-storage/pail/dist/src/diff.d.ts.map +1 -1
  15. package/src/@web3-storage/pail/dist/src/index.d.ts +1 -1
  16. package/src/@web3-storage/pail/dist/src/index.d.ts.map +1 -1
  17. package/src/@web3-storage/pail/dist/src/merge.d.ts.map +1 -1
  18. package/src/@web3-storage/pail/dist/src/shard.d.ts +4 -4
  19. package/src/@web3-storage/pail/dist/src/shard.d.ts.map +1 -1
  20. package/src/@web3-storage/pail/dist/tsconfig.tsbuildinfo +1 -1
  21. package/src/@web3-storage/pail/src/api.ts +1 -1
  22. package/src/@web3-storage/pail/src/clock/index.js +1 -1
  23. package/src/@web3-storage/pail/src/shard.js +1 -1
  24. package/src/@ipld/car/LICENSE +0 -4
  25. package/src/@ipld/car/README.md +0 -1132
  26. package/src/@ipld/car/dist/index.min.js +0 -5
  27. package/src/@ipld/car/dist/src/api.d.ts +0 -72
  28. package/src/@ipld/car/dist/src/api.d.ts.map +0 -1
  29. package/src/@ipld/car/dist/src/buffer-decoder.d.ts +0 -67
  30. package/src/@ipld/car/dist/src/buffer-decoder.d.ts.map +0 -1
  31. package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts +0 -116
  32. package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts.map +0 -1
  33. package/src/@ipld/car/dist/src/buffer-reader.d.ts +0 -31
  34. package/src/@ipld/car/dist/src/buffer-reader.d.ts.map +0 -1
  35. package/src/@ipld/car/dist/src/buffer-writer.d.ts +0 -86
  36. package/src/@ipld/car/dist/src/buffer-writer.d.ts.map +0 -1
  37. package/src/@ipld/car/dist/src/coding.d.ts +0 -49
  38. package/src/@ipld/car/dist/src/coding.d.ts.map +0 -1
  39. package/src/@ipld/car/dist/src/decoder-common.d.ts +0 -43
  40. package/src/@ipld/car/dist/src/decoder-common.d.ts.map +0 -1
  41. package/src/@ipld/car/dist/src/decoder.d.ts +0 -87
  42. package/src/@ipld/car/dist/src/decoder.d.ts.map +0 -1
  43. package/src/@ipld/car/dist/src/encoder.d.ts +0 -17
  44. package/src/@ipld/car/dist/src/encoder.d.ts.map +0 -1
  45. package/src/@ipld/car/dist/src/header-validator.d.ts +0 -5
  46. package/src/@ipld/car/dist/src/header-validator.d.ts.map +0 -1
  47. package/src/@ipld/car/dist/src/index-browser.d.ts +0 -10
  48. package/src/@ipld/car/dist/src/index-browser.d.ts.map +0 -1
  49. package/src/@ipld/car/dist/src/index.d.ts +0 -11
  50. package/src/@ipld/car/dist/src/index.d.ts.map +0 -1
  51. package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts +0 -5
  52. package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts.map +0 -1
  53. package/src/@ipld/car/dist/src/indexed-reader.d.ts +0 -152
  54. package/src/@ipld/car/dist/src/indexed-reader.d.ts.map +0 -1
  55. package/src/@ipld/car/dist/src/indexer.d.ts +0 -95
  56. package/src/@ipld/car/dist/src/indexer.d.ts.map +0 -1
  57. package/src/@ipld/car/dist/src/iterator-channel.d.ts +0 -7
  58. package/src/@ipld/car/dist/src/iterator-channel.d.ts.map +0 -1
  59. package/src/@ipld/car/dist/src/iterator.d.ts +0 -174
  60. package/src/@ipld/car/dist/src/iterator.d.ts.map +0 -1
  61. package/src/@ipld/car/dist/src/reader-browser.d.ts +0 -151
  62. package/src/@ipld/car/dist/src/reader-browser.d.ts.map +0 -1
  63. package/src/@ipld/car/dist/src/reader.d.ts +0 -35
  64. package/src/@ipld/car/dist/src/reader.d.ts.map +0 -1
  65. package/src/@ipld/car/dist/src/writer-browser.d.ts +0 -155
  66. package/src/@ipld/car/dist/src/writer-browser.d.ts.map +0 -1
  67. package/src/@ipld/car/dist/src/writer.d.ts +0 -45
  68. package/src/@ipld/car/dist/src/writer.d.ts.map +0 -1
  69. package/src/@ipld/car/src/api.ts +0 -90
  70. package/src/@ipld/car/src/buffer-decoder.js +0 -213
  71. package/src/@ipld/car/src/buffer-reader-browser.js +0 -144
  72. package/src/@ipld/car/src/buffer-reader.js +0 -51
  73. package/src/@ipld/car/src/buffer-writer.js +0 -286
  74. package/src/@ipld/car/src/coding.ts +0 -68
  75. package/src/@ipld/car/src/decoder-common.js +0 -82
  76. package/src/@ipld/car/src/decoder.js +0 -347
  77. package/src/@ipld/car/src/encoder.js +0 -76
  78. package/src/@ipld/car/src/header-validator.js +0 -214
  79. package/src/@ipld/car/src/header.ipldsch +0 -18
  80. package/src/@ipld/car/src/index-browser.js +0 -18
  81. package/src/@ipld/car/src/index.js +0 -21
  82. package/src/@ipld/car/src/indexed-reader-browser.js +0 -7
  83. package/src/@ipld/car/src/indexed-reader.js +0 -211
  84. package/src/@ipld/car/src/indexer.js +0 -130
  85. package/src/@ipld/car/src/iterator-channel.js +0 -91
  86. package/src/@ipld/car/src/iterator.js +0 -267
  87. package/src/@ipld/car/src/reader-browser.js +0 -194
  88. package/src/@ipld/car/src/reader.js +0 -73
  89. package/src/@ipld/car/src/writer-browser.js +0 -250
  90. package/src/@ipld/car/src/writer.js +0 -84
  91. package/src/@ipld/dag-cbor/LICENSE +0 -4
  92. package/src/@ipld/dag-cbor/README.md +0 -80
  93. package/src/@ipld/dag-cbor/dist/index.min.js +0 -3
  94. package/src/@ipld/dag-cbor/dist/src/index.d.ts +0 -67
  95. package/src/@ipld/dag-cbor/dist/src/index.d.ts.map +0 -1
  96. package/src/@ipld/dag-cbor/src/index.js +0 -147
  97. package/src/@ipld/dag-json/LICENSE +0 -4
  98. package/src/@ipld/dag-json/README.md +0 -58
  99. package/src/@ipld/dag-json/dist/index.min.js +0 -3
  100. package/src/@ipld/dag-json/dist/src/index.d.ts +0 -12
  101. package/src/@ipld/dag-json/dist/src/index.d.ts.map +0 -1
  102. package/src/@ipld/dag-json/src/index.js +0 -291
  103. package/src/cborg/.github/dependabot.yml +0 -16
  104. package/src/cborg/.github/workflows/test-and-release.yml +0 -52
  105. package/src/cborg/CHANGELOG.md +0 -513
  106. package/src/cborg/LICENSE +0 -13
  107. package/src/cborg/README.md +0 -515
  108. package/src/cborg/bench/bench.js +0 -117
  109. package/src/cborg/bench/json.js +0 -124
  110. package/src/cborg/bench/package.json +0 -8
  111. package/src/cborg/cborg/bin.js +0 -189
  112. package/src/cborg/cborg/common.js +0 -28
  113. package/src/cborg/cborg/decode.js +0 -211
  114. package/src/cborg/cborg/diagnostic.js +0 -158
  115. package/src/cborg/cborg/diagnostic_test.js +0 -117
  116. package/src/cborg/cborg/encode.js +0 -466
  117. package/src/cborg/cborg/index.js +0 -33
  118. package/src/cborg/cborg/is.js +0 -106
  119. package/src/cborg/cborg/length.js +0 -62
  120. package/src/cborg/example-bytestrings.js +0 -180
  121. package/src/cborg/example-json.js +0 -6
  122. package/src/cborg/example.js +0 -5
  123. package/src/cborg/interface.ts +0 -59
  124. package/src/cborg/json/decode.js +0 -462
  125. package/src/cborg/json/encode.js +0 -302
  126. package/src/cborg/json/json.js +0 -4
  127. package/src/cborg/taglib.js +0 -75
  128. package/src/cborg/test/appendix_a.js +0 -647
  129. package/src/cborg/test/common.js +0 -18
  130. package/src/cborg/test/node-test-bin.js +0 -402
  131. package/src/cborg/test/noop-bin-test.js +0 -3
  132. package/src/cborg/test/test-0uint.js +0 -103
  133. package/src/cborg/test/test-1negint.js +0 -96
  134. package/src/cborg/test/test-2bytes.js +0 -198
  135. package/src/cborg/test/test-3string.js +0 -136
  136. package/src/cborg/test/test-4array.js +0 -93
  137. package/src/cborg/test/test-5map.js +0 -284
  138. package/src/cborg/test/test-6tag.js +0 -84
  139. package/src/cborg/test/test-7float.js +0 -131
  140. package/src/cborg/test/test-bl.js +0 -37
  141. package/src/cborg/test/test-cbor-vectors.js +0 -107
  142. package/src/cborg/test/test-decode-errors.js +0 -65
  143. package/src/cborg/test/test-fuzz.js +0 -42
  144. package/src/cborg/test/test-json.js +0 -219
  145. package/src/cborg/test/test-length.js +0 -65
  146. package/src/cborg/test/test-partial.js +0 -111
  147. package/src/cborg/tsconfig.json +0 -48
  148. package/src/cborg/types/cborg/decode.d.ts +0 -43
  149. package/src/cborg/types/cborg/decode.d.ts.map +0 -1
  150. package/src/cborg/types/cborg/encode.d.ts +0 -51
  151. package/src/cborg/types/cborg/encode.d.ts.map +0 -1
  152. package/src/cborg/types/cborg/index.d.ts +0 -26
  153. package/src/cborg/types/cborg/index.d.ts.map +0 -1
  154. package/src/cborg/types/cborg/is.d.ts +0 -6
  155. package/src/cborg/types/cborg/is.d.ts.map +0 -1
  156. package/src/cborg/types/example.d.ts +0 -2
  157. package/src/cborg/types/example.d.ts.map +0 -1
  158. package/src/cborg/types/interface.d.ts +0 -49
  159. package/src/cborg/types/interface.d.ts.map +0 -1
  160. package/src/cborg/types/json/decode.d.ts +0 -67
  161. package/src/cborg/types/json/decode.d.ts.map +0 -1
  162. package/src/cborg/types/json/encode.d.ts +0 -11
  163. package/src/cborg/types/json/encode.d.ts.map +0 -1
  164. package/src/cborg/types/json/json.d.ts +0 -6
  165. package/src/cborg/types/json/json.d.ts.map +0 -1
  166. package/src/cborg/types/taglib.d.ts +0 -18
  167. package/src/cborg/types/taglib.d.ts.map +0 -1
  168. package/src/cborg/types/tsconfig.tsbuildinfo +0 -1
  169. package/src/cborg/types/utils/0uint.d.ts +0 -102
  170. package/src/cborg/types/utils/0uint.d.ts.map +0 -1
  171. package/src/cborg/types/utils/1negint.d.ts +0 -59
  172. package/src/cborg/types/utils/1negint.d.ts.map +0 -1
  173. package/src/cborg/types/utils/2bytes.d.ts +0 -69
  174. package/src/cborg/types/utils/2bytes.d.ts.map +0 -1
  175. package/src/cborg/types/utils/3string.d.ts +0 -46
  176. package/src/cborg/types/utils/3string.d.ts.map +0 -1
  177. package/src/cborg/types/utils/4array.d.ts +0 -66
  178. package/src/cborg/types/utils/4array.d.ts.map +0 -1
  179. package/src/cborg/types/utils/5map.d.ts +0 -66
  180. package/src/cborg/types/utils/5map.d.ts.map +0 -1
  181. package/src/cborg/types/utils/6tag.d.ts +0 -62
  182. package/src/cborg/types/utils/6tag.d.ts.map +0 -1
  183. package/src/cborg/types/utils/7float.d.ts +0 -60
  184. package/src/cborg/types/utils/7float.d.ts.map +0 -1
  185. package/src/cborg/types/utils/bl.d.ts +0 -26
  186. package/src/cborg/types/utils/bl.d.ts.map +0 -1
  187. package/src/cborg/types/utils/byte-utils.d.ts +0 -53
  188. package/src/cborg/types/utils/byte-utils.d.ts.map +0 -1
  189. package/src/cborg/types/utils/common.d.ts +0 -8
  190. package/src/cborg/types/utils/common.d.ts.map +0 -1
  191. package/src/cborg/types/utils/index.d.ts +0 -13
  192. package/src/cborg/types/utils/index.d.ts.map +0 -1
  193. package/src/cborg/types/utils/jump.d.ts +0 -16
  194. package/src/cborg/types/utils/jump.d.ts.map +0 -1
  195. package/src/cborg/types/utils/token.d.ts +0 -59
  196. package/src/cborg/types/utils/token.d.ts.map +0 -1
  197. package/src/cborg/utils/0uint.js +0 -229
  198. package/src/cborg/utils/1negint.js +0 -111
  199. package/src/cborg/utils/2bytes.js +0 -135
  200. package/src/cborg/utils/3string.js +0 -90
  201. package/src/cborg/utils/4array.js +0 -114
  202. package/src/cborg/utils/5map.js +0 -113
  203. package/src/cborg/utils/6tag.js +0 -81
  204. package/src/cborg/utils/7float.js +0 -310
  205. package/src/cborg/utils/bl.js +0 -124
  206. package/src/cborg/utils/byte-utils.js +0 -417
  207. package/src/cborg/utils/common.js +0 -11
  208. package/src/cborg/utils/index.js +0 -12
  209. package/src/cborg/utils/jump.js +0 -222
  210. package/src/cborg/utils/token.js +0 -76
  211. package/src/ipfs-unixfs-exporter/LICENSE +0 -4
  212. package/src/ipfs-unixfs-exporter/README.md +0 -105
  213. package/src/ipfs-unixfs-exporter/dist/index.min.js +0 -3
  214. package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts +0 -57
  215. package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts.map +0 -1
  216. package/src/ipfs-unixfs-exporter/dist/src/errors.js +0 -73
  217. package/src/ipfs-unixfs-exporter/dist/src/errors.js.map +0 -1
  218. package/src/ipfs-unixfs-exporter/dist/src/index.d.ts +0 -355
  219. package/src/ipfs-unixfs-exporter/dist/src/index.d.ts.map +0 -1
  220. package/src/ipfs-unixfs-exporter/dist/src/index.js +0 -197
  221. package/src/ipfs-unixfs-exporter/dist/src/index.js.map +0 -1
  222. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts +0 -4
  223. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts.map +0 -1
  224. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js +0 -9
  225. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js.map +0 -1
  226. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts +0 -4
  227. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts.map +0 -1
  228. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js +0 -9
  229. package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js.map +0 -1
  230. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts +0 -4
  231. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts.map +0 -1
  232. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js +0 -38
  233. package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js.map +0 -1
  234. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts +0 -4
  235. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts.map +0 -1
  236. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js +0 -30
  237. package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js.map +0 -1
  238. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts +0 -4
  239. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts.map +0 -1
  240. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js +0 -9
  241. package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js.map +0 -1
  242. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts +0 -4
  243. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts.map +0 -1
  244. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js +0 -37
  245. package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js.map +0 -1
  246. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts +0 -4
  247. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts.map +0 -1
  248. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js +0 -29
  249. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js.map +0 -1
  250. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts +0 -4
  251. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts.map +0 -1
  252. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js +0 -153
  253. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js.map +0 -1
  254. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +0 -4
  255. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +0 -1
  256. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +0 -59
  257. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +0 -1
  258. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts +0 -4
  259. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts.map +0 -1
  260. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js +0 -25
  261. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js.map +0 -1
  262. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts +0 -4
  263. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts.map +0 -1
  264. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js +0 -104
  265. package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js.map +0 -1
  266. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts +0 -3
  267. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts.map +0 -1
  268. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js +0 -20
  269. package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js.map +0 -1
  270. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts +0 -6
  271. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts.map +0 -1
  272. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js +0 -116
  273. package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js.map +0 -1
  274. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts +0 -4
  275. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts.map +0 -1
  276. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js +0 -57
  277. package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js.map +0 -1
  278. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts +0 -6
  279. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts.map +0 -1
  280. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js +0 -30
  281. package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js.map +0 -1
  282. package/src/ipfs-unixfs-exporter/dist/typedoc-urls.json +0 -58
  283. package/src/ipfs-unixfs-exporter/src/errors.ts +0 -87
  284. package/src/ipfs-unixfs-exporter/src/index.ts +0 -498
  285. package/src/ipfs-unixfs-exporter/src/resolvers/dag-cbor.ts +0 -12
  286. package/src/ipfs-unixfs-exporter/src/resolvers/dag-json.ts +0 -12
  287. package/src/ipfs-unixfs-exporter/src/resolvers/identity.ts +0 -49
  288. package/src/ipfs-unixfs-exporter/src/resolvers/index.ts +0 -35
  289. package/src/ipfs-unixfs-exporter/src/resolvers/json.ts +0 -12
  290. package/src/ipfs-unixfs-exporter/src/resolvers/raw.ts +0 -49
  291. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/directory.ts +0 -39
  292. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.ts +0 -198
  293. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +0 -76
  294. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/raw.ts +0 -37
  295. package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.ts +0 -121
  296. package/src/ipfs-unixfs-exporter/src/utils/extract-data-from-block.ts +0 -24
  297. package/src/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.ts +0 -149
  298. package/src/ipfs-unixfs-exporter/src/utils/resolve-object-path.ts +0 -62
  299. package/src/ipfs-unixfs-exporter/src/utils/validate-offset-and-length.ts +0 -38
@@ -1,417 +0,0 @@
1
- // Use Uint8Array directly in the browser, use Buffer in Node.js but don't
2
- // speak its name directly to avoid bundlers pulling in the `Buffer` polyfill
3
-
4
- // @ts-ignore
5
- export const useBuffer = globalThis.process &&
6
- // @ts-ignore
7
- !globalThis.process.browser &&
8
- // @ts-ignore
9
- globalThis.Buffer &&
10
- // @ts-ignore
11
- typeof globalThis.Buffer.isBuffer === 'function'
12
-
13
- const textDecoder = new TextDecoder()
14
- const textEncoder = new TextEncoder()
15
-
16
- /**
17
- * @param {Uint8Array} buf
18
- * @returns {boolean}
19
- */
20
- function isBuffer (buf) {
21
- // @ts-ignore
22
- return useBuffer && globalThis.Buffer.isBuffer(buf)
23
- }
24
-
25
- /**
26
- * @param {Uint8Array|number[]} buf
27
- * @returns {Uint8Array}
28
- */
29
- export function asU8A (buf) {
30
- /* c8 ignore next */
31
- if (!(buf instanceof Uint8Array)) {
32
- return Uint8Array.from(buf)
33
- }
34
- return isBuffer(buf) ? new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength) : buf
35
- }
36
-
37
- export const toString = useBuffer
38
- ? // eslint-disable-line operator-linebreak
39
- /**
40
- * @param {Uint8Array} bytes
41
- * @param {number} start
42
- * @param {number} end
43
- */
44
- (bytes, start, end) => {
45
- return end - start > 64
46
- ? // eslint-disable-line operator-linebreak
47
- // @ts-ignore
48
- globalThis.Buffer.from(bytes.subarray(start, end)).toString('utf8')
49
- : utf8Slice(bytes, start, end)
50
- }
51
- /* c8 ignore next 11 */
52
- : // eslint-disable-line operator-linebreak
53
- /**
54
- * @param {Uint8Array} bytes
55
- * @param {number} start
56
- * @param {number} end
57
- */
58
- (bytes, start, end) => {
59
- return end - start > 64
60
- ? textDecoder.decode(bytes.subarray(start, end))
61
- : utf8Slice(bytes, start, end)
62
- }
63
-
64
- export const fromString = useBuffer
65
- ? // eslint-disable-line operator-linebreak
66
- /**
67
- * @param {string} string
68
- */
69
- (string) => {
70
- return string.length > 64
71
- ? // eslint-disable-line operator-linebreak
72
- // @ts-ignore
73
- globalThis.Buffer.from(string)
74
- : utf8ToBytes(string)
75
- }
76
- /* c8 ignore next 7 */
77
- : // eslint-disable-line operator-linebreak
78
- /**
79
- * @param {string} string
80
- */
81
- (string) => {
82
- return string.length > 64 ? textEncoder.encode(string) : utf8ToBytes(string)
83
- }
84
-
85
- /**
86
- * Buffer variant not fast enough for what we need
87
- * @param {number[]} arr
88
- * @returns {Uint8Array}
89
- */
90
- export const fromArray = (arr) => {
91
- return Uint8Array.from(arr)
92
- }
93
-
94
- export const slice = useBuffer
95
- ? // eslint-disable-line operator-linebreak
96
- /**
97
- * @param {Uint8Array} bytes
98
- * @param {number} start
99
- * @param {number} end
100
- */
101
- (bytes, start, end) => {
102
- if (isBuffer(bytes)) {
103
- return new Uint8Array(bytes.subarray(start, end))
104
- }
105
- return bytes.slice(start, end)
106
- }
107
- /* c8 ignore next 9 */
108
- : // eslint-disable-line operator-linebreak
109
- /**
110
- * @param {Uint8Array} bytes
111
- * @param {number} start
112
- * @param {number} end
113
- */
114
- (bytes, start, end) => {
115
- return bytes.slice(start, end)
116
- }
117
-
118
- export const concat = useBuffer
119
- ? // eslint-disable-line operator-linebreak
120
- /**
121
- * @param {Uint8Array[]} chunks
122
- * @param {number} length
123
- * @returns {Uint8Array}
124
- */
125
- (chunks, length) => {
126
- // might get a stray plain Array here
127
- /* c8 ignore next 1 */
128
- chunks = chunks.map((c) => c instanceof Uint8Array
129
- ? c
130
- // this case is occasionally missed during test runs so becomes coverage-flaky
131
- /* c8 ignore next 4 */
132
- : // eslint-disable-line operator-linebreak
133
- // @ts-ignore
134
- globalThis.Buffer.from(c))
135
- // @ts-ignore
136
- return asU8A(globalThis.Buffer.concat(chunks, length))
137
- }
138
- /* c8 ignore next 19 */
139
- : // eslint-disable-line operator-linebreak
140
- /**
141
- * @param {Uint8Array[]} chunks
142
- * @param {number} length
143
- * @returns {Uint8Array}
144
- */
145
- (chunks, length) => {
146
- const out = new Uint8Array(length)
147
- let off = 0
148
- for (let b of chunks) {
149
- if (off + b.length > out.length) {
150
- // final chunk that's bigger than we need
151
- b = b.subarray(0, out.length - off)
152
- }
153
- out.set(b, off)
154
- off += b.length
155
- }
156
- return out
157
- }
158
-
159
- export const alloc = useBuffer
160
- ? // eslint-disable-line operator-linebreak
161
- /**
162
- * @param {number} size
163
- * @returns {Uint8Array}
164
- */
165
- (size) => {
166
- // we always write over the contents we expose so this should be safe
167
- // @ts-ignore
168
- return globalThis.Buffer.allocUnsafe(size)
169
- }
170
- /* c8 ignore next 8 */
171
- : // eslint-disable-line operator-linebreak
172
- /**
173
- * @param {number} size
174
- * @returns {Uint8Array}
175
- */
176
- (size) => {
177
- return new Uint8Array(size)
178
- }
179
-
180
- export const toHex = useBuffer
181
- ? // eslint-disable-line operator-linebreak
182
- /**
183
- * @param {Uint8Array} d
184
- * @returns {string}
185
- */
186
- (d) => {
187
- if (typeof d === 'string') {
188
- return d
189
- }
190
- // @ts-ignore
191
- return globalThis.Buffer.from(toBytes(d)).toString('hex')
192
- }
193
- /* c8 ignore next 12 */
194
- : // eslint-disable-line operator-linebreak
195
- /**
196
- * @param {Uint8Array} d
197
- * @returns {string}
198
- */
199
- (d) => {
200
- if (typeof d === 'string') {
201
- return d
202
- }
203
- // @ts-ignore not smart enough to figure this out
204
- return Array.prototype.reduce.call(toBytes(d), (p, c) => `${p}${c.toString(16).padStart(2, '0')}`, '')
205
- }
206
-
207
- export const fromHex = useBuffer
208
- ? // eslint-disable-line operator-linebreak
209
- /**
210
- * @param {string|Uint8Array} hex
211
- * @returns {Uint8Array}
212
- */
213
- (hex) => {
214
- if (hex instanceof Uint8Array) {
215
- return hex
216
- }
217
- // @ts-ignore
218
- return globalThis.Buffer.from(hex, 'hex')
219
- }
220
- /* c8 ignore next 17 */
221
- : // eslint-disable-line operator-linebreak
222
- /**
223
- * @param {string|Uint8Array} hex
224
- * @returns {Uint8Array}
225
- */
226
- (hex) => {
227
- if (hex instanceof Uint8Array) {
228
- return hex
229
- }
230
- if (!hex.length) {
231
- return new Uint8Array(0)
232
- }
233
- return new Uint8Array(hex.split('')
234
- .map((/** @type {string} */ c, /** @type {number} */ i, /** @type {string[]} */ d) => i % 2 === 0 ? `0x${c}${d[i + 1]}` : '')
235
- .filter(Boolean)
236
- .map((/** @type {string} */ e) => parseInt(e, 16)))
237
- }
238
-
239
- /**
240
- * @param {Uint8Array|ArrayBuffer|ArrayBufferView} obj
241
- * @returns {Uint8Array}
242
- */
243
- function toBytes (obj) {
244
- if (obj instanceof Uint8Array && obj.constructor.name === 'Uint8Array') {
245
- return obj
246
- }
247
- if (obj instanceof ArrayBuffer) {
248
- return new Uint8Array(obj)
249
- }
250
- if (ArrayBuffer.isView(obj)) {
251
- return new Uint8Array(obj.buffer, obj.byteOffset, obj.byteLength)
252
- }
253
- /* c8 ignore next */
254
- throw new Error('Unknown type, must be binary type')
255
- }
256
-
257
- /**
258
- * @param {Uint8Array} b1
259
- * @param {Uint8Array} b2
260
- * @returns {number}
261
- */
262
- export function compare (b1, b2) {
263
- /* c8 ignore next 5 */
264
- if (isBuffer(b1) && isBuffer(b2)) {
265
- // probably not possible to get here in the current API
266
- // @ts-ignore Buffer
267
- return b1.compare(b2)
268
- }
269
- for (let i = 0; i < b1.length; i++) {
270
- if (b1[i] === b2[i]) {
271
- continue
272
- }
273
- return b1[i] < b2[i] ? -1 : 1
274
- } /* c8 ignore next 3 */
275
- return 0
276
- }
277
-
278
- // The below code is taken from https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt.js#L117-L143
279
- // Licensed Apache-2.0.
280
-
281
- /**
282
- * @param {string} str
283
- * @returns {number[]}
284
- */
285
- function utf8ToBytes (str) {
286
- const out = []
287
- let p = 0
288
- for (let i = 0; i < str.length; i++) {
289
- let c = str.charCodeAt(i)
290
- if (c < 128) {
291
- out[p++] = c
292
- } else if (c < 2048) {
293
- out[p++] = (c >> 6) | 192
294
- out[p++] = (c & 63) | 128
295
- } else if (
296
- ((c & 0xFC00) === 0xD800) && (i + 1) < str.length &&
297
- ((str.charCodeAt(i + 1) & 0xFC00) === 0xDC00)) {
298
- // Surrogate Pair
299
- c = 0x10000 + ((c & 0x03FF) << 10) + (str.charCodeAt(++i) & 0x03FF)
300
- out[p++] = (c >> 18) | 240
301
- out[p++] = ((c >> 12) & 63) | 128
302
- out[p++] = ((c >> 6) & 63) | 128
303
- out[p++] = (c & 63) | 128
304
- } else {
305
- out[p++] = (c >> 12) | 224
306
- out[p++] = ((c >> 6) & 63) | 128
307
- out[p++] = (c & 63) | 128
308
- }
309
- }
310
- return out
311
- }
312
-
313
- // The below code is mostly taken from https://github.com/feross/buffer
314
- // Licensed MIT. Copyright (c) Feross Aboukhadijeh
315
-
316
- /**
317
- * @param {Uint8Array} buf
318
- * @param {number} offset
319
- * @param {number} end
320
- * @returns {string}
321
- */
322
- function utf8Slice (buf, offset, end) {
323
- const res = []
324
-
325
- while (offset < end) {
326
- const firstByte = buf[offset]
327
- let codePoint = null
328
- let bytesPerSequence = (firstByte > 0xef) ? 4 : (firstByte > 0xdf) ? 3 : (firstByte > 0xbf) ? 2 : 1
329
-
330
- if (offset + bytesPerSequence <= end) {
331
- let secondByte, thirdByte, fourthByte, tempCodePoint
332
-
333
- switch (bytesPerSequence) {
334
- case 1:
335
- if (firstByte < 0x80) {
336
- codePoint = firstByte
337
- }
338
- break
339
- case 2:
340
- secondByte = buf[offset + 1]
341
- if ((secondByte & 0xc0) === 0x80) {
342
- tempCodePoint = (firstByte & 0x1f) << 0x6 | (secondByte & 0x3f)
343
- if (tempCodePoint > 0x7f) {
344
- codePoint = tempCodePoint
345
- }
346
- }
347
- break
348
- case 3:
349
- secondByte = buf[offset + 1]
350
- thirdByte = buf[offset + 2]
351
- if ((secondByte & 0xc0) === 0x80 && (thirdByte & 0xc0) === 0x80) {
352
- tempCodePoint = (firstByte & 0xf) << 0xc | (secondByte & 0x3f) << 0x6 | (thirdByte & 0x3f)
353
- /* c8 ignore next 3 */
354
- if (tempCodePoint > 0x7ff && (tempCodePoint < 0xd800 || tempCodePoint > 0xdfff)) {
355
- codePoint = tempCodePoint
356
- }
357
- }
358
- break
359
- case 4:
360
- secondByte = buf[offset + 1]
361
- thirdByte = buf[offset + 2]
362
- fourthByte = buf[offset + 3]
363
- if ((secondByte & 0xc0) === 0x80 && (thirdByte & 0xc0) === 0x80 && (fourthByte & 0xc0) === 0x80) {
364
- tempCodePoint = (firstByte & 0xf) << 0x12 | (secondByte & 0x3f) << 0xc | (thirdByte & 0x3f) << 0x6 | (fourthByte & 0x3f)
365
- if (tempCodePoint > 0xffff && tempCodePoint < 0x110000) {
366
- codePoint = tempCodePoint
367
- }
368
- }
369
- }
370
- }
371
-
372
- /* c8 ignore next 5 */
373
- if (codePoint === null) {
374
- // we did not generate a valid codePoint so insert a
375
- // replacement char (U+FFFD) and advance only 1 byte
376
- codePoint = 0xfffd
377
- bytesPerSequence = 1
378
- } else if (codePoint > 0xffff) {
379
- // encode to utf16 (surrogate pair dance)
380
- codePoint -= 0x10000
381
- res.push(codePoint >>> 10 & 0x3ff | 0xd800)
382
- codePoint = 0xdc00 | codePoint & 0x3ff
383
- }
384
-
385
- res.push(codePoint)
386
- offset += bytesPerSequence
387
- }
388
-
389
- return decodeCodePointsArray(res)
390
- }
391
-
392
- // Based on http://stackoverflow.com/a/22747272/680742, the browser with
393
- // the lowest limit is Chrome, with 0x10000 args.
394
- // We go 1 magnitude less, for safety
395
- const MAX_ARGUMENTS_LENGTH = 0x1000
396
-
397
- /**
398
- * @param {number[]} codePoints
399
- * @returns {string}
400
- */
401
- export function decodeCodePointsArray (codePoints) {
402
- const len = codePoints.length
403
- if (len <= MAX_ARGUMENTS_LENGTH) {
404
- return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
405
- }
406
- /* c8 ignore next 10 */
407
- // Decode in chunks to avoid "call stack size exceeded".
408
- let res = ''
409
- let i = 0
410
- while (i < len) {
411
- res += String.fromCharCode.apply(
412
- String,
413
- codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
414
- )
415
- }
416
- return res
417
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * @param {Uint8Array} data
3
- * @param {number} pos
4
- * @param {number} need
5
- * @param {string} decodeErrPrefix
6
- */
7
- export function assertEnoughData (data, pos, need, decodeErrPrefix) {
8
- if (data.length - pos < need) {
9
- throw new Error(`${decodeErrPrefix} not enough data for type`)
10
- }
11
- }
@@ -1,12 +0,0 @@
1
- export * from './byte-utils.js'
2
- export { encodeUint, uintBoundaries } from './0uint.js'
3
- export { encodeNegint } from './1negint.js'
4
- export { encodeBytes } from './2bytes.js'
5
- export { encodeString } from './3string.js'
6
- export { encodeArray } from './4array.js'
7
- export { encodeMap } from './5map.js'
8
- export { encodeTag } from './6tag.js'
9
- export { encodeFloat } from './7float.js'
10
- export { Bl } from './bl.js'
11
- export { Token, Type } from './token.js'
12
- export * from './jump.js'
@@ -1,222 +0,0 @@
1
- import { Token, Type } from './token.js'
2
- import * as uint from './0uint.js'
3
- import * as negint from './1negint.js'
4
- import * as bytes from './2bytes.js'
5
- import * as string from './3string.js'
6
- import * as array from './4array.js'
7
- import * as map from './5map.js'
8
- import * as tag from './6tag.js'
9
- import * as float from './7float.js'
10
- import { fromArray } from './byte-utils.js'
11
-
12
- /**
13
- * @typedef {import('../interface.js').DecodeOptions} DecodeOptions
14
- * @typedef {import('../interface.js').DecodeFunction} DecodeFunction
15
- */
16
-
17
- /**
18
- * @param {string} decodeErrPrefix
19
- * @returns {DecodeFunction}
20
- */
21
- function invalidMinorWithPrefix (decodeErrPrefix) {
22
- /**
23
- * @param {Uint8Array} data
24
- * @param {number} pos
25
- * @param {number} minor
26
- */
27
- return (data, pos, minor) => {
28
- throw new Error(`${decodeErrPrefix} encountered invalid minor (${minor}) for major ${data[pos] >>> 5}`)
29
- }
30
- }
31
-
32
- /**
33
- * @param {string} msg
34
- * @param {string} decodeErrPrefix
35
- * @returns {()=>any}
36
- */
37
- function errorer (msg, decodeErrPrefix) {
38
- return () => { throw new Error(`${decodeErrPrefix} ${msg}`) }
39
- }
40
-
41
- /**
42
- * @param {string} decodeErrPrefix
43
- * @return {DecodeFunction[]}
44
- */
45
- export function jump (decodeErrPrefix) {
46
- const invalidMinor = invalidMinorWithPrefix(decodeErrPrefix)
47
- const jump = Array(256).fill(invalidMinor)
48
- // unsigned integer, 0x00..0x17 (0..23)
49
- // for (let i = 0; i <= 0x17; i++) {
50
- // jump[i] = invalidMinor // uint.decodeUintCompact, handled by quick[]
51
- // }
52
- jump[0x18] = uint.decodeUint8 // unsigned integer, one-byte uint8_t follows
53
- jump[0x19] = uint.decodeUint16 // unsigned integer, two-byte uint16_t follows
54
- jump[0x1a] = uint.decodeUint32 // unsigned integer, four-byte uint32_t follows
55
- jump[0x1b] = uint.decodeUint64 // unsigned integer, eight-byte uint64_t follows
56
- // jump[0x1c] = invalidMinor
57
- // jump[0x1d] = invalidMinor
58
- // jump[0x1e] = invalidMinor
59
- // jump[0x1f] = invalidMinor
60
- // negative integer, -1-0x00..-1-0x17 (-1..-24)
61
- // for (let i = 0x20; i <= 0x37; i++) {
62
- // jump[i] = invalidMinor // negintDecode, handled by quick[]
63
- // }
64
- jump[0x38] = negint.decodeNegint8 // negative integer, -1-n one-byte uint8_t for n follows
65
- jump[0x39] = negint.decodeNegint16 // negative integer, -1-n two-byte uint16_t for n follows
66
- jump[0x3a] = negint.decodeNegint32 // negative integer, -1-n four-byte uint32_t for follows
67
- jump[0x3b] = negint.decodeNegint64 // negative integer, -1-n eight-byte uint64_t for follows
68
- // jump[0x3c] = invalidMinor
69
- // jump[0x3d] = invalidMinor
70
- // jump[0x3e] = invalidMinor
71
- // jump[0x3f] = invalidMinor
72
- // byte string, 0x00..0x17 bytes follow
73
- for (let i = 0x40; i <= 0x57; i++) {
74
- jump[i] = bytes.decodeBytesCompact
75
- }
76
- jump[0x58] = bytes.decodeBytes8 // byte string, one-byte uint8_t for n, and then n bytes follow
77
- jump[0x59] = bytes.decodeBytes16 // byte string, two-byte uint16_t for n, and then n bytes follow
78
- jump[0x5a] = bytes.decodeBytes32 // byte string, four-byte uint32_t for n, and then n bytes follow
79
- jump[0x5b] = bytes.decodeBytes64 // byte string, eight-byte uint64_t for n, and then n bytes follow
80
- // jump[0x5c] = invalidMinor
81
- // jump[0x5d] = invalidMinor
82
- // jump[0x5e] = invalidMinor
83
- jump[0x5f] = errorer('indefinite length bytes/strings are not supported', decodeErrPrefix) // byte string, byte strings follow, terminated by "break"
84
- // UTF-8 string 0x00..0x17 bytes follow
85
- for (let i = 0x60; i <= 0x77; i++) {
86
- jump[i] = string.decodeStringCompact
87
- }
88
- jump[0x78] = string.decodeString8 // UTF-8 string, one-byte uint8_t for n, and then n bytes follow
89
- jump[0x79] = string.decodeString16 // UTF-8 string, two-byte uint16_t for n, and then n bytes follow
90
- jump[0x7a] = string.decodeString32 // UTF-8 string, four-byte uint32_t for n, and then n bytes follow
91
- jump[0x7b] = string.decodeString64 // UTF-8 string, eight-byte uint64_t for n, and then n bytes follow
92
- // jump[0x7c] = invalidMinor
93
- // jump[0x7d] = invalidMinor
94
- // jump[0x7e] = invalidMinor
95
- jump[0x7f] = errorer('indefinite length bytes/strings are not supported', decodeErrPrefix) // UTF-8 strings follow, terminated by "break"
96
- // array, 0x00..0x17 data items follow
97
- for (let i = 0x80; i <= 0x97; i++) {
98
- jump[i] = array.decodeArrayCompact
99
- }
100
- jump[0x98] = array.decodeArray8 // array, one-byte uint8_t for n, and then n data items follow
101
- jump[0x99] = array.decodeArray16 // array, two-byte uint16_t for n, and then n data items follow
102
- jump[0x9a] = array.decodeArray32 // array, four-byte uint32_t for n, and then n data items follow
103
- jump[0x9b] = array.decodeArray64 // array, eight-byte uint64_t for n, and then n data items follow
104
- // jump[0x9c] = invalidMinor
105
- // jump[0x9d] = invalidMinor
106
- // jump[0x9e] = invalidMinor
107
- jump[0x9f] = array.decodeArrayIndefinite // array, data items follow, terminated by "break"
108
- // map, 0x00..0x17 pairs of data items follow
109
- for (let i = 0xa0; i <= 0xb7; i++) {
110
- jump[i] = map.decodeMapCompact
111
- }
112
- jump[0xb8] = map.decodeMap8 // map, one-byte uint8_t for n, and then n pairs of data items follow
113
- jump[0xb9] = map.decodeMap16 // map, two-byte uint16_t for n, and then n pairs of data items follow
114
- jump[0xba] = map.decodeMap32 // map, four-byte uint32_t for n, and then n pairs of data items follow
115
- jump[0xbb] = map.decodeMap64 // map, eight-byte uint64_t for n, and then n pairs of data items follow
116
- // jump[0xbc] = invalidMinor
117
- // jump[0xbd] = invalidMinor
118
- // jump[0xbe] = invalidMinor
119
- jump[0xbf] = map.decodeMapIndefinite // map, pairs of data items follow, terminated by "break"
120
- // tags
121
- for (let i = 0xc0; i <= 0xd7; i++) {
122
- jump[i] = tag.decodeTagCompact
123
- }
124
- jump[0xd8] = tag.decodeTag8
125
- jump[0xd9] = tag.decodeTag16
126
- jump[0xda] = tag.decodeTag32
127
- jump[0xdb] = tag.decodeTag64
128
- // jump[0xdc] = invalidMinor
129
- // jump[0xdd] = invalidMinor
130
- // jump[0xde] = invalidMinor
131
- // jump[0xdf] = invalidMinor
132
- // 0xe0..0xf3 simple values, unsupported
133
- for (let i = 0xe0; i <= 0xf3; i++) {
134
- jump[i] = errorer('simple values are not supported', decodeErrPrefix)
135
- }
136
- // jump[0xf4] = invalidMinor // false, handled by quick[]
137
- // jump[0xf5] = invalidMinor // true, handled by quick[]
138
- // jump[0xf6] = invalidMinor // null, handled by quick[]
139
- jump[0xf7] = float.decodeUndefined // undefined
140
- jump[0xf8] = errorer('simple values are not supported', decodeErrPrefix) // simple value, one byte follows, unsupported
141
- jump[0xf9] = float.decodeFloat16 // half-precision float (two-byte IEEE 754)
142
- jump[0xfa] = float.decodeFloat32 // single-precision float (four-byte IEEE 754)
143
- jump[0xfb] = float.decodeFloat64 // double-precision float (eight-byte IEEE 754)
144
- // jump[0xfc] = invalidMinor
145
- // jump[0xfd] = invalidMinor
146
- // jump[0xfe] = invalidMinor
147
- jump[0xff] = float.decodeBreak // "break" stop code
148
- return jump
149
- }
150
-
151
- /** @type {Token[]} */
152
- export const quick = []
153
- // ints <24
154
- for (let i = 0; i < 24; i++) {
155
- quick[i] = new Token(Type.uint, i, 1)
156
- }
157
- // negints >= -24
158
- for (let i = -1; i >= -24; i--) {
159
- quick[31 - i] = new Token(Type.negint, i, 1)
160
- }
161
- // empty bytes
162
- quick[0x40] = new Token(Type.bytes, new Uint8Array(0), 1)
163
- // empty string
164
- quick[0x60] = new Token(Type.string, '', 1)
165
- // empty list
166
- quick[0x80] = new Token(Type.array, 0, 1)
167
- // empty map
168
- quick[0xa0] = new Token(Type.map, 0, 1)
169
- // false
170
- quick[0xf4] = new Token(Type.false, false, 1)
171
- // true
172
- quick[0xf5] = new Token(Type.true, true, 1)
173
- // null
174
- quick[0xf6] = new Token(Type.null, null, 1)
175
-
176
- /**
177
- * @param {Token} token
178
- * @returns {Uint8Array|undefined}
179
- */
180
- export function quickEncodeToken (token) {
181
- switch (token.type) {
182
- case Type.false:
183
- return fromArray([0xf4])
184
- case Type.true:
185
- return fromArray([0xf5])
186
- case Type.null:
187
- return fromArray([0xf6])
188
- case Type.bytes:
189
- if (!token.value.length) {
190
- return fromArray([0x40])
191
- }
192
- return
193
- case Type.string:
194
- if (token.value === '') {
195
- return fromArray([0x60])
196
- }
197
- return
198
- case Type.array:
199
- if (token.value === 0) {
200
- return fromArray([0x80])
201
- }
202
- /* c8 ignore next 2 */
203
- // shouldn't be possible if this were called when there was only one token
204
- return
205
- case Type.map:
206
- if (token.value === 0) {
207
- return fromArray([0xa0])
208
- }
209
- /* c8 ignore next 2 */
210
- // shouldn't be possible if this were called when there was only one token
211
- return
212
- case Type.uint:
213
- if (token.value < 24) {
214
- return fromArray([Number(token.value)])
215
- }
216
- return
217
- case Type.negint:
218
- if (token.value >= -24) {
219
- return fromArray([31 - Number(token.value)])
220
- }
221
- }
222
- }