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.
@@ -16,7 +16,7 @@ jobs:
16
16
 
17
17
  - name: Setup Bun
18
18
  uses: oven-sh/setup-bun@v1
19
-
19
+
20
20
  - name: Install Dependencies
21
21
  run: bun install
22
22
 
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
- [UNRELEASED] v0.9.9
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.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
 
@@ -559,6 +559,5 @@ describe("Should deserialize Objects", () => {
559
559
  });
560
560
 
561
561
  run({
562
- log: true,
563
- coverage: true
562
+ log: true
564
563
  });
@@ -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 TokenMetaData {
5
- id: u64;
6
- name: string;
7
- uri: string;
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 NonFungibleToken {
18
- owner: string;
19
- counter: u64;
20
- tokens: Map<u64, TokenMetaData>;
21
- owners: Map<u64, string>;
22
- balances: Map<string, u64[]>;
23
- constructor() {
24
- this.owner = "";
25
- this.counter = 0;
26
- this.tokens = new Map<u64, TokenMetaData>();
27
- this.owners = new Map<u64, string>();
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
- let state = JSON.parse<NonFungibleToken>(
34
- '"{"owner":"","counter":0,"tokens":{},"owners":{},"balances":{}}"'
35
- );
36
- // let state = new NonFungibleToken();
36
+ const stringified = JSON.stringify<Player>(player);
37
37
 
38
- if (!state.balances.has("bhavya")) {
39
- state.balances.set("bhavya", []);
40
- }
41
- console.log(JSON.stringify(state))
38
+ const parsed = JSON.parse<Player>(stringified);
Binary file