-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
executable file
·84 lines (75 loc) · 2.39 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
type BytesLike = number[]|Uint8Array;
interface Coder {
decode(s: string): Uint8Array;
encode(v: BytesLike, pad?: boolean): string,
}
export class CID {
static from(v: string|BytesLike): CID;
constructor(codec: number, hash: Uint8Array, base?: Multibase);
version: number;
codec: number;
base?: Multibase;
get bytes(): Uint8Array;
upgrade(): CID;
}
export class Multibase implements Coder {
static decode(s: string): {base: Multibase, data: Uint8Array};
static for(prefix: string|Multibase): Multibase;
static [Symbol.iterator](): Iterable<Multibase>;
prefix: string;
name: string;
constructor(prefix: string, name: string);
decode(s: string): Uint8Array;
encode(v: BytesLike): string;
encodeWithPrefix(v: BytesLike): string;
}
export class Multibased extends Multibase {
constructor(prefix: string, name: string, coder: Coder, options?: {casing?: boolean, padding?: boolean});
coder: Coder;
casing?: boolean;
padding?: boolean;
}
export class Multihash {
static from(v: string|BytesLike): Multihash;
constructor(codec: number, data: Uint8Array);
codec: number;
data: Uint8Array;
get bytes(): Uint8Array;
write(v: Uint8Array, pos?: number): number;
}
export const uvarint: {
write(v: BytesLike, u: BytesLike|string|number, pos?: number): number;
read(v: BytesLike, pos?: number, n?: number): [...number[], pos: number];
readHex(v: BytesLike, pos?: number, n?: number): [...string[], pos: number];
readBigInt(v: BytesLike, pos?: number, n?: number): [...BigInt[], pos: number];
}
export class RFC4648 implements Coder {
constructor(chars: string);
decode(s: string): Uint8Array;
encode(v: BytesLike, pad?: boolean): string;
}
export class Prefix0 implements Coder {
constructor(chars: string);
decode(s: string): Uint8Array;
encode(v: BytesLike): string;
}
export class Bech32 {
static M: number;
static decode(s: string): Bech32;
constructor(hrp: string, v32: number[], type?: number);
hrp: string;
v32: number[];
type: number;
}
export const Base2: RFC4648;
export const Base8: RFC4648;
export const Base10: Prefix0;
export const Base16: RFC4648;
export const Base32: RFC4648;
export const Base32Hex: RFC4648;
export const Base32Z: RFC4648;
export const Base36: Prefix0;
export const Base58BTC: Prefix0;
export const Base58Flickr: Prefix0;
export const Base64URL: RFC4648;
export const Base64: RFC4648;