Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Aug 28, 2023
1 parent 764e6fb commit a387c02
Show file tree
Hide file tree
Showing 23 changed files with 61 additions and 65 deletions.
4 changes: 2 additions & 2 deletions src/buffer-decoder.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { decode as decodeDagCbor } from '@ipld/dag-cbor'
import { CID } from 'multiformats/cid'
import * as Digest from 'multiformats/hashes/digest'
import { decode as decodeDagCbor } from '@ipld/dag-cbor'
import { CarHeader as headerValidator } from './header-validator.js'
import { CIDV0_BYTES, decodeV2Header, decodeVarint, getMultihashLength, V2_HEADER_LENGTH } from './decoder-common.js'
import { CarHeader as headerValidator } from './header-validator.js'

/**
* @typedef {import('./api').Block} Block
Expand Down
4 changes: 2 additions & 2 deletions src/buffer-writer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import varint from 'varint'
import * as CBOR from '@ipld/dag-cbor'
import { Token, Type } from 'cborg'
import { tokensToLength } from 'cborg/length'
import * as CBOR from '@ipld/dag-cbor'
import varint from 'varint'

/**
* @typedef {import('./api').CID} CID
Expand Down
6 changes: 3 additions & 3 deletions src/coding.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { CID } from 'multiformats/cid'
import type { Block, BlockIndex } from './api.js'
import type { CID } from 'multiformats/cid'

export interface CarEncoder {
setRoots: (roots: CID[]) => Promise<void>
Expand Down Expand Up @@ -38,7 +38,7 @@ export interface CarV2Header extends CarV2FixedHeader {
}

export interface CarDecoder {
header: () => Promise<CarHeader|CarV2Header>
header: () => Promise<CarHeader | CarV2Header>

blocks: () => AsyncGenerator<Block>

Expand All @@ -57,7 +57,7 @@ export interface BytesReader extends Seekable {
pos: number
}

export interface BytesBufferReader extends Seekable{
export interface BytesBufferReader extends Seekable {
upTo: (length: number) => Uint8Array

exactly: (length: number, seek?: boolean) => Uint8Array
Expand Down
4 changes: 2 additions & 2 deletions src/decoder.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { decode as decodeDagCbor } from '@ipld/dag-cbor'
import { CID } from 'multiformats/cid'
import * as Digest from 'multiformats/hashes/digest'
import { decode as decodeDagCbor } from '@ipld/dag-cbor'
import { CarHeader as headerValidator } from './header-validator.js'
import { CIDV0_BYTES, decodeV2Header, decodeVarint, getMultihashLength, V2_HEADER_LENGTH } from './decoder-common.js'
import { CarHeader as headerValidator } from './header-validator.js'

/**
* @typedef {import('./api').Block} Block
Expand Down
2 changes: 1 addition & 1 deletion src/encoder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import varint from 'varint'
import { encode as dagCborEncode } from '@ipld/dag-cbor'
import varint from 'varint'

/**
* @typedef {import('multiformats').CID} CID
Expand Down
8 changes: 4 additions & 4 deletions src/index-browser.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { CarReader } from './reader-browser.js'
import { CarBufferReader } from './buffer-reader.js'
import * as CarBufferWriter from './buffer-writer.js'
import { CarIndexedReader } from './indexed-reader-browser.js'
import { CarIndexer } from './indexer.js'
import { CarBlockIterator, CarCIDIterator } from './iterator.js'
import { CarReader } from './reader-browser.js'
import { CarWriter } from './writer-browser.js'
import { CarIndexedReader } from './indexed-reader-browser.js'
import { CarBufferReader } from './buffer-reader.js'
import * as CarBufferWriter from './buffer-writer.js'

export {
CarReader,
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { CarReader } from './reader.js'
import { CarBufferReader } from './buffer-reader.js'
import * as CarBufferWriter from './buffer-writer.js'
import { CarIndexedReader } from './indexed-reader.js'
import { CarIndexer } from './indexer.js'
import { CarBlockIterator, CarCIDIterator } from './iterator.js'
import { CarReader } from './reader.js'
import { CarWriter } from './writer.js'
import { CarIndexedReader } from './indexed-reader.js'
import * as CarBufferWriter from './buffer-writer.js'

// @see https://www.iana.org/assignments/media-types/application/vnd.ipld.car
export const contentType = 'application/vnd.ipld.car'
Expand Down
2 changes: 1 addition & 1 deletion src/writer-browser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CID } from 'multiformats/cid'
import { bytesReader, readHeader } from './decoder.js'
import { createEncoder, createHeader } from './encoder.js'
import { create as iteratorChannel } from './iterator-channel.js'
import { bytesReader, readHeader } from './decoder.js'

/**
* @typedef {import('./api').Block} Block
Expand Down
4 changes: 1 addition & 3 deletions src/writer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'fs'
import { promisify } from 'util'
import { CarWriter as BrowserCarWriter } from './writer-browser.js'
import { readHeader, chunkReader } from './decoder.js'
import { createHeader } from './encoder.js'
import { CarWriter as BrowserCarWriter } from './writer-browser.js'

const fsread = promisify(fs.read)
const fswrite = promisify(fs.write)
Expand Down Expand Up @@ -64,8 +64,6 @@ export class CarWriter extends BrowserCarWriter {
const read = await readChunk()
offset += read
// TODO: test header > 256 bytes
// also Node.js 12 c8 bug
/* c8 ignore next 2 */
return read < chunkSize ? bytes.subarray(0, read) : bytes
})

