@fireproof/vendor 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +12 -8
- package/src/@ipld/car/README.md +229 -175
- package/src/@ipld/car/dist/src/reader.d.ts.map +1 -1
- package/src/@ipld/car/src/reader.js +19 -2
- package/src/cborg/.github/dependabot.yml +16 -0
- package/src/cborg/.github/workflows/test-and-release.yml +52 -0
- package/src/cborg/{lib → cborg}/bin.js +2 -2
- package/src/cborg/cborg/common.js +28 -0
- package/src/cborg/{lib → cborg}/decode.js +24 -22
- package/src/cborg/{lib → cborg}/diagnostic.js +6 -4
- package/src/cborg/{lib → cborg}/diagnostic_test.js +1 -1
- package/src/cborg/{lib → cborg}/encode.js +23 -21
- package/src/cborg/{cborg.js → cborg/index.js} +12 -10
- package/src/cborg/{lib → cborg}/length.js +3 -2
- package/src/cborg/interface.ts +7 -4
- package/src/cborg/{lib/json → json}/decode.js +25 -25
- package/src/cborg/{lib/json → json}/encode.js +19 -16
- package/src/cborg/taglib.js +3 -1
- package/src/cborg/test/common.js +1 -1
- package/src/cborg/test/noop-bin-test.js +1 -1
- package/src/cborg/test/test-0uint.js +2 -2
- package/src/cborg/test/test-1negint.js +2 -2
- package/src/cborg/test/test-2bytes.js +2 -2
- package/src/cborg/test/test-3string.js +2 -2
- package/src/cborg/test/test-4array.js +2 -2
- package/src/cborg/test/test-5map.js +2 -2
- package/src/cborg/test/test-6tag.js +2 -3
- package/src/cborg/test/test-7float.js +2 -2
- package/src/cborg/test/test-bl.js +1 -1
- package/src/cborg/test/test-cbor-vectors.js +2 -2
- package/src/cborg/test/test-decode-errors.js +2 -2
- package/src/cborg/test/test-fuzz.js +1 -1
- package/src/cborg/test/test-json.js +25 -25
- package/src/cborg/test/test-length.js +3 -3
- package/src/cborg/test/test-partial.js +2 -2
- package/src/cborg/tsconfig.json +5 -2
- package/src/cborg/types/{lib → cborg}/decode.d.ts +5 -3
- package/src/cborg/types/cborg/decode.d.ts.map +1 -0
- package/src/cborg/types/{lib → cborg}/encode.d.ts +4 -3
- package/src/cborg/types/cborg/encode.d.ts.map +1 -0
- package/src/cborg/types/cborg/index.d.ts +26 -0
- package/src/cborg/types/cborg/index.d.ts.map +1 -0
- package/src/cborg/types/cborg/is.d.ts.map +1 -0
- package/src/cborg/types/interface.d.ts +6 -4
- package/src/cborg/types/interface.d.ts.map +1 -1
- package/src/cborg/types/{lib/json → json}/decode.d.ts +7 -7
- package/src/cborg/types/json/decode.d.ts.map +1 -0
- package/src/cborg/types/json/encode.d.ts +11 -0
- package/src/cborg/types/json/encode.d.ts.map +1 -0
- package/src/cborg/types/json/json.d.ts.map +1 -0
- package/src/cborg/types/taglib.d.ts +1 -1
- package/src/cborg/types/taglib.d.ts.map +1 -1
- package/src/cborg/types/tsconfig.tsbuildinfo +1 -1
- package/src/cborg/types/{lib → utils}/0uint.d.ts +6 -4
- package/src/cborg/types/utils/0uint.d.ts.map +1 -0
- package/src/cborg/types/{lib → utils}/1negint.d.ts +4 -3
- package/src/cborg/types/utils/1negint.d.ts.map +1 -0
- package/src/cborg/types/{lib → utils}/2bytes.d.ts +5 -4
- package/src/cborg/types/utils/2bytes.d.ts.map +1 -0
- package/src/cborg/types/{lib → utils}/3string.d.ts +1 -1
- package/src/cborg/types/utils/3string.d.ts.map +1 -0
- package/src/cborg/types/{lib → utils}/4array.d.ts +3 -2
- package/src/cborg/types/utils/4array.d.ts.map +1 -0
- package/src/cborg/types/{lib → utils}/5map.d.ts +3 -2
- package/src/cborg/types/utils/5map.d.ts.map +1 -0
- package/src/cborg/types/{lib → utils}/6tag.d.ts +4 -3
- package/src/cborg/types/utils/6tag.d.ts.map +1 -0
- package/src/cborg/types/{lib → utils}/7float.d.ts +2 -2
- package/src/cborg/types/utils/7float.d.ts.map +1 -0
- package/src/cborg/types/utils/bl.d.ts.map +1 -0
- package/src/cborg/types/utils/byte-utils.d.ts.map +1 -0
- package/src/cborg/types/utils/common.d.ts +8 -0
- package/src/cborg/types/utils/common.d.ts.map +1 -0
- package/src/cborg/types/utils/index.d.ts +13 -0
- package/src/cborg/types/utils/index.d.ts.map +1 -0
- package/src/cborg/types/utils/jump.d.ts +16 -0
- package/src/cborg/types/utils/jump.d.ts.map +1 -0
- package/src/cborg/types/utils/token.d.ts.map +1 -0
- package/src/cborg/{lib → utils}/0uint.js +16 -14
- package/src/cborg/{lib → utils}/1negint.js +5 -5
- package/src/cborg/{lib → utils}/2bytes.js +16 -14
- package/src/cborg/{lib → utils}/3string.js +4 -4
- package/src/cborg/{lib → utils}/4array.js +7 -6
- package/src/cborg/{lib → utils}/5map.js +6 -6
- package/src/cborg/{lib → utils}/6tag.js +4 -3
- package/src/cborg/{lib → utils}/7float.js +23 -21
- package/src/cborg/{lib → utils}/bl.js +1 -1
- package/src/cborg/utils/common.js +11 -0
- package/src/cborg/utils/index.js +12 -0
- package/src/cborg/utils/jump.js +222 -0
- package/src/@ipld/car/package.json +0 -235
- package/src/@ipld/dag-cbor/package.json +0 -171
- package/src/@ipld/dag-json/package.json +0 -173
- package/src/@web3-storage/pail/package.json +0 -173
- package/src/cborg/lib/common.js +0 -27
- package/src/cborg/lib/jump.js +0 -209
- package/src/cborg/package.json +0 -168
- package/src/cborg/types/cborg.d.ts +0 -28
- package/src/cborg/types/cborg.d.ts.map +0 -1
- package/src/cborg/types/lib/0uint.d.ts.map +0 -1
- package/src/cborg/types/lib/1negint.d.ts.map +0 -1
- package/src/cborg/types/lib/2bytes.d.ts.map +0 -1
- package/src/cborg/types/lib/3string.d.ts.map +0 -1
- package/src/cborg/types/lib/4array.d.ts.map +0 -1
- package/src/cborg/types/lib/5map.d.ts.map +0 -1
- package/src/cborg/types/lib/6tag.d.ts.map +0 -1
- package/src/cborg/types/lib/7float.d.ts.map +0 -1
- package/src/cborg/types/lib/bin.d.ts +0 -4
- package/src/cborg/types/lib/bin.d.ts.map +0 -1
- package/src/cborg/types/lib/bl.d.ts.map +0 -1
- package/src/cborg/types/lib/byte-utils.d.ts.map +0 -1
- package/src/cborg/types/lib/common.d.ts +0 -10
- package/src/cborg/types/lib/common.d.ts.map +0 -1
- package/src/cborg/types/lib/decode.d.ts.map +0 -1
- package/src/cborg/types/lib/diagnostic.d.ts +0 -12
- package/src/cborg/types/lib/diagnostic.d.ts.map +0 -1
- package/src/cborg/types/lib/diagnostic_test.d.ts +0 -2
- package/src/cborg/types/lib/diagnostic_test.d.ts.map +0 -1
- package/src/cborg/types/lib/encode.d.ts.map +0 -1
- package/src/cborg/types/lib/is.d.ts.map +0 -1
- package/src/cborg/types/lib/json/decode.d.ts.map +0 -1
- package/src/cborg/types/lib/json/encode.d.ts +0 -11
- package/src/cborg/types/lib/json/encode.d.ts.map +0 -1
- package/src/cborg/types/lib/json/forward-cborg.d.ts +0 -6
- package/src/cborg/types/lib/json/forward-cborg.d.ts.map +0 -1
- package/src/cborg/types/lib/json/json.d.ts.map +0 -1
- package/src/cborg/types/lib/jump.d.ts +0 -12
- package/src/cborg/types/lib/jump.d.ts.map +0 -1
- package/src/cborg/types/lib/length.d.ts +0 -27
- package/src/cborg/types/lib/length.d.ts.map +0 -1
- package/src/cborg/types/lib/token.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/package.json +0 -180
- /package/src/cborg/{lib → cborg}/is.js +0 -0
- /package/src/cborg/{lib/json → json}/json.js +0 -0
- /package/src/cborg/types/{lib → cborg}/is.d.ts +0 -0
- /package/src/cborg/types/{lib/json → json}/json.d.ts +0 -0
- /package/src/cborg/types/{lib → utils}/bl.d.ts +0 -0
- /package/src/cborg/types/{lib → utils}/byte-utils.d.ts +0 -0
- /package/src/cborg/types/{lib → utils}/token.d.ts +0 -0
- /package/src/cborg/{lib → utils}/byte-utils.js +0 -0
- /package/src/cborg/{lib → utils}/token.js +0 -0
package/src/@ipld/car/README.md
CHANGED
|
@@ -217,73 +217,73 @@ be directly fed to a
|
|
|
217
217
|
|
|
218
218
|
### Contents
|
|
219
219
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
* [`CarBufferReader.readRaw(fd, blockIndex)`](#CarBufferReader__readRaw)
|
|
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)
|
|
280
279
|
|
|
281
280
|
<a name="CarReader"></a>
|
|
281
|
+
|
|
282
282
|
### `class CarReader`
|
|
283
283
|
|
|
284
284
|
Properties:
|
|
285
285
|
|
|
286
|
-
|
|
286
|
+
- `version` `(number)`: The version number of the CAR referenced by this
|
|
287
287
|
reader (should be `1` or `2`).
|
|
288
288
|
|
|
289
289
|
Provides blockstore-like access to a CAR.
|
|
@@ -301,29 +301,32 @@ The former will likely result in smaller bundle sizes where this is
|
|
|
301
301
|
important.
|
|
302
302
|
|
|
303
303
|
<a name="CarReader_getRoots"></a>
|
|
304
|
+
|
|
304
305
|
### `async CarReader#getRoots()`
|
|
305
306
|
|
|
306
|
-
|
|
307
|
+
- Returns: `Promise<CID[]>`
|
|
307
308
|
|
|
308
309
|
Get the list of roots defined by the CAR referenced by this reader. May be
|
|
309
310
|
zero or more `CID`s.
|
|
310
311
|
|
|
311
312
|
<a name="CarReader_has"></a>
|
|
313
|
+
|
|
312
314
|
### `async CarReader#has(key)`
|
|
313
315
|
|
|
314
|
-
|
|
316
|
+
- `key` `(CID)`
|
|
315
317
|
|
|
316
|
-
|
|
318
|
+
- Returns: `Promise<boolean>`
|
|
317
319
|
|
|
318
320
|
Check whether a given `CID` exists within the CAR referenced by this
|
|
319
321
|
reader.
|
|
320
322
|
|
|
321
323
|
<a name="CarReader_get"></a>
|
|
324
|
+
|
|
322
325
|
### `async CarReader#get(key)`
|
|
323
326
|
|
|
324
|
-
|
|
327
|
+
- `key` `(CID)`
|
|
325
328
|
|
|
326
|
-
|
|
329
|
+
- Returns: `Promise<(Block|undefined)>`
|
|
327
330
|
|
|
328
331
|
Fetch a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) from the CAR
|
|
329
332
|
referenced by this reader matching the provided `CID`. In the case where
|
|
@@ -331,39 +334,43 @@ the provided `CID` doesn't exist within the CAR, `undefined` will be
|
|
|
331
334
|
returned.
|
|
332
335
|
|
|
333
336
|
<a name="CarReader_blocks"></a>
|
|
337
|
+
|
|
334
338
|
### `async * CarReader#blocks()`
|
|
335
339
|
|
|
336
|
-
|
|
340
|
+
- Returns: `AsyncGenerator<Block>`
|
|
337
341
|
|
|
338
342
|
Returns a `BlockIterator` (`AsyncIterable<Block>`) that iterates over all
|
|
339
343
|
of the `Block`s (`{ cid:CID, bytes:Uint8Array }` pairs) contained within
|
|
340
344
|
the CAR referenced by this reader.
|
|
341
345
|
|
|
342
346
|
<a name="CarReader_cids"></a>
|
|
347
|
+
|
|
343
348
|
### `async * CarReader#cids()`
|
|
344
349
|
|
|
345
|
-
|
|
350
|
+
- Returns: `AsyncGenerator<CID>`
|
|
346
351
|
|
|
347
352
|
Returns a `CIDIterator` (`AsyncIterable<CID>`) that iterates over all of
|
|
348
353
|
the `CID`s contained within the CAR referenced by this reader.
|
|
349
354
|
|
|
350
355
|
<a name="CarReader__fromBytes"></a>
|
|
356
|
+
|
|
351
357
|
### `async CarReader.fromBytes(bytes)`
|
|
352
358
|
|
|
353
|
-
|
|
359
|
+
- `bytes` `(Uint8Array)`
|
|
354
360
|
|
|
355
|
-
|
|
361
|
+
- Returns: `Promise<CarReader>`
|
|
356
362
|
|
|
357
363
|
Instantiate a [`CarReader`](#CarReader) from a `Uint8Array` blob. This performs a
|
|
358
364
|
decode fully in memory and maintains the decoded state in memory for full
|
|
359
365
|
access to the data via the `CarReader` API.
|
|
360
366
|
|
|
361
367
|
<a name="CarReader__fromIterable"></a>
|
|
368
|
+
|
|
362
369
|
### `async CarReader.fromIterable(asyncIterable)`
|
|
363
370
|
|
|
364
|
-
|
|
371
|
+
- `asyncIterable` `(AsyncIterable<Uint8Array>)`
|
|
365
372
|
|
|
366
|
-
|
|
373
|
+
- Returns: `Promise<CarReader>`
|
|
367
374
|
|
|
368
375
|
Instantiate a [`CarReader`](#CarReader) from a `AsyncIterable<Uint8Array>`, such as
|
|
369
376
|
a [modern Node.js stream](https://nodejs.org/api/stream.html#stream_streams_compatibility_with_async_generators_and_async_iterators).
|
|
@@ -375,16 +382,17 @@ where memory is a concern or the archive is potentially larger than the
|
|
|
375
382
|
amount of memory that the runtime can handle.
|
|
376
383
|
|
|
377
384
|
<a name="CarReader__readRaw"></a>
|
|
385
|
+
|
|
378
386
|
### `async CarReader.readRaw(fd, blockIndex)`
|
|
379
387
|
|
|
380
|
-
|
|
388
|
+
- `fd` `(fs.promises.FileHandle|number)`: A file descriptor from the
|
|
381
389
|
Node.js `fs` module. Either an integer, from `fs.open()` or a `FileHandle`
|
|
382
390
|
from `fs.promises.open()`.
|
|
383
|
-
|
|
391
|
+
- `blockIndex` `(BlockIndex)`: An index pointing to the location of the
|
|
384
392
|
Block required. This `BlockIndex` should take the form:
|
|
385
393
|
`{cid:CID, blockLength:number, blockOffset:number}`.
|
|
386
394
|
|
|
387
|
-
|
|
395
|
+
- Returns: `Promise<Block>`: A `{ cid:CID, bytes:Uint8Array }` pair.
|
|
388
396
|
|
|
389
397
|
Reads a block directly from a file descriptor for an open CAR file. This
|
|
390
398
|
function is **only available in Node.js** and not a browser environment.
|
|
@@ -395,11 +403,12 @@ the `BlockIndex` objects that are required by this function.
|
|
|
395
403
|
The user is responsible for opening and closing the file used in this call.
|
|
396
404
|
|
|
397
405
|
<a name="CarIndexedReader"></a>
|
|
406
|
+
|
|
398
407
|
### `class CarIndexedReader`
|
|
399
408
|
|
|
400
409
|
Properties:
|
|
401
410
|
|
|
402
|
-
|
|
411
|
+
- `version` `(number)`: The version number of the CAR referenced by this
|
|
403
412
|
reader (should be `1`).
|
|
404
413
|
|
|
405
414
|
A form of [`CarReader`](#CarReader) that pre-indexes a CAR archive from a file and
|
|
@@ -426,58 +435,65 @@ Load this class with either
|
|
|
426
435
|
result in smaller bundle sizes where this is important.
|
|
427
436
|
|
|
428
437
|
<a name="CarIndexedReader_getRoots"></a>
|
|
438
|
+
|
|
429
439
|
### `async CarIndexedReader#getRoots()`
|
|
430
440
|
|
|
431
|
-
|
|
441
|
+
- Returns: `Promise<CID[]>`
|
|
432
442
|
|
|
433
443
|
See [`CarReader#getRoots`](#CarReader_getRoots)
|
|
434
444
|
|
|
435
445
|
<a name="CarIndexedReader_has"></a>
|
|
446
|
+
|
|
436
447
|
### `async CarIndexedReader#has(key)`
|
|
437
448
|
|
|
438
|
-
|
|
449
|
+
- `key` `(CID)`
|
|
439
450
|
|
|
440
|
-
|
|
451
|
+
- Returns: `Promise<boolean>`
|
|
441
452
|
|
|
442
453
|
See [`CarReader#has`](#CarReader_has)
|
|
443
454
|
|
|
444
455
|
<a name="CarIndexedReader_get"></a>
|
|
456
|
+
|
|
445
457
|
### `async CarIndexedReader#get(key)`
|
|
446
458
|
|
|
447
|
-
|
|
459
|
+
- `key` `(CID)`
|
|
448
460
|
|
|
449
|
-
|
|
461
|
+
- Returns: `Promise<(Block|undefined)>`
|
|
450
462
|
|
|
451
463
|
See [`CarReader#get`](#CarReader_get)
|
|
452
464
|
|
|
453
465
|
<a name="CarIndexedReader_blocks"></a>
|
|
466
|
+
|
|
454
467
|
### `async * CarIndexedReader#blocks()`
|
|
455
468
|
|
|
456
|
-
|
|
469
|
+
- Returns: `AsyncGenerator<Block>`
|
|
457
470
|
|
|
458
471
|
See [`CarReader#blocks`](#CarReader_blocks)
|
|
459
472
|
|
|
460
473
|
<a name="CarIndexedReader_cids"></a>
|
|
474
|
+
|
|
461
475
|
### `async * CarIndexedReader#cids()`
|
|
462
476
|
|
|
463
|
-
|
|
477
|
+
- Returns: `AsyncGenerator<CID>`
|
|
464
478
|
|
|
465
479
|
See [`CarReader#cids`](#CarReader_cids)
|
|
466
480
|
|
|
467
481
|
<a name="CarIndexedReader_close"></a>
|
|
482
|
+
|
|
468
483
|
### `async CarIndexedReader#close()`
|
|
469
484
|
|
|
470
|
-
|
|
485
|
+
- Returns: `Promise<void>`
|
|
471
486
|
|
|
472
487
|
Close the underlying file descriptor maintained by this `CarIndexedReader`.
|
|
473
488
|
This must be called for proper resource clean-up to occur.
|
|
474
489
|
|
|
475
490
|
<a name="CarIndexedReader__fromFile"></a>
|
|
491
|
+
|
|
476
492
|
### `async CarIndexedReader.fromFile(path)`
|
|
477
493
|
|
|
478
|
-
|
|
494
|
+
- `path` `(string)`
|
|
479
495
|
|
|
480
|
-
|
|
496
|
+
- Returns: `Promise<CarIndexedReader>`
|
|
481
497
|
|
|
482
498
|
Instantiate an [`CarIndexedReader`](#CarIndexedReader) from a file with the provided
|
|
483
499
|
`path`. The CAR file is first indexed with a full path that collects `CID`s
|
|
@@ -489,11 +505,12 @@ For large archives, the initial indexing may take some time. The returned
|
|
|
489
505
|
`Promise` will resolve only after this is complete.
|
|
490
506
|
|
|
491
507
|
<a name="CarBlockIterator"></a>
|
|
508
|
+
|
|
492
509
|
### `class CarBlockIterator`
|
|
493
510
|
|
|
494
511
|
Properties:
|
|
495
512
|
|
|
496
|
-
|
|
513
|
+
- `version` `(number)`: The version number of the CAR referenced by this
|
|
497
514
|
iterator (should be `1`).
|
|
498
515
|
|
|
499
516
|
Provides an iterator over all of the `Block`s in a CAR. Implements a
|
|
@@ -517,19 +534,21 @@ Load this class with either
|
|
|
517
534
|
(`const { CarBlockIterator } = require('@ipld/car')`).
|
|
518
535
|
|
|
519
536
|
<a name="CarBlockIterator_getRoots"></a>
|
|
537
|
+
|
|
520
538
|
### `async CarBlockIterator#getRoots()`
|
|
521
539
|
|
|
522
|
-
|
|
540
|
+
- Returns: `Promise<CID[]>`
|
|
523
541
|
|
|
524
542
|
Get the list of roots defined by the CAR referenced by this iterator. May be
|
|
525
543
|
zero or more `CID`s.
|
|
526
544
|
|
|
527
545
|
<a name="CarBlockIterator__fromBytes"></a>
|
|
546
|
+
|
|
528
547
|
### `async CarBlockIterator.fromBytes(bytes)`
|
|
529
548
|
|
|
530
|
-
|
|
549
|
+
- `bytes` `(Uint8Array)`
|
|
531
550
|
|
|
532
|
-
|
|
551
|
+
- Returns: `Promise<CarBlockIterator>`
|
|
533
552
|
|
|
534
553
|
Instantiate a [`CarBlockIterator`](#CarBlockIterator) from a `Uint8Array` blob. Rather
|
|
535
554
|
than decoding the entire byte array prior to returning the iterator, as in
|
|
@@ -537,11 +556,12 @@ than decoding the entire byte array prior to returning the iterator, as in
|
|
|
537
556
|
of the CAR is parsed as the `Block`s as yielded.
|
|
538
557
|
|
|
539
558
|
<a name="CarBlockIterator__fromIterable"></a>
|
|
559
|
+
|
|
540
560
|
### `async CarBlockIterator.fromIterable(asyncIterable)`
|
|
541
561
|
|
|
542
|
-
|
|
562
|
+
- `asyncIterable` `(AsyncIterable<Uint8Array>)`
|
|
543
563
|
|
|
544
|
-
|
|
564
|
+
- Returns: `Promise<CarBlockIterator>`
|
|
545
565
|
|
|
546
566
|
Instantiate a [`CarBlockIterator`](#CarBlockIterator) from a `AsyncIterable<Uint8Array>`,
|
|
547
567
|
such as a [modern Node.js stream](https://nodejs.org/api/stream.html#stream_streams_compatibility_with_async_generators_and_async_iterators).
|
|
@@ -550,11 +570,12 @@ as in [`CarReader.fromIterable`](#CarReader__fromIterable), only the header is d
|
|
|
550
570
|
remainder of the CAR is parsed as the `Block`s as yielded.
|
|
551
571
|
|
|
552
572
|
<a name="CarCIDIterator"></a>
|
|
573
|
+
|
|
553
574
|
### `class CarCIDIterator`
|
|
554
575
|
|
|
555
576
|
Properties:
|
|
556
577
|
|
|
557
|
-
|
|
578
|
+
- `version` `(number)`: The version number of the CAR referenced by this
|
|
558
579
|
iterator (should be `1`).
|
|
559
580
|
|
|
560
581
|
Provides an iterator over all of the `CID`s in a CAR. Implements a
|
|
@@ -578,19 +599,21 @@ Load this class with either
|
|
|
578
599
|
(`const { CarCIDIterator } = require('@ipld/car')`).
|
|
579
600
|
|
|
580
601
|
<a name="CarCIDIterator_getRoots"></a>
|
|
602
|
+
|
|
581
603
|
### `async CarCIDIterator#getRoots()`
|
|
582
604
|
|
|
583
|
-
|
|
605
|
+
- Returns: `Promise<CID[]>`
|
|
584
606
|
|
|
585
607
|
Get the list of roots defined by the CAR referenced by this iterator. May be
|
|
586
608
|
zero or more `CID`s.
|
|
587
609
|
|
|
588
610
|
<a name="CarCIDIterator__fromBytes"></a>
|
|
611
|
+
|
|
589
612
|
### `async CarCIDIterator.fromBytes(bytes)`
|
|
590
613
|
|
|
591
|
-
|
|
614
|
+
- `bytes` `(Uint8Array)`
|
|
592
615
|
|
|
593
|
-
|
|
616
|
+
- Returns: `Promise<CarCIDIterator>`
|
|
594
617
|
|
|
595
618
|
Instantiate a [`CarCIDIterator`](#CarCIDIterator) from a `Uint8Array` blob. Rather
|
|
596
619
|
than decoding the entire byte array prior to returning the iterator, as in
|
|
@@ -598,11 +621,12 @@ than decoding the entire byte array prior to returning the iterator, as in
|
|
|
598
621
|
of the CAR is parsed as the `CID`s as yielded.
|
|
599
622
|
|
|
600
623
|
<a name="CarCIDIterator__fromIterable"></a>
|
|
624
|
+
|
|
601
625
|
### `async CarCIDIterator.fromIterable(asyncIterable)`
|
|
602
626
|
|
|
603
|
-
|
|
627
|
+
- `asyncIterable` `(AsyncIterable<Uint8Array>)`
|
|
604
628
|
|
|
605
|
-
|
|
629
|
+
- Returns: `Promise<CarCIDIterator>`
|
|
606
630
|
|
|
607
631
|
Instantiate a [`CarCIDIterator`](#CarCIDIterator) from a `AsyncIterable<Uint8Array>`,
|
|
608
632
|
such as a [modern Node.js stream](https://nodejs.org/api/stream.html#stream_streams_compatibility_with_async_generators_and_async_iterators).
|
|
@@ -611,11 +635,12 @@ as in [`CarReader.fromIterable`](#CarReader__fromIterable), only the header is d
|
|
|
611
635
|
remainder of the CAR is parsed as the `CID`s as yielded.
|
|
612
636
|
|
|
613
637
|
<a name="CarIndexer"></a>
|
|
638
|
+
|
|
614
639
|
### `class CarIndexer`
|
|
615
640
|
|
|
616
641
|
Properties:
|
|
617
642
|
|
|
618
|
-
|
|
643
|
+
- `version` `(number)`: The version number of the CAR referenced by this
|
|
619
644
|
reader (should be `1`).
|
|
620
645
|
|
|
621
646
|
Provides an iterator over all of the `Block`s in a CAR, returning their CIDs
|
|
@@ -641,30 +666,33 @@ Load this class with either
|
|
|
641
666
|
result in smaller bundle sizes where this is important.
|
|
642
667
|
|
|
643
668
|
<a name="CarIndexer_getRoots"></a>
|
|
669
|
+
|
|
644
670
|
### `async CarIndexer#getRoots()`
|
|
645
671
|
|
|
646
|
-
|
|
672
|
+
- Returns: `Promise<CID[]>`
|
|
647
673
|
|
|
648
674
|
Get the list of roots defined by the CAR referenced by this indexer. May be
|
|
649
675
|
zero or more `CID`s.
|
|
650
676
|
|
|
651
677
|
<a name="CarIndexer__fromBytes"></a>
|
|
678
|
+
|
|
652
679
|
### `async CarIndexer.fromBytes(bytes)`
|
|
653
680
|
|
|
654
|
-
|
|
681
|
+
- `bytes` `(Uint8Array)`
|
|
655
682
|
|
|
656
|
-
|
|
683
|
+
- Returns: `Promise<CarIndexer>`
|
|
657
684
|
|
|
658
685
|
Instantiate a [`CarIndexer`](#CarIndexer) from a `Uint8Array` blob. Only the header
|
|
659
686
|
is decoded initially, the remainder is processed and emitted via the
|
|
660
687
|
iterator as it is consumed.
|
|
661
688
|
|
|
662
689
|
<a name="CarIndexer__fromIterable"></a>
|
|
690
|
+
|
|
663
691
|
### `async CarIndexer.fromIterable(asyncIterable)`
|
|
664
692
|
|
|
665
|
-
|
|
693
|
+
- `asyncIterable` `(AsyncIterable<Uint8Array>)`
|
|
666
694
|
|
|
667
|
-
|
|
695
|
+
- Returns: `Promise<CarIndexer>`
|
|
668
696
|
|
|
669
697
|
Instantiate a [`CarIndexer`](#CarIndexer) from a `AsyncIterable<Uint8Array>`,
|
|
670
698
|
such as a [modern Node.js stream](https://nodejs.org/api/stream.html#stream_streams_compatibility_with_async_generators_and_async_iterators).
|
|
@@ -672,6 +700,7 @@ is decoded initially, the remainder is processed and emitted via the
|
|
|
672
700
|
iterator as it is consumed.
|
|
673
701
|
|
|
674
702
|
<a name="CarWriter"></a>
|
|
703
|
+
|
|
675
704
|
### `class CarWriter`
|
|
676
705
|
|
|
677
706
|
Provides a writer interface for the creation of CAR files.
|
|
@@ -706,45 +735,42 @@ Load this class with either
|
|
|
706
735
|
result in smaller bundle sizes where this is important.
|
|
707
736
|
|
|
708
737
|
<a name="CarWriter_put"></a>
|
|
738
|
+
|
|
709
739
|
### `async CarWriter#put(block)`
|
|
710
740
|
|
|
711
|
-
|
|
741
|
+
- `block` `(Block)`: A `{ cid:CID, bytes:Uint8Array }` pair.
|
|
712
742
|
|
|
713
|
-
|
|
743
|
+
- Returns: `Promise<void>`: The returned promise will only resolve once the
|
|
714
744
|
bytes this block generates are written to the `out` iterable.
|
|
715
745
|
|
|
716
746
|
Write a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) to the archive.
|
|
717
747
|
|
|
718
748
|
<a name="CarWriter_close"></a>
|
|
749
|
+
|
|
719
750
|
### `async CarWriter#close()`
|
|
720
751
|
|
|
721
|
-
|
|
752
|
+
- Returns: `Promise<void>`
|
|
722
753
|
|
|
723
754
|
Finalise the CAR archive and signal that the `out` iterable should end once
|
|
724
755
|
any remaining bytes are written.
|
|
725
756
|
|
|
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
757
|
<a name="CarWriter__create"></a>
|
|
758
|
+
|
|
734
759
|
### `async CarWriter.create(roots)`
|
|
735
760
|
|
|
736
|
-
|
|
761
|
+
- `roots` `(CID[]|CID|void)`
|
|
737
762
|
|
|
738
|
-
|
|
763
|
+
- Returns: `WriterChannel`: The channel takes the form of
|
|
739
764
|
`{ writer:CarWriter, out:AsyncIterable<Uint8Array> }`.
|
|
740
765
|
|
|
741
766
|
Create a new CAR writer "channel" which consists of a
|
|
742
767
|
`{ writer:CarWriter, out:AsyncIterable<Uint8Array> }` pair.
|
|
743
768
|
|
|
744
769
|
<a name="CarWriter__createAppender"></a>
|
|
770
|
+
|
|
745
771
|
### `async CarWriter.createAppender()`
|
|
746
772
|
|
|
747
|
-
|
|
773
|
+
- Returns: `WriterChannel`: The channel takes the form of
|
|
748
774
|
`{ writer:CarWriter, out:AsyncIterable<Uint8Array> }`.
|
|
749
775
|
|
|
750
776
|
Create a new CAR appender "channel" which consists of a
|
|
@@ -755,15 +781,16 @@ expected that `out` will be concatenated onto the end of an existing
|
|
|
755
781
|
archive that already has a properly formatted header.
|
|
756
782
|
|
|
757
783
|
<a name="CarWriter__updateRootsInBytes"></a>
|
|
784
|
+
|
|
758
785
|
### `async CarWriter.updateRootsInBytes(bytes, roots)`
|
|
759
786
|
|
|
760
|
-
|
|
761
|
-
|
|
787
|
+
- `bytes` `(Uint8Array)`
|
|
788
|
+
- `roots` `(CID[])`: A new list of roots to replace the existing list in
|
|
762
789
|
the CAR header. The new header must take up the same number of bytes as the
|
|
763
790
|
existing header, so the roots should collectively be the same byte length
|
|
764
791
|
as the existing roots.
|
|
765
792
|
|
|
766
|
-
|
|
793
|
+
- Returns: `Promise<Uint8Array>`
|
|
767
794
|
|
|
768
795
|
Update the list of roots in the header of an existing CAR as represented
|
|
769
796
|
in a Uint8Array.
|
|
@@ -778,17 +805,18 @@ The byte array passed in an argument will be modified and also returned
|
|
|
778
805
|
upon successful modification.
|
|
779
806
|
|
|
780
807
|
<a name="CarWriter__updateRootsInFile"></a>
|
|
808
|
+
|
|
781
809
|
### `async CarWriter.updateRootsInFile(fd, roots)`
|
|
782
810
|
|
|
783
|
-
|
|
811
|
+
- `fd` `(fs.promises.FileHandle|number)`: A file descriptor from the
|
|
784
812
|
Node.js `fs` module. Either an integer, from `fs.open()` or a `FileHandle`
|
|
785
813
|
from `fs.promises.open()`.
|
|
786
|
-
|
|
814
|
+
- `roots` `(CID[])`: A new list of roots to replace the existing list in
|
|
787
815
|
the CAR header. The new header must take up the same number of bytes as the
|
|
788
816
|
existing header, so the roots should collectively be the same byte length
|
|
789
817
|
as the existing roots.
|
|
790
818
|
|
|
791
|
-
|
|
819
|
+
- Returns: `Promise<void>`
|
|
792
820
|
|
|
793
821
|
Update the list of roots in the header of an existing CAR file. The first
|
|
794
822
|
argument must be a file descriptor for CAR file that is open in read and
|
|
@@ -805,93 +833,105 @@ This function is **only available in Node.js** and not a browser
|
|
|
805
833
|
environment.
|
|
806
834
|
|
|
807
835
|
<a name="CarBufferWriter"></a>
|
|
836
|
+
|
|
808
837
|
### `class CarBufferWriter`
|
|
809
838
|
|
|
810
839
|
A simple CAR writer that writes to a pre-allocated buffer.
|
|
811
840
|
|
|
812
841
|
<a name="CarBufferWriter_addRoot"></a>
|
|
842
|
+
|
|
813
843
|
### `CarBufferWriter#addRoot(root, options)`
|
|
814
844
|
|
|
815
|
-
|
|
816
|
-
|
|
845
|
+
- `root` `(CID)`
|
|
846
|
+
- `options`
|
|
817
847
|
|
|
818
|
-
|
|
848
|
+
- Returns: `CarBufferWriter`
|
|
819
849
|
|
|
820
850
|
Add a root to this writer, to be used to create a header when the CAR is
|
|
821
851
|
finalized with [`close()`](#CarBufferWriter__close)
|
|
822
852
|
|
|
823
853
|
<a name="CarBufferWriter_write"></a>
|
|
854
|
+
|
|
824
855
|
### `CarBufferWriter#write(block)`
|
|
825
856
|
|
|
826
|
-
|
|
857
|
+
- `block` `(Block)`: A `{ cid:CID, bytes:Uint8Array }` pair.
|
|
827
858
|
|
|
828
|
-
|
|
859
|
+
- Returns: `CarBufferWriter`
|
|
829
860
|
|
|
830
861
|
Write a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) to the archive.
|
|
831
862
|
Throws if there is not enough capacity.
|
|
832
863
|
|
|
833
864
|
<a name="CarBufferWriter_close"></a>
|
|
865
|
+
|
|
834
866
|
### `CarBufferWriter#close([options])`
|
|
835
867
|
|
|
836
|
-
|
|
837
|
-
* `options.resize` `(boolean, optional)`
|
|
868
|
+
- `options` `(object, optional)`
|
|
838
869
|
|
|
839
|
-
|
|
870
|
+
- `options.resize` `(boolean, optional)`
|
|
871
|
+
|
|
872
|
+
- Returns: `Uint8Array`
|
|
840
873
|
|
|
841
874
|
Finalize the CAR and return it as a `Uint8Array`.
|
|
842
875
|
|
|
843
876
|
<a name="CarBufferWriter__blockLength__Block__"></a>
|
|
877
|
+
|
|
844
878
|
### `CarBufferWriter.blockLength(Block)`
|
|
845
879
|
|
|
846
|
-
|
|
880
|
+
- `block` `(Block)`
|
|
847
881
|
|
|
848
|
-
|
|
882
|
+
- Returns: `number`
|
|
849
883
|
|
|
850
884
|
Calculates number of bytes required for storing given block in CAR. Useful in
|
|
851
885
|
estimating size of an `ArrayBuffer` for the `CarBufferWriter`.
|
|
852
886
|
|
|
853
887
|
<a name="CarBufferWriter__calculateHeaderLength__rootLengths__"></a>
|
|
888
|
+
|
|
854
889
|
### `CarBufferWriter.calculateHeaderLength(rootLengths)`
|
|
855
890
|
|
|
856
|
-
|
|
891
|
+
- `rootLengths` `(number[])`
|
|
857
892
|
|
|
858
|
-
|
|
893
|
+
- Returns: `number`
|
|
859
894
|
|
|
860
895
|
Calculates header size given the array of byteLength for roots.
|
|
861
896
|
|
|
862
897
|
<a name="CarBufferWriter__headerLength______roots______"></a>
|
|
898
|
+
|
|
863
899
|
### `CarBufferWriter.headerLength({ roots })`
|
|
864
900
|
|
|
865
|
-
|
|
866
|
-
* `options.roots` `(CID[])`
|
|
901
|
+
- `options` `(object)`
|
|
867
902
|
|
|
868
|
-
|
|
903
|
+
- `options.roots` `(CID[])`
|
|
904
|
+
|
|
905
|
+
- Returns: `number`
|
|
869
906
|
|
|
870
907
|
Calculates header size given the array of roots.
|
|
871
908
|
|
|
872
909
|
<a name="CarBufferWriter__estimateHeaderLength__rootCount______rootByteLength____"></a>
|
|
910
|
+
|
|
873
911
|
### `CarBufferWriter.estimateHeaderLength(rootCount[, rootByteLength])`
|
|
874
912
|
|
|
875
|
-
|
|
876
|
-
|
|
913
|
+
- `rootCount` `(number)`
|
|
914
|
+
- `rootByteLength` `(number, optional)`
|
|
877
915
|
|
|
878
|
-
|
|
916
|
+
- Returns: `number`
|
|
879
917
|
|
|
880
918
|
Estimates header size given a count of the roots and the expected byte length
|
|
881
919
|
of the root CIDs. The default length works for a standard CIDv1 with a
|
|
882
920
|
single-byte multihash code, such as SHA2-256 (i.e. the most common CIDv1).
|
|
883
921
|
|
|
884
922
|
<a name="CarBufferWriter__createWriter__buffer______options____"></a>
|
|
923
|
+
|
|
885
924
|
### `CarBufferWriter.createWriter(buffer[, options])`
|
|
886
925
|
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
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)`
|
|
893
933
|
|
|
894
|
-
|
|
934
|
+
- Returns: `CarBufferWriter`
|
|
895
935
|
|
|
896
936
|
Creates synchronous CAR writer that can be used to encode blocks into a given
|
|
897
937
|
buffer. Optionally you could pass `byteOffset` and `byteLength` to specify a
|
|
@@ -905,22 +945,24 @@ Note: Incorrect `headerSize` may lead to copying bytes inside a buffer
|
|
|
905
945
|
which will have a negative impact on performance.
|
|
906
946
|
|
|
907
947
|
<a name="async__decoder__readHeader__reader__"></a>
|
|
948
|
+
|
|
908
949
|
### `async decoder.readHeader(reader)`
|
|
909
950
|
|
|
910
|
-
|
|
911
|
-
|
|
951
|
+
- `reader` `(BytesReader)`
|
|
952
|
+
- `strictVersion` `(number, optional)`
|
|
912
953
|
|
|
913
|
-
|
|
954
|
+
- Returns: `Promise<(CarHeader|CarV2Header)>`
|
|
914
955
|
|
|
915
956
|
Reads header data from a `BytesReader`. The header may either be in the form
|
|
916
957
|
of a `CarHeader` or `CarV2Header` depending on the CAR being read.
|
|
917
958
|
|
|
918
959
|
<a name="async__decoder__readBlockHead__reader__"></a>
|
|
960
|
+
|
|
919
961
|
### `async decoder.readBlockHead(reader)`
|
|
920
962
|
|
|
921
|
-
|
|
963
|
+
- `reader` `(BytesReader)`
|
|
922
964
|
|
|
923
|
-
|
|
965
|
+
- Returns: `Promise<BlockHeader>`
|
|
924
966
|
|
|
925
967
|
Reads the leading data of an individual block from CAR data from a
|
|
926
968
|
`BytesReader`. Returns a `BlockHeader` object which contains
|
|
@@ -928,53 +970,58 @@ Reads the leading data of an individual block from CAR data from a
|
|
|
928
970
|
or read the block binary data.
|
|
929
971
|
|
|
930
972
|
<a name="decoder__createDecoder__reader__"></a>
|
|
973
|
+
|
|
931
974
|
### `decoder.createDecoder(reader)`
|
|
932
975
|
|
|
933
|
-
|
|
976
|
+
- `reader` `(BytesReader)`
|
|
934
977
|
|
|
935
|
-
|
|
978
|
+
- Returns: `CarDecoder`
|
|
936
979
|
|
|
937
980
|
Creates a `CarDecoder` from a `BytesReader`. The `CarDecoder` is as async
|
|
938
981
|
interface that will consume the bytes from the `BytesReader` to yield a
|
|
939
982
|
`header()` and either `blocks()` or `blocksIndex()` data.
|
|
940
983
|
|
|
941
984
|
<a name="decoder__bytesReader__bytes__"></a>
|
|
985
|
+
|
|
942
986
|
### `decoder.bytesReader(bytes)`
|
|
943
987
|
|
|
944
|
-
|
|
988
|
+
- `bytes` `(Uint8Array)`
|
|
945
989
|
|
|
946
|
-
|
|
990
|
+
- Returns: `BytesReader`
|
|
947
991
|
|
|
948
992
|
Creates a `BytesReader` from a `Uint8Array`.
|
|
949
993
|
|
|
950
994
|
<a name="decoder__asyncIterableReader__asyncIterable__"></a>
|
|
995
|
+
|
|
951
996
|
### `decoder.asyncIterableReader(asyncIterable)`
|
|
952
997
|
|
|
953
|
-
|
|
998
|
+
- `asyncIterable` `(AsyncIterable<Uint8Array>)`
|
|
954
999
|
|
|
955
|
-
|
|
1000
|
+
- Returns: `BytesReader`
|
|
956
1001
|
|
|
957
1002
|
Creates a `BytesReader` from an `AsyncIterable<Uint8Array>`, which allows for
|
|
958
1003
|
consumption of CAR data from a streaming source.
|
|
959
1004
|
|
|
960
1005
|
<a name="decoder__limitReader__reader____byteLimit__"></a>
|
|
1006
|
+
|
|
961
1007
|
### `decoder.limitReader(reader, byteLimit)`
|
|
962
1008
|
|
|
963
|
-
|
|
964
|
-
|
|
1009
|
+
- `reader` `(BytesReader)`
|
|
1010
|
+
- `byteLimit` `(number)`
|
|
965
1011
|
|
|
966
|
-
|
|
1012
|
+
- Returns: `BytesReader`
|
|
967
1013
|
|
|
968
1014
|
Wraps a `BytesReader` in a limiting `BytesReader` which limits maximum read
|
|
969
1015
|
to `byteLimit` bytes. It _does not_ update `pos` of the original
|
|
970
1016
|
`BytesReader`.
|
|
971
1017
|
|
|
972
1018
|
<a name="CarBufferReader"></a>
|
|
1019
|
+
|
|
973
1020
|
### `class CarBufferReader`
|
|
974
1021
|
|
|
975
1022
|
Properties:
|
|
976
1023
|
|
|
977
|
-
|
|
1024
|
+
- `version` `(number)`: The version number of the CAR referenced by this
|
|
978
1025
|
reader (should be `1` or `2`).
|
|
979
1026
|
|
|
980
1027
|
Provides blockstore-like access to a CAR.
|
|
@@ -992,29 +1039,32 @@ The former will likely result in smaller bundle sizes where this is
|
|
|
992
1039
|
important.
|
|
993
1040
|
|
|
994
1041
|
<a name="CarBufferReader_getRoots"></a>
|
|
1042
|
+
|
|
995
1043
|
### `CarBufferReader#getRoots()`
|
|
996
1044
|
|
|
997
|
-
|
|
1045
|
+
- Returns: `CID[]`
|
|
998
1046
|
|
|
999
1047
|
Get the list of roots defined by the CAR referenced by this reader. May be
|
|
1000
1048
|
zero or more `CID`s.
|
|
1001
1049
|
|
|
1002
1050
|
<a name="CarBufferReader_has"></a>
|
|
1051
|
+
|
|
1003
1052
|
### `CarBufferReader#has(key)`
|
|
1004
1053
|
|
|
1005
|
-
|
|
1054
|
+
- `key` `(CID)`
|
|
1006
1055
|
|
|
1007
|
-
|
|
1056
|
+
- Returns: `boolean`
|
|
1008
1057
|
|
|
1009
1058
|
Check whether a given `CID` exists within the CAR referenced by this
|
|
1010
1059
|
reader.
|
|
1011
1060
|
|
|
1012
1061
|
<a name="CarBufferReader_get"></a>
|
|
1062
|
+
|
|
1013
1063
|
### `CarBufferReader#get(key)`
|
|
1014
1064
|
|
|
1015
|
-
|
|
1065
|
+
- `key` `(CID)`
|
|
1016
1066
|
|
|
1017
|
-
|
|
1067
|
+
- Returns: `Block|undefined`
|
|
1018
1068
|
|
|
1019
1069
|
Fetch a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) from the CAR
|
|
1020
1070
|
referenced by this reader matching the provided `CID`. In the case where
|
|
@@ -1022,41 +1072,45 @@ the provided `CID` doesn't exist within the CAR, `undefined` will be
|
|
|
1022
1072
|
returned.
|
|
1023
1073
|
|
|
1024
1074
|
<a name="CarBufferReader_blocks"></a>
|
|
1075
|
+
|
|
1025
1076
|
### `CarBufferReader#blocks()`
|
|
1026
1077
|
|
|
1027
|
-
|
|
1078
|
+
- Returns: `Block[]`
|
|
1028
1079
|
|
|
1029
1080
|
Returns a `Block[]` of the `Block`s (`{ cid:CID, bytes:Uint8Array }` pairs) contained within
|
|
1030
1081
|
the CAR referenced by this reader.
|
|
1031
1082
|
|
|
1032
1083
|
<a name="CarBufferReader_cids"></a>
|
|
1084
|
+
|
|
1033
1085
|
### `CarBufferReader#cids()`
|
|
1034
1086
|
|
|
1035
|
-
|
|
1087
|
+
- Returns: `CID[]`
|
|
1036
1088
|
|
|
1037
1089
|
Returns a `CID[]` of the `CID`s contained within the CAR referenced by this reader.
|
|
1038
1090
|
|
|
1039
1091
|
<a name="CarBufferReader__fromBytes"></a>
|
|
1092
|
+
|
|
1040
1093
|
### `CarBufferReader.fromBytes(bytes)`
|
|
1041
1094
|
|
|
1042
|
-
|
|
1095
|
+
- `bytes` `(Uint8Array)`
|
|
1043
1096
|
|
|
1044
|
-
|
|
1097
|
+
- Returns: `CarBufferReader`
|
|
1045
1098
|
|
|
1046
1099
|
Instantiate a [`CarBufferReader`](#CarBufferReader) from a `Uint8Array` blob. This performs a
|
|
1047
1100
|
decode fully in memory and maintains the decoded state in memory for full
|
|
1048
1101
|
access to the data via the `CarReader` API.
|
|
1049
1102
|
|
|
1050
1103
|
<a name="CarBufferReader__readRaw"></a>
|
|
1104
|
+
|
|
1051
1105
|
### `CarBufferReader.readRaw(fd, blockIndex)`
|
|
1052
1106
|
|
|
1053
|
-
|
|
1107
|
+
- `fd` `(number)`: A file descriptor from the
|
|
1054
1108
|
Node.js `fs` module. An integer, from `fs.open()`.
|
|
1055
|
-
|
|
1109
|
+
- `blockIndex` `(BlockIndex)`: An index pointing to the location of the
|
|
1056
1110
|
Block required. This `BlockIndex` should take the form:
|
|
1057
1111
|
`{cid:CID, blockLength:number, blockOffset:number}`.
|
|
1058
1112
|
|
|
1059
|
-
|
|
1113
|
+
- Returns: `Block`: A `{ cid:CID, bytes:Uint8Array }` pair.
|
|
1060
1114
|
|
|
1061
1115
|
Reads a block directly from a file descriptor for an open CAR file. This
|
|
1062
1116
|
function is **only available in Node.js** and not a browser environment.
|