json-as 0.9.9 → 0.9.10
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/.github/workflows/nodejs.yml +1 -1
- package/CHANGELOG +6 -1
- package/README.md +2 -1
- package/assembly/__tests__/test.spec.ts +1 -2
- package/assembly/deserialize/map.ts +2 -0
- package/assembly/test.ts +29 -32
- package/build/test.spec.wasm +0 -0
- package/build/test.spec.wasm.map +1 -1
- package/build/test.spec.wat +3488 -8664
- package/build/test.wasm +0 -0
- package/build/test.wasm.map +1 -1
- package/build/test.wat +8885 -19439
- package/package.json +2 -3
- package/transform/lib/index.js +17 -6
- package/transform/package.json +1 -1
- package/transform/src/index.ts +21 -6
package/CHANGELOG
CHANGED
|
@@ -15,10 +15,15 @@ v0.9.7 - Update testing framework and readme logo
|
|
|
15
15
|
v0.9.8 - Update dependencies
|
|
16
16
|
v0.9.8a - Fix #80 - Empty Maps were not serialized to {}, instead, threw memory out of bounds
|
|
17
17
|
v0.9.8b - Fix #81 - Revert transform
|
|
18
|
-
|
|
18
|
+
v0.9.9 - Fix #82 - Initialize maps
|
|
19
|
+
v0.9.9a - Remove extraneous logs from transform
|
|
20
|
+
v0.9.10 - Fix transform type checks. switch to nodekind checks
|
|
21
|
+
|
|
22
|
+
[UNRELEASED] v1.0.0
|
|
19
23
|
- Allow nullable primitives
|
|
20
24
|
- Port over JSON.Value
|
|
21
25
|
- Performance improvements
|
|
26
|
+
- Add SIMD support
|
|
22
27
|
- Introduce options
|
|
23
28
|
- Custom serializers
|
|
24
29
|
- Support arbitrary-length integers (@hypercubed/as-mpz)
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
__| || __|| || | | ___ | _ || __|
|
|
4
4
|
| | ||__ || | || | | ||___|| ||__ |
|
|
5
5
|
|_____||_____||_____||_|___| |__|__||_____|
|
|
6
|
-
v0.9.
|
|
6
|
+
v0.9.10
|
|
7
7
|
</pre>
|
|
8
8
|
</h5>
|
|
9
9
|
|
|
@@ -187,6 +187,7 @@ Below are benchmark results comparing JavaScript's built-in JSON implementation
|
|
|
187
187
|
|
|
188
188
|
My library beats JSON (written in C++) on all counts *and*, I see many places where I can pull at least a 60% uplift in performance if I implement it.
|
|
189
189
|
|
|
190
|
+
Note: SIMD is in-development and only available on the `v1` branch on GitHub
|
|
190
191
|
|
|
191
192
|
Serialization Benchmarks:
|
|
192
193
|
|
|
@@ -72,6 +72,8 @@ import { deserializeFloat } from "./float";
|
|
|
72
72
|
depth--;
|
|
73
73
|
if (depth === 0) {
|
|
74
74
|
++objectValueIndex;
|
|
75
|
+
console.log("Index: " + nameof<indexof<T>>());
|
|
76
|
+
console.log("Value: " + nameof<valueof<T>>());
|
|
75
77
|
map.set(deserializeMapKey<indexof<T>>(key), JSON.parse<valueof<T>>(data.slice(outerLoopIndex, objectValueIndex)));
|
|
76
78
|
outerLoopIndex = objectValueIndex;
|
|
77
79
|
isKey = false;
|
package/assembly/test.ts
CHANGED
|
@@ -1,41 +1,38 @@
|
|
|
1
1
|
import { JSON } from ".";
|
|
2
|
-
|
|
3
2
|
@json
|
|
4
|
-
class
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
constructor(id: u64, name: string, uri: string) {
|
|
10
|
-
this.id = id;
|
|
11
|
-
this.name = name;
|
|
12
|
-
this.uri = uri;
|
|
13
|
-
}
|
|
3
|
+
class Vec3 {
|
|
4
|
+
x: f32 = 0.0;
|
|
5
|
+
y: f32 = 0.0;
|
|
6
|
+
z: f32 = 0.0;
|
|
14
7
|
}
|
|
15
8
|
|
|
16
9
|
@json
|
|
17
|
-
class
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.balances = new Map<string, u64[]>();
|
|
29
|
-
}
|
|
10
|
+
class Player {
|
|
11
|
+
@alias("first name")
|
|
12
|
+
firstName!: string;
|
|
13
|
+
lastName!: string;
|
|
14
|
+
lastActive!: i32[];
|
|
15
|
+
// Drop in a code block, function, or expression that evaluates to a boolean
|
|
16
|
+
@omitif("this.age < 18")
|
|
17
|
+
age!: i32;
|
|
18
|
+
@omitnull()
|
|
19
|
+
pos!: Vec3 | null;
|
|
20
|
+
isVerified!: boolean;
|
|
30
21
|
}
|
|
31
22
|
|
|
23
|
+
const player: Player = {
|
|
24
|
+
firstName: "Emmet",
|
|
25
|
+
lastName: "West",
|
|
26
|
+
lastActive: [8, 27, 2022],
|
|
27
|
+
age: 23,
|
|
28
|
+
pos: {
|
|
29
|
+
x: 3.4,
|
|
30
|
+
y: 1.2,
|
|
31
|
+
z: 8.3
|
|
32
|
+
},
|
|
33
|
+
isVerified: true
|
|
34
|
+
};
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
'"{"owner":"","counter":0,"tokens":{},"owners":{},"balances":{}}"'
|
|
35
|
-
);
|
|
36
|
-
// let state = new NonFungibleToken();
|
|
36
|
+
const stringified = JSON.stringify<Player>(player);
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
state.balances.set("bhavya", []);
|
|
40
|
-
}
|
|
41
|
-
console.log(JSON.stringify(state))
|
|
38
|
+
const parsed = JSON.parse<Player>(stringified);
|
package/build/test.spec.wasm
CHANGED
|
Binary file
|