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

Commit

Permalink
feat: add flow typedefs
Browse files Browse the repository at this point in the history
Add flow type definitions which would improve workflow for dependent libraries that happen to use flow type-checker.
  • Loading branch information
Gozala committed Apr 4, 2019
1 parent 537f604 commit 1cf9740
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 1cf9740

Please sign in to comment.