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