json-as 0.8.7 → 0.8.8

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.
@@ -9,10 +9,7 @@ jobs:
9
9
 
10
10
  steps:
11
11
  - name: Checkout the repository
12
- uses: actions/checkout@v4
13
-
14
- - name: Install Wasmtime
15
- uses: jcbhmr/setup-wasmtime@v2
12
+ uses: actions/checkout@v2
16
13
 
17
14
  - name: Setup Node.js
18
15
  uses: actions/setup-node@v2
@@ -20,9 +17,6 @@ jobs:
20
17
  - name: Install dependencies
21
18
  if: steps.node-cache.outputs.cache-hit != 'true'
22
19
  run: yarn
23
-
24
- - name: Build tests
25
- run: yarn run tests:build
26
20
 
27
21
  - name: Perform tests
28
22
  run: yarn run test
package/CHANGELOG CHANGED
@@ -3,6 +3,4 @@ v0.8.3 - Dirty fix to issue #68. Add __JSON_Stringify callable to global scope.
3
3
  v0.8.4 - Fix #71. Classes with the extending class overriding a property cause the property to be serialized twice.
4
4
  v0.8.5 - Fix #73. Support for nullable primatives with Box<T> from as-container
5
5
  v0.8.6 - Fix. Forgot to stash before publishing. Stash and push what should have been v0.8.5
6
-
7
- v0.9.0 - Large update. Refactor all the code, nullable primitives, rewrite the transform, allow extensibility with @omit keywords, and fix a plethora of bugs
8
- [UNRELEASED] v0.9.1 - Port JSON.Value from the `develop` branch to allow for union types, parsing of arbitrary data, and whatever the hell you want.
6
+ v0.8.8 - Depreacte v0.8.7, roll 0.8.6 -> 0.8.8
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  ██║ ██║███████║ ╚█████╔╝███████║╚██████╔╝██║ ╚████║
8
8
  ╚═╝ ╚═╝╚══════╝ ╚════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═══╝
9
9
 
10
- v0.9.0
10
+ v0.8.6
11
11
  </pre>
12
12
  </h3>
13
13
 
@@ -34,8 +34,6 @@ Alternatively, add it to your `asconfig.json`
34
34
  }
35
35
  ```
36
36
 
37
- If you'd like to see the code that the transform generates, run with `JSON_DEBUG=true`
38
-
39
37
  ## Usage
40
38
 
41
39
  ```js
@@ -55,10 +53,7 @@ class Player {
55
53
  firstName!: string;
56
54
  lastName!: string;
57
55
  lastActive!: i32[];
58
- // Drop in a code block, function, or expression that evaluates to a boolean
59
- @omitif("this.age < 18")
60
56
  age!: i32;
61
- @omitnull()
62
57
  pos!: Vec3 | null;
63
58
  isVerified!: boolean;
64
59
  }
@@ -76,17 +71,15 @@ const player: Player = {
76
71
  isVerified: true
77
72
  };
78
73
 
79
- const stringified = JSON.stringify<Player>(player);
74
+ const stringified = JSON.stringify<Player>(player, true);
75
+ // You can toggle on setting default values with the 2nd parameter
76
+ // Alternative: use JSON.serializeTo(player, out);
80
77
 
81
78
  const parsed = JSON.parse<Player>(stringified);
