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

Commit 1cf9740

Browse files
committed
feat: add flow typedefs
Add flow type definitions which would improve workflow for dependent libraries that happen to use flow type-checker.
1 parent 537f604 commit 1cf9740

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

.flowconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[ignore]
2+
3+
[include]
4+
5+
[libs]
6+
7+
[lints]
8+
9+
[options]
10+
11+
[strict]

src/index.js.flow

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// @flow strict
2+
3+
export type Version = 0 | 1
4+
export type Codec = string
5+
export type Multihash = Buffer
6+
export type BaseEncodedString = string
7+
8+
declare class CID<a> {
9+
constructor(Version, Codec, Multihash): void;
10+
constructor(BaseEncodedString): void;
11+
constructor(Buffer): void;
12+
13+
+codec: Codec;
14+
+multihash: Multihash;
15+
+buffer: Buffer;
16+
+prefix: Buffer;
17+
18+
toV0(): CID<a>;
19+
toV1(): CID<a>;
20+
toBaseEncodedString(base?: string): BaseEncodedString;
21+
toString(): BaseEncodedString;
22+
toJSON(): { codec: Codec, version: Version, hash: Multihash };
23+
24+
equals(mixed): boolean;
25+
26+
static codecs: { [string]: Codec };
27+
static isCID(mixed): boolean;
28+
static validateCID(mixed): void;
29+
}
30+
31+
export default CID
32+
export type { CID }

0 commit comments

Comments
 (0)