diff --git a/.flowconfig b/.flowconfig new file mode 100644 index 0000000..1fed445 --- /dev/null +++ b/.flowconfig @@ -0,0 +1,11 @@ +[ignore] + +[include] + +[libs] + +[lints] + +[options] + +[strict] diff --git a/src/index.js.flow b/src/index.js.flow new file mode 100644 index 0000000..4216deb --- /dev/null +++ b/src/index.js.flow @@ -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 { + constructor(Version, Codec, Multihash): void; + constructor(BaseEncodedString): void; + constructor(Buffer): void; + + +codec: Codec; + +multihash: Multihash; + +buffer: Buffer; + +prefix: Buffer; + + toV0(): CID; + toV1(): CID; + 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 }