CarWriter.fromIterable(roots, blockIterator)
- Dominant language
- JavaScript
- Stars
- 51
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Description
@alanshaw had an API suggestion over @ https://github.com/web3-storage/ipfs-car/pull/74
```js
const out = await CarWriter.fromIterable([root], blockstore.blocks())
```
Some things to be resolved:
1. Should it be named `fromBlockIterable()` to make absolutely clear that this is a `{cid,bytes}` iterator it wants, because every other `fromIterable()` in the API currently is a `Uint8Array` iterator? This API would be able to take as input a `CarBlockIterator`, so we have prior-art for that name. (`fs.createWriteStream('out.car', CarWriter.fromIterable([], await CarBlockIterator.fromIterable(fs.createReadStream('in.car'))` [transferring roots is possible but it would take more than one line!]).
2. Does it need an `await` and if so what is it waiting on? Looking at the code, I think `CarWriter.create()` now is sync and doesn't need the `await` even though I see I've used it on the README! I don't think there's any good reason why a `CarWriter.fromIterable()` couldn't return `out` straight away, so maybe the `await` is entirely unnecessary here. The AsyncIterable protocol gives us everything we need to set up async constructions and should also allow proper error propagation regardless of where it happens in this chain.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.