solidity-codecs 0.0.1-beta.2 → 0.0.1-beta.3

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.
Files changed (41) hide show
  1. package/dist/codecs/Bytes.d.ts +5 -5
  2. package/dist/codecs/Fixed.d.ts +3 -0
  3. package/dist/codecs/{int.d.ts → Int.d.ts} +1 -1
  4. package/dist/codecs/Struct.d.ts +2 -25
  5. package/dist/codecs/Tuple.d.ts +2 -25
  6. package/dist/codecs/Uint.d.ts +6 -0
  7. package/dist/codecs/Vector.d.ts +6 -14
  8. package/dist/codecs/index.d.ts +7 -8
  9. package/dist/solidity-codecs.cjs.development.js +159 -166
  10. package/dist/solidity-codecs.cjs.development.js.map +3 -3
  11. package/dist/solidity-codecs.cjs.production.min.js +1 -1
  12. package/dist/solidity-codecs.cjs.production.min.js.map +3 -3
  13. package/dist/solidity-codecs.js +159 -166
  14. package/dist/solidity-codecs.js.map +3 -3
  15. package/dist/solidity-codecs.mjs +159 -166
  16. package/dist/solidity-codecs.mjs.map +3 -3
  17. package/dist/types.d.ts +4 -4
  18. package/dist/utils.d.ts +6 -1
  19. package/package.json +1 -1
  20. package/dist/codecs/Enum.d.ts +0 -57
  21. package/dist/codecs/Option.d.ts +0 -6
  22. package/dist/codecs/Result.d.ts +0 -22
  23. package/dist/codecs/bytes.d.ts +0 -6
  24. package/dist/codecs/call.d.ts +0 -6
  25. package/dist/codecs/compact.d.ts +0 -2
  26. package/dist/codecs/fixed-width-ints.d.ts +0 -11
  27. package/dist/codecs/fixed.d.ts +0 -3
  28. package/dist/codecs/struct.d.ts +0 -6
  29. package/dist/codecs/tuple.d.ts +0 -6
  30. package/dist/codecs/uint.d.ts +0 -2
  31. package/dist/codecs/vector.d.ts +0 -6
  32. package/dist/codecs/void.d.ts +0 -2
  33. package/dist/scale-ts.cjs.development.js +0 -427
  34. package/dist/scale-ts.cjs.development.js.map +0 -7
  35. package/dist/scale-ts.cjs.production.min.js +0 -318
  36. package/dist/scale-ts.cjs.production.min.js.map +0 -7
  37. package/dist/scale-ts.es2017.js +0 -403
  38. package/dist/scale-ts.es2017.js.map +0 -7
  39. package/dist/scale-ts.es2019.mjs +0 -348
  40. package/dist/scale-ts.es2019.mjs.map +0 -7
  41. package/dist/test-utils.d.ts +0 -5
