@helios-lang/effect 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bun.lock +60 -0
- package/dist/Uplc/Data.js +20 -0
- package/dist/Uplc/Data.js.map +1 -1
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.check.tsbuildinfo +1 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/types/Address.d.ts +5 -0
- package/types/Address.d.ts.map +1 -0
- package/types/Bech32.d.ts +30 -0
- package/types/Bech32.d.ts.map +1 -0
- package/types/Cbor.d.ts +430 -0
- package/types/Cbor.d.ts.map +1 -0
- package/types/Ledger/Address.d.ts +109 -0
- package/types/Ledger/Address.d.ts.map +1 -0
- package/types/Ledger/AssetClass.d.ts +101 -0
- package/types/Ledger/AssetClass.d.ts.map +1 -0
- package/types/Ledger/Assets.d.ts +70 -0
- package/types/Ledger/Assets.d.ts.map +1 -0
- package/types/Ledger/Credential.d.ts +26 -0
- package/types/Ledger/Credential.d.ts.map +1 -0
- package/types/Ledger/DatumHash.d.ts +40 -0
- package/types/Ledger/DatumHash.d.ts.map +1 -0
- package/types/Ledger/IsMainnet.d.ts +6 -0
- package/types/Ledger/IsMainnet.d.ts.map +1 -0
- package/types/Ledger/MintingPolicy.d.ts +39 -0
- package/types/Ledger/MintingPolicy.d.ts.map +1 -0
- package/{src/Ledger/NetworkParams.ts → types/Ledger/NetworkParams.d.ts} +24 -26
- package/types/Ledger/NetworkParams.d.ts.map +1 -0
- package/types/Ledger/PubKeyHash.d.ts +40 -0
- package/types/Ledger/PubKeyHash.d.ts.map +1 -0
- package/types/Ledger/TxId.d.ts +10 -0
- package/types/Ledger/TxId.d.ts.map +1 -0
- package/types/Ledger/TxInput.d.ts +55 -0
- package/types/Ledger/TxInput.d.ts.map +1 -0
- package/types/Ledger/TxOutput.d.ts +63 -0
- package/types/Ledger/TxOutput.d.ts.map +1 -0
- package/types/Ledger/TxOutputDatum.d.ts +41 -0
- package/types/Ledger/TxOutputDatum.d.ts.map +1 -0
- package/types/Ledger/TxOutputId.d.ts +14 -0
- package/types/Ledger/TxOutputId.d.ts.map +1 -0
- package/types/Ledger/ValidatorHash.d.ts +40 -0
- package/types/Ledger/ValidatorHash.d.ts.map +1 -0
- package/types/Ledger/index.d.ts +16 -0
- package/types/Ledger/index.d.ts.map +1 -0
- package/types/Uplc/Cek.d.ts +72 -0
- package/types/Uplc/Cek.d.ts.map +1 -0
- package/types/Uplc/Data.d.ts +559 -0
- package/types/Uplc/Data.d.ts.map +1 -0
- package/types/Uplc/DataSchema.d.ts +227 -0
- package/types/Uplc/DataSchema.d.ts.map +1 -0
- package/types/Uplc/Primitive.d.ts +26 -0
- package/types/Uplc/Primitive.d.ts.map +1 -0
- package/types/Uplc/index.d.ts +3 -0
- package/types/Uplc/index.d.ts.map +1 -0
- package/types/index.d.ts +5 -0
- package/types/index.d.ts.map +1 -0
- package/types/internal/Base32.d.ts +49 -0
- package/types/internal/Base32.d.ts.map +1 -0
- package/types/internal/BigEndian.d.ts +22 -0
- package/types/internal/BigEndian.d.ts.map +1 -0
- package/types/internal/Bits.d.ts +123 -0
- package/types/internal/Bits.d.ts.map +1 -0
- package/types/internal/Bytes.d.ts +88 -0
- package/types/internal/Bytes.d.ts.map +1 -0
- package/types/internal/Flat.d.ts +71 -0
- package/types/internal/Flat.d.ts.map +1 -0
- package/types/internal/Float.d.ts +38 -0
- package/types/internal/Float.d.ts.map +1 -0
- package/types/internal/Utf8.d.ts +24 -0
- package/types/internal/Utf8.d.ts.map +1 -0
- package/src/Bech32.test.ts +0 -117
- package/src/Bech32.ts +0 -198
- package/src/Cbor.test.ts +0 -1610
- package/src/Cbor.ts +0 -1704
- package/src/Ledger/Address.ts +0 -248
- package/src/Ledger/AssetClass.ts +0 -90
- package/src/Ledger/Assets.ts +0 -164
- package/src/Ledger/Credential.ts +0 -29
- package/src/Ledger/DatumHash.ts +0 -36
- package/src/Ledger/IsMainnet.ts +0 -6
- package/src/Ledger/MintingPolicy.ts +0 -57
- package/src/Ledger/PubKeyHash.ts +0 -36
- package/src/Ledger/TxId.ts +0 -31
- package/src/Ledger/TxInput.test.ts +0 -21
- package/src/Ledger/TxInput.ts +0 -66
- package/src/Ledger/TxOutput.ts +0 -166
- package/src/Ledger/TxOutputDatum.ts +0 -64
- package/src/Ledger/TxOutputId.ts +0 -63
- package/src/Ledger/ValidatorHash.ts +0 -36
- package/src/Ledger/index.ts +0 -15
- package/src/Uplc/Cek.ts +0 -92
- package/src/Uplc/Data.test.ts +0 -321
- package/src/Uplc/Data.ts +0 -657
- package/src/Uplc/Primitive.ts +0 -56
- package/src/Uplc/index.ts +0 -2
- package/src/index.ts +0 -4
- package/src/internal/Base32.test.ts +0 -219
- package/src/internal/Base32.ts +0 -341
- package/src/internal/BigEndian.test.ts +0 -79
- package/src/internal/BigEndian.ts +0 -67
- package/src/internal/Bits.test.ts +0 -300
- package/src/internal/Bits.ts +0 -398
- package/src/internal/Bytes.test.ts +0 -369
- package/src/internal/Bytes.ts +0 -343
- package/src/internal/Flat.test.ts +0 -29
- package/src/internal/Flat.ts +0 -387
- package/src/internal/Float.test.ts +0 -51
- package/src/internal/Float.ts +0 -190
- package/src/internal/Utf8.test.ts +0 -69
- package/src/internal/Utf8.ts +0 -58
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { DataUnencoded as Data } from "./Data.js";
|
|
3
|
+
declare const BigIntSchema: Schema.transformOrFail<Schema.SchemaClass<{
|
|
4
|
+
readonly bytes: string;
|
|
5
|
+
} | {
|
|
6
|
+
readonly int: bigint;
|
|
7
|
+
} | {
|
|
8
|
+
readonly fields: readonly import("./Data.js").Data[];
|
|
9
|
+
readonly constructor: number;
|
|
10
|
+
} | {
|
|
11
|
+
readonly list: readonly import("./Data.js").Data[];
|
|
12
|
+
} | {
|
|
13
|
+
readonly map: readonly {
|
|
14
|
+
readonly k: import("./Data.js").Data;
|
|
15
|
+
readonly v: import("./Data.js").Data;
|
|
16
|
+
}[];
|
|
17
|
+
}, {
|
|
18
|
+
readonly bytes: string;
|
|
19
|
+
} | {
|
|
20
|
+
readonly int: bigint;
|
|
21
|
+
} | {
|
|
22
|
+
readonly fields: readonly import("./Data.js").Data[];
|
|
23
|
+
readonly constructor: number;
|
|
24
|
+
} | {
|
|
25
|
+
readonly list: readonly import("./Data.js").Data[];
|
|
26
|
+
} | {
|
|
27
|
+
readonly map: readonly {
|
|
28
|
+
readonly k: import("./Data.js").Data;
|
|
29
|
+
readonly v: import("./Data.js").Data;
|
|
30
|
+
}[];
|
|
31
|
+
}, never>, typeof Schema.BigIntFromSelf, never>;
|
|
32
|
+
export { BigIntSchema as BigInt };
|
|
33
|
+
export declare const Int: Schema.transformOrFail<Schema.SchemaClass<{
|
|
34
|
+
readonly bytes: string;
|
|
35
|
+
} | {
|
|
36
|
+
readonly int: bigint;
|
|
37
|
+
} | {
|
|
38
|
+
readonly fields: readonly import("./Data.js").Data[];
|
|
39
|
+
readonly constructor: number;
|
|
40
|
+
} | {
|
|
41
|
+
readonly list: readonly import("./Data.js").Data[];
|
|
42
|
+
} | {
|
|
43
|
+
readonly map: readonly {
|
|
44
|
+
readonly k: import("./Data.js").Data;
|
|
45
|
+
readonly v: import("./Data.js").Data;
|
|
46
|
+
}[];
|
|
47
|
+
}, {
|
|
48
|
+
readonly bytes: string;
|
|
49
|
+
} | {
|
|
50
|
+
readonly int: bigint;
|
|
51
|
+
} | {
|
|
52
|
+
readonly fields: readonly import("./Data.js").Data[];
|
|
53
|
+
readonly constructor: number;
|
|
54
|
+
} | {
|
|
55
|
+
readonly list: readonly import("./Data.js").Data[];
|
|
56
|
+
} | {
|
|
57
|
+
readonly map: readonly {
|
|
58
|
+
readonly k: import("./Data.js").Data;
|
|
59
|
+
readonly v: import("./Data.js").Data;
|
|
60
|
+
}[];
|
|
61
|
+
}, never>, typeof Schema.Int, never>;
|
|
62
|
+
export declare const ByteArray: Schema.transformOrFail<Schema.SchemaClass<{
|
|
63
|
+
readonly bytes: string;
|
|
64
|
+
} | {
|
|
65
|
+
readonly int: bigint;
|
|
66
|
+
} | {
|
|
67
|
+
readonly fields: readonly import("./Data.js").Data[];
|
|
68
|
+
readonly constructor: number;
|
|
69
|
+
} | {
|
|
70
|
+
readonly list: readonly import("./Data.js").Data[];
|
|
71
|
+
} | {
|
|
72
|
+
readonly map: readonly {
|
|
73
|
+
readonly k: import("./Data.js").Data;
|
|
74
|
+
readonly v: import("./Data.js").Data;
|
|
75
|
+
}[];
|
|
76
|
+
}, {
|
|
77
|
+
readonly bytes: string;
|
|
78
|
+
} | {
|
|
79
|
+
readonly int: bigint;
|
|
80
|
+
} | {
|
|
81
|
+
readonly fields: readonly import("./Data.js").Data[];
|
|
82
|
+
readonly constructor: number;
|
|
83
|
+
} | {
|
|
84
|
+
readonly list: readonly import("./Data.js").Data[];
|
|
85
|
+
} | {
|
|
86
|
+
readonly map: readonly {
|
|
87
|
+
readonly k: import("./Data.js").Data;
|
|
88
|
+
readonly v: import("./Data.js").Data;
|
|
89
|
+
}[];
|
|
90
|
+
}, never>, Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>, never>;
|
|
91
|
+
declare const StringSchema: Schema.transformOrFail<Schema.SchemaClass<{
|
|
92
|
+
readonly bytes: string;
|
|
93
|
+
} | {
|
|
94
|
+
readonly int: bigint;
|
|
95
|
+
} | {
|
|
96
|
+
readonly fields: readonly import("./Data.js").Data[];
|
|
97
|
+
readonly constructor: number;
|
|
98
|
+
} | {
|
|
99
|
+
readonly list: readonly import("./Data.js").Data[];
|
|
100
|
+
} | {
|
|
101
|
+
readonly map: readonly {
|
|
102
|
+
readonly k: import("./Data.js").Data;
|
|
103
|
+
readonly v: import("./Data.js").Data;
|
|
104
|
+
}[];
|
|
105
|
+
}, {
|
|
106
|
+
readonly bytes: string;
|
|
107
|
+
} | {
|
|
108
|
+
readonly int: bigint;
|
|
109
|
+
} | {
|
|
110
|
+
readonly fields: readonly import("./Data.js").Data[];
|
|
111
|
+
readonly constructor: number;
|
|
112
|
+
} | {
|
|
113
|
+
readonly list: readonly import("./Data.js").Data[];
|
|
114
|
+
} | {
|
|
115
|
+
readonly map: readonly {
|
|
116
|
+
readonly k: import("./Data.js").Data;
|
|
117
|
+
readonly v: import("./Data.js").Data;
|
|
118
|
+
}[];
|
|
119
|
+
}, never>, typeof Schema.String, never>;
|
|
120
|
+
export { StringSchema as String };
|
|
121
|
+
declare const ArraySchema: <ItemType>(itemSchema: Schema.Schema<ItemType, Schema.Schema.Encoded<typeof Data>>) => Schema.transformOrFail<Schema.SchemaClass<{
|
|
122
|
+
readonly bytes: string;
|
|
123
|
+
} | {
|
|
124
|
+
readonly int: bigint;
|
|
125
|
+
} | {
|
|
126
|
+
readonly fields: readonly import("./Data.js").Data[];
|
|
127
|
+
readonly constructor: number;
|
|
128
|
+
} | {
|
|
129
|
+
readonly list: readonly import("./Data.js").Data[];
|
|
130
|
+
} | {
|
|
131
|
+
readonly map: readonly {
|
|
132
|
+
readonly k: import("./Data.js").Data;
|
|
133
|
+
readonly v: import("./Data.js").Data;
|
|
134
|
+
}[];
|
|
135
|
+
}, {
|
|
136
|
+
readonly bytes: string;
|
|
137
|
+
} | {
|
|
138
|
+
readonly int: bigint;
|
|
139
|
+
} | {
|
|
140
|
+
readonly fields: readonly import("./Data.js").Data[];
|
|
141
|
+
readonly constructor: number;
|
|
142
|
+
} | {
|
|
143
|
+
readonly list: readonly import("./Data.js").Data[];
|
|
144
|
+
} | {
|
|
145
|
+
readonly map: readonly {
|
|
146
|
+
readonly k: import("./Data.js").Data;
|
|
147
|
+
readonly v: import("./Data.js").Data;
|
|
148
|
+
}[];
|
|
149
|
+
}, never>, Schema.Array$<Schema.Schema<ItemType, {
|
|
150
|
+
readonly bytes: string;
|
|
151
|
+
} | {
|
|
152
|
+
readonly int: bigint;
|
|
153
|
+
} | {
|
|
154
|
+
readonly fields: readonly import("./Data.js").Data[];
|
|
155
|
+
readonly constructor: number;
|
|
156
|
+
} | {
|
|
157
|
+
readonly list: readonly import("./Data.js").Data[];
|
|
158
|
+
} | {
|
|
159
|
+
readonly map: readonly {
|
|
160
|
+
readonly k: import("./Data.js").Data;
|
|
161
|
+
readonly v: import("./Data.js").Data;
|
|
162
|
+
}[];
|
|
163
|
+
}, never>>, never>;
|
|
164
|
+
export { ArraySchema as Array };
|
|
165
|
+
export declare const Struct: <FieldTypes extends {
|
|
166
|
+
[key: string]: any;
|
|
167
|
+
}>(fieldSchemas: { [FieldName in keyof FieldTypes]: Schema.Schema<FieldTypes[FieldName], Data>; }) => Schema.transformOrFail<Schema.SchemaClass<{
|
|
168
|
+
readonly bytes: string;
|
|
169
|
+
} | {
|
|
170
|
+
readonly int: bigint;
|
|
171
|
+
} | {
|
|
172
|
+
readonly fields: readonly import("./Data.js").Data[];
|
|
173
|
+
readonly constructor: number;
|
|
174
|
+
} | {
|
|
175
|
+
readonly list: readonly import("./Data.js").Data[];
|
|
176
|
+
} | {
|
|
177
|
+
readonly map: readonly {
|
|
178
|
+
readonly k: import("./Data.js").Data;
|
|
179
|
+
readonly v: import("./Data.js").Data;
|
|
180
|
+
}[];
|
|
181
|
+
}, {
|
|
182
|
+
readonly bytes: string;
|
|
183
|
+
} | {
|
|
184
|
+
readonly int: bigint;
|
|
185
|
+
} | {
|
|
186
|
+
readonly fields: readonly import("./Data.js").Data[];
|
|
187
|
+
readonly constructor: number;
|
|
188
|
+
} | {
|
|
189
|
+
readonly list: readonly import("./Data.js").Data[];
|
|
190
|
+
} | {
|
|
191
|
+
readonly map: readonly {
|
|
192
|
+
readonly k: import("./Data.js").Data;
|
|
193
|
+
readonly v: import("./Data.js").Data;
|
|
194
|
+
}[];
|
|
195
|
+
}, never>, Schema.Struct<{ [FieldName in keyof FieldTypes]: Schema.Schema<FieldTypes[FieldName], import("./Data.js").Data, never>; }>, never>;
|
|
196
|
+
export declare const EnumVariant: <FieldTypes extends {
|
|
197
|
+
[key: string]: any;
|
|
198
|
+
}>(tag: number | bigint, fieldSchemas: { [FieldName in keyof FieldTypes]: Schema.Schema<FieldTypes[FieldName], Data>; }) => Schema.transformOrFail<Schema.SchemaClass<{
|
|
199
|
+
readonly bytes: string;
|
|
200
|
+
} | {
|
|
201
|
+
readonly int: bigint;
|
|
202
|
+
} | {
|
|
203
|
+
readonly fields: readonly import("./Data.js").Data[];
|
|
204
|
+
readonly constructor: number;
|
|
205
|
+
} | {
|
|
206
|
+
readonly list: readonly import("./Data.js").Data[];
|
|
207
|
+
} | {
|
|
208
|
+
readonly map: readonly {
|
|
209
|
+
readonly k: import("./Data.js").Data;
|
|
210
|
+
readonly v: import("./Data.js").Data;
|
|
211
|
+
}[];
|
|
212
|
+
}, {
|
|
213
|
+
readonly bytes: string;
|
|
214
|
+
} | {
|
|
215
|
+
readonly int: bigint;
|
|
216
|
+
} | {
|
|
217
|
+
readonly fields: readonly import("./Data.js").Data[];
|
|
218
|
+
readonly constructor: number;
|
|
219
|
+
} | {
|
|
220
|
+
readonly list: readonly import("./Data.js").Data[];
|
|
221
|
+
} | {
|
|
222
|
+
readonly map: readonly {
|
|
223
|
+
readonly k: import("./Data.js").Data;
|
|
224
|
+
readonly v: import("./Data.js").Data;
|
|
225
|
+
}[];
|
|
226
|
+
}, never>, Schema.Struct<{ [FieldName in keyof FieldTypes]: Schema.Schema<FieldTypes[FieldName], import("./Data.js").Data, never>; }>, never>;
|
|
227
|
+
//# sourceMappingURL=DataSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataSchema.d.ts","sourceRoot":"","sources":["../../src/Uplc/DataSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE9D,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,MAAM,WAAW,CAAA;AAEjD,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;+CAYhB,CAAA;AAEF,OAAO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brand.Brand<"Bool">;
|
|
3
|
+
export declare const makeBool: Brand.Brand.Constructor<Bool>;
|
|
4
|
+
export type ByteArray = number[] & Brand.Brand<"ByteArray">;
|
|
5
|
+
export declare const makeByteArray: Brand.Brand.Constructor<ByteArray>;
|
|
6
|
+
export declare const Int: Schema.brand<typeof Schema.BigInt, "Int">;
|
|
7
|
+
export type Int = bigint & Brand.Brand<"Int">;
|
|
8
|
+
export declare const makeInt: Brand.Brand.Constructor<Int>;
|
|
9
|
+
export type List = {
|
|
10
|
+
readonly _tag: "List";
|
|
11
|
+
readonly itemType: string;
|
|
12
|
+
readonly items: Primitive[];
|
|
13
|
+
};
|
|
14
|
+
export declare function makeList(itemType: string, items: Primitive[]): List;
|
|
15
|
+
export type Pair = {
|
|
16
|
+
readonly _tag: "Pair";
|
|
17
|
+
readonly first: Primitive;
|
|
18
|
+
readonly second: Primitive;
|
|
19
|
+
};
|
|
20
|
+
export declare function makePair(first: Primitive, second: Primitive): Pair;
|
|
21
|
+
export type String = string & Brand.Brand<"String">;
|
|
22
|
+
export declare const makeString: Brand.Brand.Constructor<String>;
|
|
23
|
+
export type Unit = Brand.Brand<"Unit">;
|
|
24
|
+
export declare const makeUnit: () => Unit;
|
|
25
|
+
export type Primitive = Bool | ByteArray | Int | List | Pair | String | Unit;
|
|
26
|
+
//# sourceMappingURL=Primitive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Primitive.d.ts","sourceRoot":"","sources":["../../src/Uplc/Primitive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEtC,MAAM,MAAM,IAAI,GAAG,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;AAEhD,eAAO,MAAM,QAAQ,+BAAwB,CAAA;AAE7C,MAAM,MAAM,SAAS,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAA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AAW,CAAA;AACjC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA"}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAA;AAClC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Encoding, Either } from "effect";
|
|
2
|
+
export interface Base32 {
|
|
3
|
+
readonly alphabet: string;
|
|
4
|
+
readonly padChar: string;
|
|
5
|
+
readonly strict: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* @param encoded
|
|
8
|
+
* @returns array of bytes
|
|
9
|
+
*/
|
|
10
|
+
decode(encoded: string): Either.Either<Uint8Array, Encoding.DecodeException>;
|
|
11
|
+
/**
|
|
12
|
+
* @param encoded
|
|
13
|
+
* @returns array of numbers in range [0,32)
|
|
14
|
+
*/
|
|
15
|
+
decodeRaw(encoded: string): Either.Either<number[], Encoding.DecodeException>;
|
|
16
|
+
/**
|
|
17
|
+
* @param bytes
|
|
18
|
+
* @returns base32 encoded string
|
|
19
|
+
*/
|
|
20
|
+
encode(bytes: string | Uint8Array | number[]): string;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param bytes
|
|
24
|
+
* @returns array of numbers in range [0,32)
|
|
25
|
+
*/
|
|
26
|
+
encodeRaw(bytes: string | Uint8Array | number[]): number[];
|
|
27
|
+
/**
|
|
28
|
+
* Checks if encoded bytes are valid base32
|
|
29
|
+
* @param encoded
|
|
30
|
+
*/
|
|
31
|
+
isValid(encoded: string): boolean;
|
|
32
|
+
}
|
|
33
|
+
export type Props = {
|
|
34
|
+
alphabet?: string;
|
|
35
|
+
} | {
|
|
36
|
+
alphabet?: string;
|
|
37
|
+
padChar: string;
|
|
38
|
+
strict?: boolean;
|
|
39
|
+
};
|
|
40
|
+
export declare const DEFAULT_ALPHABET: "abcdefghijklmnopqrstuvwxyz234567";
|
|
41
|
+
export declare const DEFAULT_PAD_CHAR: "=";
|
|
42
|
+
export declare const DEFAULT_PROPS: Props;
|
|
43
|
+
export declare const DEFAULT: Base32;
|
|
44
|
+
/**
|
|
45
|
+
* @param props
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
export declare function make(props?: Props): Base32;
|
|
49
|
+
//# sourceMappingURL=Base32.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Base32.d.ts","sourceRoot":"","sources":["../../src/internal/Base32.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAGzC,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IAExB;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAA;IAE5E;;;OAGG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAA;IAE7E;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,EAAE,GAAG,MAAM,CAAA;IAErD;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,CAAA;IAE1D;;;OAGG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAA;CAClC;AAED,MAAM,MAAM,KAAK,GACb;IACE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GACD;IACE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAEL,eAAO,MAAM,gBAAgB,EAAG,kCAA2C,CAAA;AAE3E,eAAO,MAAM,gBAAgB,EAAG,GAAY,CAAA;AAE5C,eAAO,MAAM,aAAa,EAAE,KAI3B,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,MAA+B,CAAA;AAErD;;;GAGG;AACH,wBAAgB,IAAI,CAAC,KAAK,GAAE,KAAqB,GAAG,MAAM,CA0BzD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Either, Encoding } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Converts a list of big endian uint8 numbers into an unbounded int
|
|
4
|
+
* @param bytes
|
|
5
|
+
* @returns
|
|
6
|
+
* @throws
|
|
7
|
+
* If `bytes` is empty
|
|
8
|
+
* @throws
|
|
9
|
+
* If any input number is out of range [0,256) or not a whole number
|
|
10
|
+
*/
|
|
11
|
+
export declare function decode(bytes: number[] | Uint8Array): Either.Either<bigint, Encoding.DecodeException>;
|
|
12
|
+
/**
|
|
13
|
+
* Converts an unbounded integer into a list of big endian uint8 numbers.
|
|
14
|
+
* @param x
|
|
15
|
+
* @returns
|
|
16
|
+
* @throws
|
|
17
|
+
* If `x` isn't a whole number
|
|
18
|
+
* @throws
|
|
19
|
+
* If `x` is negative.
|
|
20
|
+
*/
|
|
21
|
+
export declare function encode(x: number | bigint): number[];
|
|
22
|
+
//# sourceMappingURL=BigEndian.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BigEndian.d.ts","sourceRoot":"","sources":["../../src/internal/BigEndian.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGzC;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,GAC3B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,CAuBjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAkBnD"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Either } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Read non-byte aligned numbers
|
|
4
|
+
*/
|
|
5
|
+
export interface Reader {
|
|
6
|
+
isAtEnd(): boolean;
|
|
7
|
+
moveToByteBoundary(force?: boolean): void;
|
|
8
|
+
readBits(n: number): number;
|
|
9
|
+
readByte(): number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @param bytes
|
|
13
|
+
* @param truncate defaults to true
|
|
14
|
+
* @returns {BitReader}
|
|
15
|
+
*/
|
|
16
|
+
export declare function makeReader(bytes: string | number[] | Uint8Array, truncate?: boolean): Reader;
|
|
17
|
+
/**
|
|
18
|
+
* BitWriter turns a string of '0's and '1's into a list of bytes.
|
|
19
|
+
* Finalization pads the bits using '0*1' if not yet aligned with the byte boundary.
|
|
20
|
+
*/
|
|
21
|
+
export interface Writer {
|
|
22
|
+
readonly length: number;
|
|
23
|
+
finalize(force?: boolean): number[];
|
|
24
|
+
padToByteBoundary(force?: boolean): void;
|
|
25
|
+
pop(n: number): string;
|
|
26
|
+
writeBits(bitChars: string): Writer;
|
|
27
|
+
writeByte(byte: number): Writer;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @returns
|
|
31
|
+
* Writer instance
|
|
32
|
+
*/
|
|
33
|
+
export declare function makeWriter(): WriterImpl;
|
|
34
|
+
declare class WriterImpl implements Writer {
|
|
35
|
+
/**
|
|
36
|
+
* Concatenated and padded upon finalization
|
|
37
|
+
*/
|
|
38
|
+
private readonly parts;
|
|
39
|
+
/**
|
|
40
|
+
* Number of bits written so far
|
|
41
|
+
*/
|
|
42
|
+
private n;
|
|
43
|
+
constructor();
|
|
44
|
+
get length(): number;
|
|
45
|
+
/**
|
|
46
|
+
* Pads the Bits.Writer to align with the byte boundary and returns the resulting bytes.
|
|
47
|
+
* @param force force padding (will add one byte if already aligned)
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
finalize(force?: boolean): number[];
|
|
51
|
+
/**
|
|
52
|
+
* Add padding to the BitWriter in order to align with the byte boundary.
|
|
53
|
+
* @param force
|
|
54
|
+
* If 'force == true' then 8 bits are added if the Writer is already aligned.
|
|
55
|
+
*/
|
|
56
|
+
padToByteBoundary(force?: boolean): void;
|
|
57
|
+
/**
|
|
58
|
+
* Pop n bits of the end
|
|
59
|
+
* @param n
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
pop(n: number): string;
|
|
63
|
+
/**
|
|
64
|
+
* Write a string of '0's and '1's to the BitWriter.
|
|
65
|
+
* Returns the BitWriter to enable chaining
|
|
66
|
+
* @param bitChars
|
|
67
|
+
* @returns
|
|
68
|
+
* Self so these calls can be chain
|
|
69
|
+
*/
|
|
70
|
+
writeBits(bitChars: string): Writer;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the BitWriter to enable chaining
|
|
73
|
+
* @param byte
|
|
74
|
+
* @returns
|
|
75
|
+
* Self so these calls can be chain
|
|
76
|
+
*/
|
|
77
|
+
writeByte(byte: number): Writer;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Converts a 8 bit integer number into a bit string with an optional "0b" prefix.
|
|
81
|
+
* The result is padded with leading zeroes to become 'n' chars long ('2 + n' chars long if you count the "0b" prefix).
|
|
82
|
+
* @example
|
|
83
|
+
* byteToBits(7) == "0b00000111"
|
|
84
|
+
* @param {number} b
|
|
85
|
+
* @param {number} n
|
|
86
|
+
* @param {boolean} prefix
|
|
87
|
+
* @returns {string}
|
|
88
|
+
*/
|
|
89
|
+
export declare function fromByte(b: number, n?: number, prefix?: boolean): Either.Either<string, RangeError>;
|
|
90
|
+
/**
|
|
91
|
+
* @param bytes
|
|
92
|
+
* @param i
|
|
93
|
+
* bit index
|
|
94
|
+
* @returns
|
|
95
|
+
* 0 or 1
|
|
96
|
+
*/
|
|
97
|
+
export declare function getBit(bytes: number[], i: number): 0 | 1;
|
|
98
|
+
/**
|
|
99
|
+
* Masks bits of `b` by setting bits outside the range `[i0, i1)` to 0.
|
|
100
|
+
* `b` is an 8 bit integer (i.e. number between 0 and 255).
|
|
101
|
+
* The return value is also an 8 bit integer, shifted right by `i1`.
|
|
102
|
+
* @example
|
|
103
|
+
* maskBits(0b11111111, 1, 4) == 0b0111 // (i.e. 7)
|
|
104
|
+
* @param b
|
|
105
|
+
* @param i0
|
|
106
|
+
* @param i1
|
|
107
|
+
* @returns
|
|
108
|
+
*/
|
|
109
|
+
export declare function mask(b: number, i0: number, i1: number): number;
|
|
110
|
+
/**
|
|
111
|
+
* Prepends zeroes to a bit-string so that 'result.length == n'.
|
|
112
|
+
* If `n < nCurrent`, pad to next multiple of `n`.
|
|
113
|
+
* @example
|
|
114
|
+
* padBits("1111", 8) == "00001111"
|
|
115
|
+
* @param bits
|
|
116
|
+
* @param n
|
|
117
|
+
* @returns
|
|
118
|
+
* @throws
|
|
119
|
+
* If n is zero or negative
|
|
120
|
+
*/
|
|
121
|
+
export declare function pad(bits: string, n: number): string;
|
|
122
|
+
export {};
|
|
123
|
+
//# sourceMappingURL=Bits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bits.d.ts","sourceRoot":"","sources":["../../src/internal/Bits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAG/B;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,OAAO,IAAI,OAAO,CAAA;IAClB,kBAAkB,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAA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AC,GAAE,MAAU,EACb,MAAM,GAAE,OAAc,GACrB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAsBnC;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,CAAC,CAExD;AAOD;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAQ9D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAenD"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Effect, Encoding } from "effect";
|
|
2
|
+
export type BytesLike = string | number[] | Uint8Array | Stream;
|
|
3
|
+
declare const EndOfStreamError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
4
|
+
readonly _tag: "EndOfStreamError";
|
|
5
|
+
} & Readonly<A>;
|
|
6
|
+
export declare class EndOfStreamError extends EndOfStreamError_base<{
|
|
7
|
+
message: string;
|
|
8
|
+
}> {
|
|
9
|
+
constructor(stream: Stream);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Doesn't throw an error if any input number is outside the range [0,256)
|
|
13
|
+
* @param bytes
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare function toArray(bytes: string | readonly number[] | Uint8Array | Stream): number[];
|
|
17
|
+
export declare function toHex(bytes: string | number[] | Uint8Array | Stream): string;
|
|
18
|
+
/**
|
|
19
|
+
* Doesn't throw an error if any input number is outside the range [0,256)
|
|
20
|
+
* @param bytes
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export declare function toUint8Array(bytes: string | number[] | Uint8Array | Stream): Uint8Array;
|
|
24
|
+
export interface Stream {
|
|
25
|
+
readonly bytes: Uint8Array;
|
|
26
|
+
readonly pos: number;
|
|
27
|
+
copy(): Stream;
|
|
28
|
+
isAtEnd(): boolean;
|
|
29
|
+
peekOne(): Effect.Effect<number, EndOfStreamError>;
|
|
30
|
+
peekMany(n: number): Effect.Effect<number[], EndOfStreamError>;
|
|
31
|
+
peekRemaining(): number[];
|
|
32
|
+
shiftOne(): Effect.Effect<number, EndOfStreamError>;
|
|
33
|
+
shiftMany(n: number): Effect.Effect<number[], EndOfStreamError>;
|
|
34
|
+
shiftRemaining(): number[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @param arg
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
export declare function makeStream(arg: string | number[] | Uint8Array | Stream | {
|
|
41
|
+
bytes: string | number[] | Uint8Array | Stream;
|
|
42
|
+
}): Stream;
|
|
43
|
+
/**
|
|
44
|
+
* @param a
|
|
45
|
+
* @param b
|
|
46
|
+
* @param shortestFirst defaults to false (strictly lexicographic comparison)
|
|
47
|
+
* @returns
|
|
48
|
+
* -1 if a < b, 0 if a == b, 1 if a > b
|
|
49
|
+
*/
|
|
50
|
+
export declare function compare(a: string | number[] | Uint8Array | Stream, b: string | number[] | Uint8Array | Stream, shortestFirst?: boolean): -1 | 0 | 1;
|
|
51
|
+
/**
|
|
52
|
+
* Used to create dummy hashes for testing
|
|
53
|
+
* @param n
|
|
54
|
+
* @param seed
|
|
55
|
+
* @returns
|
|
56
|
+
*/
|
|
57
|
+
export declare function dummy(n: number, seed?: number): number[];
|
|
58
|
+
/**
|
|
59
|
+
* @param a
|
|
60
|
+
* @param b
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
export declare function equals(a: string | number[] | Uint8Array | Stream, b: string | number[] | Uint8Array | Stream): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Pad by appending zeroes.
|
|
66
|
+
* If `n < nCurrent`, pad to next multiple of `n`.
|
|
67
|
+
* @param bytes
|
|
68
|
+
* @param n pad length
|
|
69
|
+
* @returns
|
|
70
|
+
* @throws
|
|
71
|
+
* If pad length is zero or negative
|
|
72
|
+
*/
|
|
73
|
+
export declare function pad(bytes: number[], n: number): number[];
|
|
74
|
+
/**
|
|
75
|
+
* Pad by prepending zeroes.
|
|
76
|
+
* Throws an error
|
|
77
|
+
* @param bytes
|
|
78
|
+
* @param n prepad length
|
|
79
|
+
* @returns
|
|
80
|
+
* @throws
|
|
81
|
+
* If prepad length is zero or negative
|
|
82
|
+
* @throws
|
|
83
|
+
* if bytes.length > n
|
|
84
|
+
*/
|
|
85
|
+
export declare function prepad(bytes: number[], n: number): number[];
|
|
86
|
+
export declare function DecodeException(bytes: string | number[] | Uint8Array | Stream, message: string): Encoding.DecodeException;
|
|
87
|
+
export {};
|
|
88
|
+
//# sourceMappingURL=Bytes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bytes.d.ts","sourceRoot":"","sources":["../../src/internal/Bytes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAG/C,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,UAAU,GAAG,MAAM,CAAA;;;;AAE/D,qBAAa,gBAAiB,SAAQ,sBAAqC;IACzE,OAAO,EAAE,MAAM,CAAA;CAChB,CAAC;gBACY,MAAM,EAAE,MAAM;CAG3B;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,UAAU,GAAG,MAAM,GACtD,MAAM,EAAE,CAkBV;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAY5E;AAED;;;;GAIG;AACH,wBAAgB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AU,GAAG,MAAM,EAAE,CAE3D;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CACpB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,UAAU,GAAG,MAAM,EAC1C,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,UAAU,GAAG,MAAM,GACzC,OAAO,CAET;AAED;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAexD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAgB3D;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,UAAU,GAAG,MAAM,EAC9C,OAAO,EAAE,MAAM,4BAGhB"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as Bits from "./Bits.js";
|
|
2
|
+
/**
|
|
3
|
+
* Instantiate a `Flat.Reader` with {@link makeReader}.
|
|
4
|
+
*/
|
|
5
|
+
export interface Reader {
|
|
6
|
+
isAtEnd(): boolean;
|
|
7
|
+
readBits(n: number): number;
|
|
8
|
+
readBool(): boolean;
|
|
9
|
+
readBuiltinId(): number;
|
|
10
|
+
readBytes(): number[];
|
|
11
|
+
readInt(): bigint;
|
|
12
|
+
readTag(): number;
|
|
13
|
+
readList<T>(readItem: (r: Reader) => T): T[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @param bytes
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export declare function makeReader(bytes: string | number[] | Uint8Array): Reader;
|
|
20
|
+
/**
|
|
21
|
+
* Instantiate a `FlatWriter` with {@link makeWriter}.
|
|
22
|
+
*/
|
|
23
|
+
export interface Writer {
|
|
24
|
+
writeBool(b: boolean): Writer;
|
|
25
|
+
writeBytes(bytes: number[]): Writer;
|
|
26
|
+
writeInt(x: bigint | number): Writer;
|
|
27
|
+
writeListCons(): Writer;
|
|
28
|
+
writeListNil(): Writer;
|
|
29
|
+
writeTermTag(tag: number): Writer;
|
|
30
|
+
writeTypeBits(typeBits: string): Writer;
|
|
31
|
+
writeBuiltinId(id: number): Writer;
|
|
32
|
+
finalize(): number[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
export declare function makeWriter(): Writer;
|
|
38
|
+
/**
|
|
39
|
+
* @param reader
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
export declare function decodeBytes(reader: Bits.Reader): number[];
|
|
43
|
+
/**
|
|
44
|
+
* Write a list of bytes to the bitWriter using flat encoding.
|
|
45
|
+
* Used by UplcString, UplcByteArray and UplcDataValue
|
|
46
|
+
* Equivalent to E_B* function in Plutus-core docs
|
|
47
|
+
* @param writer
|
|
48
|
+
* @param bytes
|
|
49
|
+
* @param pad
|
|
50
|
+
* Optional, defaults to false
|
|
51
|
+
*/
|
|
52
|
+
export declare function encodeBytes(writer: Bits.Writer, bytes: number[], pad?: boolean): void;
|
|
53
|
+
/**
|
|
54
|
+
* Includes type bits
|
|
55
|
+
* @param n
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
export declare function bytesSize(n: number): number;
|
|
59
|
+
/**
|
|
60
|
+
* Returns an unsigned (zigzag encoded) bigint
|
|
61
|
+
* @param reader
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
export declare function decodeInt(reader: Bits.Reader): bigint;
|
|
65
|
+
/**
|
|
66
|
+
* @param bitWriter
|
|
67
|
+
* @param x
|
|
68
|
+
* positive number
|
|
69
|
+
*/
|
|
70
|
+
export declare function encodeInt(bitWriter: Bits.Writer, x: bigint): void;
|
|
71
|
+
//# sourceMappingURL=Flat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Flat.d.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