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

Commit

Permalink
fix: improve CID typings
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala authored and vmx committed Oct 14, 2020
1 parent 06a43a3 commit 4948267
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,39 @@ declare class CID {
* new CID(<cid>)
*/
constructor(
version: 0 | 1,
version: CIDVersion,
codec: string | number,
multhash: Uint8Array,
multibaseName?: string
);
constructor(cid: CID);
constructor(str: string);
constructor(buf: Uint8Array);
constructor(cid: CID|string|Uint8Array);

/**
* The version of the CID.
*/
version: number;
readonly version: CIDVersion;

/**
* The codec of the CID.
* @deprecated
*/
codec: string;
readonly codec: string;

/**
* The codec of the CID in its number form.
*/
code: number;
readonly code: number;

/**
* The multihash of the CID.
*/
multihash: Uint8Array;
readonly multihash: Uint8Array;

/**
* Multibase name as string.
* @deprecated
*/
multibaseName: string;
readonly multibaseName: string;

/**
* The CID as a `Uint8Array`
Expand All @@ -70,6 +70,7 @@ declare class CID {

/**
* The prefix of the CID.
* @deprecated
*/
readonly prefix: Uint8Array;

Expand Down Expand Up @@ -120,4 +121,6 @@ declare class CID {
static codecs: Record<string, number>;
}

type CIDVersion = 0|1

export = CID

0 comments on commit 4948267

Please sign in to comment.