82
79
  ```
83
80
 
84
81
  If you use this project in your codebase, consider dropping a [star](https://github.com/JairusSW/as-json). I would really appreciate it!
85
82
 
86
- ## Notes
87
-
88
- If you want a feature, drop an issue (and again, maybe a star). I'll likely add it in less than 7 days.
89
-
90
83
  ## Performance
91
84
 
92
85
  Run or view the benchmarks [here](https://github.com/JairusSW/as-json/tree/master/bench)
@@ -98,25 +91,21 @@ My library beats JSON (written in C++) on all counts *and*, I see many places wh
98
91
 
99
92
  Serialization Benchmarks:
100
93
 
101
- | Value | JavaScript (ops/s) | JSON-as (ops/s) | Difference |
102
- |----------------------------|--------------------|-----------------|------------|
103
- | "hello world" | 28,629,598 | 64,210,666 | + 124% |
104
- | 12345 | 31,562,431 | 56,329,066 | + 78% |
105
- | 1.2345 | 15,977,278 | 20,322,939 | + 27% |
106
- | [[],[[]],[[],[[]]]] | 8,998,624 | 34,453,102 | + 283% |
107
- | { x: f64, y: f64, z: f64 } | 15,583,686 | 17,604,821 | + 12% |
94
+ | Value | JavaScript (ops/s) | JSON-as (ops/s) | JSON-AS with Pages |
95
+ |----------------------------|--------------------|-----------------|--------------------|
96
+ | "hello world" | 28,629,598 | 64,210,666 | + 124% |
97
+ | 12345 | 31,562,431 | 56,329,066 | 321,783,941 ops/s |
98
+ | 1.2345 | 15,977,278 | 20,322,939 | 30,307,616 ops/s |
99
+ | [[],[[]],[[],[[]]]] | 8,998,624 | 34,453,102 | + 283% |
100
+
108
101
 
109
102
 
103
+ Deserialization Benchmarks: (WIP)
110
104
 
111
- Deserialization Benchmarks:
105
+ | Value | JavaScript (ops/s) | JSON-AS (ops/s) | % Diff |
106
+ |----------------------------|--------------------|-----------------|--------|
107
+ | "12345" | 34,647,886 | 254,640,930 | + 635% |
112
108
 
113
- | Value | JavaScript (ops/s) | JSON-AS (ops/s) | Difference|
114
- |----------------------------|--------------------|-----------------|-----------|
115
- | "hello world" | 12,210,131 | 24,274,496 | + 98% |
116
- | "12345" | 21,376,873 | 254,640,930 | + 1,191% |
117
- | 1.2345 | 23,193,902 | 221,869,840 | + 987% |
118
- | [[],[[]],[[],[[]]]] | 4,777,227 | 74,921,123 | + 1,568% |
119
- | { x: f64, y: f64, z: f64 } | 10,973,723 | 25,214,019 | + 230% |
120
109
 
121
110
  And my PC specs:
122
111
 
@@ -126,6 +115,7 @@ And my PC specs:
126
115
  | CPU | AMD Ryzen 7 7800x3D @ 6.00 GHz |
127
116
  | Memory | T-Force DDR5 6000 MHz |
128
117
  | OS | Ubuntu WSL2 |
118
+ | Graphics | AMD Radeon RX 6750XT |
129
119
 
130
120
  ## Issues
131
121
 
@@ -0,0 +1,88 @@
1
+ import { JSON } from "..";
2
+ import { __atoi_fast, snip_fast } from "../src/util";
3
+ @json
4
+ class Vec3 {
5
+ x: i32;
6
+ y: i32;
7
+ z: i32;
8
+ }
9
+
10
+ const vec: Vec3 = {
11
+ x: 3,
12
+ y: 1,
13
+ z: 8,
14
+ }
15
+ /*
16
+ bench("Parse Number SNIP", () => {
17
+ blackbox<i32>(snip_fast<i32>("12345"));
18
+ });
19
+
20
+ bench("Parse Number ATOI", () => {
21
+ blackbox<i32>(__atoi_fast<i32>("12345"));
22
+ })
23
+
24
+ bench("Parse Number STDLIB", () => {
25
+ blackbox<i32>(i32.parse("12345"));
26
+ });
27
+
28
+ bench("Parse Number OLD", () => {
29
+ blackbox<i32>(parseSciInteger<i32>("12345"));
30
+ });
31
+
32
+ bench("Stringify Object (Vec3)", () => {
33
+ blackbox<string>(vec.__SERIALIZE());
34
+ });*/
35
+
36
+ // TODO: Make this allocate without crashing
37
+ bench("Parse Object (Vec3)", () => {
38
+ blackbox<Vec3>(JSON.parse<Vec3>('{"x":0,"y":0,"z":0}'));
39
+ });
40
+ /*
41
+ bench("Stringify Number Array", () => {
42
+ blackbox(JSON.stringify<i32[]>([1, 2, 3]));
43
+ });
44
+
45
+ bench("Parse Number Array", () => {
46
+ blackbox(JSON.parse<i32[]>(blackbox("[1,2,3]")));
47
+ });
48
+
49
+ bench("Stringify String", () => {
50
+ blackbox(JSON.stringify(blackbox('Hello "World!')));
51
+ });
52
+
53
+ bench("Parse String", () => {
54
+ blackbox(JSON.parse<string>(blackbox('"Hello "World!"')));
55
+ });
56
+ /*
57
+ bench("Stringify Boolean Array", () => {
58
+ blackbox(JSON.stringify<boolean[]>([true, false, true]));
59
+ });
60
+
61
+ bench("Stringify String Array", () => {
62
+ blackbox(JSON.stringify<string[]>(["a", "b", "c"]));
63
+ });
64
+
65
+ bench("Stringify Boolean", () => {
66
+ blackbox(JSON.stringify(blackbox(true)));
67
+ });
68
+
69
+ bench("Parse Boolean", () => {
70
+ blackbox(JSON.parse<boolean>(blackbox("true")));
71
+ });
72
+
73
+ bench("Stringify Integer", () => {
74
+ blackbox(JSON.stringify(blackbox(314)));
75
+ });*/
76
+
77
+ bench("Parse Integer", () => {
78
+ blackbox(JSON.parse<i32>(blackbox("314")));
79
+ });
80
+ /*
81
+ bench("Stringify Float", () => {
82
+ blackbox(JSON.stringify(blackbox(3.14)));
83
+ });
84
+
85
+ bench("Parse Float", () => {
86
+ blackbox(JSON.parse<f32>(blackbox("3.14")));
87
+ });
88
+ */
@@ -0,0 +1 @@
1
+ /// <reference path="../../node_modules/@as-tral/cli/as-tral.d.ts" />