@novasamatech/scale 0.5.4 → 0.6.0
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/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lazy.d.ts +2 -0
- package/dist/lazy.js +4 -0
- package/dist/lazy.spec.d.ts +1 -0
- package/dist/lazy.spec.js +10 -0
- package/dist/record.d.ts +2 -0
- package/dist/record.js +5 -0
- package/dist/record.spec.d.ts +1 -0
- package/dist/record.spec.js +25 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export { lazy } from './lazy.js';
|
|
1
2
|
export type { HexString } from './hex.js';
|
|
2
3
|
export { Hex } from './hex.js';
|
|
3
4
|
export { Nullable } from './nullable.js';
|
|
5
|
+
export { Record } from './record.js';
|
|
4
6
|
export { Status } from './status.js';
|
|
5
7
|
export type { EnumCodec } from './enum.js';
|
|
6
8
|
export { Enum } from './enum.js';
|
package/dist/index.js
CHANGED
package/dist/lazy.d.ts
ADDED
package/dist/lazy.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Option, Struct } from 'scale-ts';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { lazy } from './lazy.js';
|
|
4
|
+
describe('lazy', () => {
|
|
5
|
+
it('should correctly encode/decode lazy', () => {
|
|
6
|
+
const codec = Struct({ child: Option(lazy(() => codec)) });
|
|
7
|
+
expect(codec.enc({ child: { child: { child: undefined } } })).toEqual(new Uint8Array([1, 1, 0]));
|
|
8
|
+
expect(codec.dec(new Uint8Array([1, 1, 0]))).toEqual({ child: { child: { child: undefined } } });
|
|
9
|
+
});
|
|
10
|
+
});
|
package/dist/record.d.ts
ADDED
package/dist/record.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Option, u8 } from 'scale-ts';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { Record } from './record.js';
|
|
4
|
+
describe('Record', () => {
|
|
5
|
+
it('should correctly encode/decode Record', () => {
|
|
6
|
+
const codec = Record(u8);
|
|
7
|
+
expect(codec.enc({ x: 1, y: 2 })).toEqual(new Uint8Array([8, 4, 120, 1, 4, 121, 2]));
|
|
8
|
+
expect(codec.dec(new Uint8Array([8, 4, 120, 1, 4, 121, 2]))).toEqual({ y: 2, x: 1 });
|
|
9
|
+
});
|
|
10
|
+
it('should correctly encode/decode Record with Optional', () => {
|
|
11
|
+
const codec = Record(Option(u8));
|
|
12
|
+
expect(codec.enc({ x: 1, y: undefined })).toMatchInlineSnapshot(`
|
|
13
|
+
Uint8Array [
|
|
14
|
+
8,
|
|
15
|
+
4,
|
|
16
|
+
120,
|
|
17
|
+
1,
|
|
18
|
+
1,
|
|
19
|
+
4,
|
|
20
|
+
121,
|
|
21
|
+
0,
|
|
22
|
+
]
|
|
23
|
+
`);
|
|
24
|
+
});
|
|
25
|
+
});
|