Skip to content

Commit

Permalink
chore: remove Node.js 12 c8 bug cruft
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Aug 28, 2023
1 parent a387c02 commit 17d3e2f
Show file tree
Hide file tree
Showing 13 changed files with 0 additions and 114 deletions.
14 changes: 0 additions & 14 deletions src/buffer-decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ export function readHeader (reader, strictVersion) {
reader.seek(v2Header.dataOffset - reader.pos)
const v1Header = readHeader(reader, 1)
return Object.assign(v1Header, v2Header)
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand All @@ -77,8 +75,6 @@ function readCid (reader) {
const bytes = reader.exactly(getMultihashLength(reader.upTo(8)), true)
const multihash = Digest.decode(bytes)
return CID.create(version, codec, multihash)
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand All @@ -104,8 +100,6 @@ export function readBlockHead (reader) {
const blockLength = length - Number(reader.pos - start) // subtract CID length

return { cid, length, blockLength }
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand Down Expand Up @@ -148,8 +142,6 @@ export function bytesReader (bytes) {
return {
upTo (length) {
return bytes.subarray(pos, pos + Math.min(length, bytes.length - pos))
/* c8 ignore next 2 */
// Node.js 12 c8 bug
},

exactly (length, seek = false) {
Expand All @@ -162,8 +154,6 @@ export function bytesReader (bytes) {
pos += length
}
return out
/* c8 ignore next 2 */
// Node.js 12 c8 bug
},

seek (length) {
Expand Down Expand Up @@ -197,8 +187,6 @@ export function limitReader (reader, byteLimit) {
bytes = bytes.subarray(0, byteLimit - bytesRead)
}
return bytes
/* c8 ignore next 2 */
// Node.js 12 c8 bug
},

exactly (length, seek = false) {
Expand All @@ -210,8 +198,6 @@ export function limitReader (reader, byteLimit) {
bytesRead += length
}
return bytes
/* c8 ignore next 2 */
// Node.js 12 c8 bug
},

seek (length) {
Expand Down
6 changes: 0 additions & 6 deletions src/buffer-reader-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ export class CarBufferReader {
*/
getRoots () {
return this._header.roots
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand All @@ -77,8 +75,6 @@ export class CarBufferReader {
*/
has (key) {
return this._blocks.some(b => b.cid.equals(key))
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand All @@ -95,8 +91,6 @@ export class CarBufferReader {
*/
get (key) {
return this._blocks.find(b => b.cid.equals(key))
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand Down
2 changes: 0 additions & 2 deletions src/buffer-reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ export class CarBufferReader extends BrowserCarBufferReader {
throw new Error(`Failed to read entire block (${read} instead of ${blockLength})`)
}
return { cid, bytes }
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/decoder-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ export function decodeVarint (bytes, seeker) {
const i = varint.decode(bytes)
seeker.seek(/** @type {number} */(varint.decode.bytes))
return i
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand Down Expand Up @@ -57,8 +55,6 @@ export function decodeV2Header (bytes) {
indexOffset: Number(dv.getBigUint64(offset += 8, true))
}
return header
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand Down
26 changes: 0 additions & 26 deletions src/decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ export async function readHeader (reader, strictVersion) {
reader.seek(v2Header.dataOffset - reader.pos)
const v1Header = await readHeader(reader, 1)
return Object.assign(v1Header, v2Header)
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand All @@ -76,8 +74,6 @@ async function readCid (reader) {
const bytes = await reader.exactly(getMultihashLength(await reader.upTo(8)), true)
const multihash = Digest.decode(bytes)
return CID.create(version, codec, multihash)
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand All @@ -103,8 +99,6 @@ export async function readBlockHead (reader) {
const blockLength = length - Number(reader.pos - start) // subtract CID length

return { cid, length, blockLength }
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand All @@ -115,8 +109,6 @@ async function readBlock (reader) {
const { cid, blockLength } = await readBlockHead(reader)
const bytes = await reader.exactly(blockLength, true)
return { bytes, cid }
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand All @@ -129,8 +121,6 @@ async function readBlockIndex (reader) {
const index = { cid, length, blockLength, offset, blockOffset: reader.pos }
reader.seek(index.blockLength)
return index
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand All @@ -150,8 +140,6 @@ export function createDecoder (reader) {
reader = limitReader(reader, header.dataSize - v1length)
}
return header
/* c8 ignore next 2 */
// Node.js 12 c8 bug
})()

return {
Expand Down Expand Up @@ -187,9 +175,7 @@ export function bytesReader (bytes) {
return {
async upTo (length) {
const out = bytes.subarray(pos, pos + Math.min(length, bytes.length - pos))
/* c8 ignore next 2 */
return out
// Node.js 12 c8 bug
},

async exactly (length, seek = false) {
Expand All @@ -201,8 +187,6 @@ export function bytesReader (bytes) {
pos += length
}
return out
/* c8 ignore next 2 */
// Node.js 12 c8 bug
},

seek (length) {
Expand Down Expand Up @@ -266,8 +250,6 @@ export function chunkReader (readChunk /*, closer */) {
await read(length)
}
return currentChunk.subarray(offset, offset + Math.min(currentChunk.length - offset, length))
/* c8 ignore next 2 */
// Node.js 12 c8 bug
},

async exactly (length, seek = false) {
Expand All @@ -283,8 +265,6 @@ export function chunkReader (readChunk /*, closer */) {
offset += length
}
return out
/* c8 ignore next 2 */
// Node.js 12 c8 bug
},

seek (length) {
Expand Down Expand Up @@ -315,8 +295,6 @@ export function asyncIterableReader (asyncIterable) {
return null
}
return next.value
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

return chunkReader(readChunk)
Expand All @@ -343,8 +321,6 @@ export function limitReader (reader, byteLimit) {
bytes = bytes.subarray(0, byteLimit - bytesRead)
}
return bytes
/* c8 ignore next 2 */
// Node.js 12 c8 bug
},

async exactly (length, seek = false) {
Expand All @@ -356,8 +332,6 @@ export function limitReader (reader, byteLimit) {
bytesRead += length
}
return bytes
/* c8 ignore next 2 */
// Node.js 12 c8 bug
},

seek (length) {
Expand Down
2 changes: 0 additions & 2 deletions src/encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ function createEncoder (writer) {
*/
async close () {
await writer.end()
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}
}
}
Expand Down
10 changes: 0 additions & 10 deletions src/indexed-reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ export class CarIndexedReader {
*/
async getRoots () {
return this._roots
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand All @@ -92,8 +90,6 @@ export class CarIndexedReader {
*/
async has (key) {
return this._index.has(key.toString())
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand Down Expand Up @@ -122,8 +118,6 @@ export class CarIndexedReader {
blockOffset: blockIndex.blockOffset
}
return NodeCarReader.readRaw(this._fd, readIndex)
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand Down Expand Up @@ -177,8 +171,6 @@ export class CarIndexedReader {
if (this._fd) {
return this._fd.close()
}
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand Down Expand Up @@ -213,8 +205,6 @@ export class CarIndexedReader {
order.push(cidStr)
}
return new CarIndexedReader(iterable.version, path, await iterable.getRoots(), index, order)
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}
}

Expand Down
8 changes: 0 additions & 8 deletions src/indexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ export class CarIndexer {
*/
async getRoots () {
return this._roots
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand All @@ -97,8 +95,6 @@ export class CarIndexer {
throw new TypeError('fromBytes() requires a Uint8Array')
}
return decodeIndexerComplete(bytesReader(bytes))
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}

/**
Expand All @@ -118,8 +114,6 @@ export class CarIndexer {
throw new TypeError('fromIterable() requires an async iterable')
}
return decodeIndexerComplete(asyncIterableReader(asyncIterable))
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}
}

Expand All @@ -133,6 +127,4 @@ async function decodeIndexerComplete (reader) {
const { version, roots } = await decoder.header()

return new CarIndexer(version, roots, decoder.blocksIndex())
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}
4 changes: 0 additions & 4 deletions src/iterator-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ export function create () {
const drainer = makeDrainer()
outWaitResolver()
await drainer
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}
}

Expand Down Expand Up @@ -86,8 +84,6 @@ export function create () {
}

return outWait
/* c8 ignore next 2 */
// Node.js 12 c8 bug
}
}

Expand Down
Loading

0 comments on commit 17d3e2f

Please sign in to comment.