Comparing version 1.0.6 to 2.0.0
@@ -1,6 +0,6 @@ | ||
import CarReader from './lib/reader-browser.js' | ||
import CarIndexer from './lib/indexer.js' | ||
import { CarReader } from './lib/reader-browser.js' | ||
import { CarIndexer } from './lib/indexer.js' | ||
import { CarBlockIterator, CarCIDIterator } from './lib/iterator.js' | ||
import CarWriter from './lib/writer.js' | ||
import CarIndexedReader from './lib/indexed-reader-browser.js' | ||
import { CarWriter } from './lib/writer.js' | ||
import { CarIndexedReader } from './lib/indexed-reader-browser.js' | ||
@@ -7,0 +7,0 @@ export { |
@@ -1,6 +0,6 @@ | ||
import CarReader from './lib/reader.js' | ||
import CarIndexer from './lib/indexer.js' | ||
import { CarReader } from './lib/reader.js' | ||
import { CarIndexer } from './lib/indexer.js' | ||
import { CarBlockIterator, CarCIDIterator } from './lib/iterator.js' | ||
import CarWriter from './lib/writer.js' | ||
import CarIndexedReader from './lib/indexed-reader.js' | ||
import { CarWriter } from './lib/writer.js' | ||
import { CarIndexedReader } from './lib/indexed-reader.js' | ||
@@ -7,0 +7,0 @@ export { |
@@ -40,3 +40,3 @@ 'use strict'; | ||
const inStream = fs__default['default'].createReadStream(path__default['default'].join(__dirname$1, './go.car')); | ||
const reader = await readerBrowser['default'].fromIterable(inStream); | ||
const reader = await readerBrowser.CarReader.fromIterable(inStream); | ||
await verifyStoreReader.verifyRoots(reader); | ||
@@ -49,3 +49,3 @@ await verifyStoreReader.verifyHas(reader); | ||
it('complete', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(roots); | ||
const {writer: writer$1, out} = writer.CarWriter.create(roots); | ||
const pipe = util.promisify(stream.pipeline)(stream.Readable.from(out), fs__default['default'].createWriteStream(tmpCarPath)); | ||
@@ -65,3 +65,3 @@ for (const block of allBlocksFlattened) { | ||
const inStream = fs__default['default'].createReadStream(tmpCarPath); | ||
const reader = await readerBrowser['default'].fromIterable(inStream); | ||
const reader = await readerBrowser.CarReader.fromIterable(inStream); | ||
await verifyStoreReader.verifyRoots(reader); | ||
@@ -68,0 +68,0 @@ await verifyStoreReader.verifyHas(reader); |
@@ -17,3 +17,3 @@ 'use strict'; | ||
it('complete', async () => { | ||
const reader = await indexedReaderBrowser['default'].fromFile(path__default['default'].join(__dirname$1, 'go.car')); | ||
const reader = await indexedReaderBrowser.CarIndexedReader.fromFile(path__default['default'].join(__dirname$1, 'go.car')); | ||
await verifyStoreReader.verifyRoots(reader); | ||
@@ -49,5 +49,5 @@ await verifyStoreReader.verifyHas(reader); | ||
]) { | ||
await common.assert.isRejected(indexedReaderBrowser['default'].fromFile(arg)); | ||
await common.assert.isRejected(indexedReaderBrowser.CarIndexedReader.fromFile(arg)); | ||
} | ||
}); | ||
}); |
@@ -48,3 +48,3 @@ 'use strict'; | ||
it('create, no roots', async () => { | ||
const {writer: writer$1, out} = writer['default'].create([]); | ||
const {writer: writer$1, out} = writer.CarWriter.create([]); | ||
stream.Readable.from(out).pipe(fs__default['default'].createWriteStream('./test.car')); | ||
@@ -84,3 +84,3 @@ let offset = dagCbor__namespace.encode({ | ||
it('CarIndexer.fromIterable', async () => { | ||
const indexer$1 = await indexer.fromIterable(fs__default['default'].createReadStream('./test.car')); | ||
const indexer$1 = await indexer.CarIndexer.fromIterable(fs__default['default'].createReadStream('./test.car')); | ||
common.assert.deepStrictEqual(await indexer$1.getRoots(), []); | ||
@@ -94,3 +94,3 @@ let i = 0; | ||
it('CarIndexer.fromBytes', async () => { | ||
const indexer$1 = await indexer.fromBytes(await fs__default['default'].promises.readFile('./test.car')); | ||
const indexer$1 = await indexer.CarIndexer.fromBytes(await fs__default['default'].promises.readFile('./test.car')); | ||
common.assert.deepStrictEqual(await indexer$1.getRoots(), []); | ||
@@ -104,3 +104,3 @@ let i = 0; | ||
it('CarReader.fromBytes', async () => { | ||
const reader = await readerBrowser['default'].fromBytes(await fs__default['default'].promises.readFile('./test.car')); | ||
const reader = await readerBrowser.CarReader.fromBytes(await fs__default['default'].promises.readFile('./test.car')); | ||
common.assert.deepStrictEqual(await reader.getRoots(), []); | ||
@@ -116,3 +116,3 @@ let i = 0; | ||
it('CarReader.fromIterable', async () => { | ||
const reader = await readerBrowser['default'].fromIterable(fs__default['default'].createReadStream('./test.car')); | ||
const reader = await readerBrowser.CarReader.fromIterable(fs__default['default'].createReadStream('./test.car')); | ||
common.assert.deepStrictEqual(await reader.getRoots(), []); | ||
@@ -128,3 +128,3 @@ let i = 0; | ||
it('CarIndexedReader.fromFile', async () => { | ||
const reader = await indexedReaderBrowser['default'].fromFile('./test.car'); | ||
const reader = await indexedReaderBrowser.CarIndexedReader.fromFile('./test.car'); | ||
common.assert.deepStrictEqual(await reader.getRoots(), []); | ||
@@ -131,0 +131,0 @@ let i = 0; |
@@ -35,3 +35,3 @@ 'use strict'; | ||
for (const blockIndex of common.goCarIndex) { | ||
const {cid, bytes} = await readerBrowser['default'].readRaw(fd, blockIndex); | ||
const {cid, bytes} = await readerBrowser.CarReader.readRaw(fd, blockIndex); | ||
const index = expectedCids.indexOf(cid.toString()); | ||
@@ -56,3 +56,3 @@ common.assert.ok(index >= 0, 'got expected block'); | ||
it('errors', async () => { | ||
await common.assert.isRejected(readerBrowser['default'].readRaw(true, common.goCarIndex[0]), { | ||
await common.assert.isRejected(readerBrowser.CarReader.readRaw(true, common.goCarIndex[0]), { | ||
name: 'TypeError', | ||
@@ -64,3 +64,3 @@ message: 'Bad fd' | ||
const fd = await fsopen(path__default['default'].join(__dirname$1, 'go.car'), 'r'); | ||
await common.assert.isRejected(readerBrowser['default'].readRaw(fd, badBlock), { | ||
await common.assert.isRejected(readerBrowser.CarReader.readRaw(fd, badBlock), { | ||
name: 'Error', | ||
@@ -67,0 +67,0 @@ message: `Failed to read entire block (${ badBlock.blockLength - 10 } instead of ${ badBlock.blockLength })` |
@@ -12,3 +12,3 @@ 'use strict'; | ||
buf2[101] = 0; | ||
await common.assert.isRejected(readerBrowser['default'].fromBytes(buf2), { | ||
await common.assert.isRejected(readerBrowser.CarReader.fromBytes(buf2), { | ||
name: 'Error', | ||
@@ -15,0 +15,0 @@ message: 'Unexpected CID version (0)' |
@@ -9,3 +9,3 @@ 'use strict'; | ||
it('complete', async () => { | ||
const indexer$1 = await indexer.fromBytes(common.goCarBytes); | ||
const indexer$1 = await indexer.CarIndexer.fromBytes(common.goCarBytes); | ||
await verifyStoreReader.verifyRoots(indexer$1); | ||
@@ -29,3 +29,3 @@ common.assert.strictEqual(indexer$1.version, 1); | ||
]) { | ||
await common.assert.isRejected(indexer.fromBytes(arg)); | ||
await common.assert.isRejected(indexer.CarIndexer.fromBytes(arg)); | ||
} | ||
@@ -45,11 +45,11 @@ }); | ||
it('complete (single chunk)', async () => { | ||
const indexer$1 = await indexer.fromIterable(common.makeIterable(common.goCarBytes, common.goCarBytes.length)); | ||
const indexer$1 = await indexer.CarIndexer.fromIterable(common.makeIterable(common.goCarBytes, common.goCarBytes.length)); | ||
return verifyIndexer(indexer$1); | ||
}); | ||
it('complete (101-byte chunks)', async () => { | ||
const indexer$1 = await indexer.fromIterable(common.makeIterable(common.goCarBytes, 101)); | ||
const indexer$1 = await indexer.CarIndexer.fromIterable(common.makeIterable(common.goCarBytes, 101)); | ||
return verifyIndexer(indexer$1); | ||
}); | ||
it('complete (32-byte chunks)', async () => { | ||
const indexer$1 = await indexer.fromIterable(common.makeIterable(common.goCarBytes, 32)); | ||
const indexer$1 = await indexer.CarIndexer.fromIterable(common.makeIterable(common.goCarBytes, 32)); | ||
return verifyIndexer(indexer$1); | ||
@@ -68,5 +68,5 @@ }); | ||
]) { | ||
await common.assert.isRejected(indexer.fromIterable(arg)); | ||
await common.assert.isRejected(indexer.CarIndexer.fromIterable(arg)); | ||
} | ||
}); | ||
}); |
@@ -12,7 +12,7 @@ 'use strict'; | ||
it('exports match', () => { | ||
common.assert.strictEqual(readerBrowser['default'], readerBrowser['default']); | ||
common.assert.strictEqual(indexer, indexer); | ||
common.assert.strictEqual(readerBrowser.CarReader, readerBrowser.CarReader); | ||
common.assert.strictEqual(indexer.CarIndexer, indexer.CarIndexer); | ||
common.assert.strictEqual(iterator.CarBlockIterator, iterator.CarBlockIterator); | ||
common.assert.strictEqual(iterator.CarCIDIterator, iterator.CarCIDIterator); | ||
common.assert.strictEqual(writer['default'], writer['default']); | ||
common.assert.strictEqual(writer.CarWriter, writer.CarWriter); | ||
}); | ||
@@ -19,0 +19,0 @@ it('browser exports', () => { |
@@ -9,3 +9,3 @@ 'use strict'; | ||
it('complete', async () => { | ||
const reader = await readerBrowser['default'].fromBytes(common.carBytes); | ||
const reader = await readerBrowser.CarReader.fromBytes(common.carBytes); | ||
await verifyStoreReader.verifyRoots(reader); | ||
@@ -19,3 +19,3 @@ await verifyStoreReader.verifyHas(reader); | ||
it('complete (get before has) switch', async () => { | ||
const reader = await readerBrowser['default'].fromBytes(common.carBytes); | ||
const reader = await readerBrowser.CarReader.fromBytes(common.carBytes); | ||
await verifyStoreReader.verifyRoots(reader); | ||
@@ -37,7 +37,7 @@ await verifyStoreReader.verifyGet(reader); | ||
]) { | ||
await common.assert.isRejected(readerBrowser['default'].fromBytes(arg)); | ||
await common.assert.isRejected(readerBrowser.CarReader.fromBytes(arg)); | ||
} | ||
}); | ||
it('decode error - truncated', async () => { | ||
await common.assert.isRejected(readerBrowser['default'].fromBytes(common.carBytes.slice(0, common.carBytes.length - 10)), { | ||
await common.assert.isRejected(readerBrowser.CarReader.fromBytes(common.carBytes.slice(0, common.carBytes.length - 10)), { | ||
name: 'Error', | ||
@@ -50,3 +50,3 @@ message: 'Unexpected end of data' | ||
it('complete (single chunk)', async () => { | ||
const reader = await readerBrowser['default'].fromIterable(common.makeIterable(common.carBytes, common.carBytes.length)); | ||
const reader = await readerBrowser.CarReader.fromIterable(common.makeIterable(common.carBytes, common.carBytes.length)); | ||
await verifyStoreReader.verifyRoots(reader); | ||
@@ -59,3 +59,3 @@ await verifyStoreReader.verifyHas(reader); | ||
it('complete (101-byte chunks)', async () => { | ||
const reader = await readerBrowser['default'].fromIterable(common.makeIterable(common.carBytes, 101)); | ||
const reader = await readerBrowser.CarReader.fromIterable(common.makeIterable(common.carBytes, 101)); | ||
await verifyStoreReader.verifyRoots(reader); | ||
@@ -68,3 +68,3 @@ await verifyStoreReader.verifyHas(reader); | ||
it('complete (64-byte chunks)', async () => { | ||
const reader = await readerBrowser['default'].fromIterable(common.makeIterable(common.carBytes, 64)); | ||
const reader = await readerBrowser.CarReader.fromIterable(common.makeIterable(common.carBytes, 64)); | ||
await verifyStoreReader.verifyRoots(reader); | ||
@@ -77,3 +77,3 @@ await verifyStoreReader.verifyHas(reader); | ||
it('complete (32-byte chunks)', async () => { | ||
const reader = await readerBrowser['default'].fromIterable(common.makeIterable(common.carBytes, 32)); | ||
const reader = await readerBrowser.CarReader.fromIterable(common.makeIterable(common.carBytes, 32)); | ||
await verifyStoreReader.verifyRoots(reader); | ||
@@ -96,7 +96,7 @@ await verifyStoreReader.verifyHas(reader); | ||
]) { | ||
await common.assert.isRejected(readerBrowser['default'].fromIterable(arg)); | ||
await common.assert.isRejected(readerBrowser.CarReader.fromIterable(arg)); | ||
} | ||
}); | ||
it('decode error - truncated', async () => { | ||
await common.assert.isRejected(readerBrowser['default'].fromIterable(common.makeIterable(common.carBytes.slice(0, common.carBytes.length - 10), 64)), { | ||
await common.assert.isRejected(readerBrowser.CarReader.fromIterable(common.makeIterable(common.carBytes.slice(0, common.carBytes.length - 10), 64)), { | ||
name: 'Error', | ||
@@ -103,0 +103,0 @@ message: 'Unexpected end of data' |
@@ -47,3 +47,3 @@ 'use strict'; | ||
it('complete', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(roots); | ||
const {writer: writer$1, out} = writer.CarWriter.create(roots); | ||
common.assert.strictEqual(typeof out[Symbol.asyncIterator], 'function'); | ||
@@ -65,3 +65,3 @@ const collection = collector(out); | ||
it('complete, deferred collection', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(roots); | ||
const {writer: writer$1, out} = writer.CarWriter.create(roots); | ||
const writeQueue = []; | ||
@@ -81,3 +81,3 @@ for (const block of allBlocksFlattened) { | ||
it('complete, close after write', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(roots); | ||
const {writer: writer$1, out} = writer.CarWriter.create(roots); | ||
common.assert.strictEqual(typeof out[Symbol.asyncIterator], 'function'); | ||
@@ -100,3 +100,3 @@ const collection = collector(out); | ||
it('complete, no queue', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(roots); | ||
const {writer: writer$1, out} = writer.CarWriter.create(roots); | ||
const collection = collector(out); | ||
@@ -111,3 +111,3 @@ for (const block of allBlocksFlattened) { | ||
it('complete, slow drip', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(roots); | ||
const {writer: writer$1, out} = writer.CarWriter.create(roots); | ||
common.assert.strictEqual(typeof out[Symbol.asyncIterator], 'function'); | ||
@@ -125,3 +125,3 @@ const collection = collector(out); | ||
it('complete, no queue, deferred collection', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(roots); | ||
const {writer: writer$1, out} = writer.CarWriter.create(roots); | ||
for (const block of allBlocksFlattened) { | ||
@@ -136,3 +136,3 @@ writer$1.put(block); | ||
it('single root', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(roots[0]); | ||
const {writer: writer$1, out} = writer.CarWriter.create(roots[0]); | ||
const collection = collector(out); | ||
@@ -149,3 +149,3 @@ for (const block of allBlocksFlattened) { | ||
it('no roots', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(); | ||
const {writer: writer$1, out} = writer.CarWriter.create(); | ||
const collection = collector(out); | ||
@@ -162,3 +162,3 @@ for (const block of allBlocksFlattened) { | ||
it('appender', async () => { | ||
let writerOut = writer['default'].create(roots); | ||
let writerOut = writer.CarWriter.create(roots); | ||
let collection = collector(writerOut.out); | ||
@@ -168,3 +168,3 @@ await writerOut.writer.close(); | ||
const append = async index => { | ||
writerOut = writer['default'].createAppender(); | ||
writerOut = writer.CarWriter.createAppender(); | ||
collection = collector(writerOut.out); | ||
@@ -202,7 +202,7 @@ for (const block of allBlocks[index][1]) { | ||
]) { | ||
common.assert.throws(() => writer['default'].create(arg)); | ||
common.assert.throws(() => writer.CarWriter.create(arg)); | ||
} | ||
}); | ||
it('bad argument for put()', async () => { | ||
const {writer: writer$1} = writer['default'].create(); | ||
const {writer: writer$1} = writer.CarWriter.create(); | ||
for (const arg of [ | ||
@@ -250,3 +250,3 @@ new Uint8Array(0), | ||
it('bad write after closed', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(); | ||
const {writer: writer$1, out} = writer.CarWriter.create(); | ||
const collection = collector(out); | ||
@@ -259,3 +259,3 @@ await writer$1.put(allBlocksFlattened[0]); | ||
it('bad attempt to multiple iterate', async () => { | ||
const {out} = writer['default'].create(); | ||
const {out} = writer.CarWriter.create(); | ||
collector(out); | ||
@@ -265,3 +265,3 @@ await common.assert.isRejected(collector(out), /multiple iterator/i); | ||
it('bad attempt to multiple close', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(); | ||
const {writer: writer$1, out} = writer.CarWriter.create(); | ||
collector(out); | ||
@@ -268,0 +268,0 @@ await writer$1.close(); |
@@ -13,7 +13,7 @@ 'use strict'; | ||
exports.CarReader = readerBrowser['default']; | ||
exports.CarIndexer = indexer; | ||
exports.CarReader = readerBrowser.CarReader; | ||
exports.CarIndexer = indexer.CarIndexer; | ||
exports.CarBlockIterator = iterator.CarBlockIterator; | ||
exports.CarCIDIterator = iterator.CarCIDIterator; | ||
exports.CarWriter = writer['default']; | ||
exports.CarIndexedReader = indexedReaderBrowser['default']; | ||
exports.CarWriter = writer.CarWriter; | ||
exports.CarIndexedReader = indexedReaderBrowser.CarIndexedReader; |
@@ -13,7 +13,7 @@ 'use strict'; | ||
exports.CarReader = reader['default']; | ||
exports.CarIndexer = indexer; | ||
exports.CarReader = reader.CarReader; | ||
exports.CarIndexer = indexer.CarIndexer; | ||
exports.CarBlockIterator = iterator.CarBlockIterator; | ||
exports.CarCIDIterator = iterator.CarCIDIterator; | ||
exports.CarWriter = writer['default']; | ||
exports.CarIndexedReader = indexedReader['default']; | ||
exports.CarWriter = writer.CarWriter; | ||
exports.CarIndexedReader = indexedReader.CarIndexedReader; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
class IndexedCarReader { | ||
class CarIndexedReader { | ||
static async fromFile() { | ||
@@ -13,3 +13,3 @@ throw new Error('Unsupported in this environment'); | ||
exports.CarIndexedReader = CarIndexedReader; | ||
exports.__browser = __browser; | ||
exports.default = IndexedCarReader; |
@@ -48,3 +48,3 @@ 'use strict'; | ||
}; | ||
return reader['default'].readRaw(this._fd, readIndex); | ||
return reader.CarReader.readRaw(this._fd, readIndex); | ||
} | ||
@@ -74,3 +74,3 @@ async *blocks() { | ||
} | ||
const iterable = await indexer.fromIterable(stream.Readable.from(fs__default['default'].createReadStream(path))); | ||
const iterable = await indexer.CarIndexer.fromIterable(stream.Readable.from(fs__default['default'].createReadStream(path))); | ||
const index = new Map(); | ||
@@ -91,3 +91,3 @@ const order = []; | ||
exports.CarIndexedReader = CarIndexedReader; | ||
exports.__browser = __browser; | ||
exports.default = CarIndexedReader; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var decoder = require('./decoder.js'); | ||
@@ -39,2 +41,2 @@ | ||
module.exports = CarIndexer; | ||
exports.CarIndexer = CarIndexer; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function noop() { | ||
@@ -75,2 +77,2 @@ } | ||
module.exports = create; | ||
exports.create = create; |
@@ -61,3 +61,3 @@ 'use strict'; | ||
exports.CarReader = CarReader; | ||
exports.__browser = __browser; | ||
exports.default = CarReader; |
@@ -14,3 +14,3 @@ 'use strict'; | ||
const fsread = util.promisify(fs__default['default'].read); | ||
class NodeCarReader extends readerBrowser['default'] { | ||
class CarReader extends readerBrowser.CarReader { | ||
static async readRaw(fd, blockIndex) { | ||
@@ -38,3 +38,3 @@ const {cid, blockLength, blockOffset} = blockIndex; | ||
exports.CarReader = CarReader; | ||
exports.__browser = __browser; | ||
exports.default = NodeCarReader; |
@@ -74,3 +74,3 @@ 'use strict'; | ||
function encodeWriter() { | ||
const iw = iteratorChannel(); | ||
const iw = iteratorChannel.create(); | ||
const {writer, iterator} = iw; | ||
@@ -105,3 +105,3 @@ const encoder$1 = encoder.createEncoder(writer); | ||
exports.CarWriter = CarWriter; | ||
exports.CarWriterOut = CarWriterOut; | ||
exports.default = CarWriter; |
@@ -40,3 +40,3 @@ 'use strict'; | ||
const inStream = fs__default['default'].createReadStream(path__default['default'].join(__dirname$1, './go.car')); | ||
const reader$1 = await reader['default'].fromIterable(inStream); | ||
const reader$1 = await reader.CarReader.fromIterable(inStream); | ||
await verifyStoreReader.verifyRoots(reader$1); | ||
@@ -49,3 +49,3 @@ await verifyStoreReader.verifyHas(reader$1); | ||
it('complete', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(roots); | ||
const {writer: writer$1, out} = writer.CarWriter.create(roots); | ||
const pipe = util.promisify(stream.pipeline)(stream.Readable.from(out), fs__default['default'].createWriteStream(tmpCarPath)); | ||
@@ -65,3 +65,3 @@ for (const block of allBlocksFlattened) { | ||
const inStream = fs__default['default'].createReadStream(tmpCarPath); | ||
const reader$1 = await reader['default'].fromIterable(inStream); | ||
const reader$1 = await reader.CarReader.fromIterable(inStream); | ||
await verifyStoreReader.verifyRoots(reader$1); | ||
@@ -68,0 +68,0 @@ await verifyStoreReader.verifyHas(reader$1); |
@@ -17,3 +17,3 @@ 'use strict'; | ||
it('complete', async () => { | ||
const reader = await indexedReader['default'].fromFile(path__default['default'].join(__dirname$1, 'go.car')); | ||
const reader = await indexedReader.CarIndexedReader.fromFile(path__default['default'].join(__dirname$1, 'go.car')); | ||
await verifyStoreReader.verifyRoots(reader); | ||
@@ -49,5 +49,5 @@ await verifyStoreReader.verifyHas(reader); | ||
]) { | ||
await common.assert.isRejected(indexedReader['default'].fromFile(arg)); | ||
await common.assert.isRejected(indexedReader.CarIndexedReader.fromFile(arg)); | ||
} | ||
}); | ||
}); |
@@ -48,3 +48,3 @@ 'use strict'; | ||
it('create, no roots', async () => { | ||
const {writer: writer$1, out} = writer['default'].create([]); | ||
const {writer: writer$1, out} = writer.CarWriter.create([]); | ||
stream.Readable.from(out).pipe(fs__default['default'].createWriteStream('./test.car')); | ||
@@ -84,3 +84,3 @@ let offset = dagCbor__namespace.encode({ | ||
it('CarIndexer.fromIterable', async () => { | ||
const indexer$1 = await indexer.fromIterable(fs__default['default'].createReadStream('./test.car')); | ||
const indexer$1 = await indexer.CarIndexer.fromIterable(fs__default['default'].createReadStream('./test.car')); | ||
common.assert.deepStrictEqual(await indexer$1.getRoots(), []); | ||
@@ -94,3 +94,3 @@ let i = 0; | ||
it('CarIndexer.fromBytes', async () => { | ||
const indexer$1 = await indexer.fromBytes(await fs__default['default'].promises.readFile('./test.car')); | ||
const indexer$1 = await indexer.CarIndexer.fromBytes(await fs__default['default'].promises.readFile('./test.car')); | ||
common.assert.deepStrictEqual(await indexer$1.getRoots(), []); | ||
@@ -104,3 +104,3 @@ let i = 0; | ||
it('CarReader.fromBytes', async () => { | ||
const reader$1 = await reader['default'].fromBytes(await fs__default['default'].promises.readFile('./test.car')); | ||
const reader$1 = await reader.CarReader.fromBytes(await fs__default['default'].promises.readFile('./test.car')); | ||
common.assert.deepStrictEqual(await reader$1.getRoots(), []); | ||
@@ -116,3 +116,3 @@ let i = 0; | ||
it('CarReader.fromIterable', async () => { | ||
const reader$1 = await reader['default'].fromIterable(fs__default['default'].createReadStream('./test.car')); | ||
const reader$1 = await reader.CarReader.fromIterable(fs__default['default'].createReadStream('./test.car')); | ||
common.assert.deepStrictEqual(await reader$1.getRoots(), []); | ||
@@ -128,3 +128,3 @@ let i = 0; | ||
it('CarIndexedReader.fromFile', async () => { | ||
const reader = await indexedReader['default'].fromFile('./test.car'); | ||
const reader = await indexedReader.CarIndexedReader.fromFile('./test.car'); | ||
common.assert.deepStrictEqual(await reader.getRoots(), []); | ||
@@ -131,0 +131,0 @@ let i = 0; |
@@ -35,3 +35,3 @@ 'use strict'; | ||
for (const blockIndex of common.goCarIndex) { | ||
const {cid, bytes} = await reader['default'].readRaw(fd, blockIndex); | ||
const {cid, bytes} = await reader.CarReader.readRaw(fd, blockIndex); | ||
const index = expectedCids.indexOf(cid.toString()); | ||
@@ -56,3 +56,3 @@ common.assert.ok(index >= 0, 'got expected block'); | ||
it('errors', async () => { | ||
await common.assert.isRejected(reader['default'].readRaw(true, common.goCarIndex[0]), { | ||
await common.assert.isRejected(reader.CarReader.readRaw(true, common.goCarIndex[0]), { | ||
name: 'TypeError', | ||
@@ -64,3 +64,3 @@ message: 'Bad fd' | ||
const fd = await fsopen(path__default['default'].join(__dirname$1, 'go.car'), 'r'); | ||
await common.assert.isRejected(reader['default'].readRaw(fd, badBlock), { | ||
await common.assert.isRejected(reader.CarReader.readRaw(fd, badBlock), { | ||
name: 'Error', | ||
@@ -67,0 +67,0 @@ message: `Failed to read entire block (${ badBlock.blockLength - 10 } instead of ${ badBlock.blockLength })` |
@@ -12,3 +12,3 @@ 'use strict'; | ||
buf2[101] = 0; | ||
await common.assert.isRejected(reader['default'].fromBytes(buf2), { | ||
await common.assert.isRejected(reader.CarReader.fromBytes(buf2), { | ||
name: 'Error', | ||
@@ -15,0 +15,0 @@ message: 'Unexpected CID version (0)' |
@@ -9,3 +9,3 @@ 'use strict'; | ||
it('complete', async () => { | ||
const indexer$1 = await indexer.fromBytes(common.goCarBytes); | ||
const indexer$1 = await indexer.CarIndexer.fromBytes(common.goCarBytes); | ||
await verifyStoreReader.verifyRoots(indexer$1); | ||
@@ -29,3 +29,3 @@ common.assert.strictEqual(indexer$1.version, 1); | ||
]) { | ||
await common.assert.isRejected(indexer.fromBytes(arg)); | ||
await common.assert.isRejected(indexer.CarIndexer.fromBytes(arg)); | ||
} | ||
@@ -45,11 +45,11 @@ }); | ||
it('complete (single chunk)', async () => { | ||
const indexer$1 = await indexer.fromIterable(common.makeIterable(common.goCarBytes, common.goCarBytes.length)); | ||
const indexer$1 = await indexer.CarIndexer.fromIterable(common.makeIterable(common.goCarBytes, common.goCarBytes.length)); | ||
return verifyIndexer(indexer$1); | ||
}); | ||
it('complete (101-byte chunks)', async () => { | ||
const indexer$1 = await indexer.fromIterable(common.makeIterable(common.goCarBytes, 101)); | ||
const indexer$1 = await indexer.CarIndexer.fromIterable(common.makeIterable(common.goCarBytes, 101)); | ||
return verifyIndexer(indexer$1); | ||
}); | ||
it('complete (32-byte chunks)', async () => { | ||
const indexer$1 = await indexer.fromIterable(common.makeIterable(common.goCarBytes, 32)); | ||
const indexer$1 = await indexer.CarIndexer.fromIterable(common.makeIterable(common.goCarBytes, 32)); | ||
return verifyIndexer(indexer$1); | ||
@@ -68,5 +68,5 @@ }); | ||
]) { | ||
await common.assert.isRejected(indexer.fromIterable(arg)); | ||
await common.assert.isRejected(indexer.CarIndexer.fromIterable(arg)); | ||
} | ||
}); | ||
}); |
@@ -12,7 +12,7 @@ 'use strict'; | ||
it('exports match', () => { | ||
common.assert.strictEqual(reader['default'], reader['default']); | ||
common.assert.strictEqual(indexer, indexer); | ||
common.assert.strictEqual(reader.CarReader, reader.CarReader); | ||
common.assert.strictEqual(indexer.CarIndexer, indexer.CarIndexer); | ||
common.assert.strictEqual(iterator.CarBlockIterator, iterator.CarBlockIterator); | ||
common.assert.strictEqual(iterator.CarCIDIterator, iterator.CarCIDIterator); | ||
common.assert.strictEqual(writer['default'], writer['default']); | ||
common.assert.strictEqual(writer.CarWriter, writer.CarWriter); | ||
}); | ||
@@ -19,0 +19,0 @@ it('browser exports', () => { |
@@ -9,3 +9,3 @@ 'use strict'; | ||
it('complete', async () => { | ||
const reader$1 = await reader['default'].fromBytes(common.carBytes); | ||
const reader$1 = await reader.CarReader.fromBytes(common.carBytes); | ||
await verifyStoreReader.verifyRoots(reader$1); | ||
@@ -19,3 +19,3 @@ await verifyStoreReader.verifyHas(reader$1); | ||
it('complete (get before has) switch', async () => { | ||
const reader$1 = await reader['default'].fromBytes(common.carBytes); | ||
const reader$1 = await reader.CarReader.fromBytes(common.carBytes); | ||
await verifyStoreReader.verifyRoots(reader$1); | ||
@@ -37,7 +37,7 @@ await verifyStoreReader.verifyGet(reader$1); | ||
]) { | ||
await common.assert.isRejected(reader['default'].fromBytes(arg)); | ||
await common.assert.isRejected(reader.CarReader.fromBytes(arg)); | ||
} | ||
}); | ||
it('decode error - truncated', async () => { | ||
await common.assert.isRejected(reader['default'].fromBytes(common.carBytes.slice(0, common.carBytes.length - 10)), { | ||
await common.assert.isRejected(reader.CarReader.fromBytes(common.carBytes.slice(0, common.carBytes.length - 10)), { | ||
name: 'Error', | ||
@@ -50,3 +50,3 @@ message: 'Unexpected end of data' | ||
it('complete (single chunk)', async () => { | ||
const reader$1 = await reader['default'].fromIterable(common.makeIterable(common.carBytes, common.carBytes.length)); | ||
const reader$1 = await reader.CarReader.fromIterable(common.makeIterable(common.carBytes, common.carBytes.length)); | ||
await verifyStoreReader.verifyRoots(reader$1); | ||
@@ -59,3 +59,3 @@ await verifyStoreReader.verifyHas(reader$1); | ||
it('complete (101-byte chunks)', async () => { | ||
const reader$1 = await reader['default'].fromIterable(common.makeIterable(common.carBytes, 101)); | ||
const reader$1 = await reader.CarReader.fromIterable(common.makeIterable(common.carBytes, 101)); | ||
await verifyStoreReader.verifyRoots(reader$1); | ||
@@ -68,3 +68,3 @@ await verifyStoreReader.verifyHas(reader$1); | ||
it('complete (64-byte chunks)', async () => { | ||
const reader$1 = await reader['default'].fromIterable(common.makeIterable(common.carBytes, 64)); | ||
const reader$1 = await reader.CarReader.fromIterable(common.makeIterable(common.carBytes, 64)); | ||
await verifyStoreReader.verifyRoots(reader$1); | ||
@@ -77,3 +77,3 @@ await verifyStoreReader.verifyHas(reader$1); | ||
it('complete (32-byte chunks)', async () => { | ||
const reader$1 = await reader['default'].fromIterable(common.makeIterable(common.carBytes, 32)); | ||
const reader$1 = await reader.CarReader.fromIterable(common.makeIterable(common.carBytes, 32)); | ||
await verifyStoreReader.verifyRoots(reader$1); | ||
@@ -96,7 +96,7 @@ await verifyStoreReader.verifyHas(reader$1); | ||
]) { | ||
await common.assert.isRejected(reader['default'].fromIterable(arg)); | ||
await common.assert.isRejected(reader.CarReader.fromIterable(arg)); | ||
} | ||
}); | ||
it('decode error - truncated', async () => { | ||
await common.assert.isRejected(reader['default'].fromIterable(common.makeIterable(common.carBytes.slice(0, common.carBytes.length - 10), 64)), { | ||
await common.assert.isRejected(reader.CarReader.fromIterable(common.makeIterable(common.carBytes.slice(0, common.carBytes.length - 10), 64)), { | ||
name: 'Error', | ||
@@ -103,0 +103,0 @@ message: 'Unexpected end of data' |
@@ -47,3 +47,3 @@ 'use strict'; | ||
it('complete', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(roots); | ||
const {writer: writer$1, out} = writer.CarWriter.create(roots); | ||
common.assert.strictEqual(typeof out[Symbol.asyncIterator], 'function'); | ||
@@ -65,3 +65,3 @@ const collection = collector(out); | ||
it('complete, deferred collection', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(roots); | ||
const {writer: writer$1, out} = writer.CarWriter.create(roots); | ||
const writeQueue = []; | ||
@@ -81,3 +81,3 @@ for (const block of allBlocksFlattened) { | ||
it('complete, close after write', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(roots); | ||
const {writer: writer$1, out} = writer.CarWriter.create(roots); | ||
common.assert.strictEqual(typeof out[Symbol.asyncIterator], 'function'); | ||
@@ -100,3 +100,3 @@ const collection = collector(out); | ||
it('complete, no queue', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(roots); | ||
const {writer: writer$1, out} = writer.CarWriter.create(roots); | ||
const collection = collector(out); | ||
@@ -111,3 +111,3 @@ for (const block of allBlocksFlattened) { | ||
it('complete, slow drip', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(roots); | ||
const {writer: writer$1, out} = writer.CarWriter.create(roots); | ||
common.assert.strictEqual(typeof out[Symbol.asyncIterator], 'function'); | ||
@@ -125,3 +125,3 @@ const collection = collector(out); | ||
it('complete, no queue, deferred collection', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(roots); | ||
const {writer: writer$1, out} = writer.CarWriter.create(roots); | ||
for (const block of allBlocksFlattened) { | ||
@@ -136,3 +136,3 @@ writer$1.put(block); | ||
it('single root', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(roots[0]); | ||
const {writer: writer$1, out} = writer.CarWriter.create(roots[0]); | ||
const collection = collector(out); | ||
@@ -149,3 +149,3 @@ for (const block of allBlocksFlattened) { | ||
it('no roots', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(); | ||
const {writer: writer$1, out} = writer.CarWriter.create(); | ||
const collection = collector(out); | ||
@@ -162,3 +162,3 @@ for (const block of allBlocksFlattened) { | ||
it('appender', async () => { | ||
let writerOut = writer['default'].create(roots); | ||
let writerOut = writer.CarWriter.create(roots); | ||
let collection = collector(writerOut.out); | ||
@@ -168,3 +168,3 @@ await writerOut.writer.close(); | ||
const append = async index => { | ||
writerOut = writer['default'].createAppender(); | ||
writerOut = writer.CarWriter.createAppender(); | ||
collection = collector(writerOut.out); | ||
@@ -202,7 +202,7 @@ for (const block of allBlocks[index][1]) { | ||
]) { | ||
common.assert.throws(() => writer['default'].create(arg)); | ||
common.assert.throws(() => writer.CarWriter.create(arg)); | ||
} | ||
}); | ||
it('bad argument for put()', async () => { | ||
const {writer: writer$1} = writer['default'].create(); | ||
const {writer: writer$1} = writer.CarWriter.create(); | ||
for (const arg of [ | ||
@@ -250,3 +250,3 @@ new Uint8Array(0), | ||
it('bad write after closed', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(); | ||
const {writer: writer$1, out} = writer.CarWriter.create(); | ||
const collection = collector(out); | ||
@@ -259,3 +259,3 @@ await writer$1.put(allBlocksFlattened[0]); | ||
it('bad attempt to multiple iterate', async () => { | ||
const {out} = writer['default'].create(); | ||
const {out} = writer.CarWriter.create(); | ||
collector(out); | ||
@@ -265,3 +265,3 @@ await common.assert.isRejected(collector(out), /multiple iterator/i); | ||
it('bad attempt to multiple close', async () => { | ||
const {writer: writer$1, out} = writer['default'].create(); | ||
const {writer: writer$1, out} = writer.CarWriter.create(); | ||
collector(out); | ||
@@ -268,0 +268,0 @@ await writer$1.close(); |
import path from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import CarIndexedReader from '../lib/indexed-reader-browser.js'; | ||
import { CarIndexedReader } from '../lib/indexed-reader-browser.js'; | ||
import { | ||
@@ -5,0 +5,0 @@ assert, |
@@ -1,2 +0,2 @@ | ||
import CarReader from '../lib/reader-browser.js'; | ||
import { CarReader } from '../lib/reader-browser.js'; | ||
import { | ||
@@ -3,0 +3,0 @@ carBytes, |
@@ -1,2 +0,2 @@ | ||
import CarIndexer from '../lib/indexer.js'; | ||
import { CarIndexer } from '../lib/indexer.js'; | ||
import { | ||
@@ -3,0 +3,0 @@ goCarBytes, |
import * as car from '../car-browser.js'; | ||
import CarReader, { __browser } from '../lib/reader-browser.js'; | ||
import CarIndexer from '../lib/indexer.js'; | ||
import { | ||
CarReader, | ||
__browser | ||
} from '../lib/reader-browser.js'; | ||
import { CarIndexer } from '../lib/indexer.js'; | ||
import { | ||
CarBlockIterator, | ||
CarCIDIterator | ||
} from '../lib/iterator.js'; | ||
import CarWriter from '../lib/writer.js'; | ||
import { CarWriter } from '../lib/writer.js'; | ||
import { assert } from './common.js'; | ||
@@ -10,0 +13,0 @@ describe('Interface', () => { |
@@ -1,2 +0,2 @@ | ||
import CarReader from '../lib/reader-browser.js'; | ||
import { CarReader } from '../lib/reader-browser.js'; | ||
import { | ||
@@ -3,0 +3,0 @@ carBytes, |
@@ -1,2 +0,2 @@ | ||
import CarWriter from '../lib/writer.js'; | ||
import { CarWriter } from '../lib/writer.js'; | ||
import { bytes } from 'multiformats'; | ||
@@ -3,0 +3,0 @@ import { |
@@ -1,3 +0,3 @@ | ||
import CarReader from './lib/reader-browser.js'; | ||
import CarIndexer from './lib/indexer.js'; | ||
import { CarReader } from './lib/reader-browser.js'; | ||
import { CarIndexer } from './lib/indexer.js'; | ||
import { | ||
@@ -7,4 +7,4 @@ CarBlockIterator, | ||
} from './lib/iterator.js'; | ||
import CarWriter from './lib/writer.js'; | ||
import CarIndexedReader from './lib/indexed-reader-browser.js'; | ||
import { CarWriter } from './lib/writer.js'; | ||
import { CarIndexedReader } from './lib/indexed-reader-browser.js'; | ||
export { | ||
@@ -11,0 +11,0 @@ CarReader, |
@@ -1,3 +0,3 @@ | ||
import CarReader from './lib/reader.js'; | ||
import CarIndexer from './lib/indexer.js'; | ||
import { CarReader } from './lib/reader.js'; | ||
import { CarIndexer } from './lib/indexer.js'; | ||
import { | ||
@@ -7,4 +7,4 @@ CarBlockIterator, | ||
} from './lib/iterator.js'; | ||
import CarWriter from './lib/writer.js'; | ||
import CarIndexedReader from './lib/indexed-reader.js'; | ||
import { CarWriter } from './lib/writer.js'; | ||
import { CarIndexedReader } from './lib/indexed-reader.js'; | ||
export { | ||
@@ -11,0 +11,0 @@ CarReader, |
@@ -1,2 +0,2 @@ | ||
export default class IndexedCarReader { | ||
export class CarIndexedReader { | ||
static async fromFile() { | ||
@@ -3,0 +3,0 @@ throw new Error('Unsupported in this environment'); |
import fs from 'fs'; | ||
import { Readable } from 'stream'; | ||
import { CID } from 'multiformats/cid'; | ||
import CarIndexer from './indexer.js'; | ||
import NodeCarReader from './reader.js'; | ||
export default class CarIndexedReader { | ||
import { CarIndexer } from './indexer.js'; | ||
import { CarReader as NodeCarReader } from './reader.js'; | ||
export class CarIndexedReader { | ||
constructor(version, path, roots, index, order) { | ||
@@ -8,0 +8,0 @@ this._version = version; |
@@ -6,3 +6,3 @@ import { | ||
} from './decoder.js'; | ||
export default class CarIndexer { | ||
export class CarIndexer { | ||
constructor(version, roots, iterator) { | ||
@@ -9,0 +9,0 @@ this._version = version; |
function noop() { | ||
} | ||
export default function create() { | ||
export function create() { | ||
const chunkQueue = []; | ||
@@ -5,0 +5,0 @@ let drainer = null; |
@@ -6,3 +6,3 @@ import { | ||
} from './decoder.js'; | ||
export default class CarReader { | ||
export class CarReader { | ||
constructor(version, roots, blocks) { | ||
@@ -9,0 +9,0 @@ this._version = version; |
import fs from 'fs'; | ||
import { promisify } from 'util'; | ||
import CarReader from './reader-browser.js'; | ||
import { CarReader as BrowserCarReader } from './reader-browser.js'; | ||
const fsread = promisify(fs.read); | ||
export default class NodeCarReader extends CarReader { | ||
export class CarReader extends BrowserCarReader { | ||
static async readRaw(fd, blockIndex) { | ||
@@ -7,0 +7,0 @@ const {cid, blockLength, blockOffset} = blockIndex; |
import { CID } from 'multiformats/cid'; | ||
import { createEncoder } from './encoder.js'; | ||
import iteratorChannel from './iterator-channel.js'; | ||
export default class CarWriter { | ||
import { create as iteratorChannel } from './iterator-channel.js'; | ||
export class CarWriter { | ||
constructor(roots, encoder) { | ||
@@ -6,0 +6,0 @@ this._encoder = encoder; |
import path from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import CarIndexedReader from '../lib/indexed-reader.js'; | ||
import { CarIndexedReader } from '../lib/indexed-reader.js'; | ||
import { | ||
@@ -5,0 +5,0 @@ assert, |
@@ -1,2 +0,2 @@ | ||
import CarReader from '../lib/reader.js'; | ||
import { CarReader } from '../lib/reader.js'; | ||
import { | ||
@@ -3,0 +3,0 @@ carBytes, |
@@ -1,2 +0,2 @@ | ||
import CarIndexer from '../lib/indexer.js'; | ||
import { CarIndexer } from '../lib/indexer.js'; | ||
import { | ||
@@ -3,0 +3,0 @@ goCarBytes, |
import * as car from '../car.js'; | ||
import CarReader, { __browser } from '../lib/reader.js'; | ||
import CarIndexer from '../lib/indexer.js'; | ||
import { | ||
CarReader, | ||
__browser | ||
} from '../lib/reader.js'; | ||
import { CarIndexer } from '../lib/indexer.js'; | ||
import { | ||
CarBlockIterator, | ||
CarCIDIterator | ||
} from '../lib/iterator.js'; | ||
import CarWriter from '../lib/writer.js'; | ||
import { CarWriter } from '../lib/writer.js'; | ||
import { assert } from './common.js'; | ||
@@ -10,0 +13,0 @@ describe('Interface', () => { |
@@ -1,2 +0,2 @@ | ||
import CarReader from '../lib/reader.js'; | ||
import { CarReader } from '../lib/reader.js'; | ||
import { | ||
@@ -3,0 +3,0 @@ carBytes, |
@@ -1,2 +0,2 @@ | ||
import CarWriter from '../lib/writer.js'; | ||
import { CarWriter } from '../lib/writer.js'; | ||
import { bytes } from 'multiformats'; | ||
@@ -3,0 +3,0 @@ import { |
@@ -1,2 +0,2 @@ | ||
export default class IndexedCarReader { | ||
export class CarIndexedReader { | ||
static async fromFile () { | ||
@@ -3,0 +3,0 @@ throw new Error('Unsupported in this environment') |
import fs from 'fs' | ||
import { Readable } from 'stream' | ||
import { CID } from 'multiformats/cid' | ||
import CarIndexer from './indexer.js' | ||
import NodeCarReader from './reader.js' | ||
import { CarIndexer } from './indexer.js' | ||
import { CarReader as NodeCarReader } from './reader.js' | ||
@@ -13,3 +13,3 @@ /** | ||
* @typedef {import('../api').BlockReader} BlockReader | ||
* @typedef {import('./reader-browser').default} CarReader | ||
* @typedef {import('./reader-browser').CarReader} CarReader | ||
* @typedef {{ blockLength:number, blockOffset:number }} RawLocation | ||
@@ -36,6 +36,7 @@ */ | ||
* Load this class with either | ||
* `import CarIndexedReader from '@ipld/car/indexed-reader'` | ||
* (`const CarIndexedReader = require('@ipld/car/indexed-reader')`). Or | ||
* `import { CarIndexedReader } from '@ipld/car/indexed-reader'` | ||
* (`const { CarIndexedReader } = require('@ipld/car/indexed-reader')`). Or | ||
* `import { CarIndexedReader } from '@ipld/car'` | ||
* (`const { CarIndexedReader } = require('@ipld/car')`). | ||
* (`const { CarIndexedReader } = require('@ipld/car')`). The former will likely | ||
* result in smaller bundle sizes where this is important. | ||
* | ||
@@ -50,3 +51,3 @@ * @name CarIndexedReader | ||
*/ | ||
export default class CarIndexedReader { | ||
export class CarIndexedReader { | ||
/** | ||
@@ -175,3 +176,3 @@ * @param {number} version | ||
* @method | ||
* @memberof CarWriter | ||
* @memberof CarIndexedReader | ||
* @instance | ||
@@ -178,0 +179,0 @@ * @async |
@@ -32,6 +32,7 @@ import { | ||
* Load this class with either | ||
* `import CarIndexer from '@ipld/car/indexer'` | ||
* (`const CarIndexer = require('@ipld/car/indexer')`). Or | ||
* `import { CarIndexer } from '@ipld/car/indexer'` | ||
* (`const { CarIndexer } = require('@ipld/car/indexer')`). Or | ||
* `import { CarIndexer } from '@ipld/car'` | ||
* (`const { CarIndexer } = require('@ipld/car')`). | ||
* (`const { CarIndexer } = require('@ipld/car')`). The former will likely | ||
* result in smaller bundle sizes where this is important. | ||
* | ||
@@ -45,3 +46,3 @@ * @name CarIndexer | ||
*/ | ||
export default class CarIndexer { | ||
export class CarIndexer { | ||
/** | ||
@@ -48,0 +49,0 @@ * @param {number} version |
@@ -12,3 +12,3 @@ /** | ||
*/ | ||
export default function create () { | ||
export function create () { | ||
/** @type {T[]} */ | ||
@@ -15,0 +15,0 @@ const chunkQueue = [] |
@@ -20,5 +20,7 @@ import { asyncIterableReader, bytesReader, createDecoder } from './decoder.js' | ||
* | ||
* Load this class with either `import CarReader from '@ipld/car/reader'` | ||
* (`const CarReader = require('@ipld/car/reader')`). Or | ||
* Load this class with either `import { CarReader } from '@ipld/car/reader'` | ||
* (`const { CarReader } = require('@ipld/car/reader')`). Or | ||
* `import { CarReader } from '@ipld/car'` (`const { CarReader } = require('@ipld/car')`). | ||
* The former will likely result in smaller bundle sizes where this is | ||
* important. | ||
* | ||
@@ -32,3 +34,3 @@ * @name CarReader | ||
*/ | ||
export default class CarReader { | ||
export class CarReader { | ||
/** | ||
@@ -35,0 +37,0 @@ * @constructs CarReader |
import fs from 'fs' | ||
import { promisify } from 'util' | ||
import CarReader from './reader-browser.js' | ||
import { CarReader as BrowserCarReader } from './reader-browser.js' | ||
@@ -19,3 +19,3 @@ /** | ||
*/ | ||
export default class NodeCarReader extends CarReader { | ||
export class CarReader extends BrowserCarReader { | ||
/** | ||
@@ -22,0 +22,0 @@ * Reads a block directly from a file descriptor for an open CAR file. This |
import { CID } from 'multiformats/cid' | ||
import { createEncoder } from './encoder.js' | ||
import iteratorChannel from './iterator-channel.js' | ||
import { create as iteratorChannel } from './iterator-channel.js' | ||
@@ -39,6 +39,7 @@ /** | ||
* Load this class with either | ||
* `import CarWriter from '@ipld/car/writer'` | ||
* (`const CarWriter = require('@ipld/car/writer')`). Or | ||
* `import { CarWriter } from '@ipld/car/writer'` | ||
* (`const { CarWriter } = require('@ipld/car/writer')`). Or | ||
* `import { CarWriter } from '@ipld/car'` | ||
* (`const { CarWriter } = require('@ipld/car')`). | ||
* (`const { CarWriter } = require('@ipld/car')`). The former will likely | ||
* result in smaller bundle sizes where this is important. | ||
* | ||
@@ -49,3 +50,3 @@ * @name CarWriter | ||
*/ | ||
export default class CarWriter { | ||
export class CarWriter { | ||
/** | ||
@@ -52,0 +53,0 @@ * @param {CID[]} roots |
{ | ||
"name": "@ipld/car", | ||
"version": "1.0.6", | ||
"version": "2.0.0", | ||
"description": "Content Addressable aRchive format reader and writer", | ||
@@ -41,9 +41,9 @@ "main": "./cjs/car.js", | ||
"devDependencies": { | ||
"@ipld/dag-pb": "^1.0.0", | ||
"@types/chai": "^4.2.16", | ||
"@types/chai-as-promised": "^7.1.3", | ||
"@ipld/dag-pb": "^1.1.4", | ||
"@types/chai": "^4.2.18", | ||
"@types/chai-as-promised": "^7.1.4", | ||
"@types/mocha": "^8.2.2", | ||
"@types/node": "^15.0.2", | ||
"@typescript-eslint/eslint-plugin": "^4.22.0", | ||
"@typescript-eslint/parser": "^4.22.0", | ||
"@types/node": "^15.3.0", | ||
"@typescript-eslint/eslint-plugin": "^4.24.0", | ||
"@typescript-eslint/parser": "^4.24.0", | ||
"chai": "^4.3.4", | ||
@@ -53,5 +53,5 @@ "chai-as-promised": "^7.1.1", | ||
"ipjs": "^5.0.0", | ||
"ipld-garbage": "^3.0.2", | ||
"ipld-garbage": "^3.0.3", | ||
"jsdoc4readme": "^1.4.0", | ||
"mocha": "^8.3.2", | ||
"mocha": "^8.4.0", | ||
"polendina": "^1.1.0", | ||
@@ -62,5 +62,5 @@ "standard": "^16.0.3", | ||
"dependencies": { | ||
"@ipld/dag-cbor": "^5.0.0", | ||
"@ipld/dag-cbor": "^5.0.5", | ||
"@types/varint": "^6.0.0", | ||
"multiformats": "^8.0.3", | ||
"multiformats": "^8.0.6", | ||
"varint": "^6.0.0" | ||
@@ -67,0 +67,0 @@ }, |
@@ -93,3 +93,3 @@ # @ipld/car | ||
```js | ||
import CarReader from '@ipld/car/reader' | ||
import { CarReader } from '@ipld/car/reader' | ||
``` | ||
@@ -118,3 +118,3 @@ | ||
```js | ||
import CarIndexedReader from '@ipld/car/indexed-reader' | ||
import { CarIndexedReader } from '@ipld/car/indexed-reader' | ||
``` | ||
@@ -224,3 +224,3 @@ | ||
* [`async * CarIndexedReader#cids()`](#CarIndexedReader_cids) | ||
* [`async CarWriter#close()`](#CarWriter_close) | ||
* [`async CarIndexedReader#close()`](#CarIndexedReader_close) | ||
* [`async CarIndexedReader.fromFile(path)`](#CarIndexedReader__fromFile) | ||
@@ -261,5 +261,7 @@ * [`class CarBlockIterator`](#CarBlockIterator) | ||
Load this class with either `import CarReader from '@ipld/car/reader'` | ||
(`const CarReader = require('@ipld/car/reader')`). Or | ||
Load this class with either `import { CarReader } from '@ipld/car/reader'` | ||
(`const { CarReader } = require('@ipld/car/reader')`). Or | ||
`import { CarReader } from '@ipld/car'` (`const { CarReader } = require('@ipld/car')`). | ||
The former will likely result in smaller bundle sizes where this is | ||
important. | ||
@@ -385,6 +387,7 @@ <a name="CarReader_getRoots"></a> | ||
Load this class with either | ||
`import CarIndexedReader from '@ipld/car/indexed-reader'` | ||
(`const CarIndexedReader = require('@ipld/car/indexed-reader')`). Or | ||
`import { CarIndexedReader } from '@ipld/car/indexed-reader'` | ||
(`const { CarIndexedReader } = require('@ipld/car/indexed-reader')`). Or | ||
`import { CarIndexedReader } from '@ipld/car'` | ||
(`const { CarIndexedReader } = require('@ipld/car')`). | ||
(`const { CarIndexedReader } = require('@ipld/car')`). The former will likely | ||
result in smaller bundle sizes where this is important. | ||
@@ -430,4 +433,4 @@ <a name="CarIndexedReader_getRoots"></a> | ||
<a name="CarWriter_close"></a> | ||
### `async CarWriter#close()` | ||
<a name="CarIndexedReader_close"></a> | ||
### `async CarIndexedReader#close()` | ||
@@ -601,6 +604,7 @@ * Returns: `Promise<void>` | ||
Load this class with either | ||
`import CarIndexer from '@ipld/car/indexer'` | ||
(`const CarIndexer = require('@ipld/car/indexer')`). Or | ||
`import { CarIndexer } from '@ipld/car/indexer'` | ||
(`const { CarIndexer } = require('@ipld/car/indexer')`). Or | ||
`import { CarIndexer } from '@ipld/car'` | ||
(`const { CarIndexer } = require('@ipld/car')`). | ||
(`const { CarIndexer } = require('@ipld/car')`). The former will likely | ||
result in smaller bundle sizes where this is important. | ||
@@ -666,6 +670,7 @@ <a name="CarIndexer_getRoots"></a> | ||
Load this class with either | ||
`import CarWriter from '@ipld/car/writer'` | ||
(`const CarWriter = require('@ipld/car/writer')`). Or | ||
`import { CarWriter } from '@ipld/car/writer'` | ||
(`const { CarWriter } = require('@ipld/car/writer')`). Or | ||
`import { CarWriter } from '@ipld/car'` | ||
(`const { CarWriter } = require('@ipld/car')`). | ||
(`const { CarWriter } = require('@ipld/car')`). The former will likely | ||
result in smaller bundle sizes where this is important. | ||
@@ -672,0 +677,0 @@ <a name="CarWriter_put"></a> |
@@ -5,3 +5,3 @@ /* eslint-env mocha */ | ||
import { fileURLToPath } from 'url' | ||
import CarIndexedReader from '@ipld/car/indexed-reader' | ||
import { CarIndexedReader } from '@ipld/car/indexed-reader' | ||
import { assert, goCarIndex } from './common.js' | ||
@@ -8,0 +8,0 @@ import { |
/* eslint-env mocha */ | ||
import CarReader from '@ipld/car/reader' | ||
import { CarReader } from '@ipld/car/reader' | ||
import { carBytes, assert } from './common.js' | ||
@@ -4,0 +4,0 @@ |
/* eslint-env mocha */ | ||
import CarIndexer from '@ipld/car/indexer' | ||
import { CarIndexer } from '@ipld/car/indexer' | ||
import { goCarBytes, goCarIndex, makeIterable, assert } from './common.js' | ||
@@ -5,0 +5,0 @@ import { verifyRoots } from './verify-store-reader.js' |
/* eslint-env mocha */ | ||
import * as car from '@ipld/car' | ||
import CarReader, { __browser } from '@ipld/car/reader' | ||
import CarIndexer from '@ipld/car/indexer' | ||
import { CarReader, __browser } from '@ipld/car/reader' | ||
import { CarIndexer } from '@ipld/car/indexer' | ||
import { CarBlockIterator, CarCIDIterator } from '@ipld/car/iterator' | ||
import CarWriter from '@ipld/car/writer' | ||
import { CarWriter } from '@ipld/car/writer' | ||
@@ -8,0 +8,0 @@ import { assert } from './common.js' |
/* eslint-env mocha */ | ||
import CarReader from '@ipld/car/reader' | ||
import { CarReader } from '@ipld/car/reader' | ||
import { carBytes, makeIterable, assert } from './common.js' | ||
@@ -5,0 +5,0 @@ import { |
/* eslint-env mocha */ | ||
/* globals describe, it */ | ||
import CarWriter from '@ipld/car/writer' | ||
import { CarWriter } from '@ipld/car/writer' | ||
import { bytes } from 'multiformats' | ||
@@ -6,0 +6,0 @@ import { carBytes, makeData, assert, rndCid } from './common.js' |
@@ -1,8 +0,8 @@ | ||
import CarReader from "./lib/reader-browser.js"; | ||
import CarIndexer from "./lib/indexer.js"; | ||
import { CarReader } from "./lib/reader-browser.js"; | ||
import { CarIndexer } from "./lib/indexer.js"; | ||
import { CarBlockIterator } from "./lib/iterator.js"; | ||
import { CarCIDIterator } from "./lib/iterator.js"; | ||
import CarWriter from "./lib/writer.js"; | ||
import CarIndexedReader from "./lib/indexed-reader-browser.js"; | ||
import { CarWriter } from "./lib/writer.js"; | ||
import { CarIndexedReader } from "./lib/indexed-reader-browser.js"; | ||
export { CarReader, CarIndexer, CarBlockIterator, CarCIDIterator, CarWriter, CarIndexedReader }; | ||
//# sourceMappingURL=car-browser.d.ts.map |
@@ -1,8 +0,8 @@ | ||
import CarReader from "./lib/reader.js"; | ||
import CarIndexer from "./lib/indexer.js"; | ||
import { CarReader } from "./lib/reader.js"; | ||
import { CarIndexer } from "./lib/indexer.js"; | ||
import { CarBlockIterator } from "./lib/iterator.js"; | ||
import { CarCIDIterator } from "./lib/iterator.js"; | ||
import CarWriter from "./lib/writer.js"; | ||
import CarIndexedReader from "./lib/indexed-reader.js"; | ||
import { CarWriter } from "./lib/writer.js"; | ||
import { CarIndexedReader } from "./lib/indexed-reader.js"; | ||
export { CarReader, CarIndexer, CarBlockIterator, CarCIDIterator, CarWriter, CarIndexedReader }; | ||
//# sourceMappingURL=car.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export default class IndexedCarReader { | ||
export class CarIndexedReader { | ||
static fromFile(): Promise<void>; | ||
@@ -3,0 +3,0 @@ } |
@@ -8,3 +8,3 @@ /// <reference types="node" /> | ||
* @typedef {import('../api').BlockReader} BlockReader | ||
* @typedef {import('./reader-browser').default} CarReader | ||
* @typedef {import('./reader-browser').CarReader} CarReader | ||
* @typedef {{ blockLength:number, blockOffset:number }} RawLocation | ||
@@ -30,6 +30,7 @@ */ | ||
* Load this class with either | ||
* `import CarIndexedReader from '@ipld/car/indexed-reader'` | ||
* (`const CarIndexedReader = require('@ipld/car/indexed-reader')`). Or | ||
* `import { CarIndexedReader } from '@ipld/car/indexed-reader'` | ||
* (`const { CarIndexedReader } = require('@ipld/car/indexed-reader')`). Or | ||
* `import { CarIndexedReader } from '@ipld/car'` | ||
* (`const { CarIndexedReader } = require('@ipld/car')`). | ||
* (`const { CarIndexedReader } = require('@ipld/car')`). The former will likely | ||
* result in smaller bundle sizes where this is important. | ||
* | ||
@@ -44,3 +45,3 @@ * @name CarIndexedReader | ||
*/ | ||
export default class CarIndexedReader implements RootsReader, BlockReader { | ||
export class CarIndexedReader implements RootsReader, BlockReader { | ||
/** | ||
@@ -137,3 +138,3 @@ * Instantiate an {@link CarIndexedReader} from a file with the provided | ||
* @method | ||
* @memberof CarWriter | ||
* @memberof CarIndexedReader | ||
* @instance | ||
@@ -151,3 +152,3 @@ * @async | ||
export type BlockReader = import('../api').BlockReader; | ||
export type CarReader = import('./reader-browser').default; | ||
export type CarReader = import('./reader-browser').CarReader; | ||
export type RawLocation = { | ||
@@ -154,0 +155,0 @@ blockLength: number; |
@@ -25,6 +25,7 @@ /** | ||
* Load this class with either | ||
* `import CarIndexer from '@ipld/car/indexer'` | ||
* (`const CarIndexer = require('@ipld/car/indexer')`). Or | ||
* `import { CarIndexer } from '@ipld/car/indexer'` | ||
* (`const { CarIndexer } = require('@ipld/car/indexer')`). Or | ||
* `import { CarIndexer } from '@ipld/car'` | ||
* (`const { CarIndexer } = require('@ipld/car')`). | ||
* (`const { CarIndexer } = require('@ipld/car')`). The former will likely | ||
* result in smaller bundle sizes where this is important. | ||
* | ||
@@ -38,3 +39,3 @@ * @name CarIndexer | ||
*/ | ||
export default class CarIndexer implements RootsReader, AsyncIterable<BlockIndex> { | ||
export class CarIndexer implements RootsReader, AsyncIterable<BlockIndex> { | ||
/** | ||
@@ -41,0 +42,0 @@ * Instantiate a {@link CarIndexer} from a `Uint8Array` blob. Only the header |
@@ -5,4 +5,4 @@ /** | ||
*/ | ||
export default function create<T extends unknown>(): import("./coding").IteratorChannel<T>; | ||
export function create<T extends unknown>(): import("./coding").IteratorChannel<T>; | ||
export type IteratorChannel<T extends unknown> = import('./coding').IteratorChannel<T>; | ||
//# sourceMappingURL=iterator-channel.d.ts.map |
@@ -17,5 +17,7 @@ /** | ||
* | ||
* Load this class with either `import CarReader from '@ipld/car/reader'` | ||
* (`const CarReader = require('@ipld/car/reader')`). Or | ||
* Load this class with either `import { CarReader } from '@ipld/car/reader'` | ||
* (`const { CarReader } = require('@ipld/car/reader')`). Or | ||
* `import { CarReader } from '@ipld/car'` (`const { CarReader } = require('@ipld/car')`). | ||
* The former will likely result in smaller bundle sizes where this is | ||
* important. | ||
* | ||
@@ -29,3 +31,3 @@ * @name CarReader | ||
*/ | ||
export default class CarReader implements RootsReader, BlockReader { | ||
export class CarReader implements RootsReader, BlockReader { | ||
/** | ||
@@ -32,0 +34,0 @@ * Instantiate a {@link CarReader} from a `Uint8Array` blob. This performs a |
@@ -7,3 +7,3 @@ /// <reference types="node" /> | ||
*/ | ||
export default class NodeCarReader extends CarReader implements RootsReader, BlockReader { | ||
export class CarReader extends BrowserCarReader implements RootsReader, BlockReader { | ||
/** | ||
@@ -36,4 +36,4 @@ * Reads a block directly from a file descriptor for an open CAR file. This | ||
export type BlockReader = import('../api').BlockReader; | ||
import CarReader from "./reader-browser.js"; | ||
import { CarReader as BrowserCarReader } from "./reader-browser.js"; | ||
import fs from "fs"; | ||
//# sourceMappingURL=reader.d.ts.map |
@@ -34,6 +34,7 @@ /** | ||
* Load this class with either | ||
* `import CarWriter from '@ipld/car/writer'` | ||
* (`const CarWriter = require('@ipld/car/writer')`). Or | ||
* `import { CarWriter } from '@ipld/car/writer'` | ||
* (`const { CarWriter } = require('@ipld/car/writer')`). Or | ||
* `import { CarWriter } from '@ipld/car'` | ||
* (`const { CarWriter } = require('@ipld/car')`). | ||
* (`const { CarWriter } = require('@ipld/car')`). The former will likely | ||
* result in smaller bundle sizes where this is important. | ||
* | ||
@@ -44,3 +45,3 @@ * @name CarWriter | ||
*/ | ||
export default class CarWriter implements BlockWriter { | ||
export class CarWriter implements BlockWriter { | ||
/** | ||
@@ -47,0 +48,0 @@ * Create a new CAR writer "channel" which consists of a |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
679914
16791
721
Updated@ipld/dag-cbor@^5.0.5
Updatedmultiformats@^8.0.6