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

Commit 3b27338

Browse files
carsonfarmervmx
authored andcommitted
feat: typescript types
Offering to submit and maintain these types. Given the relative stability of js-cids, this seems like a low maintenance PR.
1 parent 6c215bd commit 3b27338

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/index.d.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export type Version = 0 | 1
2+
export type Codec = string
3+
export type Multihash = Buffer
4+
export type BaseEncodedString = string
5+
export type MultibaseName = string
6+
7+
export class CID {
8+
constructor(version: Version, codec: Codec, multhash: Multihash, multibaseName?: MultibaseName)
9+
constructor(cidStr: BaseEncodedString)
10+
constructor(cidBuf: Buffer)
11+
constructor(cidMultihash: Multihash)
12+
constructor(cid: CID)
13+
codec: Codec
14+
multihash: Multihash
15+
buffer: Buffer
16+
prefix: Buffer
17+
version: number
18+
toV0(): CID
19+
toV1(): CID
20+
toBaseEncodedString(base?: string): BaseEncodedString
21+
toString(): BaseEncodedString
22+
toJSON(): { codec: Codec, version: Version, hash: Multihash }
23+
equals(other: any): boolean
24+
static codecs: Record<string, Codec>
25+
static isCID(mixed: any): boolean
26+
static validateCID(other: any): void
27+
}
28+
29+
export default CID

0 commit comments

Comments
 (0)