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

Commit

Permalink
Merge pull request #79 from Gozala/flowtypes
Browse files Browse the repository at this point in the history
feat: add flow typedefs
  • Loading branch information
mikeal authored Apr 4, 2019
2 parents 537f604 + 1cf9740 commit a75da83
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[ignore]

[include]

[libs]

[lints]

[options]

[strict]
32 changes: 32 additions & 0 deletions src/index.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// @flow strict

export type Version = 0 | 1
export type Codec = string
export type Multihash = Buffer
export type BaseEncodedString = string

declare class CID<a> {
constructor(Version, Codec, Multihash): void;
constructor(BaseEncodedString): void;
constructor(Buffer): void;

+codec: Codec;
+multihash: Multihash;
+buffer: Buffer;
+prefix: Buffer;

toV0(): CID<a>;
toV1(): CID<a>;
toBaseEncodedString(base?: string): BaseEncodedString;
toString(): BaseEncodedString;
toJSON(): { codec: Codec, version: Version, hash: Multihash };

equals(mixed): boolean;

static codecs: { [string]: Codec };
static isCID(mixed): boolean;
static validateCID(mixed): void;
}

export default CID
export type { CID }

0 comments on commit a75da83

Please sign in to comment.