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

Commit 4948267

Browse files
Gozalavmx
authored andcommitted
fix: improve CID typings
1 parent 06a43a3 commit 4948267

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/index.d.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,39 @@ declare class CID {
2929
* new CID(<cid>)
3030
*/
3131
constructor(
32-
version: 0 | 1,
32+
version: CIDVersion,
3333
codec: string | number,
3434
multhash: Uint8Array,
3535
multibaseName?: string
3636
);
37-
constructor(cid: CID);
38-
constructor(str: string);
39-
constructor(buf: Uint8Array);
37+
constructor(cid: CID|string|Uint8Array);
4038

4139
/**
4240
* The version of the CID.
4341
*/
44-
version: number;
42+
readonly version: CIDVersion;
4543

4644
/**
4745
* The codec of the CID.
46+
* @deprecated
4847
*/
49-
codec: string;
48+
readonly codec: string;
5049

5150
/**
5251
* The codec of the CID in its number form.
5352
*/
54-
code: number;
53+
readonly code: number;
5554

5655
/**
5756
* The multihash of the CID.
5857
*/
59-
multihash: Uint8Array;
58+
readonly multihash: Uint8Array;
6059

6160
/**
6261
* Multibase name as string.
62+
* @deprecated
6363
*/
64-
multibaseName: string;
64+
readonly multibaseName: string;
6565

6666
/**
6767
* The CID as a `Uint8Array`
@@ -70,6 +70,7 @@ declare class CID {
7070

7171
/**
7272
* The prefix of the CID.
73+
* @deprecated
7374
*/
7475
readonly prefix: Uint8Array;
7576

@@ -120,4 +121,6 @@ declare class CID {
120121
static codecs: Record<string, number>;
121122
}
122123

124+
type CIDVersion = 0|1
125+
123126
export = CID

0 commit comments

Comments
 (0)