Expand Down
6 changes: 3 additions & 3 deletions test/common.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { bytes, CID } from 'multiformats'
import { sha256 } from 'multiformats/hashes/sha2'
import * as raw from 'multiformats/codecs/raw'
import * as dagCbor from '@ipld/dag-cbor'
import * as dagPb from '@ipld/dag-pb'
import { assert } from 'aegir/chai'
import { bytes, CID } from 'multiformats'
import * as raw from 'multiformats/codecs/raw'
import { sha256 } from 'multiformats/hashes/sha2'

/**
* @typedef {import('../src/api').Block} Block
Expand Down
4 changes: 2 additions & 2 deletions test/node-test-file-streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

// this test is not intended to run in the browser

import path from 'path'
import { fileURLToPath } from 'url'
import fs from 'fs'
import path from 'path'
import { Readable, pipeline } from 'stream'
import { fileURLToPath } from 'url'
import { promisify } from 'util'
import { CarReader, CarWriter } from '../src/index.js'
import { makeData, assert } from './common.js'
Expand Down
6 changes: 3 additions & 3 deletions test/node-test-large.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

import fs from 'fs'
import { Readable } from 'stream'
import { garbage } from '@ipld/garbage'
import varint from 'varint'
import * as dagCbor from '@ipld/dag-cbor'
import { sha256 } from 'multiformats/hashes/sha2'
import { garbage } from '@ipld/garbage'
import { CID } from 'multiformats/cid'
import { sha256 } from 'multiformats/hashes/sha2'
import varint from 'varint'
import { CarWriter, CarIndexer, CarReader, CarIndexedReader } from '../src/index.js'
import { assert } from './common.js'

Expand Down
4 changes: 2 additions & 2 deletions test/node-test-raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

// this test is not intended to run in the browser

import path from 'path'
import fs from 'fs'
import { promisify } from 'util'
import path from 'path'
import { fileURLToPath } from 'url'
import { promisify } from 'util'
import { bytes } from 'multiformats'
import { CarReader } from '../src/index.js'
import { assert, makeData, goCarIndex } from './common.js'
Expand Down
4 changes: 2 additions & 2 deletions test/node-test-updateroots.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

// this test is not intended to run in the browser

import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
import fs from 'fs'
import { promisify } from 'util'
import { CID } from 'multiformats/cid'
import { CarReader } from '../src/reader.js'
import { CarWriter } from '../src/writer.js'
import { assert } from './common.js'
import {
verifyRoots,
verifyHas,
verifyGet,
verifyBlocks,
verifyCids
} from './verify-store-reader.js'
import { assert } from './common.js'

const fsopen = promisify(fs.open)
const fsclose = promisify(fs.close)
Expand Down
1 change: 0 additions & 1 deletion test/node.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import './node-test-file-streams.js'
import './node-test-indexed-reader.js'
import './node-test-large.js'
Expand Down
14 changes: 7 additions & 7 deletions test/test-buffer-writer.spec.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* eslint-env mocha */

import * as CBOR from '@ipld/dag-cbor'
import { CID, varint } from 'multiformats'
import * as Block from 'multiformats/block'
import * as Raw from 'multiformats/codecs/raw'
import { identity } from 'multiformats/hashes/identity'
import { sha256, sha512 } from 'multiformats/hashes/sha2'
import * as CarBufferWriter from '../src/buffer-writer.js'
import { CarReader } from '../src/reader.js'
import { createHeader } from '../src/encoder.js'
import { CarReader } from '../src/reader.js'
import { assert } from './common.js'
import { CID, varint } from 'multiformats'
import * as CBOR from '@ipld/dag-cbor'
import { sha256, sha512 } from 'multiformats/hashes/sha2'
import { identity } from 'multiformats/hashes/identity'
import * as Raw from 'multiformats/codecs/raw'
import * as Block from 'multiformats/block'

