@fireproof/vendor 0.0.0-smoke → 0.22.0-dev-preview

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 (489) hide show
  1. package/merge-package.ts +207 -0
  2. package/p-limit/index.d.ts +81 -0
  3. package/p-limit/index.js +104 -0
  4. package/p-limit/index.test-d.ts +19 -0
  5. package/p-limit/license +9 -0
  6. package/p-limit/package.json +59 -0
  7. package/p-limit/readme.md +128 -0
  8. package/p-limit/test.js +241 -0
  9. package/package.json +12 -9
  10. package/to-esm-transform.ts +42 -0
  11. package/patched/@ipld/dag-json/.github/dependabot.yml +0 -11
  12. package/patched/@ipld/dag-json/.github/workflows/js-test-and-release.yml +0 -28
  13. package/patched/@ipld/dag-json/CHANGELOG.md +0 -202
  14. package/patched/@ipld/dag-json/LICENSE +0 -4
  15. package/patched/@ipld/dag-json/LICENSE-APACHE +0 -5
  16. package/patched/@ipld/dag-json/LICENSE-MIT +0 -19
  17. package/patched/@ipld/dag-json/README.md +0 -58
  18. package/patched/@ipld/dag-json/ipld-dag-json-10.2.3.tgz +0 -0
  19. package/patched/@ipld/dag-json/package.json +0 -173
  20. package/patched/@ipld/dag-json/src/index.js +0 -291
  21. package/patched/@ipld/dag-json/test/test-basics.spec.js +0 -290
  22. package/patched/@ipld/dag-json/test/ts-use/package.json +0 -11
  23. package/patched/@ipld/dag-json/test/ts-use/src/main.ts +0 -54
  24. package/patched/@ipld/dag-json/test/ts-use/tsconfig.json +0 -9
  25. package/patched/@ipld/dag-json/tsconfig.json +0 -14
  26. package/patched/cborg/.github/dependabot.yml +0 -16
  27. package/patched/cborg/.github/workflows/test-and-release.yml +0 -52
  28. package/patched/cborg/CHANGELOG.md +0 -513
  29. package/patched/cborg/LICENSE +0 -13
  30. package/patched/cborg/README.md +0 -515
  31. package/patched/cborg/bench/bench.js +0 -117
  32. package/patched/cborg/bench/json.js +0 -124
  33. package/patched/cborg/bench/package.json +0 -8
  34. package/patched/cborg/cborg-4.2.7.tgz +0 -0
  35. package/patched/cborg/cborg.js +0 -31
  36. package/patched/cborg/example-bytestrings.js +0 -180
  37. package/patched/cborg/example-json.js +0 -6
  38. package/patched/cborg/example.js +0 -5
  39. package/patched/cborg/interface.ts +0 -56
  40. package/patched/cborg/lib/0uint.js +0 -227
  41. package/patched/cborg/lib/1negint.js +0 -111
  42. package/patched/cborg/lib/2bytes.js +0 -133
  43. package/patched/cborg/lib/3string.js +0 -90
  44. package/patched/cborg/lib/4array.js +0 -113
  45. package/patched/cborg/lib/5map.js +0 -113
  46. package/patched/cborg/lib/6tag.js +0 -80
  47. package/patched/cborg/lib/7float.js +0 -308
  48. package/patched/cborg/lib/bin.js +0 -189
  49. package/patched/cborg/lib/bl.js +0 -124
  50. package/patched/cborg/lib/byte-utils.js +0 -417
  51. package/patched/cborg/lib/common.js +0 -27
  52. package/patched/cborg/lib/decode.js +0 -209
  53. package/patched/cborg/lib/diagnostic.js +0 -156
  54. package/patched/cborg/lib/diagnostic_test.js +0 -117
  55. package/patched/cborg/lib/encode.js +0 -464
  56. package/patched/cborg/lib/is.js +0 -106
  57. package/patched/cborg/lib/json/decode.js +0 -462
  58. package/patched/cborg/lib/json/encode.js +0 -299
  59. package/patched/cborg/lib/json/json.js +0 -4
  60. package/patched/cborg/lib/jump.js +0 -209
  61. package/patched/cborg/lib/length.js +0 -61
  62. package/patched/cborg/lib/token.js +0 -76
  63. package/patched/cborg/package.json +0 -169
  64. package/patched/cborg/pnpm-lock.yaml +0 -6096
  65. package/patched/cborg/taglib.js +0 -73
  66. package/patched/cborg/test/appendix_a.js +0 -647
  67. package/patched/cborg/test/common.js +0 -18
  68. package/patched/cborg/test/node-test-bin.js +0 -402
  69. package/patched/cborg/test/noop-bin-test.js +0 -3
  70. package/patched/cborg/test/test-0uint.js +0 -103
  71. package/patched/cborg/test/test-1negint.js +0 -96
  72. package/patched/cborg/test/test-2bytes.js +0 -198
  73. package/patched/cborg/test/test-3string.js +0 -136
  74. package/patched/cborg/test/test-4array.js +0 -93
  75. package/patched/cborg/test/test-5map.js +0 -284
  76. package/patched/cborg/test/test-6tag.js +0 -85
  77. package/patched/cborg/test/test-7float.js +0 -131
  78. package/patched/cborg/test/test-bl.js +0 -37
  79. package/patched/cborg/test/test-cbor-vectors.js +0 -107
  80. package/patched/cborg/test/test-decode-errors.js +0 -65
  81. package/patched/cborg/test/test-fuzz.js +0 -42
  82. package/patched/cborg/test/test-json.js +0 -219
  83. package/patched/cborg/test/test-length.js +0 -65
  84. package/patched/cborg/test/test-partial.js +0 -111
  85. package/patched/cborg/tsconfig.json +0 -45
  86. package/patched/cborg/types/cborg.d.ts +0 -28
  87. package/patched/cborg/types/cborg.d.ts.map +0 -1
  88. package/patched/cborg/types/example.d.ts +0 -2
  89. package/patched/cborg/types/example.d.ts.map +0 -1
  90. package/patched/cborg/types/interface.d.ts +0 -47
  91. package/patched/cborg/types/interface.d.ts.map +0 -1
  92. package/patched/cborg/types/lib/0uint.d.ts +0 -100
  93. package/patched/cborg/types/lib/0uint.d.ts.map +0 -1
  94. package/patched/cborg/types/lib/1negint.d.ts +0 -58
  95. package/patched/cborg/types/lib/1negint.d.ts.map +0 -1
  96. package/patched/cborg/types/lib/2bytes.d.ts +0 -68
  97. package/patched/cborg/types/lib/2bytes.d.ts.map +0 -1
  98. package/patched/cborg/types/lib/3string.d.ts +0 -46
  99. package/patched/cborg/types/lib/3string.d.ts.map +0 -1
  100. package/patched/cborg/types/lib/4array.d.ts +0 -65
  101. package/patched/cborg/types/lib/4array.d.ts.map +0 -1
  102. package/patched/cborg/types/lib/5map.d.ts +0 -65
  103. package/patched/cborg/types/lib/5map.d.ts.map +0 -1
  104. package/patched/cborg/types/lib/6tag.d.ts +0 -61
  105. package/patched/cborg/types/lib/6tag.d.ts.map +0 -1
  106. package/patched/cborg/types/lib/7float.d.ts +0 -60
  107. package/patched/cborg/types/lib/7float.d.ts.map +0 -1
  108. package/patched/cborg/types/lib/bin.d.ts +0 -4
  109. package/patched/cborg/types/lib/bin.d.ts.map +0 -1
  110. package/patched/cborg/types/lib/bl.d.ts +0 -26
  111. package/patched/cborg/types/lib/bl.d.ts.map +0 -1
  112. package/patched/cborg/types/lib/byte-utils.d.ts +0 -53
  113. package/patched/cborg/types/lib/byte-utils.d.ts.map +0 -1
  114. package/patched/cborg/types/lib/common.d.ts +0 -10
  115. package/patched/cborg/types/lib/common.d.ts.map +0 -1
  116. package/patched/cborg/types/lib/decode.d.ts +0 -41
  117. package/patched/cborg/types/lib/decode.d.ts.map +0 -1
  118. package/patched/cborg/types/lib/diagnostic.d.ts +0 -12
  119. package/patched/cborg/types/lib/diagnostic.d.ts.map +0 -1
  120. package/patched/cborg/types/lib/diagnostic_test.d.ts +0 -2
  121. package/patched/cborg/types/lib/diagnostic_test.d.ts.map +0 -1
  122. package/patched/cborg/types/lib/encode.d.ts +0 -50
  123. package/patched/cborg/types/lib/encode.d.ts.map +0 -1
  124. package/patched/cborg/types/lib/is.d.ts +0 -6
  125. package/patched/cborg/types/lib/is.d.ts.map +0 -1
  126. package/patched/cborg/types/lib/json/decode.d.ts +0 -67
  127. package/patched/cborg/types/lib/json/decode.d.ts.map +0 -1
  128. package/patched/cborg/types/lib/json/encode.d.ts +0 -11
  129. package/patched/cborg/types/lib/json/encode.d.ts.map +0 -1
  130. package/patched/cborg/types/lib/json/forward-cborg.d.ts +0 -6
  131. package/patched/cborg/types/lib/json/forward-cborg.d.ts.map +0 -1
  132. package/patched/cborg/types/lib/json/json.d.ts +0 -6
  133. package/patched/cborg/types/lib/json/json.d.ts.map +0 -1
  134. package/patched/cborg/types/lib/jump.d.ts +0 -12
  135. package/patched/cborg/types/lib/jump.d.ts.map +0 -1
  136. package/patched/cborg/types/lib/length.d.ts +0 -27
  137. package/patched/cborg/types/lib/length.d.ts.map +0 -1
  138. package/patched/cborg/types/lib/token.d.ts +0 -59
  139. package/patched/cborg/types/lib/token.d.ts.map +0 -1
  140. package/patched/cborg/types/taglib.d.ts +0 -18
  141. package/patched/cborg/types/taglib.d.ts.map +0 -1
  142. package/patched/cborg/types/tsconfig.tsbuildinfo +0 -1
  143. package/src/@ipld/car/car/LICENSE +0 -4
  144. package/src/@ipld/car/car/README.md +0 -1078
  145. package/src/@ipld/car/car/dist/index.min.js +0 -5
  146. package/src/@ipld/car/car/dist/src/api.d.ts +0 -72
  147. package/src/@ipld/car/car/dist/src/api.d.ts.map +0 -1
  148. package/src/@ipld/car/car/dist/src/buffer-decoder.d.ts +0 -67
  149. package/src/@ipld/car/car/dist/src/buffer-decoder.d.ts.map +0 -1
  150. package/src/@ipld/car/car/dist/src/buffer-reader-browser.d.ts +0 -116
  151. package/src/@ipld/car/car/dist/src/buffer-reader-browser.d.ts.map +0 -1
  152. package/src/@ipld/car/car/dist/src/buffer-reader.d.ts +0 -31
  153. package/src/@ipld/car/car/dist/src/buffer-reader.d.ts.map +0 -1
  154. package/src/@ipld/car/car/dist/src/buffer-writer.d.ts +0 -86
  155. package/src/@ipld/car/car/dist/src/buffer-writer.d.ts.map +0 -1
  156. package/src/@ipld/car/car/dist/src/coding.d.ts +0 -49
  157. package/src/@ipld/car/car/dist/src/coding.d.ts.map +0 -1
  158. package/src/@ipld/car/car/dist/src/decoder-common.d.ts +0 -43
  159. package/src/@ipld/car/car/dist/src/decoder-common.d.ts.map +0 -1
  160. package/src/@ipld/car/car/dist/src/decoder.d.ts +0 -87
  161. package/src/@ipld/car/car/dist/src/decoder.d.ts.map +0 -1
  162. package/src/@ipld/car/car/dist/src/encoder.d.ts +0 -17
  163. package/src/@ipld/car/car/dist/src/encoder.d.ts.map +0 -1
  164. package/src/@ipld/car/car/dist/src/header-validator.d.ts +0 -5
  165. package/src/@ipld/car/car/dist/src/header-validator.d.ts.map +0 -1
  166. package/src/@ipld/car/car/dist/src/index-browser.d.ts +0 -10
  167. package/src/@ipld/car/car/dist/src/index-browser.d.ts.map +0 -1
  168. package/src/@ipld/car/car/dist/src/index.d.ts +0 -11
  169. package/src/@ipld/car/car/dist/src/index.d.ts.map +0 -1
  170. package/src/@ipld/car/car/dist/src/indexed-reader-browser.d.ts +0 -5
  171. package/src/@ipld/car/car/dist/src/indexed-reader-browser.d.ts.map +0 -1
  172. package/src/@ipld/car/car/dist/src/indexed-reader.d.ts +0 -152
  173. package/src/@ipld/car/car/dist/src/indexed-reader.d.ts.map +0 -1
  174. package/src/@ipld/car/car/dist/src/indexer.d.ts +0 -95
  175. package/src/@ipld/car/car/dist/src/indexer.d.ts.map +0 -1
  176. package/src/@ipld/car/car/dist/src/iterator-channel.d.ts +0 -7
  177. package/src/@ipld/car/car/dist/src/iterator-channel.d.ts.map +0 -1
  178. package/src/@ipld/car/car/dist/src/iterator.d.ts +0 -174
  179. package/src/@ipld/car/car/dist/src/iterator.d.ts.map +0 -1
  180. package/src/@ipld/car/car/dist/src/reader-browser.d.ts +0 -151
  181. package/src/@ipld/car/car/dist/src/reader-browser.d.ts.map +0 -1
  182. package/src/@ipld/car/car/dist/src/reader.d.ts +0 -35
  183. package/src/@ipld/car/car/dist/src/reader.d.ts.map +0 -1
  184. package/src/@ipld/car/car/dist/src/writer-browser.d.ts +0 -155
  185. package/src/@ipld/car/car/dist/src/writer-browser.d.ts.map +0 -1
  186. package/src/@ipld/car/car/dist/src/writer.d.ts +0 -45
  187. package/src/@ipld/car/car/dist/src/writer.d.ts.map +0 -1
  188. package/src/@ipld/car/car/node_modules/.bin/cborg +0 -17
  189. package/src/@ipld/car/car/package.json +0 -235
  190. package/src/@ipld/car/car/src/api.ts +0 -90
  191. package/src/@ipld/car/car/src/buffer-decoder.js +0 -213
  192. package/src/@ipld/car/car/src/buffer-reader-browser.js +0 -144
  193. package/src/@ipld/car/car/src/buffer-reader.js +0 -51
  194. package/src/@ipld/car/car/src/buffer-writer.js +0 -286
  195. package/src/@ipld/car/car/src/coding.ts +0 -68
  196. package/src/@ipld/car/car/src/decoder-common.js +0 -82
  197. package/src/@ipld/car/car/src/decoder.js +0 -347
  198. package/src/@ipld/car/car/src/encoder.js +0 -76
  199. package/src/@ipld/car/car/src/header-validator.js +0 -214
  200. package/src/@ipld/car/car/src/header.ipldsch +0 -18
  201. package/src/@ipld/car/car/src/index-browser.js +0 -18
  202. package/src/@ipld/car/car/src/index.js +0 -21
  203. package/src/@ipld/car/car/src/indexed-reader-browser.js +0 -7
  204. package/src/@ipld/car/car/src/indexed-reader.js +0 -211
  205. package/src/@ipld/car/car/src/indexer.js +0 -130
  206. package/src/@ipld/car/car/src/iterator-channel.js +0 -91
  207. package/src/@ipld/car/car/src/iterator.js +0 -267
  208. package/src/@ipld/car/car/src/reader-browser.js +0 -194
  209. package/src/@ipld/car/car/src/reader.js +0 -56
  210. package/src/@ipld/car/car/src/writer-browser.js +0 -250
  211. package/src/@ipld/car/car/src/writer.js +0 -84
  212. package/src/@ipld/dag-cbor/dag-cbor/LICENSE +0 -4
  213. package/src/@ipld/dag-cbor/dag-cbor/README.md +0 -80
  214. package/src/@ipld/dag-cbor/dag-cbor/dist/index.min.js +0 -3
  215. package/src/@ipld/dag-cbor/dag-cbor/dist/src/index.d.ts +0 -67
  216. package/src/@ipld/dag-cbor/dag-cbor/dist/src/index.d.ts.map +0 -1
  217. package/src/@ipld/dag-cbor/dag-cbor/node_modules/.bin/cborg +0 -17
  218. package/src/@ipld/dag-cbor/dag-cbor/package.json +0 -171
  219. package/src/@ipld/dag-cbor/dag-cbor/src/index.js +0 -147
  220. package/src/@ipld/dag-json/dag-json/LICENSE +0 -4
  221. package/src/@ipld/dag-json/dag-json/README.md +0 -58
  222. package/src/@ipld/dag-json/dag-json/dist/index.min.js +0 -3
  223. package/src/@ipld/dag-json/dag-json/dist/src/index.d.ts +0 -12
  224. package/src/@ipld/dag-json/dag-json/dist/src/index.d.ts.map +0 -1
  225. package/src/@ipld/dag-json/dag-json/node_modules/.bin/cborg +0 -17
  226. package/src/@ipld/dag-json/dag-json/package.json +0 -173
  227. package/src/@ipld/dag-json/dag-json/src/index.js +0 -291
  228. package/src/@web3-storage/pail/pail/LICENSE.md +0 -232
  229. package/src/@web3-storage/pail/pail/README.md +0 -84
  230. package/src/@web3-storage/pail/pail/cli.js +0 -218
  231. package/src/@web3-storage/pail/pail/dist/src/api.d.ts +0 -59
  232. package/src/@web3-storage/pail/pail/dist/src/api.d.ts.map +0 -1
  233. package/src/@web3-storage/pail/pail/dist/src/batch/api.d.ts +0 -31
  234. package/src/@web3-storage/pail/pail/dist/src/batch/api.d.ts.map +0 -1
  235. package/src/@web3-storage/pail/pail/dist/src/batch/index.d.ts +0 -75
  236. package/src/@web3-storage/pail/pail/dist/src/batch/index.d.ts.map +0 -1
  237. package/src/@web3-storage/pail/pail/dist/src/batch/shard.d.ts +0 -3
  238. package/src/@web3-storage/pail/pail/dist/src/batch/shard.d.ts.map +0 -1
  239. package/src/@web3-storage/pail/pail/dist/src/block.d.ts +0 -35
  240. package/src/@web3-storage/pail/pail/dist/src/block.d.ts.map +0 -1
  241. package/src/@web3-storage/pail/pail/dist/src/clock/api.d.ts +0 -10
  242. package/src/@web3-storage/pail/pail/dist/src/clock/api.d.ts.map +0 -1
  243. package/src/@web3-storage/pail/pail/dist/src/clock/index.d.ts +0 -48
  244. package/src/@web3-storage/pail/pail/dist/src/clock/index.d.ts.map +0 -1
  245. package/src/@web3-storage/pail/pail/dist/src/crdt/api.d.ts +0 -26
  246. package/src/@web3-storage/pail/pail/dist/src/crdt/api.d.ts.map +0 -1
  247. package/src/@web3-storage/pail/pail/dist/src/crdt/batch/api.d.ts +0 -11
  248. package/src/@web3-storage/pail/pail/dist/src/crdt/batch/api.d.ts.map +0 -1
  249. package/src/@web3-storage/pail/pail/dist/src/crdt/batch/index.d.ts +0 -5
  250. package/src/@web3-storage/pail/pail/dist/src/crdt/batch/index.d.ts.map +0 -1
  251. package/src/@web3-storage/pail/pail/dist/src/crdt/index.d.ts +0 -9
  252. package/src/@web3-storage/pail/pail/dist/src/crdt/index.d.ts.map +0 -1
  253. package/src/@web3-storage/pail/pail/dist/src/diff.d.ts +0 -13
  254. package/src/@web3-storage/pail/pail/dist/src/diff.d.ts.map +0 -1
  255. package/src/@web3-storage/pail/pail/dist/src/index.d.ts +0 -10
  256. package/src/@web3-storage/pail/pail/dist/src/index.d.ts.map +0 -1
  257. package/src/@web3-storage/pail/pail/dist/src/merge.d.ts +0 -5
  258. package/src/@web3-storage/pail/pail/dist/src/merge.d.ts.map +0 -1
  259. package/src/@web3-storage/pail/pail/dist/src/shard.d.ts +0 -43
  260. package/src/@web3-storage/pail/pail/dist/src/shard.d.ts.map +0 -1
  261. package/src/@web3-storage/pail/pail/dist/tsconfig.tsbuildinfo +0 -1
  262. package/src/@web3-storage/pail/pail/node_modules/.bin/pail +0 -17
  263. package/src/@web3-storage/pail/pail/package.json +0 -173
  264. package/src/@web3-storage/pail/pail/src/api.js +0 -1
  265. package/src/@web3-storage/pail/pail/src/api.ts +0 -90
  266. package/src/@web3-storage/pail/pail/src/batch/api.js +0 -1
  267. package/src/@web3-storage/pail/pail/src/batch/api.ts +0 -59
  268. package/src/@web3-storage/pail/pail/src/batch/index.js +0 -258
  269. package/src/@web3-storage/pail/pail/src/batch/shard.js +0 -13
  270. package/src/@web3-storage/pail/pail/src/block.js +0 -75
  271. package/src/@web3-storage/pail/pail/src/clock/api.js +0 -1
  272. package/src/@web3-storage/pail/pail/src/clock/api.ts +0 -12
  273. package/src/@web3-storage/pail/pail/src/clock/index.js +0 -182
  274. package/src/@web3-storage/pail/pail/src/crdt/api.js +0 -1
  275. package/src/@web3-storage/pail/pail/src/crdt/api.ts +0 -33
  276. package/src/@web3-storage/pail/pail/src/crdt/batch/api.js +0 -1
  277. package/src/@web3-storage/pail/pail/src/crdt/batch/api.ts +0 -30
  278. package/src/@web3-storage/pail/pail/src/crdt/batch/index.js +0 -155
  279. package/src/@web3-storage/pail/pail/src/crdt/index.js +0 -354
  280. package/src/@web3-storage/pail/pail/src/diff.js +0 -151
  281. package/src/@web3-storage/pail/pail/src/index.js +0 -406
  282. package/src/@web3-storage/pail/pail/src/merge.js +0 -43
  283. package/src/@web3-storage/pail/pail/src/shard.js +0 -180
  284. package/src/cborg/cborg/.github/dependabot.yml +0 -16
  285. package/src/cborg/cborg/.github/workflows/test-and-release.yml +0 -52
  286. package/src/cborg/cborg/CHANGELOG.md +0 -513
  287. package/src/cborg/cborg/LICENSE +0 -13
  288. package/src/cborg/cborg/README.md +0 -515
  289. package/src/cborg/cborg/bench/bench.js +0 -117
  290. package/src/cborg/cborg/bench/json.js +0 -124
  291. package/src/cborg/cborg/bench/package.json +0 -8
  292. package/src/cborg/cborg/cborg.js +0 -31
  293. package/src/cborg/cborg/example-bytestrings.js +0 -180
  294. package/src/cborg/cborg/example-json.js +0 -6
  295. package/src/cborg/cborg/example.js +0 -5
  296. package/src/cborg/cborg/interface.ts +0 -56
  297. package/src/cborg/cborg/lib/0uint.js +0 -227
  298. package/src/cborg/cborg/lib/1negint.js +0 -111
  299. package/src/cborg/cborg/lib/2bytes.js +0 -133
  300. package/src/cborg/cborg/lib/3string.js +0 -90
  301. package/src/cborg/cborg/lib/4array.js +0 -113
  302. package/src/cborg/cborg/lib/5map.js +0 -113
  303. package/src/cborg/cborg/lib/6tag.js +0 -80
  304. package/src/cborg/cborg/lib/7float.js +0 -308
  305. package/src/cborg/cborg/lib/bin.js +0 -189
  306. package/src/cborg/cborg/lib/bl.js +0 -124
  307. package/src/cborg/cborg/lib/byte-utils.js +0 -417
  308. package/src/cborg/cborg/lib/common.js +0 -27
  309. package/src/cborg/cborg/lib/decode.js +0 -209
  310. package/src/cborg/cborg/lib/diagnostic.js +0 -156
  311. package/src/cborg/cborg/lib/diagnostic_test.js +0 -117
  312. package/src/cborg/cborg/lib/encode.js +0 -464
  313. package/src/cborg/cborg/lib/is.js +0 -106
  314. package/src/cborg/cborg/lib/json/decode.js +0 -462
  315. package/src/cborg/cborg/lib/json/encode.js +0 -299
  316. package/src/cborg/cborg/lib/json/json.js +0 -4
  317. package/src/cborg/cborg/lib/jump.js +0 -209
  318. package/src/cborg/cborg/lib/length.js +0 -61
  319. package/src/cborg/cborg/lib/token.js +0 -76
  320. package/src/cborg/cborg/node_modules/.bin/cborg +0 -17
  321. package/src/cborg/cborg/package.json +0 -168
  322. package/src/cborg/cborg/taglib.js +0 -73
  323. package/src/cborg/cborg/test/appendix_a.js +0 -647
  324. package/src/cborg/cborg/test/common.js +0 -18
  325. package/src/cborg/cborg/test/node-test-bin.js +0 -402
  326. package/src/cborg/cborg/test/noop-bin-test.js +0 -3
  327. package/src/cborg/cborg/test/test-0uint.js +0 -103
  328. package/src/cborg/cborg/test/test-1negint.js +0 -96
  329. package/src/cborg/cborg/test/test-2bytes.js +0 -198
  330. package/src/cborg/cborg/test/test-3string.js +0 -136
  331. package/src/cborg/cborg/test/test-4array.js +0 -93
  332. package/src/cborg/cborg/test/test-5map.js +0 -284
  333. package/src/cborg/cborg/test/test-6tag.js +0 -85
  334. package/src/cborg/cborg/test/test-7float.js +0 -131
  335. package/src/cborg/cborg/test/test-bl.js +0 -37
  336. package/src/cborg/cborg/test/test-cbor-vectors.js +0 -107
  337. package/src/cborg/cborg/test/test-decode-errors.js +0 -65
  338. package/src/cborg/cborg/test/test-fuzz.js +0 -42
  339. package/src/cborg/cborg/test/test-json.js +0 -219
  340. package/src/cborg/cborg/test/test-length.js +0 -65
  341. package/src/cborg/cborg/test/test-partial.js +0 -111
  342. package/src/cborg/cborg/tsconfig.json +0 -45
  343. package/src/cborg/cborg/types/cborg.d.ts +0 -28
  344. package/src/cborg/cborg/types/cborg.d.ts.map +0 -1
  345. package/src/cborg/cborg/types/example.d.ts +0 -2
  346. package/src/cborg/cborg/types/example.d.ts.map +0 -1
  347. package/src/cborg/cborg/types/interface.d.ts +0 -47
  348. package/src/cborg/cborg/types/interface.d.ts.map +0 -1
  349. package/src/cborg/cborg/types/lib/0uint.d.ts +0 -100
  350. package/src/cborg/cborg/types/lib/0uint.d.ts.map +0 -1
  351. package/src/cborg/cborg/types/lib/1negint.d.ts +0 -58
  352. package/src/cborg/cborg/types/lib/1negint.d.ts.map +0 -1
  353. package/src/cborg/cborg/types/lib/2bytes.d.ts +0 -68
  354. package/src/cborg/cborg/types/lib/2bytes.d.ts.map +0 -1
  355. package/src/cborg/cborg/types/lib/3string.d.ts +0 -46
  356. package/src/cborg/cborg/types/lib/3string.d.ts.map +0 -1
  357. package/src/cborg/cborg/types/lib/4array.d.ts +0 -65
  358. package/src/cborg/cborg/types/lib/4array.d.ts.map +0 -1
  359. package/src/cborg/cborg/types/lib/5map.d.ts +0 -65
  360. package/src/cborg/cborg/types/lib/5map.d.ts.map +0 -1
  361. package/src/cborg/cborg/types/lib/6tag.d.ts +0 -61
  362. package/src/cborg/cborg/types/lib/6tag.d.ts.map +0 -1
  363. package/src/cborg/cborg/types/lib/7float.d.ts +0 -60
  364. package/src/cborg/cborg/types/lib/7float.d.ts.map +0 -1
  365. package/src/cborg/cborg/types/lib/bin.d.ts +0 -4
  366. package/src/cborg/cborg/types/lib/bin.d.ts.map +0 -1
  367. package/src/cborg/cborg/types/lib/bl.d.ts +0 -26
  368. package/src/cborg/cborg/types/lib/bl.d.ts.map +0 -1
  369. package/src/cborg/cborg/types/lib/byte-utils.d.ts +0 -53
  370. package/src/cborg/cborg/types/lib/byte-utils.d.ts.map +0 -1
  371. package/src/cborg/cborg/types/lib/common.d.ts +0 -10
  372. package/src/cborg/cborg/types/lib/common.d.ts.map +0 -1
  373. package/src/cborg/cborg/types/lib/decode.d.ts +0 -41
  374. package/src/cborg/cborg/types/lib/decode.d.ts.map +0 -1
  375. package/src/cborg/cborg/types/lib/diagnostic.d.ts +0 -12
  376. package/src/cborg/cborg/types/lib/diagnostic.d.ts.map +0 -1
  377. package/src/cborg/cborg/types/lib/diagnostic_test.d.ts +0 -2
  378. package/src/cborg/cborg/types/lib/diagnostic_test.d.ts.map +0 -1
  379. package/src/cborg/cborg/types/lib/encode.d.ts +0 -50
  380. package/src/cborg/cborg/types/lib/encode.d.ts.map +0 -1
  381. package/src/cborg/cborg/types/lib/is.d.ts +0 -6
  382. package/src/cborg/cborg/types/lib/is.d.ts.map +0 -1
  383. package/src/cborg/cborg/types/lib/json/decode.d.ts +0 -67
  384. package/src/cborg/cborg/types/lib/json/decode.d.ts.map +0 -1
  385. package/src/cborg/cborg/types/lib/json/encode.d.ts +0 -11
  386. package/src/cborg/cborg/types/lib/json/encode.d.ts.map +0 -1
  387. package/src/cborg/cborg/types/lib/json/forward-cborg.d.ts +0 -6
  388. package/src/cborg/cborg/types/lib/json/forward-cborg.d.ts.map +0 -1
  389. package/src/cborg/cborg/types/lib/json/json.d.ts +0 -6
  390. package/src/cborg/cborg/types/lib/json/json.d.ts.map +0 -1
  391. package/src/cborg/cborg/types/lib/jump.d.ts +0 -12
  392. package/src/cborg/cborg/types/lib/jump.d.ts.map +0 -1
  393. package/src/cborg/cborg/types/lib/length.d.ts +0 -27
  394. package/src/cborg/cborg/types/lib/length.d.ts.map +0 -1
  395. package/src/cborg/cborg/types/lib/token.d.ts +0 -59
  396. package/src/cborg/cborg/types/lib/token.d.ts.map +0 -1
  397. package/src/cborg/cborg/types/taglib.d.ts +0 -18
  398. package/src/cborg/cborg/types/taglib.d.ts.map +0 -1
  399. package/src/cborg/cborg/types/tsconfig.tsbuildinfo +0 -1
  400. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/LICENSE +0 -4
  401. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/README.md +0 -105
  402. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/index.min.js +0 -3
  403. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.d.ts +0 -57
  404. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.d.ts.map +0 -1
  405. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.js +0 -73
  406. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.js.map +0 -1
  407. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.d.ts +0 -355
  408. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.d.ts.map +0 -1
  409. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.js +0 -197
  410. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.js.map +0 -1
  411. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts +0 -4
  412. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts.map +0 -1
  413. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js +0 -9
  414. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js.map +0 -1
  415. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts +0 -4
  416. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts.map +0 -1
  417. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js +0 -9
  418. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js.map +0 -1
  419. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts +0 -4
  420. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts.map +0 -1
  421. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.js +0 -38
  422. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.js.map +0 -1
  423. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts +0 -4
  424. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts.map +0 -1
  425. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.js +0 -30
  426. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.js.map +0 -1
  427. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts +0 -4
  428. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts.map +0 -1
  429. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.js +0 -9
  430. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.js.map +0 -1
  431. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts +0 -4
  432. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts.map +0 -1
  433. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.js +0 -37
  434. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.js.map +0 -1
  435. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts +0 -4
  436. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts.map +0 -1
  437. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js +0 -29
  438. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js.map +0 -1
  439. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts +0 -4
  440. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts.map +0 -1
  441. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js +0 -153
  442. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js.map +0 -1
  443. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +0 -4
  444. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +0 -1
  445. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +0 -59
  446. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +0 -1
  447. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts +0 -4
  448. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts.map +0 -1
  449. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js +0 -25
  450. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js.map +0 -1
  451. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts +0 -4
  452. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts.map +0 -1
  453. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js +0 -104
  454. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js.map +0 -1
  455. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts +0 -3
  456. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts.map +0 -1
  457. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js +0 -20
  458. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js.map +0 -1
  459. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts +0 -6
  460. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts.map +0 -1
  461. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js +0 -116
  462. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js.map +0 -1
  463. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts +0 -4
  464. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts.map +0 -1
  465. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js +0 -57
  466. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js.map +0 -1
  467. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts +0 -6
  468. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts.map +0 -1
  469. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js +0 -30
  470. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js.map +0 -1
  471. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/typedoc-urls.json +0 -58
  472. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/package.json +0 -180
  473. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/errors.ts +0 -87
  474. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/index.ts +0 -498
  475. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/dag-cbor.ts +0 -12
  476. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/dag-json.ts +0 -12
  477. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/identity.ts +0 -49
  478. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/index.ts +0 -35
  479. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/json.ts +0 -12
  480. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/raw.ts +0 -49
  481. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/directory.ts +0 -39
  482. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.ts +0 -198
  483. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +0 -76
  484. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/raw.ts +0 -37
  485. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.ts +0 -121
  486. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/extract-data-from-block.ts +0 -24
  487. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.ts +0 -149
  488. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/resolve-object-path.ts +0 -62
  489. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/validate-offset-and-length.ts +0 -38
