Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Commit

Permalink
feat: typescript types
Browse files Browse the repository at this point in the history
Offering to submit and maintain these types. Given the relative stability of js-cids, this seems like a low maintenance PR.
  • Loading branch information
carsonfarmer authored and vmx committed Dec 2, 2019
1 parent 6c215bd commit 3b27338
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export type Version = 0 | 1
export type Codec = string
export type Multihash = Buffer
export type BaseEncodedString = string
export type MultibaseName = string

export class CID {
constructor(version: Version, codec: Codec, multhash: Multihash, multibaseName?: MultibaseName)
constructor(cidStr: BaseEncodedString)
constructor(cidBuf: Buffer)
constructor(cidMultihash: Multihash)
constructor(cid: CID)
codec: Codec
multihash: Multihash
buffer: Buffer
prefix: Buffer
version: number
toV0(): CID
toV1(): CID
toBaseEncodedString(base?: string): BaseEncodedString
toString(): BaseEncodedString
toJSON(): { codec: Codec, version: Version, hash: Multihash }
equals(other: any): boolean
static codecs: Record<string, Codec>
static isCID(mixed: any): boolean
static validateCID(other: any): void
}

export default CID

0 comments on commit 3b27338

Please sign in to comment.