Skip to content

Commit

Permalink
fix: switch interface method decl style
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Oct 3, 2023
1 parent 01b361d commit 2917947
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
30 changes: 15 additions & 15 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,41 @@ export interface BlockIndex extends BlockHeader {

export interface RootsReader {
version: number
getRoots: () => Promise<CID[]>
getRoots(): Promise<CID[]>
}

export interface RootsBufferReader {
version: number
getRoots: () => CID[]
getRoots(): CID[]
}

export interface BlockIterator extends AsyncIterable<Block> {}

export interface CIDIterator extends AsyncIterable<CID> {}

export interface BlockReader {
has: (key: CID) => Promise<boolean>
get: (key: CID) => Promise<Block | undefined>
blocks: () => BlockIterator
cids: () => CIDIterator
has(key: CID): Promise<boolean>
get(key: CID): Promise<Block | undefined>
blocks(): BlockIterator
cids(): CIDIterator
}

export interface BlockBufferReader {
has: (key: CID) => boolean
get: (key: CID) => Block | undefined
blocks: () => Iterable<Block>
cids: () => Iterable<CID>
has(key: CID): boolean
get(key: CID): Block | undefined
blocks(): Iterable<Block>
cids(): Iterable<CID>
}

export interface BlockWriter {
put: (block: Block) => Promise<void>
close: () => Promise<void>
put(block: Block): Promise<void>
close(): Promise<void>
}

export interface CarBufferWriter {
addRoot: (root: CID, options?: { resize?: boolean }) => CarBufferWriter
write: (block: Block) => CarBufferWriter
close: (options?: { resize?: boolean }) => Uint8Array
addRoot(root: CID, options?: { resize?: boolean }): CarBufferWriter
write(block: Block): CarBufferWriter
close(options?: { resize?: boolean }): Uint8Array
}

export interface CarBufferWriterOptions {
Expand Down
26 changes: 13 additions & 13 deletions src/coding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import type { Block, BlockIndex } from './api.js'
import type { CID } from 'multiformats/cid'

export interface CarEncoder {
setRoots: (roots: CID[]) => Promise<void>
setRoots(roots: CID[]): Promise<void>

writeBlock: (block: Block) => Promise<void>
writeBlock(block: Block): Promise<void>

close: () => Promise<void>
close(): Promise<void>
}

export interface IteratorChannel_Writer<T> {
write: (chunk: T) => Promise<void>
end: () => Promise<void>
write(chunk: T): Promise<void>
end(): Promise<void>
}

export interface IteratorChannel<T> {
Expand All @@ -38,29 +38,29 @@ export interface CarV2Header extends CarV2FixedHeader {
}

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

blocks: () => AsyncGenerator<Block>
blocks(): AsyncGenerator<Block>

blocksIndex: () => AsyncGenerator<BlockIndex>
blocksIndex(): AsyncGenerator<BlockIndex>
}

export interface Seekable {
seek: (length: number) => void
seek(length: number): void
}

export interface BytesReader extends Seekable {
upTo: (length: number) => Promise<Uint8Array>
upTo(length: number): Promise<Uint8Array>

exactly: (length: number, seek?: boolean) => Promise<Uint8Array>
exactly(length: number, seek?: boolean): Promise<Uint8Array>

pos: number
}

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

exactly: (length: number, seek?: boolean) => Uint8Array
exactly(length: number, seek?: boolean): Uint8Array

pos: number
}

0 comments on commit 2917947

Please sign in to comment.