@@ -1,1078 +0,0 @@
1
- # @ipld/car
2
-
3
- [![codecov](https://img.shields.io/codecov/c/github/ipld/js-car.svg?style=flat-square)](https://codecov.io/gh/ipld/js-car)
4
- [![CI](https://img.shields.io/github/actions/workflow/status/ipld/js-car/js-test-and-release.yml?branch=master&style=flat-square)](https://github.com/ipld/js-car/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
5
-
6
- > Content Addressable aRchive format reader and writer
7
-
8
- ## Install
9
-
10
- ```console
11
- $ npm i @ipld/car
12
- ```
13
-
14
- See also:
15
-
16
- - Original [Go implementation](https://github.com/ipfs/go-car)
17
- - [CAR specification](https://github.com/ipld/specs/blob/master/block-layer/content-addressable-archives.md)
18
- - [IPLD](https://ipld.io)
19
-
20
- ## Contents
21
-
22
- - [Example](#example)
23
- - [Usage](#usage)
24
- - [API](#api)
25
- - [License](#license)
26
-
27
- ## Example
28
-
29
- ```js
30
- // Create a simple .car file with a single block and that block's CID as the
31
- // single root. Then read the .car and fetch the block again.
32
-
33
- import fs from 'fs'
34
- import { Readable } from 'stream'
35
- import { CarReader, CarWriter } from '@ipld/car'
36
- import * as raw from 'multiformats/codecs/raw'
37
- import { CID } from 'multiformats/cid'
38
- import { sha256 } from 'multiformats/hashes/sha2'
39
-
40
- async function example() {
41
- const bytes = new TextEncoder().encode('random meaningless bytes')
42
- const hash = await sha256.digest(raw.encode(bytes))
43
- const cid = CID.create(1, raw.code, hash)
44
-
45
- // create the writer and set the header with a single root
46
- const { writer, out } = await CarWriter.create([cid])
47
- Readable.from(out).pipe(fs.createWriteStream('example.car'))
48
-
49
- // store a new block, creates a new file entry in the CAR archive
50
- await writer.put({ cid, bytes })
51
- await writer.close()
52
-
53
- const inStream = fs.createReadStream('example.car')
54
- // read and parse the entire stream in one go, this will cache the contents of
55
- // the car in memory so is not suitable for large files.
56
- const reader = await CarReader.fromIterable(inStream)
57
-
58
- // read the list of roots from the header
59
- const roots = await reader.getRoots()
60
- // retrieve a block, as a { cid:CID, bytes:UInt8Array } pair from the archive
61
- const got = await reader.get(roots[0])
62
- // also possible: for await (const { cid, bytes } of CarIterator.fromIterable(inStream)) { ... }
63
-
64
- console.log(
65
- 'Retrieved [%s] from example.car with CID [%s]',
66
- new TextDecoder().decode(got.bytes),
67
- roots[0].toString()
68
- )
69
- }
70
-
71
- example().catch((err) => {
72
- console.error(err)
73
- process.exit(1)
74
- })
75
- ```
76
-
77
- Will output:
78
-
79
- ```
80
- Retrieved [random meaningless bytes] from example.car with CID [bafkreihwkf6mtnjobdqrkiksr7qhp6tiiqywux64aylunbvmfhzeql2coa]
81
- ```
82
-
83
- See the [examples](./examples) directory for more.
84
-
85
- ## Usage
86
-
87
- `@ipld/car` is consumed through factory methods on its different classes. Each
88
- class represents a discrete set of functionality. You should select the classes
89
- that make the most sense for your use-case.
90
-
91
- Please be aware that `@ipld/car` **does not validate** that block data matches
92
- the paired CIDs when reading a CAR. See the
93
- [verify-car.js](./examples/verify-car.js) example for one possible approach to
94
- validating blocks as they are read. Any CID verification requires that the hash
95
- function that was used to generate the CID be available, the CAR format does
96
- not restrict the allowable multihashes.
97
-
98
- ### [`CarReader`](#CarReader)
99
-
100
- The basic `CarReader` class is consumed via:
101
-
102
- ```js
103
- import { CarReader } from '@ipld/car/reader'
104
- import { CarBufferReader } from '@ipld/car/buffer-reader'
105
- ```
106
-
107
- Or alternatively: `import { CarReader } from '@ipld/car'`. CommonJS `require`
108
- will also work for the same import paths and references.
109
-
110
- `CarReader` is useful for relatively small CAR archives as it buffers the
111
- entirety of the archive in memory to provide access to its data. This class is
112
- also suitable in a browser environment. The `CarReader` class provides
113
- random-access [`get(key)`](#CarReader_get) and [`has(key)`](#CarReader_has)
114
- methods as well as iterators for [`blocks()`](#CarReader_blocks)] and
115
- [`cids()`](#CarReader_cids)].
116
-
117
- `CarReader` can be instantiated from a
118
- [single `Uint8Array`](#CarReader__fromBytes) or from
119
- [an `AsyncIterable`](#CarReader__fromIterable) of `Uint8Array`s (note that
120
- Node.js streams are `AsyncIterable`s and can be consumed in this way).
121
-
122
- `CarBufferReader` works exactly the same way as `CarReader` but all methods are synchronous.
123
-
124
- ### [`CarIndexedReader`](#CarIndexedReader)
125
-
126
- The `CarIndexedReader` class is a special form of `CarReader` and can be
127
- consumed in **Node.js only** (not in the browser) via:
128
-
129
- ```js
130
- import { CarIndexedReader } from '@ipld/car/indexed-reader'
131
- ```
132
-
133
- Or alternatively: `import { CarIndexedReader } from '@ipld/car'`. CommonJS
134
- `require` will also work for the same import paths and references.
135
-
136
- A `CarIndexedReader` provides the same functionality as `CarReader` but is
137
- instantiated from [a path to a CAR file](#CarIndexedReader__fromFile) and also
138
- adds a [`close()`](#CarWriter_close) method that must be called when the reader
139
- is no longer required, to clean up resources.
140
-
141
- `CarIndexedReader` performs a single full-scan of a CAR file, collecting a list
142
- of `CID`s and their block positions in the archive. It then performs
143
- random-access reads when blocks are requested via `get()` and the `blocks()` and
144
- `cids()` iterators.
145
-
146
- This class may be sutiable for random-access (primarily via `has()` and `get()`)
147
- to relatively large CAR files.
148
-
149
- ### [`CarBlockIterator`](#CarBlockIterator) and [`CarCIDIterator`](#CarCIDIterator)
150
-
151
- ```js
152
- import { CarBlockIterator } from '@ipld/car/iterator'
153
- // or
154
- import { CarCIDIterator } from '@ipld/car/iterator'
155
- ```
156
-
157
- Or alternatively:
158
- `import { CarBlockIterator, CarCIDIterator } from '@ipld/car'`. CommonJS
159
- `require` will also work for the same import paths and references.
160
-
161
- These two classes provide `AsyncIterable`s to the blocks or just the `CIDs`
162
- contained within a CAR archive. These are efficient mechanisms for scanning an
163
- entire CAR archive, regardless of size, if random-access to blocks is not
164
- required.
165
-
166
- `CarBlockIterator` and `CarCIDIterator` can be instantiated from a
167
- single `Uint8Array` (see
168
- [`CarBlockIterator.fromBytes()`](#CarBlockIterator__fromBytes) and
169
- [`CarCIDIterator.fromBytes()`](#CarCIDIterator__fromBytes)) or from
170
- an `AsyncIterable` of `Uint8Array`s (see
171
- [`CarBlockIterator.fromIterable()`](#CarBlockIterator__fromIterable) and
172
- [`CarCIDIterator.fromIterable()`](#CarCIDIterator__fromIterable))—note that
173
- Node.js streams are `AsyncIterable`s and can be consumed in this way.
174
-
175
- ### [`CarIndexer`](#CarIndexer)
176
-
177
- The `CarIndexer` class can be used to scan a CAR archive and provide indexing
178
- data on the contents. It can be consumed via:
179
-
180
- ```js
181
- import CarIndexer from '@ipld/car/indexed-reader'
182
- ```
183
-
184
- Or alternatively: `import { CarIndexer } from '@ipld/car'`. CommonJS
185
- `require` will also work for the same import paths and references.
186
-
187
- This class is used within [`CarIndexedReader`](#CarIndexedReader) and is only
188
- useful in cases where an external index of a CAR needs to be generated and used.
189
-
190
- The index data can also be used with
191
- [`CarReader.readRaw()`](#CarReader__readRaw)] to fetch block data directly from
192
- a file descriptor using the index data for that block.
193
-
194
- ### [`CarWriter`](#CarWriter)
195
-
196
- A `CarWriter` is used to create new CAR archives. It can be consumed via:
197
-
198
- ```js
199
- import CarWriter from '@ipld/car/writer'
200
- ```
201
-
202
- Or alternatively: `import { CarWriter } from '@ipld/car'`. CommonJS
203
- `require` will also work for the same import paths and references.
204
-
205
- [Creation of a `CarWriter`](#CarWriter__create) involves a "channel", or a
206
- `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }` pair. The `writer` side
207
- of the channel is used to [`put()`](#CarWriter_put) blocks, while the `out`
208
- side of the channel emits the bytes that form the encoded CAR archive.
209
-
210
- In Node.js, you can use the
211
- [`Readable.from()`](https://nodejs.org/api/stream.html#stream_stream_readable_from_iterable_options)
212
- API to convert the `out` `AsyncIterable` to a standard Node.js stream, or it can
213
- be directly fed to a
214
- [`stream.pipeline()`](https://nodejs.org/api/stream.html#stream_stream_pipeline_source_transforms_destination_callback).
215
-
216
- ## API
217
-
218
- ### Contents
219
-
220
- * [`class CarReader`](#CarReader)
221
- * [`async CarReader#getRoots()`](#CarReader_getRoots)
222
- * [`async CarReader#has(key)`](#CarReader_has)
223
- * [`async CarReader#get(key)`](#CarReader_get)
224
- * [`async * CarReader#blocks()`](#CarReader_blocks)
225
- * [`async * CarReader#cids()`](#CarReader_cids)
226
- * [`async CarReader.fromBytes(bytes)`](#CarReader__fromBytes)
227
- * [`async CarReader.fromIterable(asyncIterable)`](#CarReader__fromIterable)
228
- * [`async CarReader.readRaw(fd, blockIndex)`](#CarReader__readRaw)
229
- * [`class CarIndexedReader`](#CarIndexedReader)
230
- * [`async CarIndexedReader#getRoots()`](#CarIndexedReader_getRoots)
231
- * [`async CarIndexedReader#has(key)`](#CarIndexedReader_has)
232
- * [`async CarIndexedReader#get(key)`](#CarIndexedReader_get)
233
- * [`async * CarIndexedReader#blocks()`](#CarIndexedReader_blocks)
234
- * [`async * CarIndexedReader#cids()`](#CarIndexedReader_cids)
235
- * [`async CarIndexedReader#close()`](#CarIndexedReader_close)
236
- * [`async CarIndexedReader.fromFile(path)`](#CarIndexedReader__fromFile)
237
- * [`class CarBlockIterator`](#CarBlockIterator)
238
- * [`async CarBlockIterator#getRoots()`](#CarBlockIterator_getRoots)
239
- * [`async CarBlockIterator.fromBytes(bytes)`](#CarBlockIterator__fromBytes)
240
- * [`async CarBlockIterator.fromIterable(asyncIterable)`](#CarBlockIterator__fromIterable)
241
- * [`class CarCIDIterator`](#CarCIDIterator)
242
- * [`async CarCIDIterator#getRoots()`](#CarCIDIterator_getRoots)
243
- * [`async CarCIDIterator.fromBytes(bytes)`](#CarCIDIterator__fromBytes)
244
- * [`async CarCIDIterator.fromIterable(asyncIterable)`](#CarCIDIterator__fromIterable)
245
- * [`class CarIndexer`](#CarIndexer)
246
- * [`async CarIndexer#getRoots()`](#CarIndexer_getRoots)
247
- * [`async CarIndexer.fromBytes(bytes)`](#CarIndexer__fromBytes)
248
- * [`async CarIndexer.fromIterable(asyncIterable)`](#CarIndexer__fromIterable)
249
- * [`class CarWriter`](#CarWriter)
250
- * [`async CarWriter#put(block)`](#CarWriter_put)
251
- * [`async CarWriter#close()`](#CarWriter_close)
252
- * [`CarWriter#version()`](#CarWriter_version)
253
- * [`async CarWriter.create(roots)`](#CarWriter__create)
254
- * [`async CarWriter.createAppender()`](#CarWriter__createAppender)
255
- * [`async CarWriter.updateRootsInBytes(bytes, roots)`](#CarWriter__updateRootsInBytes)
256
- * [`async CarWriter.updateRootsInFile(fd, roots)`](#CarWriter__updateRootsInFile)
257
- * [`class CarBufferWriter`](#CarBufferWriter)
258
- * [`CarBufferWriter#addRoot(root, options)`](#CarBufferWriter_addRoot)
259
- * [`CarBufferWriter#write(block)`](#CarBufferWriter_write)
260
- * [`CarBufferWriter#close([options])`](#CarBufferWriter_close)
261
- * [`CarBufferWriter.blockLength(Block)`](#CarBufferWriter__blockLength__Block__)
262
- * [`CarBufferWriter.calculateHeaderLength(rootLengths)`](#CarBufferWriter__calculateHeaderLength__rootLengths__)
263
- * [`CarBufferWriter.headerLength({ roots })`](#CarBufferWriter__headerLength______roots______)
264
- * [`CarBufferWriter.estimateHeaderLength(rootCount[, rootByteLength])`](#CarBufferWriter__estimateHeaderLength__rootCount______rootByteLength____)
265
- * [`CarBufferWriter.createWriter(buffer[, options])`](#CarBufferWriter__createWriter__buffer______options____)
266
- * [`async decoder.readHeader(reader)`](#async__decoder__readHeader__reader__)
267
- * [`async decoder.readBlockHead(reader)`](#async__decoder__readBlockHead__reader__)
268
- * [`decoder.createDecoder(reader)`](#decoder__createDecoder__reader__)
269
- * [`decoder.bytesReader(bytes)`](#decoder__bytesReader__bytes__)
270
- * [`decoder.asyncIterableReader(asyncIterable)`](#decoder__asyncIterableReader__asyncIterable__)
271
- * [`decoder.limitReader(reader, byteLimit)`](#decoder__limitReader__reader____byteLimit__)
272
- * [`class CarBufferReader`](#CarBufferReader)
273
- * [`CarBufferReader#getRoots()`](#CarBufferReader_getRoots)
274
- * [`CarBufferReader#has(key)`](#CarBufferReader_has)
275
- * [`CarBufferReader#get(key)`](#CarBufferReader_get)
276
- * [`CarBufferReader#blocks()`](#CarBufferReader_blocks)
277
- * [`CarBufferReader#cids()`](#CarBufferReader_cids)
278
- * [`CarBufferReader.fromBytes(bytes)`](#CarBufferReader__fromBytes)
279
- * [`CarBufferReader.readRaw(fd, blockIndex)`](#CarBufferReader__readRaw)
280
-
281
- <a name="CarReader"></a>
282
- ### `class CarReader`
283
-
284
- Properties:
285
-
286
- * `version` `(number)`: The version number of the CAR referenced by this
287
- reader (should be `1` or `2`).
288
-
289
- Provides blockstore-like access to a CAR.
290
-
291
- Implements the `RootsReader` interface:
292
- [`getRoots()`](#CarReader__getRoots). And the `BlockReader` interface:
293
- [`get()`](#CarReader__get), [`has()`](#CarReader__has),
294
- [`blocks()`](#CarReader__blocks) (defined as a `BlockIterator`) and
295
- [`cids()`](#CarReader__cids) (defined as a `CIDIterator`).
296
-
297
- Load this class with either `import { CarReader } from '@ipld/car/reader'`
298
- (`const { CarReader } = require('@ipld/car/reader')`). Or
299
- `import { CarReader } from '@ipld/car'` (`const { CarReader } = require('@ipld/car')`).
300
- The former will likely result in smaller bundle sizes where this is
301
- important.
302
-
303
- <a name="CarReader_getRoots"></a>
304
- ### `async CarReader#getRoots()`
305
-
306
- * Returns: `Promise<CID[]>`
307
-
308
- Get the list of roots defined by the CAR referenced by this reader. May be
309
- zero or more `CID`s.
310
-
311
- <a name="CarReader_has"></a>
312
- ### `async CarReader#has(key)`
313
-
314
- * `key` `(CID)`
315
-
316
- * Returns: `Promise<boolean>`
317
-
318
- Check whether a given `CID` exists within the CAR referenced by this
319
- reader.
320
-
321
- <a name="CarReader_get"></a>
322
- ### `async CarReader#get(key)`
323
-
324
- * `key` `(CID)`
325
-
326
- * Returns: `Promise<(Block|undefined)>`
327
-
328
- Fetch a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) from the CAR
329
- referenced by this reader matching the provided `CID`. In the case where
330
- the provided `CID` doesn't exist within the CAR, `undefined` will be
331
- returned.
332
-
333
- <a name="CarReader_blocks"></a>
334
- ### `async * CarReader#blocks()`
335
-
336
- * Returns: `AsyncGenerator<Block>`
337
-
338
- Returns a `BlockIterator` (`AsyncIterable<Block>`) that iterates over all
339
- of the `Block`s (`{ cid:CID, bytes:Uint8Array }` pairs) contained within
340
- the CAR referenced by this reader.
341
-
342
- <a name="CarReader_cids"></a>
343
- ### `async * CarReader#cids()`
344
-
345
- * Returns: `AsyncGenerator<CID>`
346
-
347
- Returns a `CIDIterator` (`AsyncIterable<CID>`) that iterates over all of
348
- the `CID`s contained within the CAR referenced by this reader.
349
-
350
- <a name="CarReader__fromBytes"></a>
351
- ### `async CarReader.fromBytes(bytes)`
352
-
353
- * `bytes` `(Uint8Array)`
354
-
355
- * Returns: `Promise<CarReader>`
356
-
357
- Instantiate a [`CarReader`](#CarReader) from a `Uint8Array` blob. This performs a
358
- decode fully in memory and maintains the decoded state in memory for full
359
- access to the data via the `CarReader` API.
360
-
361
- <a name="CarReader__fromIterable"></a>
362
- ### `async CarReader.fromIterable(asyncIterable)`
363
-
364
- * `asyncIterable` `(AsyncIterable<Uint8Array>)`
365
-
366
- * Returns: `Promise<CarReader>`
367
-
368
- Instantiate a [`CarReader`](#CarReader) from a `AsyncIterable<Uint8Array>`, such as
369
- a [modern Node.js stream](https://nodejs.org/api/stream.html#stream_streams_compatibility_with_async_generators_and_async_iterators).
370
- This performs a decode fully in memory and maintains the decoded state in
371
- memory for full access to the data via the `CarReader` API.
372
-
373
- Care should be taken for large archives; this API may not be appropriate
374
- where memory is a concern or the archive is potentially larger than the
375
- amount of memory that the runtime can handle.
376
-
377
- <a name="CarReader__readRaw"></a>
378
- ### `async CarReader.readRaw(fd, blockIndex)`
379
-
380
- * `fd` `(fs.promises.FileHandle|number)`: A file descriptor from the
381
- Node.js `fs` module. Either an integer, from `fs.open()` or a `FileHandle`
382
- from `fs.promises.open()`.
383
- * `blockIndex` `(BlockIndex)`: An index pointing to the location of the
384
- Block required. This `BlockIndex` should take the form:
385
- `{cid:CID, blockLength:number, blockOffset:number}`.
386
-
387
- * Returns: `Promise<Block>`: A `{ cid:CID, bytes:Uint8Array }` pair.
388
-
389
- Reads a block directly from a file descriptor for an open CAR file. This
390
- function is **only available in Node.js** and not a browser environment.
391
-
392
- This function can be used in connection with [`CarIndexer`](#CarIndexer) which emits
393
- the `BlockIndex` objects that are required by this function.
394
-
395
- The user is responsible for opening and closing the file used in this call.
396
-
397
- <a name="CarIndexedReader"></a>
398
- ### `class CarIndexedReader`
399
-
400
- Properties:
401
-
402
- * `version` `(number)`: The version number of the CAR referenced by this
403
- reader (should be `1`).
404
-
405
- A form of [`CarReader`](#CarReader) that pre-indexes a CAR archive from a file and
406
- provides random access to blocks within the file using the index data. This
407
- function is **only available in Node.js** and not a browser environment.
408
-
409
- For large CAR files, using this form of `CarReader` can be singificantly more
410
- efficient in terms of memory. The index consists of a list of `CID`s and
411
- their location within the archive (see [`CarIndexer`](#CarIndexer)). For large numbers
412
- of blocks, this index can also occupy a significant amount of memory. In some
413
- cases it may be necessary to expand the memory capacity of a Node.js instance
414
- to allow this index to fit. (e.g. by running with
415
- `NODE_OPTIONS="--max-old-space-size=16384"`).
416
-
417
- As an `CarIndexedReader` instance maintains an open file descriptor for its
418
- CAR file, an additional [`CarReader#close`](#CarReader_close) method is attached. This
419
- _must_ be called to have full clean-up of resources after use.
420
-
421
- Load this class with either
422
- `import { CarIndexedReader } from '@ipld/car/indexed-reader'`
423
- (`const { CarIndexedReader } = require('@ipld/car/indexed-reader')`). Or
424
- `import { CarIndexedReader } from '@ipld/car'`
425
- (`const { CarIndexedReader } = require('@ipld/car')`). The former will likely
426
- result in smaller bundle sizes where this is important.
427
-
428
- <a name="CarIndexedReader_getRoots"></a>
429
- ### `async CarIndexedReader#getRoots()`
430
-
431
- * Returns: `Promise<CID[]>`
432
-
433
- See [`CarReader#getRoots`](#CarReader_getRoots)
434
-
435
- <a name="CarIndexedReader_has"></a>
436
- ### `async CarIndexedReader#has(key)`
437
-
438
- * `key` `(CID)`
439
-
440
- * Returns: `Promise<boolean>`
441
-
442
- See [`CarReader#has`](#CarReader_has)
443
-
444
- <a name="CarIndexedReader_get"></a>
445
- ### `async CarIndexedReader#get(key)`
446
-
447
- * `key` `(CID)`
448
-
449
- * Returns: `Promise<(Block|undefined)>`
450
-
451
- See [`CarReader#get`](#CarReader_get)
452
-
453
- <a name="CarIndexedReader_blocks"></a>
454
- ### `async * CarIndexedReader#blocks()`
455
-
456
- * Returns: `AsyncGenerator<Block>`
457
-
458
- See [`CarReader#blocks`](#CarReader_blocks)
459
-
460
- <a name="CarIndexedReader_cids"></a>
461
- ### `async * CarIndexedReader#cids()`
462
-
463
- * Returns: `AsyncGenerator<CID>`
464
-
465
- See [`CarReader#cids`](#CarReader_cids)
466
-
467
- <a name="CarIndexedReader_close"></a>
468
- ### `async CarIndexedReader#close()`
469
-
470
- * Returns: `Promise<void>`
471
-
472
- Close the underlying file descriptor maintained by this `CarIndexedReader`.
473
- This must be called for proper resource clean-up to occur.
474
-
475
- <a name="CarIndexedReader__fromFile"></a>
476
- ### `async CarIndexedReader.fromFile(path)`
477
-
478
- * `path` `(string)`
479
-
480
- * Returns: `Promise<CarIndexedReader>`
481
-
482
- Instantiate an [`CarIndexedReader`](#CarIndexedReader) from a file with the provided
483
- `path`. The CAR file is first indexed with a full path that collects `CID`s
484
- and block locations. This index is maintained in memory. Subsequent reads
485
- operate on a read-only file descriptor, fetching the block from its in-file
486
- location.
487
-
488
- For large archives, the initial indexing may take some time. The returned
489
- `Promise` will resolve only after this is complete.
490
-
491
- <a name="CarBlockIterator"></a>
492
- ### `class CarBlockIterator`
493
-
494
- Properties:
495
-
496
- * `version` `(number)`: The version number of the CAR referenced by this
497
- iterator (should be `1`).
498
-
499
- Provides an iterator over all of the `Block`s in a CAR. Implements a
500
- `BlockIterator` interface, or `AsyncIterable<Block>`. Where a `Block` is
501
- a `{ cid:CID, bytes:Uint8Array }` pair.
502
-
503
- As an implementer of `AsyncIterable`, this class can be used directly in a
504
- `for await (const block of iterator) {}` loop. Where the `iterator` is
505
- constructed using [`CarBlockiterator.fromBytes`](#CarBlockiterator__fromBytes) or
506
- [`CarBlockiterator.fromIterable`](#CarBlockiterator__fromIterable).
507
-
508
- An iteration can only be performce _once_ per instantiation.
509
-
510
- `CarBlockIterator` also implements the `RootsReader` interface and provides
511
- the [`getRoots()`](#CarBlockiterator__getRoots) method.
512
-
513
- Load this class with either
514
- `import { CarBlockIterator } from '@ipld/car/iterator'`
515
- (`const { CarBlockIterator } = require('@ipld/car/iterator')`). Or
516
- `import { CarBlockIterator } from '@ipld/car'`
517
- (`const { CarBlockIterator } = require('@ipld/car')`).
518
-
519
- <a name="CarBlockIterator_getRoots"></a>
520
- ### `async CarBlockIterator#getRoots()`
521
-
522
- * Returns: `Promise<CID[]>`
523
-
524
- Get the list of roots defined by the CAR referenced by this iterator. May be
525
- zero or more `CID`s.
526
-
527
- <a name="CarBlockIterator__fromBytes"></a>
528
- ### `async CarBlockIterator.fromBytes(bytes)`
529
-
530
- * `bytes` `(Uint8Array)`
531
-
532
- * Returns: `Promise<CarBlockIterator>`
533
-
534
- Instantiate a [`CarBlockIterator`](#CarBlockIterator) from a `Uint8Array` blob. Rather
535
- than decoding the entire byte array prior to returning the iterator, as in
536
- [`CarReader.fromBytes`](#CarReader__fromBytes), only the header is decoded and the remainder
537
- of the CAR is parsed as the `Block`s as yielded.
538
-
539
- <a name="CarBlockIterator__fromIterable"></a>
540
- ### `async CarBlockIterator.fromIterable(asyncIterable)`
541
-
542
- * `asyncIterable` `(AsyncIterable<Uint8Array>)`
543
-
544
- * Returns: `Promise<CarBlockIterator>`
545
-
546
- Instantiate a [`CarBlockIterator`](#CarBlockIterator) from a `AsyncIterable<Uint8Array>`,
547
- such as a [modern Node.js stream](https://nodejs.org/api/stream.html#stream_streams_compatibility_with_async_generators_and_async_iterators).
548
- Rather than decoding the entire byte array prior to returning the iterator,
549
- as in [`CarReader.fromIterable`](#CarReader__fromIterable), only the header is decoded and the
550
- remainder of the CAR is parsed as the `Block`s as yielded.
551
-
552
- <a name="CarCIDIterator"></a>
553
- ### `class CarCIDIterator`
554
-
555
- Properties:
556
-
557
- * `version` `(number)`: The version number of the CAR referenced by this
558
- iterator (should be `1`).
559
-
560
- Provides an iterator over all of the `CID`s in a CAR. Implements a
561
- `CIDIterator` interface, or `AsyncIterable<CID>`. Similar to
562
- [`CarBlockIterator`](#CarBlockIterator) but only yields the CIDs in the CAR.
563
-
564
- As an implementer of `AsyncIterable`, this class can be used directly in a
565
- `for await (const cid of iterator) {}` loop. Where the `iterator` is
566
- constructed using [`CarCIDiterator.fromBytes`](#CarCIDiterator__fromBytes) or
567
- [`CarCIDiterator.fromIterable`](#CarCIDiterator__fromIterable).
568
-
569
- An iteration can only be performce _once_ per instantiation.
570
-
571
- `CarCIDIterator` also implements the `RootsReader` interface and provides
572
- the [`getRoots()`](#CarCIDiterator__getRoots) method.
573
-
574
- Load this class with either
575
- `import { CarCIDIterator } from '@ipld/car/iterator'`
576
- (`const { CarCIDIterator } = require('@ipld/car/iterator')`). Or
577
- `import { CarCIDIterator } from '@ipld/car'`
578
- (`const { CarCIDIterator } = require('@ipld/car')`).
579
-
580
- <a name="CarCIDIterator_getRoots"></a>
581
- ### `async CarCIDIterator#getRoots()`
582
-
583
- * Returns: `Promise<CID[]>`
584
-
585
- Get the list of roots defined by the CAR referenced by this iterator. May be
586
- zero or more `CID`s.
587
-
588
- <a name="CarCIDIterator__fromBytes"></a>
589
- ### `async CarCIDIterator.fromBytes(bytes)`
590
-
591
- * `bytes` `(Uint8Array)`
592
-
593
- * Returns: `Promise<CarCIDIterator>`
594
-
595
- Instantiate a [`CarCIDIterator`](#CarCIDIterator) from a `Uint8Array` blob. Rather
596
- than decoding the entire byte array prior to returning the iterator, as in
597
- [`CarReader.fromBytes`](#CarReader__fromBytes), only the header is decoded and the remainder
598
- of the CAR is parsed as the `CID`s as yielded.
599
-
600
- <a name="CarCIDIterator__fromIterable"></a>
601
- ### `async CarCIDIterator.fromIterable(asyncIterable)`
602
-
603
- * `asyncIterable` `(AsyncIterable<Uint8Array>)`
604
-
605
- * Returns: `Promise<CarCIDIterator>`
606
-
607
- Instantiate a [`CarCIDIterator`](#CarCIDIterator) from a `AsyncIterable<Uint8Array>`,
608
- such as a [modern Node.js stream](https://nodejs.org/api/stream.html#stream_streams_compatibility_with_async_generators_and_async_iterators).
609
- Rather than decoding the entire byte array prior to returning the iterator,
610
- as in [`CarReader.fromIterable`](#CarReader__fromIterable), only the header is decoded and the
611
- remainder of the CAR is parsed as the `CID`s as yielded.
612
-
613
- <a name="CarIndexer"></a>
614
- ### `class CarIndexer`
615
-
616
- Properties:
617
-
618
- * `version` `(number)`: The version number of the CAR referenced by this
619
- reader (should be `1`).
620
-
621
- Provides an iterator over all of the `Block`s in a CAR, returning their CIDs
622
- and byte-location information. Implements an `AsyncIterable<BlockIndex>`.
623
- Where a `BlockIndex` is a
624
- `{ cid:CID, length:number, offset:number, blockLength:number, blockOffset:number }`.
625
-
626
- As an implementer of `AsyncIterable`, this class can be used directly in a
627
- `for await (const blockIndex of iterator) {}` loop. Where the `iterator` is
628
- constructed using [`CarIndexer.fromBytes`](#CarIndexer__fromBytes) or
629
- [`CarIndexer.fromIterable`](#CarIndexer__fromIterable).
630
-
631
- An iteration can only be performce _once_ per instantiation.
632
-
633
- `CarIndexer` also implements the `RootsReader` interface and provides
634
- the [`getRoots()`](#CarIndexer__getRoots) method.
635
-
636
- Load this class with either
637
- `import { CarIndexer } from '@ipld/car/indexer'`
638
- (`const { CarIndexer } = require('@ipld/car/indexer')`). Or
639
- `import { CarIndexer } from '@ipld/car'`
640
- (`const { CarIndexer } = require('@ipld/car')`). The former will likely
641
- result in smaller bundle sizes where this is important.
642
-
643
- <a name="CarIndexer_getRoots"></a>
644
- ### `async CarIndexer#getRoots()`
645
-
646
- * Returns: `Promise<CID[]>`
647
-
648
- Get the list of roots defined by the CAR referenced by this indexer. May be
649
- zero or more `CID`s.
650
-
651
- <a name="CarIndexer__fromBytes"></a>
652
- ### `async CarIndexer.fromBytes(bytes)`
653
-
654
- * `bytes` `(Uint8Array)`
655
-
656
- * Returns: `Promise<CarIndexer>`
657
-
658
- Instantiate a [`CarIndexer`](#CarIndexer) from a `Uint8Array` blob. Only the header
659
- is decoded initially, the remainder is processed and emitted via the
660
- iterator as it is consumed.
661
-
662
- <a name="CarIndexer__fromIterable"></a>
663
- ### `async CarIndexer.fromIterable(asyncIterable)`
664
-
665
- * `asyncIterable` `(AsyncIterable<Uint8Array>)`
666
-
667
- * Returns: `Promise<CarIndexer>`
668
-
669
- Instantiate a [`CarIndexer`](#CarIndexer) from a `AsyncIterable<Uint8Array>`,
670
- such as a [modern Node.js stream](https://nodejs.org/api/stream.html#stream_streams_compatibility_with_async_generators_and_async_iterators).
671
- is decoded initially, the remainder is processed and emitted via the
672
- iterator as it is consumed.
673
-
674
- <a name="CarWriter"></a>
675
- ### `class CarWriter`
676
-
677
- Provides a writer interface for the creation of CAR files.
678
-
679
- Creation of a `CarWriter` involves the instatiation of an input / output pair
680
- in the form of a `WriterChannel`, which is a
681
- `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }` pair. These two
682
- components form what can be thought of as a stream-like interface. The
683
- `writer` component (an instantiated `CarWriter`), has methods to
684
- [`put()`](#CarWriter__put) new blocks and [`close()`](#CarWriter__put)
685
- the writing operation (finalising the CAR archive). The `out` component is
686
- an `AsyncIterable` that yields the bytes of the archive. This can be
687
- redirected to a file or other sink. In Node.js, you can use the
688
- [`Readable.from()`](https://nodejs.org/api/stream.html#stream_stream_readable_from_iterable_options)
689
- API to convert this to a standard Node.js stream, or it can be directly fed
690
- to a
691
- [`stream.pipeline()`](https://nodejs.org/api/stream.html#stream_stream_pipeline_source_transforms_destination_callback).
692
-
693
- The channel will provide a form of backpressure. The `Promise` from a
694
- `write()` won't resolve until the resulting data is drained from the `out`
695
- iterable.
696
-
697
- It is also possible to ignore the `Promise` from `write()` calls and allow
698
- the generated data to queue in memory. This should be avoided for large CAR
699
- archives of course due to the memory costs and potential for memory overflow.
700
-
701
- Load this class with either
702
- `import { CarWriter } from '@ipld/car/writer'`
703
- (`const { CarWriter } = require('@ipld/car/writer')`). Or
704
- `import { CarWriter } from '@ipld/car'`
705
- (`const { CarWriter } = require('@ipld/car')`). The former will likely
706
- result in smaller bundle sizes where this is important.
707
-
708
- <a name="CarWriter_put"></a>
709
- ### `async CarWriter#put(block)`
710
-
711
- * `block` `(Block)`: A `{ cid:CID, bytes:Uint8Array }` pair.
712
-
713
- * Returns: `Promise<void>`: The returned promise will only resolve once the
714
- bytes this block generates are written to the `out` iterable.
715
-
716
- Write a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) to the archive.
717
-
718
- <a name="CarWriter_close"></a>
719
- ### `async CarWriter#close()`
720
-
721
- * Returns: `Promise<void>`
722
-
723
- Finalise the CAR archive and signal that the `out` iterable should end once
724
- any remaining bytes are written.
725
-
726
- <a name="CarWriter_version"></a>
727
- ### `CarWriter#version()`
728
-
729
- * Returns: `number`
730
-
731
- Returns the version number of the CAR file being written
732
-
733
- <a name="CarWriter__create"></a>
734
- ### `async CarWriter.create(roots)`
735
-
736
- * `roots` `(CID[]|CID|void)`
737
-
738
- * Returns: `WriterChannel`: The channel takes the form of
739
- `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }`.
740
-
741
- Create a new CAR writer "channel" which consists of a
742
- `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }` pair.
743
-
744
- <a name="CarWriter__createAppender"></a>
745
- ### `async CarWriter.createAppender()`
746
-
747
- * Returns: `WriterChannel`: The channel takes the form of
748
- `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }`.
749
-
750
- Create a new CAR appender "channel" which consists of a
751
- `{ writer:CarWriter, out:AsyncIterable<Uint8Array> }` pair.
752
- This appender does not consider roots and does not produce a CAR header.
753
- It is designed to append blocks to an _existing_ CAR archive. It is
754
- expected that `out` will be concatenated onto the end of an existing
755
- archive that already has a properly formatted header.
756
-
757
- <a name="CarWriter__updateRootsInBytes"></a>
758
- ### `async CarWriter.updateRootsInBytes(bytes, roots)`
759
-
760
- * `bytes` `(Uint8Array)`
761
- * `roots` `(CID[])`: A new list of roots to replace the existing list in
762
- the CAR header. The new header must take up the same number of bytes as the
763
- existing header, so the roots should collectively be the same byte length
764
- as the existing roots.
765
-
766
- * Returns: `Promise<Uint8Array>`
767
-
768
- Update the list of roots in the header of an existing CAR as represented
769
- in a Uint8Array.
770
-
771
- This operation is an _overwrite_, the total length of the CAR will not be
772
- modified. A rejection will occur if the new header will not be the same
773
- length as the existing header, in which case the CAR will not be modified.
774
- It is the responsibility of the user to ensure that the roots being
775
- replaced encode as the same length as the new roots.
776
-
777
- The byte array passed in an argument will be modified and also returned
778
- upon successful modification.
779
-
780
- <a name="CarWriter__updateRootsInFile"></a>
781
- ### `async CarWriter.updateRootsInFile(fd, roots)`
782
-
783
- * `fd` `(fs.promises.FileHandle|number)`: A file descriptor from the
784
- Node.js `fs` module. Either an integer, from `fs.open()` or a `FileHandle`
785
- from `fs.promises.open()`.
786
- * `roots` `(CID[])`: A new list of roots to replace the existing list in
787
- the CAR header. The new header must take up the same number of bytes as the
788
- existing header, so the roots should collectively be the same byte length
789
- as the existing roots.
790
-
791
- * Returns: `Promise<void>`
792
-
793
- Update the list of roots in the header of an existing CAR file. The first
794
- argument must be a file descriptor for CAR file that is open in read and
795
- write mode (not append), e.g. `fs.open` or `fs.promises.open` with `'r+'`
796
- mode.
797
-
798
- This operation is an _overwrite_, the total length of the CAR will not be
799
- modified. A rejection will occur if the new header will not be the same
800
- length as the existing header, in which case the CAR will not be modified.
801
- It is the responsibility of the user to ensure that the roots being
802
- replaced encode as the same length as the new roots.
803
-
804
- This function is **only available in Node.js** and not a browser
805
- environment.
806
-
807
- <a name="CarBufferWriter"></a>
808
- ### `class CarBufferWriter`
809
-
810
- A simple CAR writer that writes to a pre-allocated buffer.
811
-
812
- <a name="CarBufferWriter_addRoot"></a>
813
- ### `CarBufferWriter#addRoot(root, options)`
814
-
815
- * `root` `(CID)`
816
- * `options`
817
-
818
- * Returns: `CarBufferWriter`
819
-
820
- Add a root to this writer, to be used to create a header when the CAR is
821
- finalized with [`close()`](#CarBufferWriter__close)
822
-
823
- <a name="CarBufferWriter_write"></a>
824
- ### `CarBufferWriter#write(block)`
825
-
826
- * `block` `(Block)`: A `{ cid:CID, bytes:Uint8Array }` pair.
827
-
828
- * Returns: `CarBufferWriter`
829
-
830
- Write a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) to the archive.
831
- Throws if there is not enough capacity.
832
-
833
- <a name="CarBufferWriter_close"></a>
834
- ### `CarBufferWriter#close([options])`
835
-
836
- * `options` `(object, optional)`
837
- * `options.resize` `(boolean, optional)`
838
-
839
- * Returns: `Uint8Array`
840
-
841
- Finalize the CAR and return it as a `Uint8Array`.
842
-
843
- <a name="CarBufferWriter__blockLength__Block__"></a>
844
- ### `CarBufferWriter.blockLength(Block)`
845
-
846
- * `block` `(Block)`
847
-
848
- * Returns: `number`
849
-
850
- Calculates number of bytes required for storing given block in CAR. Useful in
851
- estimating size of an `ArrayBuffer` for the `CarBufferWriter`.
852
-
853
- <a name="CarBufferWriter__calculateHeaderLength__rootLengths__"></a>
854
- ### `CarBufferWriter.calculateHeaderLength(rootLengths)`
855
-
856
- * `rootLengths` `(number[])`
857
-
858
- * Returns: `number`
859
-
860
- Calculates header size given the array of byteLength for roots.
861
-
862
- <a name="CarBufferWriter__headerLength______roots______"></a>
863
- ### `CarBufferWriter.headerLength({ roots })`
864
-
865
- * `options` `(object)`
866
- * `options.roots` `(CID[])`
867
-
868
- * Returns: `number`
869
-
870
- Calculates header size given the array of roots.
871
-
872
- <a name="CarBufferWriter__estimateHeaderLength__rootCount______rootByteLength____"></a>
873
- ### `CarBufferWriter.estimateHeaderLength(rootCount[, rootByteLength])`
874
-
875
- * `rootCount` `(number)`
876
- * `rootByteLength` `(number, optional)`
877
-
878
- * Returns: `number`
879
-
880
- Estimates header size given a count of the roots and the expected byte length
881
- of the root CIDs. The default length works for a standard CIDv1 with a
882
- single-byte multihash code, such as SHA2-256 (i.e. the most common CIDv1).
883
-
884
- <a name="CarBufferWriter__createWriter__buffer______options____"></a>
885
- ### `CarBufferWriter.createWriter(buffer[, options])`
886
-
887
- * `buffer` `(ArrayBuffer)`
888
- * `options` `(object, optional)`
889
- * `options.roots` `(CID[], optional)`
890
- * `options.byteOffset` `(number, optional)`
891
- * `options.byteLength` `(number, optional)`
892
- * `options.headerSize` `(number, optional)`
893
-
894
- * Returns: `CarBufferWriter`
895
-
896
- Creates synchronous CAR writer that can be used to encode blocks into a given
897
- buffer. Optionally you could pass `byteOffset` and `byteLength` to specify a
898
- range inside buffer to write into. If car file is going to have `roots` you
899
- need to either pass them under `options.roots` (from which header size will
900
- be calculated) or provide `options.headerSize` to allocate required space
901
- in the buffer. You may also provide known `roots` and `headerSize` to
902
- allocate space for the roots that may not be known ahead of time.
903
-
904
- Note: Incorrect `headerSize` may lead to copying bytes inside a buffer
905
- which will have a negative impact on performance.
906
-
907
- <a name="async__decoder__readHeader__reader__"></a>
908
- ### `async decoder.readHeader(reader)`
909
-
910
- * `reader` `(BytesReader)`
911
- * `strictVersion` `(number, optional)`
912
-
913
- * Returns: `Promise<(CarHeader|CarV2Header)>`
914
-
915
- Reads header data from a `BytesReader`. The header may either be in the form
916
- of a `CarHeader` or `CarV2Header` depending on the CAR being read.
917
-
918
- <a name="async__decoder__readBlockHead__reader__"></a>
919
- ### `async decoder.readBlockHead(reader)`
920
-
921
- * `reader` `(BytesReader)`
922
-
923
- * Returns: `Promise<BlockHeader>`
924
-
925
- Reads the leading data of an individual block from CAR data from a
926
- `BytesReader`. Returns a `BlockHeader` object which contains
927
- `{ cid, length, blockLength }` which can be used to either index the block
928
- or read the block binary data.
929
-
930
- <a name="decoder__createDecoder__reader__"></a>
931
- ### `decoder.createDecoder(reader)`
932
-
933
- * `reader` `(BytesReader)`
934
-
935
- * Returns: `CarDecoder`
936
-
937
- Creates a `CarDecoder` from a `BytesReader`. The `CarDecoder` is as async
938
- interface that will consume the bytes from the `BytesReader` to yield a
939
- `header()` and either `blocks()` or `blocksIndex()` data.
940
-
941
- <a name="decoder__bytesReader__bytes__"></a>
942
- ### `decoder.bytesReader(bytes)`
943
-
944
- * `bytes` `(Uint8Array)`
945
-
946
- * Returns: `BytesReader`
947
-
948
- Creates a `BytesReader` from a `Uint8Array`.
949
-
950
- <a name="decoder__asyncIterableReader__asyncIterable__"></a>
951
- ### `decoder.asyncIterableReader(asyncIterable)`
952
-
953
- * `asyncIterable` `(AsyncIterable<Uint8Array>)`
954
-
955
- * Returns: `BytesReader`
956
-
957
- Creates a `BytesReader` from an `AsyncIterable<Uint8Array>`, which allows for
958
- consumption of CAR data from a streaming source.
959
-
960
- <a name="decoder__limitReader__reader____byteLimit__"></a>
961
- ### `decoder.limitReader(reader, byteLimit)`
962
-
963
- * `reader` `(BytesReader)`
964
- * `byteLimit` `(number)`
965
-
966
- * Returns: `BytesReader`
967
-
968
- Wraps a `BytesReader` in a limiting `BytesReader` which limits maximum read
969
- to `byteLimit` bytes. It _does not_ update `pos` of the original
970
- `BytesReader`.
971
-
972
- <a name="CarBufferReader"></a>
973
- ### `class CarBufferReader`
974
-
975
- Properties:
976
-
977
- * `version` `(number)`: The version number of the CAR referenced by this
978
- reader (should be `1` or `2`).
979
-
980
- Provides blockstore-like access to a CAR.
981
-
982
- Implements the `RootsBufferReader` interface:
983
- [`getRoots()`](#ICarBufferReader__getRoots). And the `BlockBufferReader` interface:
984
- [`get()`](#ICarBufferReader__get), [`has()`](#ICarBufferReader__has),
985
- [`blocks()`](#ICarBufferReader__blocks) and
986
- [`cids()`](#ICarBufferReader__cids).
987
-
988
- Load this class with either `import { CarBufferReader } from '@ipld/car/buffer-reader'`
989
- (`const { CarBufferReader } = require('@ipld/car/buffer-reader')`). Or
990
- `import { CarBufferReader } from '@ipld/car'` (`const { CarBufferReader } = require('@ipld/car')`).
991
- The former will likely result in smaller bundle sizes where this is
992
- important.
993
-
994
- <a name="CarBufferReader_getRoots"></a>
995
- ### `CarBufferReader#getRoots()`
996
-
997
- * Returns: `CID[]`
998
-
999
- Get the list of roots defined by the CAR referenced by this reader. May be
1000
- zero or more `CID`s.
1001
-
1002
- <a name="CarBufferReader_has"></a>
1003
- ### `CarBufferReader#has(key)`
1004
-
1005
- * `key` `(CID)`
1006
-
1007
- * Returns: `boolean`
1008
-
1009
- Check whether a given `CID` exists within the CAR referenced by this
1010
- reader.
1011
-
1012
- <a name="CarBufferReader_get"></a>
1013
- ### `CarBufferReader#get(key)`
1014
-
1015
- * `key` `(CID)`
1016
-
1017
- * Returns: `Block|undefined`
1018
-
1019
- Fetch a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) from the CAR
1020
- referenced by this reader matching the provided `CID`. In the case where
1021
- the provided `CID` doesn't exist within the CAR, `undefined` will be
1022
- returned.
1023
-
1024
- <a name="CarBufferReader_blocks"></a>
1025
- ### `CarBufferReader#blocks()`
1026
-
1027
- * Returns: `Block[]`
1028
-
1029
- Returns a `Block[]` of the `Block`s (`{ cid:CID, bytes:Uint8Array }` pairs) contained within
1030
- the CAR referenced by this reader.
1031
-
1032
- <a name="CarBufferReader_cids"></a>
1033
- ### `CarBufferReader#cids()`
1034
-
1035
- * Returns: `CID[]`
1036
-
1037
- Returns a `CID[]` of the `CID`s contained within the CAR referenced by this reader.
1038
-
1039
- <a name="CarBufferReader__fromBytes"></a>
1040
- ### `CarBufferReader.fromBytes(bytes)`
1041
-
1042
- * `bytes` `(Uint8Array)`
1043
-
1044
- * Returns: `CarBufferReader`
1045
-
1046
- Instantiate a [`CarBufferReader`](#CarBufferReader) from a `Uint8Array` blob. This performs a
1047
- decode fully in memory and maintains the decoded state in memory for full
1048
- access to the data via the `CarReader` API.
1049
-
1050
- <a name="CarBufferReader__readRaw"></a>
1051
- ### `CarBufferReader.readRaw(fd, blockIndex)`
1052
-
1053
- * `fd` `(number)`: A file descriptor from the
1054
- Node.js `fs` module. An integer, from `fs.open()`.
1055
- * `blockIndex` `(BlockIndex)`: An index pointing to the location of the
1056
- Block required. This `BlockIndex` should take the form:
1057
- `{cid:CID, blockLength:number, blockOffset:number}`.
1058
-
1059
- * Returns: `Block`: A `{ cid:CID, bytes:Uint8Array }` pair.
1060
-
1061
- Reads a block directly from a file descriptor for an open CAR file. This
1062
- function is **only available in Node.js** and not a browser environment.
1063
-
1064
- This function can be used in connection with [`CarIndexer`](#CarIndexer) which emits
1065
- the `BlockIndex` objects that are required by this function.
1066
-
1067
- The user is responsible for opening and closing the file used in this call.
1068
-
1069
- ## License
1070
-
1071
- Licensed under either of
1072
-
1073
- - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
1074
- - MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
1075
-
1076
- ### Contribution
1077
-
1078
- Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.