@@ -1,57 +0,0 @@
1
- import { Codec, Decoder, Encoder, StringRecord } from "../types"
2
- export declare const Enum: {
3
- <
4
- O extends StringRecord<Codec<any>>,
5
- OT extends {
6
- [K in keyof O]: O[K] extends Codec<infer D>
7
- ? D extends undefined
8
- ? {
9
- tag: K
10
- value?: undefined
11
- }
12
- : {
13
- tag: K
14
- value: D
15
- }
16
- : unknown
17
- },
18
- >(
19
- inner: O,
20
- ): Codec<OT[keyof O]>
21
- enc: <
22
- O_1 extends StringRecord<Encoder<any>>,
23
- OT_1 extends {
24
- [K_1 in keyof O_1]: O_1[K_1] extends Encoder<infer D_1>
25
- ? D_1 extends undefined
26
- ? {
27
- tag: K_1
28
- value?: undefined
29
- }
30
- : {
31
- tag: K_1
32
- value: D_1
33
- }
34
- : unknown
35
- },
36
- >(
37
- inner: O_1,
38
- ) => Encoder<OT_1[keyof O_1]>
39
- dec: <
40
- O_2 extends StringRecord<Decoder<any>>,
41
- OT_2 extends {
42
- [K_2 in keyof O_2]: O_2[K_2] extends Decoder<infer D_2>
43
- ? D_2 extends undefined
44
- ? {
45
- tag: K_2
46
- value?: undefined
47
- }
48
- : {
49
- tag: K_2
50
- value: D_2
51
- }
52
- : unknown
53
- },
54
- >(
55
- inner: O_2,
56
- ) => Decoder<OT_2[keyof O_2]>
57
- }
@@ -1,6 +0,0 @@
1
- import { Decoder, Encoder, Codec } from "../types"
2
- export declare const Option: {
3
- <T>(inner: Codec<T>): Codec<void | T | undefined>
4
- enc: <T_1>(inner: Encoder<T_1>) => Encoder<void | T_1 | undefined>
5
- dec: <T_2>(inner: Decoder<T_2>) => Decoder<void | T_2 | undefined>
6
- }
@@ -1,22 +0,0 @@
1
- import { Decoder, Encoder, Codec } from "../types"
2
- declare type ResultPayload<OK, KO> =
3
- | {
4
- success: true
5
- value: OK
6
- }
7
- | {
8
- success: false
9
- value: KO
10
- }
11
- export declare const Result: {
12
- <OK, KO>(okCodec: Codec<OK>, koCodec: Codec<KO>): Codec<ResultPayload<OK, KO>>
13
- dec: <OK_1, KO_1>(
14
- okDecoder: Decoder<OK_1>,
15
- koDecoder: Decoder<KO_1>,
16
- ) => Decoder<ResultPayload<OK_1, KO_1>>
17
- enc: <OK_2, KO_2>(
18
- okEncoder: Encoder<OK_2>,
19
- koEncoder: Encoder<KO_2>,
20
- ) => Encoder<ResultPayload<OK_2, KO_2>>
21
- }
22
- export {}
@@ -1,6 +0,0 @@
1
- import { Encoder, Decoder, Codec } from "../types";
2
- export declare const bytes: {
3
- (nBytes: number): Codec<Uint8Array>;
4
- enc: (nBytes: number) => Encoder<Uint8Array>;
5
- dec: (nBytes: number) => Decoder<Uint8Array>;
6
- };
@@ -1,6 +0,0 @@
1
- import { Codec, Decoder, Encoder } from "../types";
2
- export declare const call: {
3
- <A extends Codec<any>[], OT extends { [K in keyof A]: A[K] extends Codec<infer D> ? D : unknown; }>(...codecs: A): Codec<[...OT]>;
4
- enc: <A_1 extends Encoder<any>[], OT_1 extends { [K_1 in keyof A_1]: A_1[K_1] extends Encoder<infer D_1> ? D_1 : unknown; }>(...encoders: A_1) => Encoder<[...OT_1]>;
5
- dec: <A_2 extends Decoder<any>[], OT_2 extends { [K_2 in keyof A_2]: A_2[K_2] extends Decoder<infer D_2> ? D_2 : unknown; }>(...decoders: A_2) => Decoder<[...OT_2]>;
6
- };
@@ -1,2 +0,0 @@
1
- import { Codec } from "../types"
2
- export declare const compact: Codec<number | bigint>
@@ -1,11 +0,0 @@
1
- import { Codec } from "../types"
2
- export declare const u8: Codec<number>
3
- export declare const u16: Codec<number>
4
- export declare const u32: Codec<number>
5
- export declare const u64: Codec<bigint>
6
- export declare const i8: Codec<number>
7
- export declare const i16: Codec<number>
8
- export declare const i32: Codec<number>
9
- export declare const i64: Codec<bigint>
10
- export declare const u128: Codec<bigint>
11
- export declare const i128: Codec<bigint>
@@ -1,3 +0,0 @@
1
- import { Codec, Fixed } from "../types";
2
- export declare const fixed: (nBits: number, decimals: number) => Codec<Fixed>;
3
- export declare const ufixed: (nBits: number, decimals: number) => Codec<Fixed>;
@@ -1,6 +0,0 @@
1
- import { Codec, Decoder, Encoder, StringRecord } from "../types";
2
- export declare const struct: {
3
- <A extends StringRecord<Codec<any>>, OT extends { [K in keyof A]: A[K] extends Codec<infer D> ? D : unknown; }>(codecs: A): Codec<OT>;
4
- enc: <A_1 extends StringRecord<Encoder<any>>, OT_1 extends { [K_1 in keyof A_1]: A_1[K_1] extends Encoder<infer D_1> ? D_1 : unknown; }>(encoders: A_1) => Encoder<OT_1>;
5
- dec: <A_2 extends StringRecord<Decoder<any>>, OT_2 extends { [K_2 in keyof A_2]: A_2[K_2] extends Decoder<infer D_2> ? D_2 : unknown; }>(decoders: A_2) => Decoder<OT_2>;
6
- };
@@ -1,6 +0,0 @@
1
- import { Codec, Decoder, Encoder } from "../types";
2
- export declare const tuple: {
3
- <A extends Codec<any>[], OT extends { [K in keyof A]: A[K] extends Codec<infer D> ? D : unknown; }>(...codecs: A): Codec<[...OT]>;
4
- enc: <A_1 extends Encoder<any>[], OT_1 extends { [K_1 in keyof A_1]: A_1[K_1] extends Encoder<infer D_1> ? D_1 : unknown; }>(...encoders: A_1) => Encoder<[...OT_1]>;
5
- dec: <A_2 extends Decoder<any>[], OT_2 extends { [K_2 in keyof A_2]: A_2[K_2] extends Decoder<infer D_2> ? D_2 : unknown; }>(...decoders: A_2) => Decoder<[...OT_2]>;
6
- };
@@ -1,2 +0,0 @@
1
- import { Codec } from "../types";
2
- export declare const uint: (nBits: number) => Codec<bigint>;
@@ -1,6 +0,0 @@
1
- import { Codec, Decoder, Encoder } from "../types";
2
- export declare const vector: {
3
- <T>(inner: Codec<T>, size?: number | undefined): Codec<T[]>;
4
- enc: <T_1>(inner: Encoder<T_1>, size?: number | undefined) => Encoder<T_1[]>;
5
- dec: <T_2>(getter: Decoder<T_2>, size?: number | undefined) => Decoder<T_2[]>;
6
- };
@@ -1,2 +0,0 @@
1
- import { Codec } from "../types"
2
- export declare const _void: Codec<undefined>
@@ -1,427 +0,0 @@
1
- var __defProp = Object.defineProperty
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor
3
- var __getOwnPropNames = Object.getOwnPropertyNames
4
- var __hasOwnProp = Object.prototype.hasOwnProperty
5
- var __defNormalProp = (obj, key, value) =>
6
- key in obj
7
- ? __defProp(obj, key, {
8
- enumerable: true,
9
- configurable: true,
10
- writable: true,
11
- value,
12
- })
13
- : (obj[key] = value)
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true })
17
- }
18
- var __copyProps = (to, from, except, desc) => {
19
- if ((from && typeof from === "object") || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, {
23
- get: () => from[key],
24
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
25
- })
26
- }
27
- return to
28
- }
29
- var __toCommonJS = (mod) =>
30
- __copyProps(__defProp({}, "__esModule", { value: true }), mod)
31
- var __publicField = (obj, key, value) => {
32
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value)
33
- return value
34
- }
35
-
36
- // src/index.ts
37
- var src_exports = {}
38
- __export(src_exports, {
39
- Bytes: () => Bytes,
40
- Enum: () => Enum,
41
- Option: () => Option,
42
- Result: () => Result,
43
- Struct: () => Struct,
44
- Tuple: () => Tuple,
45
- Vector: () => Vector,
46
- _void: () => _void,
47
- bool: () => bool,
48
- compact: () => compact,
49
- createCodec: () => createCodec,
50
- enhanceCodec: () => enhanceCodec,
51
- enhanceDecoder: () => enhanceDecoder,
52
- enhanceEncoder: () => enhanceEncoder,
53
- i128: () => i128,
54
- i16: () => i16,
55
- i32: () => i32,
56
- i64: () => i64,
57
- i8: () => i8,
58
- str: () => str,
59
- u128: () => u128,
60
- u16: () => u16,
61
- u32: () => u32,
62
- u64: () => u64,
63
- u8: () => u8,
64
- })
65
- module.exports = __toCommonJS(src_exports)
66
-
67
- // src/utils.ts
68
- var createCodec = (encoder, decoder) => {
69
- const result = [encoder, decoder]
70
- result.enc = encoder
71
- result.dec = decoder
72
- return result
73
- }
74
- var enhanceEncoder = (encoder, mapper) => (value) => encoder(mapper(value))
75
- var enhanceDecoder = (decoder, mapper) => (value) => mapper(decoder(value))
76
- var enhanceCodec = ([encoder, decoder], toFrom, fromTo) =>
77
- createCodec(enhanceEncoder(encoder, toFrom), enhanceDecoder(decoder, fromTo))
78
-
79
- // src/internal/toInternalBytes.ts
80
- var HEX_MAP = {
81
- 0: 0,
82
- 1: 1,
83
- 2: 2,
84
- 3: 3,
85
- 4: 4,
86
- 5: 5,
87
- 6: 6,
88
- 7: 7,
89
- 8: 8,
90
- 9: 9,
91
- a: 10,
92
- b: 11,
93
- c: 12,
94
- d: 13,
95
- e: 14,
96
- f: 15,
97
- A: 10,
98
- B: 11,
99
- C: 12,
100
- D: 13,
101
- E: 14,
102
- F: 15,
103
- }
104
- function fromHex(hexString) {
105
- const isOdd = hexString.length % 2
106
- const base = (hexString[1] === "x" ? 2 : 0) + isOdd
107
- const nBytes = (hexString.length - base) / 2 + isOdd
108
- const bytes = new Uint8Array(nBytes)
109
- if (isOdd) bytes[0] = 0 | HEX_MAP[hexString[2]]
110
- for (let i = 0; i < nBytes; ) {
111
- const idx = base + i * 2
112
- const a = HEX_MAP[hexString[idx]]
113
- const b = HEX_MAP[hexString[idx + 1]]
114
- bytes[isOdd + i++] = (a << 4) | b
115
- }
116
- return bytes
117
- }
118
- var InternalUint8Array = class extends Uint8Array {
119
- constructor(buffer) {
120
- super(buffer)
121
- __publicField(this, "i", 0)
122
- __publicField(this, "v")
123
- this.v = new DataView(buffer)
124
- }
125
- }
126
- var toInternalBytes = (fn) => (buffer) =>
127
- fn(
128
- buffer instanceof InternalUint8Array
129
- ? buffer
130
- : new InternalUint8Array(
131
- typeof buffer === "string"
132
- ? fromHex(buffer).buffer
133
- : buffer instanceof Uint8Array
134
- ? buffer.buffer
135
- : buffer,
136
- ),
137
- )
138
-
139
- // src/internal/mergeUint8.ts
140
- var mergeUint8 = (...inputs) => {
141
- const totalLen = inputs.reduce((acc, a) => acc + a.byteLength, 0)
142
- const result = new Uint8Array(totalLen)
143
- for (let idx = 0, at = 0; idx < inputs.length; idx++) {
144
- const current = inputs[idx]
145
- result.set(current, at)
146
- at += current.byteLength
147
- }
148
- return result
149
- }
150
-
151
- // src/internal/mapObject.ts
152
- function mapObject(input, mapper) {
153
- return Object.fromEntries(
154
- Object.entries(input).map(([key, value]) => [key, mapper(value, key)]),
155
- )
156
- }
157
-
158
- // src/codecs/fixed-width-ints.ts
159
- function decodeInt(nBytes, getter) {
160
- return toInternalBytes((bytes) => {
161
- const result = bytes.v[getter](bytes.i, true)
162
- bytes.i += nBytes
163
- return result
164
- })
165
- }
166
- function encodeInt(nBytes, setter) {
167
- return (input) => {
168
- const result = new Uint8Array(nBytes)
169
- const dv = new DataView(result.buffer)
170
- dv[setter](0, input, true)
171
- return result
172
- }
173
- }
174
- function intCodec(nBytes, getter, setter) {
175
- return createCodec(encodeInt(nBytes, setter), decodeInt(nBytes, getter))
176
- }
177
- var u8 = intCodec(1, "getUint8", "setUint8")
178
- var u16 = intCodec(2, "getUint16", "setUint16")
179
- var u32 = intCodec(4, "getUint32", "setUint32")
180
- var u64 = intCodec(8, "getBigUint64", "setBigUint64")
181
- var i8 = intCodec(1, "getInt8", "setInt8")
182
- var i16 = intCodec(2, "getInt16", "setInt16")
183
- var i32 = intCodec(4, "getInt32", "setInt32")
184
- var i64 = intCodec(8, "getBigInt64", "setBigInt64")
185
- var x128Enc = (value) => {
186
- const result = new Uint8Array(16)
187
- const dv = new DataView(result.buffer)
188
- dv.setBigInt64(0, value, true)
189
- dv.setBigInt64(8, value >> 64n, true)
190
- return result
191
- }
192
- var create128Dec = (isSigned) =>
193
- toInternalBytes((input) => {
194
- const { v, i } = input
195
- const right = v.getBigUint64(i, true)
196
- const left = v[isSigned ? "getBigInt64" : "getBigUint64"](i + 8, true)
197
- input.i += 16
198
- return (left << 64n) | right
199
- })
200
- var u128 = createCodec(x128Enc, create128Dec())
201
- var i128 = createCodec(x128Enc, create128Dec(1))
202
-
203
- // src/codecs/bool.ts
204
- var booleanToNumber = (value) => (value ? 1 : 0)
205
- var bool = enhanceCodec(u8, booleanToNumber, Boolean)
206
-
207
- // src/codecs/compact.ts
208
- var bytesToIntType = {
209
- [1]: u8[1],
210
- [2]: u16[1],
211
- [4]: u32[1],
212
- }
213
- var compactDec = toInternalBytes((bytes) => {
214
- let usedBytes = bytes.i
215
- const init = bytes[usedBytes]
216
- const kind = init & 3
217
- if (kind !== 3) {
218
- const nBytes2 = kind === 2 ? 4 : kind + 1
219
- return bytesToIntType[nBytes2](bytes) >>> 2
220
- }
221
- const nBytes = (init >>> 2) + 4
222
- const start = usedBytes + 1
223
- bytes.i += nBytes + 1
224
- let result = 0n
225
- for (let i = nBytes - 1; i >= 0; i--)
226
- result = (result << 8n) | BigInt(bytes[start + i])
227
- return result
228
- })
229
- var compactEnc = (input) => {
230
- if (input < 0) {
231
- throw new Error(`Wrong Compat input (${input})`)
232
- }
233
- if (input < 1 << 6) {
234
- const temp = new Uint8Array(1)
235
- temp[0] = Number(input) << 2
236
- return temp
237
- }
238
- if (input < 1 << 14) {
239
- const temp = new Uint8Array(2)
240
- let pInput = (Number(input) << 2) + 1
241
- const dv = new DataView(temp.buffer)
242
- dv.setUint16(0, pInput, true)
243
- return temp
244
- }
245
- if (input < 1 << 30) {
246
- const temp = new Uint8Array(4)
247
- let pInput = (Number(input) << 2) + 2
248
- const dv = new DataView(temp.buffer)
249
- dv.setUint32(0, pInput, true)
250
- return temp
251
- }
252
- const result = []
253
- let tmp = BigInt(input)
254
- while (tmp > 0) {
255
- result.push(Number(tmp))
256
- tmp >>= 8n
257
- }
258
- result.unshift(((result.length - 4) << 2) + 3)
259
- return new Uint8Array(result)
260
- }
261
- var compact = createCodec(compactEnc, compactDec)
262
-
263
- // src/codecs/str.ts
264
- var textEncoder = new TextEncoder()
265
- var strEnc = (str2) => {
266
- const val = textEncoder.encode(str2)
267
- return mergeUint8(compact.enc(val.length), val)
268
- }
269
- var textDecoder = new TextDecoder()
270
- var strDec = toInternalBytes((bytes) => {
271
- let nElements = compact.dec(bytes)
272
- const dv = new DataView(bytes.buffer, bytes.i, nElements)
273
- bytes.i += nElements
274
- return textDecoder.decode(dv)
275
- })
276
- var str = createCodec(strEnc, strDec)
277
-
278
- // src/codecs/void.ts
279
- var emptyArr = new Uint8Array(0)
280
- var _void = createCodec(() => emptyArr, Function.prototype)
281
-
282
- // src/codecs/Bytes.ts
283
- var BytesEnc = (nBytes) => (bytes) =>
284
- bytes.length === nBytes ? bytes : bytes.slice(0, nBytes)
285
- var BytesDec = (nBytes) =>
286
- toInternalBytes((bytes) => {
287
- const nUsedBytes = bytes.i
288
- const len = nBytes !== Infinity ? nBytes : bytes.byteLength - nUsedBytes
289
- const result = new Uint8Array(bytes.buffer, nUsedBytes, len)
290
- bytes.i += len
291
- return result
292
- })
293
- var Bytes = (nBytes) => createCodec(BytesEnc(nBytes), BytesDec(nBytes))
294
- Bytes.enc = BytesEnc
295
- Bytes.dec = BytesDec
296
-
297
- // src/codecs/Enum.ts
298
- var enumEnc = (inner) => {
299
- const keys = Object.keys(inner)
300
- return ({ tag, value }) => {
301
- const idx = keys.indexOf(tag)
302
- return mergeUint8(u8.enc(idx), inner[tag](value))
303
- }
304
- }
305
- var enumDec = (inner) => {
306
- const entries = Object.entries(inner)
307
- return toInternalBytes((bytes) => {
308
- const idx = u8.dec(bytes)
309
- const [tag, innerDecoder] = entries[idx]
310
- const innerResult = innerDecoder(bytes)
311
- return {
312
- tag,
313
- value: innerResult,
314
- }
315
- })
316
- }
317
- var Enum = (inner) =>
318
- createCodec(
319
- enumEnc(mapObject(inner, ([encoder]) => encoder)),
320
- enumDec(mapObject(inner, ([, decoder]) => decoder)),
321
- )
322
- Enum.enc = enumEnc
323
- Enum.dec = enumDec
324
-
325
- // src/codecs/Option.ts
326
- var OptionDec = (inner) =>
327
- toInternalBytes((bytes) => {
328
- const val = u8.dec(bytes)
329
- if (val === 0) return void 0
330
- return inner === bool[1] ? val === 1 : inner(bytes)
331
- })
332
- var OptionEnc = (inner) => (value) => {
333
- const result = new Uint8Array(1)
334
- if (value === void 0) {
335
- result[0] = 0
336
- return result
337
- }
338
- result[0] = 1
339
- if (inner === bool[0]) {
340
- result[0] = value ? 1 : 2
341
- return result
342
- }
343
- return mergeUint8(result, inner(value))
344
- }
345
- var Option = (inner) => createCodec(OptionEnc(inner[0]), OptionDec(inner[1]))
346
- Option.enc = OptionEnc
347
- Option.dec = OptionDec
348
-
349
- // src/codecs/Result.ts
350
- var ResultDec = (okDecoder, koDecoder) =>
351
- toInternalBytes((bytes) => {
352
- const val = u8[1](bytes)
353
- const success = val === 0
354
- const decoder = success ? okDecoder : koDecoder
355
- const value = decoder(bytes)
356
- return { success, value }
357
- })
358
- var ResultEnc =
359
- (okEncoder, koEncoder) =>
360
- ({ success, value }) =>
361
- mergeUint8(u8[0](success ? 0 : 1), (success ? okEncoder : koEncoder)(value))
362
- var Result = (okCodec, koCodec) =>
363
- createCodec(
364
- ResultEnc(okCodec[0], koCodec[0]),
365
- ResultDec(okCodec[1], koCodec[1]),
366
- )
367
- Result.dec = ResultDec
368
- Result.enc = ResultEnc
369
-
370
- // src/codecs/Tuple.ts
371
- var TupleDec = (...decoders) =>
372
- toInternalBytes((bytes) => decoders.map((decoder) => decoder(bytes)))
373
- var TupleEnc =
374
- (...encoders) =>
375
- (values) =>
376
- mergeUint8(...values.map((value, idx) => encoders[idx](value)))
377
- var Tuple = (...codecs) =>
378
- createCodec(
379
- TupleEnc(...codecs.map(([encoder]) => encoder)),
380
- TupleDec(...codecs.map(([, decoder]) => decoder)),
381
- )
382
- Tuple.enc = TupleEnc
383
- Tuple.dec = TupleDec
384
-
385
- // src/codecs/Struct.ts
386
- var StructEnc = (encoders) => {
387
- const keys = Object.keys(encoders)
388
- return enhanceEncoder(Tuple.enc(...Object.values(encoders)), (input) =>
389
- keys.map((k) => input[k]),
390
- )
391
- }
392
- var StructDec = (decoders) => {
393
- const keys = Object.keys(decoders)
394
- return enhanceDecoder(Tuple.dec(...Object.values(decoders)), (tuple) =>
395
- Object.fromEntries(tuple.map((value, idx) => [keys[idx], value])),
396
- )
397
- }
398
- var Struct = (codecs) =>
399
- createCodec(
400
- StructEnc(mapObject(codecs, (x) => x[0])),
401
- StructDec(mapObject(codecs, (x) => x[1])),
402
- )
403
- Struct.enc = StructEnc
404
- Struct.dec = StructDec
405
-
406
- // src/codecs/Vector.ts
407
- var VectorEnc = (inner, size) =>
408
- size > 0
409
- ? (value) => mergeUint8(...value.map(inner))
410
- : (value) => mergeUint8(compact.enc(value.length), ...value.map(inner))
411
- function VectorDec(getter, size) {
412
- return toInternalBytes((bytes) => {
413
- const nElements = size > 0 ? size : compact.dec(bytes)
414
- const result = new Array(nElements)
415
- for (let i = 0; i < nElements; i++) {
416
- const current = getter(bytes)
417
- result[i] = current
418
- }
419
- return result
420
- })
421
- }
422
- function Vector(inner, size) {
423
- return createCodec(VectorEnc(inner[0], size), VectorDec(inner[1], size))
424
- }
425
- Vector.enc = VectorEnc
426
- Vector.dec = VectorDec
427
- //# sourceMappingURL=scale-ts.cjs.development.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/index.ts", "../src/utils.ts", "../src/internal/toInternalBytes.ts", "../src/internal/mergeUint8.ts", "../src/internal/mapObject.ts", "../src/codecs/fixed-width-ints.ts", "../src/codecs/bool.ts", "../src/codecs/compact.ts", "../src/codecs/str.ts", "../src/codecs/void.ts", "../src/codecs/Bytes.ts", "../src/codecs/Enum.ts", "../src/codecs/Option.ts", "../src/codecs/Result.ts", "../src/codecs/Tuple.ts", "../src/codecs/Struct.ts", "../src/codecs/Vector.ts"],
4
- "sourcesContent": ["export * from \"./utils\"\nexport * from \"./types\"\nexport * from \"./codecs\"\n", "import type { Codec, Decoder, Encoder } from \"./types\"\n\nexport const createCodec = <T>(\n encoder: Encoder<T>,\n decoder: Decoder<T>,\n): Codec<T> => {\n const result = [encoder, decoder] as any\n result.enc = encoder\n result.dec = decoder\n return result\n}\n\nexport const enhanceEncoder =\n <I, O>(encoder: Encoder<I>, mapper: (value: O) => I): Encoder<O> =>\n (value) =>\n encoder(mapper(value))\n\nexport const enhanceDecoder =\n <I, O>(decoder: Decoder<I>, mapper: (value: I) => O): Decoder<O> =>\n (value) =>\n mapper(decoder(value))\n\nexport const enhanceCodec = <I, O>(\n [encoder, decoder]: Codec<I>,\n toFrom: (value: O) => I,\n fromTo: (value: I) => O,\n): Codec<O> =>\n createCodec(enhanceEncoder(encoder, toFrom), enhanceDecoder(decoder, fromTo))\n", "import { Decoder } from \"../types\"\n\n// https://jsben.ch/URe1X\nconst HEX_MAP: Record<string, number> = {\n 0: 0,\n 1: 1,\n 2: 2,\n 3: 3,\n 4: 4,\n 5: 5,\n 6: 6,\n 7: 7,\n 8: 8,\n 9: 9,\n a: 10,\n b: 11,\n c: 12,\n d: 13,\n e: 14,\n f: 15,\n A: 10,\n B: 11,\n C: 12,\n D: 13,\n E: 14,\n F: 15,\n}\nexport function fromHex(hexString: string): Uint8Array {\n const isOdd = hexString.length % 2\n const base = (hexString[1] === \"x\" ? 2 : 0) + isOdd\n const nBytes = (hexString.length - base) / 2 + isOdd\n const bytes = new Uint8Array(nBytes)\n\n if (isOdd) bytes[0] = 0 | HEX_MAP[hexString[2]]\n\n for (let i = 0; i < nBytes; ) {\n const idx = base + i * 2\n const a = HEX_MAP[hexString[idx]]\n const b = HEX_MAP[hexString[idx + 1]]\n bytes[isOdd + i++] = (a << 4) | b\n }\n\n return bytes\n}\n\nclass InternalUint8Array extends Uint8Array {\n i: number = 0\n v: DataView\n\n constructor(buffer: ArrayBuffer) {\n super(buffer)\n this.v = new DataView(buffer)\n }\n}\n\nexport const toInternalBytes =\n <T>(fn: (input: InternalUint8Array) => T): Decoder<T> =>\n (buffer: string | ArrayBuffer | Uint8Array | InternalUint8Array) =>\n fn(\n buffer instanceof InternalUint8Array\n ? buffer\n : new InternalUint8Array(\n typeof buffer === \"string\"\n ? fromHex(buffer).buffer\n : buffer instanceof Uint8Array\n ? buffer.buffer\n : buffer,\n ),\n )\n", "export const mergeUint8 = (...inputs: Array<Uint8Array>): Uint8Array => {\n const totalLen = inputs.reduce((acc, a) => acc + a.byteLength, 0)\n const result = new Uint8Array(totalLen)\n\n for (let idx = 0, at = 0; idx < inputs.length; idx++) {\n const current = inputs[idx]\n result.set(current, at)\n at += current.byteLength\n }\n\n return result\n}\n", "export function mapObject<K extends string | number | symbol, I, O>(\n input: Record<K, I>,\n mapper: (i: I, k: K) => O,\n): Record<K, O>\n\nexport function mapObject<K extends string | number | symbol, I, O>(\n input: Record<K, I>,\n mapper: (i: I, k?: K) => O,\n): Record<K, O> {\n return Object.fromEntries(\n Object.entries(input).map(\n ([key, value]: any) => [key, mapper(value, key)] as const,\n ),\n ) as any\n}\n", "import { createCodec } from \"../utils\"\nimport { Codec, Decoder, Encoder } from \"../types\"\nimport { toInternalBytes } from \"../internal\"\n\nfunction decodeInt(nBytes: 8, getter: keyof DataView): Decoder<bigint>\nfunction decodeInt(nBytes: number, getter: keyof DataView): Decoder<number>\nfunction decodeInt(\n nBytes: number,\n getter: keyof DataView,\n): Decoder<number> | Decoder<bigint> {\n return toInternalBytes((bytes) => {\n const result = (bytes.v[getter] as any)(bytes.i, true) as number\n bytes.i += nBytes\n return result\n })\n}\n\nfunction encodeInt(nBytes: 8, setter: keyof DataView): Encoder<bigint>\nfunction encodeInt(nBytes: number, setter: keyof DataView): Encoder<number>\nfunction encodeInt(\n nBytes: number,\n setter: keyof DataView,\n): Encoder<number> | Encoder<bigint> {\n return (input: number | bigint) => {\n const result = new Uint8Array(nBytes)\n const dv = new DataView(result.buffer)\n ;(dv[setter] as any)(0, input, true)\n return result\n }\n}\n\nfunction intCodec(\n nBytes: 8,\n getter: keyof DataView,\n setter: keyof DataView,\n): Codec<bigint>\nfunction intCodec(\n nBytes: number,\n getter: keyof DataView,\n setter: keyof DataView,\n): Codec<number>\nfunction intCodec(\n nBytes: number,\n getter: keyof DataView,\n setter: keyof DataView,\n): Codec<bigint> | Codec<number> {\n return createCodec(encodeInt(nBytes, setter), decodeInt(nBytes, getter))\n}\n\nexport const u8 = intCodec(1, \"getUint8\", \"setUint8\")\nexport const u16 = intCodec(2, \"getUint16\", \"setUint16\")\nexport const u32 = intCodec(4, \"getUint32\", \"setUint32\")\nexport const u64 = intCodec(8, \"getBigUint64\", \"setBigUint64\")\nexport const i8 = intCodec(1, \"getInt8\", \"setInt8\")\nexport const i16 = intCodec(2, \"getInt16\", \"setInt16\")\nexport const i32 = intCodec(4, \"getInt32\", \"setInt32\")\nexport const i64 = intCodec(8, \"getBigInt64\", \"setBigInt64\")\n\nconst x128Enc: Encoder<bigint> = (value) => {\n const result = new Uint8Array(16)\n const dv = new DataView(result.buffer)\n dv.setBigInt64(0, value, true)\n dv.setBigInt64(8, value >> 64n, true)\n return result\n}\n\nconst create128Dec = (isSigned?: number): Decoder<bigint> =>\n toInternalBytes((input) => {\n const { v, i } = input\n const right = v.getBigUint64(i, true)\n const left = v[isSigned ? \"getBigInt64\" : \"getBigUint64\"](i + 8, true)\n input.i += 16\n return (left << 64n) | right\n })\n\nexport const u128 = createCodec(x128Enc, create128Dec())\nexport const i128 = createCodec(x128Enc, create128Dec(1))\n", "import { Codec } from \"../types\"\nimport { enhanceCodec } from \"../\"\nimport { u8 } from \"./fixed-width-ints\"\n\nconst booleanToNumber = (value: boolean) => (value ? 1 : 0)\n\nexport const bool: Codec<boolean> = enhanceCodec(u8, booleanToNumber, Boolean)\n", "import { createCodec } from \"../\"\nimport { toInternalBytes } from \"../internal\"\nimport { u8, u16, u32 } from \"./fixed-width-ints\"\nimport { Decoder, Encoder, Codec } from \"../types\"\n\nconst bytesToIntType = {\n [1]: u8[1],\n [2]: u16[1],\n [4]: u32[1],\n} as const\n\nconst compactDec: Decoder<number | bigint> = toInternalBytes<number | bigint>(\n (bytes) => {\n let usedBytes = bytes.i\n const init = bytes[usedBytes]\n\n const kind = init & 3\n\n if (kind !== 3) {\n const nBytes = kind === 2 ? 4 : kind + 1\n return bytesToIntType[nBytes as 1 | 2 | 4](bytes) >>> 2\n }\n\n const nBytes = (init >>> 2) + 4\n const start = usedBytes + 1\n bytes.i += nBytes + 1\n\n let result = 0n\n for (let i = nBytes - 1; i >= 0; i--)\n result = (result << 8n) | BigInt(bytes[start + i])\n\n return result\n },\n)\n\nconst compactEnc: Encoder<number | bigint> = (input) => {\n if (input < 0) {\n throw new Error(`Wrong Compat input (${input})`)\n }\n if (input < 1 << 6) {\n const temp = new Uint8Array(1)\n temp[0] = Number(input) << 2\n return temp\n }\n if (input < 1 << 14) {\n const temp = new Uint8Array(2)\n let pInput = (Number(input) << 2) + 1\n const dv = new DataView(temp.buffer)\n dv.setUint16(0, pInput, true)\n return temp\n }\n if (input < 1 << 30) {\n const temp = new Uint8Array(4)\n let pInput = (Number(input) << 2) + 2\n const dv = new DataView(temp.buffer)\n dv.setUint32(0, pInput, true)\n return temp\n }\n\n const result: number[] = []\n let tmp = BigInt(input)\n while (tmp > 0) {\n result.push(Number(tmp))\n tmp >>= 8n\n }\n result.unshift(((result.length - 4) << 2) + 3)\n return new Uint8Array(result)\n}\n\nexport const compact: Codec<number | bigint> = createCodec(\n compactEnc,\n compactDec,\n)\n", "import { createCodec, Decoder, Encoder } from \"../\"\nimport { toInternalBytes, mergeUint8 } from \"../internal\"\nimport { compact } from \"./compact\"\n\nconst textEncoder = new TextEncoder()\nconst strEnc: Encoder<string> = (str) => {\n const val = textEncoder.encode(str)\n return mergeUint8(compact.enc(val.length), val)\n}\n\nconst textDecoder = new TextDecoder()\nconst strDec: Decoder<string> = toInternalBytes((bytes) => {\n let nElements = compact.dec(bytes) as number\n const dv = new DataView(bytes.buffer, bytes.i, nElements)\n bytes.i += nElements\n return textDecoder.decode(dv)\n})\n\nexport const str = createCodec(strEnc, strDec)\n", "import { Codec } from \"../types\"\nimport { createCodec } from \"../\"\n\nconst emptyArr = new Uint8Array(0)\nexport const _void: Codec<undefined> = createCodec(\n () => emptyArr,\n Function.prototype as () => undefined,\n)\n", "import { Encoder, Decoder, Codec } from \"../types\"\nimport { createCodec } from \"../\"\nimport { toInternalBytes } from \"../internal\"\n\nconst BytesEnc =\n (nBytes: number): Encoder<Uint8Array> =>\n (bytes) =>\n bytes.length === nBytes ? bytes : bytes.slice(0, nBytes)\n\nconst BytesDec = (nBytes: number): Decoder<Uint8Array> =>\n toInternalBytes((bytes) => {\n const nUsedBytes = bytes.i\n const len = nBytes !== Infinity ? nBytes : bytes.byteLength - nUsedBytes\n const result = new Uint8Array(bytes.buffer, nUsedBytes, len)\n bytes.i += len\n return result\n })\n\nexport const Bytes = (nBytes: number): Codec<Uint8Array> =>\n createCodec(BytesEnc(nBytes), BytesDec(nBytes))\n\nBytes.enc = BytesEnc\nBytes.dec = BytesDec\n", "import { Codec, Decoder, Encoder, StringRecord } from \"../types\"\nimport { toInternalBytes, mapObject, mergeUint8 } from \"../internal\"\nimport { createCodec, u8 } from \"../\"\n\nconst enumEnc = <\n O extends StringRecord<Encoder<any>>,\n OT extends {\n [K in keyof O]: O[K] extends Encoder<infer D>\n ? D extends undefined\n ? { tag: K; value?: undefined }\n : { tag: K; value: D }\n : unknown\n },\n>(\n inner: O,\n): Encoder<OT[keyof O]> => {\n const keys = Object.keys(inner)\n return ({ tag, value }: any) => {\n const idx = keys.indexOf(tag)\n return mergeUint8(u8.enc(idx), (inner as any)[tag](value))\n }\n}\n\nconst enumDec = <\n O extends StringRecord<Decoder<any>>,\n OT extends {\n [K in keyof O]: O[K] extends Decoder<infer D>\n ? D extends undefined\n ? { tag: K; value?: undefined }\n : { tag: K; value: D }\n : unknown\n },\n>(\n inner: O,\n): Decoder<OT[keyof O]> => {\n const entries = Object.entries(inner)\n\n return toInternalBytes((bytes) => {\n const idx = u8.dec(bytes)\n const [tag, innerDecoder] = entries[idx]\n const innerResult = innerDecoder(bytes)\n\n return {\n tag,\n value: innerResult,\n } as OT[keyof O]\n })\n}\n\nexport const Enum = <\n O extends StringRecord<Codec<any>>,\n OT extends {\n [K in keyof O]: O[K] extends Codec<infer D>\n ? D extends undefined\n ? { tag: K; value?: undefined }\n : { tag: K; value: D }\n : unknown\n },\n>(\n inner: O,\n): Codec<OT[keyof O]> =>\n createCodec<OT[keyof O]>(\n enumEnc(mapObject(inner, ([encoder]) => encoder) as any) as any,\n enumDec(mapObject(inner, ([, decoder]) => decoder) as any),\n )\n\nEnum.enc = enumEnc\nEnum.dec = enumDec\n", "import { Decoder, Encoder, Codec } from \"../types\"\nimport { toInternalBytes, mergeUint8 } from \"../internal\"\nimport { createCodec } from \"../utils\"\nimport { u8 } from \"./fixed-width-ints\"\nimport { bool } from \"./bool\"\n\nconst OptionDec = <T>(inner: Decoder<T>): Decoder<T | undefined | void> =>\n toInternalBytes<T | undefined>((bytes) => {\n const val = u8.dec(bytes)\n if (val === 0) return undefined\n\n return inner === (bool[1] as any)\n ? ((val === 1) as unknown as T)\n : inner(bytes)\n })\n\nconst OptionEnc =\n <T>(inner: Encoder<T>): Encoder<T | undefined | void> =>\n (value) => {\n const result = new Uint8Array(1)\n if (value === undefined) {\n result[0] = 0\n return result\n }\n\n result[0] = 1\n if (inner === (bool[0] as any)) {\n result[0] = value ? 1 : 2\n return result\n }\n\n return mergeUint8(result, inner(value))\n }\n\nexport const Option = <T>(inner: Codec<T>): Codec<T | undefined | void> =>\n createCodec(OptionEnc(inner[0]), OptionDec(inner[1]))\n\nOption.enc = OptionEnc\nOption.dec = OptionDec\n", "import { createCodec } from \"../utils\"\nimport { mergeUint8, toInternalBytes } from \"../internal\"\nimport { Decoder, Encoder, Codec } from \"../types\"\nimport { u8 } from \"./fixed-width-ints\"\n\ntype ResultPayload<OK, KO> =\n | { success: true; value: OK }\n | { success: false; value: KO }\n\nconst ResultDec = <OK, KO>(\n okDecoder: Decoder<OK>,\n koDecoder: Decoder<KO>,\n): Decoder<ResultPayload<OK, KO>> =>\n toInternalBytes((bytes) => {\n const val = u8[1](bytes)\n const success = val === 0\n const decoder = success ? okDecoder : koDecoder\n const value = decoder(bytes)\n return { success, value } as ResultPayload<OK, KO>\n })\n\nconst ResultEnc =\n <OK, KO>(\n okEncoder: Encoder<OK>,\n koEncoder: Encoder<KO>,\n ): Encoder<ResultPayload<OK, KO>> =>\n ({ success, value }) =>\n mergeUint8(\n u8[0](success ? 0 : 1),\n (success ? okEncoder : koEncoder)(value as any),\n )\n\nexport const Result = <OK, KO>(\n okCodec: Codec<OK>,\n koCodec: Codec<KO>,\n): Codec<ResultPayload<OK, KO>> =>\n createCodec(\n ResultEnc(okCodec[0], koCodec[0]),\n ResultDec(okCodec[1], koCodec[1]),\n )\n\nResult.dec = ResultDec\nResult.enc = ResultEnc\n", "import { Codec, Decoder, Encoder } from \"../types\"\nimport { mergeUint8, toInternalBytes } from \"../internal\"\nimport { createCodec } from \"../utils\"\n\nconst TupleDec = <\n A extends Array<Decoder<any>>,\n OT extends { [K in keyof A]: A[K] extends Decoder<infer D> ? D : unknown },\n>(\n ...decoders: A\n): Decoder<[...OT]> =>\n toInternalBytes(\n (bytes) => decoders.map((decoder) => decoder(bytes)) as [...OT],\n )\n\nconst TupleEnc =\n <\n A extends Array<Encoder<any>>,\n OT extends { [K in keyof A]: A[K] extends Encoder<infer D> ? D : unknown },\n >(\n ...encoders: A\n ): Encoder<[...OT]> =>\n (values) =>\n mergeUint8(...values.map((value, idx) => encoders[idx](value)))\n\nexport const Tuple = <\n A extends Array<Codec<any>>,\n OT extends { [K in keyof A]: A[K] extends Codec<infer D> ? D : unknown },\n>(\n ...codecs: A\n): Codec<[...OT]> =>\n createCodec(\n TupleEnc(...codecs.map(([encoder]) => encoder)),\n TupleDec(...codecs.map(([, decoder]) => decoder)),\n )\n\nTuple.enc = TupleEnc\nTuple.dec = TupleDec\n", "import { mapObject } from \"../internal\"\nimport { Codec, Decoder, Encoder, StringRecord } from \"../types\"\nimport { createCodec, enhanceDecoder, enhanceEncoder } from \"../utils\"\nimport { Tuple } from \"./Tuple\"\n\nconst StructEnc = <\n A extends StringRecord<Encoder<any>>,\n OT extends { [K in keyof A]: A[K] extends Encoder<infer D> ? D : unknown },\n>(\n encoders: A,\n): Encoder<OT> => {\n const keys = Object.keys(encoders)\n return enhanceEncoder(Tuple.enc(...Object.values(encoders)), (input: OT) =>\n keys.map((k) => input[k]),\n )\n}\n\nconst StructDec = <\n A extends StringRecord<Decoder<any>>,\n OT extends { [K in keyof A]: A[K] extends Decoder<infer D> ? D : unknown },\n>(\n decoders: A,\n): Decoder<OT> => {\n const keys = Object.keys(decoders)\n return enhanceDecoder(\n Tuple.dec(...Object.values(decoders)),\n (tuple: Array<any>) =>\n Object.fromEntries(tuple.map((value, idx) => [keys[idx], value])) as OT,\n )\n}\n\nexport const Struct = <\n A extends StringRecord<Codec<any>>,\n OT extends { [K in keyof A]: A[K] extends Codec<infer D> ? D : unknown },\n>(\n codecs: A,\n): Codec<OT> =>\n createCodec(\n StructEnc(mapObject(codecs, (x) => x[0]) as any),\n StructDec(mapObject(codecs, (x) => x[1]) as any),\n )\n\nStruct.enc = StructEnc\nStruct.dec = StructDec\n", "import { toInternalBytes, mergeUint8 } from \"../internal\"\nimport { createCodec } from \"../utils\"\nimport { Codec, Decoder, Encoder } from \"../types\"\nimport { compact } from \"./compact\"\n\nconst VectorEnc = <T>(inner: Encoder<T>, size?: number): Encoder<Array<T>> =>\n size! > 0\n ? (value) => mergeUint8(...value.map(inner))\n : (value) => mergeUint8(compact.enc(value.length), ...value.map(inner))\n\nfunction VectorDec<T>(getter: Decoder<T>, size?: number): Decoder<Array<T>> {\n return toInternalBytes((bytes) => {\n const nElements = size! > 0 ? size! : compact.dec(bytes)\n const result = new Array(nElements as number)\n\n for (let i = 0; i < nElements; i++) {\n const current = getter(bytes)\n result[i] = current\n }\n\n return result\n })\n}\n\nexport function Vector<T>(inner: Codec<T>, size?: number): Codec<Array<T>> {\n return createCodec(VectorEnc(inner[0], size), VectorDec(inner[1], size))\n}\n\nVector.enc = VectorEnc\nVector.dec = VectorDec\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,cAAc,CACzB,SACA,YACa;AACb,QAAM,SAAS,CAAC,SAAS,OAAO;AAChC,SAAO,MAAM;AACb,SAAO,MAAM;AACb,SAAO;AACT;AAEO,IAAM,iBACX,CAAO,SAAqB,WAC5B,CAAC,UACC,QAAQ,OAAO,KAAK,CAAC;AAElB,IAAM,iBACX,CAAO,SAAqB,WAC5B,CAAC,UACC,OAAO,QAAQ,KAAK,CAAC;AAElB,IAAM,eAAe,CAC1B,CAAC,SAAS,UACV,QACA,WAEA,YAAY,eAAe,SAAS,MAAM,GAAG,eAAe,SAAS,MAAM,CAAC;;;ACxB9E,IAAM,UAAkC;AAAA,EACtC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;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