describe('CarBufferWriter', () => {
const cid = CID.parse('bafkreifuosuzujyf4i6psbneqtwg2fhplc2wxptc5euspa2gn3bwhnihfu')
Expand Down
3 changes: 2 additions & 1 deletion test/test-errors.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-env mocha */
import { bytes } from 'multiformats'

import { encode as cbEncode } from '@ipld/dag-cbor'
import { bytes } from 'multiformats'
import { encode as vEncode } from 'varint'
import { CarReader } from '../src/reader.js'
import { carBytes, assert, goCarV2Bytes } from './common.js'
Expand Down
2 changes: 1 addition & 1 deletion test/test-indexer.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-env mocha */

import { expect } from 'aegir/chai'
import { CarIndexer } from '../src/indexer.js'
import {
goCarBytes,
Expand All @@ -11,7 +12,6 @@ import {
assert
} from './common.js'
import { verifyRoots } from './verify-store-reader.js'
import { expect } from 'aegir/chai'

describe('CarIndexer fromBytes()', () => {
it('complete', async () => {
Expand Down
3 changes: 1 addition & 2 deletions test/test-interface.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint-env mocha */
import * as car from '../src/index.js'
import { CarReader, __browser } from '../src/reader.js'
import { CarIndexer } from '../src/indexer.js'
import { CarBlockIterator, CarCIDIterator } from '../src/iterator.js'
import { CarReader, __browser } from '../src/reader.js'
import { CarWriter } from '../src/writer.js'

import { assert } from './common.js'

// simple sanity check that our main exports match the direct exports
Expand Down
2 changes: 1 addition & 1 deletion test/test-iterator.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-env mocha */

import { expect } from 'aegir/chai'
import { CarBlockIterator, CarCIDIterator } from '../src/iterator.js'
import { carBytes, makeIterable, assert } from './common.js'
import { verifyRoots, verifyBlocks, verifyCids } from './verify-store-reader.js'
import { expect } from 'aegir/chai'

/**
* @param {CarBlockIterator} iter
Expand Down
12 changes: 6 additions & 6 deletions test/test-reader-sync.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-env mocha */

import { CarBufferReader } from '../src/buffer-reader-browser.js'
import { bytesReader, readHeader } from '../src/buffer-decoder.js'
import { base64 } from 'multiformats/bases/base64'
import * as dagPb from '@ipld/dag-pb'
import { expect } from 'aegir/chai'
import { base64 } from 'multiformats/bases/base64'
import { bytesReader, readHeader } from '../src/buffer-decoder.js'
import { CarBufferReader } from '../src/buffer-reader-browser.js'
import {
carBytes,
assert,
Expand All @@ -12,16 +13,15 @@ import {
goCarV2Index,
goCarV2Contents
} from './common.js'
import { expectations as fixtureExpectations } from './fixtures-expectations.js'
import { data as fixtures } from './fixtures.js'
import {
verifyRoots,
verifyHas,
verifyGet,
verifyBlocks,
verifyCids
} from './verify-store-reader.js'
import { data as fixtures } from './fixtures.js'
import { expectations as fixtureExpectations } from './fixtures-expectations.js'
import { expect } from 'aegir/chai'

describe('CarReader Sync fromBytes()', () => {
it('complete', async () => {
Expand Down
18 changes: 9 additions & 9 deletions test/test-reader.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/* eslint-env mocha */

import { CarReader } from '../src/reader.js'
import { CarWriter } from '../src/writer.js'
import { bytesReader, readHeader } from '../src/decoder.js'
import * as dagPb from '@ipld/dag-pb'
import { expect } from 'aegir/chai'
import { base64 } from 'multiformats/bases/base64'
import * as Block from 'multiformats/block'
import { sha256 } from 'multiformats/hashes/sha2'
import * as raw from 'multiformats/codecs/raw'
import { base64 } from 'multiformats/bases/base64'
import * as dagPb from '@ipld/dag-pb'
import { sha256 } from 'multiformats/hashes/sha2'
import { bytesReader, readHeader } from '../src/decoder.js'
import { CarReader } from '../src/reader.js'
import { CarWriter } from '../src/writer.js'
import {
carBytes,
makeIterable,
Expand All @@ -17,16 +18,15 @@ import {
goCarV2Index,
goCarV2Contents
} from './common.js'
import { expectations as fixtureExpectations } from './fixtures-expectations.js'
import { data as fixtures } from './fixtures.js'
import {
verifyRoots,
verifyHas,
verifyGet,
verifyBlocks,
verifyCids
} from './verify-store-reader.js'
import { data as fixtures } from './fixtures.js'
import { expectations as fixtureExpectations } from './fixtures-expectations.js'
import { expect } from 'aegir/chai'

describe('CarReader fromBytes()', () => {
it('complete', async () => {
Expand Down
7 changes: 3 additions & 4 deletions test/test-writer.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-env mocha */
/* globals describe, it */

import { CarWriter } from '../src/writer.js'
import { CarReader } from '../src/reader.js'
import { expect } from 'aegir/chai'
import { bytes, CID } from 'multiformats'
import { CarReader } from '../src/reader.js'
import { CarWriter } from '../src/writer.js'
import { carBytes, makeData, assert, rndCid } from './common.js'
import {
verifyRoots,
Expand All @@ -12,7 +12,6 @@ import {
verifyBlocks,
verifyCids
} from './verify-store-reader.js'
import { expect } from 'aegir/chai'

/**
* @typedef {import('../src/api').Block} Block
Expand Down

0 comments on commit a387c02

Please sign in to comment.