json-as 1.1.11 → 1.1.13
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/CHANGELOG.md +15 -0
- package/README.md +1 -1
- package/assembly/__benches__/large.bench.ts +22 -19
- package/assembly/__tests__/generics.spec.ts +40 -0
- package/assembly/__tests__/lib/index.ts +3 -7
- package/assembly/__tests__/resolving.spec.ts +47 -0
- package/assembly/__tests__/types.spec.ts +26 -0
- package/assembly/test.json.ts +388 -0
- package/assembly/test.ts +28 -177
- package/assembly/types.ts +0 -1
- package/bench/large.bench.ts +104 -215
- package/package.json +2 -3
- package/run-bench.js.sh +1 -1
- package/transform/lib/index.js +78 -82
- package/transform/lib/index.js.map +1 -1
- package/transform/lib/linkers/alias.js +49 -0
- package/transform/lib/linkers/alias.js.map +1 -0
- package/transform/lib/{linker.js → linkers/classes.js} +3 -17
- package/transform/lib/linkers/classes.js.map +1 -0
- package/transform/lib/linkers/custom.js +32 -0
- package/transform/lib/linkers/custom.js.map +1 -0
- package/transform/lib/linkers/imports.js +17 -0
- package/transform/lib/linkers/imports.js.map +1 -0
- package/transform/lib/types.js +13 -0
- package/transform/lib/types.js.map +1 -1
- package/transform/src/index.ts +73 -84
- package/transform/src/linkers/alias.ts +59 -0
- package/transform/src/{linker.ts → linkers/classes.ts} +3 -23
- package/transform/src/linkers/custom.ts +32 -0
- package/transform/src/linkers/imports.ts +22 -0
- package/transform/src/types.ts +15 -1
- package/transform/tsconfig.json +1 -1
- package/bench/lib/test.ts +0 -37
- package/transform/lib/linker.js.map +0 -1
package/bench/large.bench.ts
CHANGED
|
@@ -1,231 +1,120 @@
|
|
|
1
1
|
import { bench } from "./lib/bench.js";
|
|
2
|
-
import { expect } from "./lib/test.js";
|
|
3
2
|
|
|
4
|
-
class
|
|
5
|
-
public
|
|
6
|
-
public
|
|
7
|
-
public
|
|
8
|
-
public avatar_url!: string;
|
|
9
|
-
public gravatar_id!: string;
|
|
10
|
-
public url!: string;
|
|
11
|
-
public html_url!: string;
|
|
12
|
-
public followers_url!: string;
|
|
13
|
-
public following_url!: string;
|
|
14
|
-
public gists_url!: string;
|
|
15
|
-
public starred_url!: string;
|
|
16
|
-
public subscriptions_url!: string;
|
|
17
|
-
public organizations_url!: string;
|
|
18
|
-
public repos_url!: string;
|
|
19
|
-
public events_url!: string;
|
|
20
|
-
public received_events_url!: string;
|
|
21
|
-
public type!: string;
|
|
22
|
-
public user_view_type!: string;
|
|
23
|
-
public site_admin!: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
class RepoLicense {
|
|
27
|
-
public key!: string;
|
|
28
|
-
public name!: string;
|
|
29
|
-
public spdx_id!: string;
|
|
30
|
-
public url!: string | null;
|
|
31
|
-
public node_id!: string;
|
|
3
|
+
class Vec3 {
|
|
4
|
+
public x!: number;
|
|
5
|
+
public y!: number;
|
|
6
|
+
public z!: number;
|
|
32
7
|
}
|
|
33
8
|
|
|
34
|
-
class
|
|
9
|
+
class LargeJSON {
|
|
35
10
|
public id!: number;
|
|
36
|
-
public node_id!: string;
|
|
37
11
|
public name!: string;
|
|
38
|
-
public
|
|
39
|
-
public
|
|
40
|
-
public
|
|
41
|
-
public
|
|
42
|
-
public
|
|
43
|
-
public
|
|
44
|
-
public
|
|
45
|
-
public
|
|
46
|
-
public
|
|
47
|
-
public
|
|
48
|
-
public
|
|
49
|
-
public hooks_url!: string;
|
|
50
|
-
public issue_events_url!: string;
|
|
51
|
-
public events_url!: string;
|
|
52
|
-
public assignees_url!: string;
|
|
53
|
-
public branches_url!: string;
|
|
54
|
-
public tags_url!: string;
|
|
55
|
-
public blobs_url!: string;
|
|
56
|
-
public git_tags_url!: string;
|
|
57
|
-
public git_refs_url!: string;
|
|
58
|
-
public trees_url!: string;
|
|
59
|
-
public statuses_url!: string;
|
|
60
|
-
public languages_url!: string;
|
|
61
|
-
public stargazers_url!: string;
|
|
62
|
-
public contributors_url!: string;
|
|
63
|
-
public subscribers_url!: string;
|
|
64
|
-
public subscription_url!: string;
|
|
65
|
-
public commits_url!: string;
|
|
66
|
-
public git_commits_url!: string;
|
|
67
|
-
public comments_url!: string;
|
|
68
|
-
public issue_comment_url!: string;
|
|
69
|
-
public contents_url!: string;
|
|
70
|
-
public compare_url!: string;
|
|
71
|
-
public merges_url!: string;
|
|
72
|
-
public archive_url!: string;
|
|
73
|
-
public downloads_url!: string;
|
|
74
|
-
public issues_url!: string;
|
|
75
|
-
public pulls_url!: string;
|
|
76
|
-
public milestones_url!: string;
|
|
77
|
-
public notifications_url!: string;
|
|
78
|
-
public labels_url!: string;
|
|
79
|
-
public releases_url!: string;
|
|
80
|
-
public deployments_url!: string;
|
|
81
|
-
public created_at!: string;
|
|
82
|
-
public updated_at!: string;
|
|
83
|
-
public pushed_at!: string;
|
|
84
|
-
public git_url!: string;
|
|
85
|
-
public ssh_url!: string;
|
|
86
|
-
public clone_url!: string;
|
|
87
|
-
public svn_url!: string;
|
|
88
|
-
public homepage!: string | null;
|
|
89
|
-
public size!: number;
|
|
90
|
-
public stargazers_count!: number;
|
|
91
|
-
public watchers_count!: number;
|
|
92
|
-
public language!: string | null;
|
|
93
|
-
public has_issues!: boolean;
|
|
94
|
-
public has_projects!: boolean;
|
|
95
|
-
public has_downloads!: boolean;
|
|
96
|
-
public has_wiki!: boolean;
|
|
97
|
-
public has_pages!: boolean;
|
|
98
|
-
public has_discussions!: boolean;
|
|
99
|
-
public forks_count!: number;
|
|
100
|
-
public mirror_url!: string | null;
|
|
101
|
-
public archived!: boolean;
|
|
102
|
-
public disabled!: boolean;
|
|
103
|
-
public open_issues_count!: number;
|
|
104
|
-
public license!: RepoLicense | null;
|
|
105
|
-
public allow_forking!: boolean;
|
|
106
|
-
public is_template!: boolean;
|
|
107
|
-
public web_commit_signoff_required!: boolean;
|
|
108
|
-
public topics!: string[];
|
|
109
|
-
public visibility!: string;
|
|
110
|
-
public forks!: number;
|
|
111
|
-
public open_issues!: number;
|
|
112
|
-
public watchers!: number;
|
|
113
|
-
public default_branch!: string;
|
|
12
|
+
public age!: number;
|
|
13
|
+
public email!: string;
|
|
14
|
+
public street!: string;
|
|
15
|
+
public city!: string;
|
|
16
|
+
public state!: string;
|
|
17
|
+
public zip!: string;
|
|
18
|
+
public tags!: string[];
|
|
19
|
+
public theme!: string;
|
|
20
|
+
public notifications!: boolean;
|
|
21
|
+
public language!: string;
|
|
22
|
+
public movement!: Vec3[];
|
|
114
23
|
}
|
|
115
24
|
|
|
116
|
-
|
|
117
|
-
id:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
has_discussions: false,
|
|
201
|
-
forks_count: 20,
|
|
202
|
-
mirror_url: null,
|
|
203
|
-
archived: false,
|
|
204
|
-
disabled: false,
|
|
205
|
-
open_issues_count: 1,
|
|
206
|
-
license: null,
|
|
207
|
-
allow_forking: true,
|
|
208
|
-
is_template: false,
|
|
209
|
-
web_commit_signoff_required: false,
|
|
210
|
-
topics: [],
|
|
211
|
-
visibility: "public",
|
|
212
|
-
forks: 20,
|
|
213
|
-
open_issues: 1,
|
|
214
|
-
watchers: 332,
|
|
215
|
-
default_branch: "master"
|
|
216
|
-
}
|
|
25
|
+
const v1: LargeJSON = {
|
|
26
|
+
id: 2,
|
|
27
|
+
name: "Medium Object",
|
|
28
|
+
age: 18,
|
|
29
|
+
email: "me@jairus.dev",
|
|
30
|
+
street: "I don't want to say my street",
|
|
31
|
+
city: "I don't want to say this either",
|
|
32
|
+
state: "It really depends",
|
|
33
|
+
zip: "I forget what it is",
|
|
34
|
+
tags: ["me", "dogs", "mountains", "bar", "foo"],
|
|
35
|
+
theme: "Hyper Term Black",
|
|
36
|
+
notifications: true,
|
|
37
|
+
language: "en-US",
|
|
38
|
+
movement: [
|
|
39
|
+
{ x: 1, y: 2, z: 3 },
|
|
40
|
+
{ x: 1, y: 2, z: 3 },
|
|
41
|
+
{ x: 1, y: 2, z: 3 },
|
|
42
|
+
{ x: 1, y: 2, z: 3 },
|
|
43
|
+
{ x: 1, y: 2, z: 3 },
|
|
44
|
+
{ x: 1, y: 2, z: 3 },
|
|
45
|
+
{ x: 1, y: 2, z: 3 },
|
|
46
|
+
{ x: 1, y: 2, z: 3 },
|
|
47
|
+
{ x: 1, y: 2, z: 3 },
|
|
48
|
+
{ x: 1, y: 2, z: 3 },
|
|
49
|
+
{ x: 1, y: 2, z: 3 },
|
|
50
|
+
{ x: 1, y: 2, z: 3 },
|
|
51
|
+
{ x: 1, y: 2, z: 3 },
|
|
52
|
+
{ x: 1, y: 2, z: 3 },
|
|
53
|
+
{ x: 1, y: 2, z: 3 },
|
|
54
|
+
{ x: 1, y: 2, z: 3 },
|
|
55
|
+
{ x: 1, y: 2, z: 3 },
|
|
56
|
+
{ x: 1, y: 2, z: 3 },
|
|
57
|
+
{ x: 1, y: 2, z: 3 },
|
|
58
|
+
{ x: 1, y: 2, z: 3 },
|
|
59
|
+
{ x: 1, y: 2, z: 3 },
|
|
60
|
+
{ x: 1, y: 2, z: 3 },
|
|
61
|
+
{ x: 1, y: 2, z: 3 },
|
|
62
|
+
{ x: 1, y: 2, z: 3 },
|
|
63
|
+
{ x: 1, y: 2, z: 3 },
|
|
64
|
+
{ x: 1, y: 2, z: 3 },
|
|
65
|
+
{ x: 1, y: 2, z: 3 },
|
|
66
|
+
{ x: 1, y: 2, z: 3 },
|
|
67
|
+
{ x: 1, y: 2, z: 3 },
|
|
68
|
+
{ x: 1, y: 2, z: 3 },
|
|
69
|
+
{ x: 1, y: 2, z: 3 },
|
|
70
|
+
{ x: 1, y: 2, z: 3 },
|
|
71
|
+
{ x: 1, y: 2, z: 3 },
|
|
72
|
+
{ x: 1, y: 2, z: 3 },
|
|
73
|
+
{ x: 1, y: 2, z: 3 },
|
|
74
|
+
{ x: 1, y: 2, z: 3 },
|
|
75
|
+
{ x: 1, y: 2, z: 3 },
|
|
76
|
+
{ x: 1, y: 2, z: 3 },
|
|
77
|
+
{ x: 1, y: 2, z: 3 },
|
|
78
|
+
{ x: 1, y: 2, z: 3 },
|
|
79
|
+
{ x: 1, y: 2, z: 3 },
|
|
80
|
+
{ x: 1, y: 2, z: 3 },
|
|
81
|
+
{ x: 1, y: 2, z: 3 },
|
|
82
|
+
{ x: 1, y: 2, z: 3 },
|
|
83
|
+
{ x: 1, y: 2, z: 3 },
|
|
84
|
+
{ x: 1, y: 2, z: 3 },
|
|
85
|
+
{ x: 1, y: 2, z: 3 },
|
|
86
|
+
{ x: 1, y: 2, z: 3 },
|
|
87
|
+
{ x: 1, y: 2, z: 3 },
|
|
88
|
+
{ x: 1, y: 2, z: 3 },
|
|
89
|
+
{ x: 1, y: 2, z: 3 },
|
|
90
|
+
{ x: 1, y: 2, z: 3 },
|
|
91
|
+
{ x: 1, y: 2, z: 3 },
|
|
92
|
+
{ x: 1, y: 2, z: 3 },
|
|
93
|
+
{ x: 1, y: 2, z: 3 },
|
|
94
|
+
{ x: 1, y: 2, z: 3 },
|
|
95
|
+
{ x: 1, y: 2, z: 3 },
|
|
96
|
+
{ x: 1, y: 2, z: 3 },
|
|
97
|
+
{ x: 1, y: 2, z: 3 },
|
|
98
|
+
{ x: 1, y: 2, z: 3 },
|
|
99
|
+
{ x: 1, y: 2, z: 3 },
|
|
100
|
+
{ x: 1, y: 2, z: 3 },
|
|
101
|
+
{ x: 1, y: 2, z: 3 },
|
|
102
|
+
{ x: 1, y: 2, z: 3 },
|
|
103
|
+
{ x: 1, y: 2, z: 3 },
|
|
104
|
+
{ x: 1, y: 2, z: 3 },
|
|
105
|
+
{ x: 1, y: 2, z: 3 },
|
|
106
|
+
{ x: 1, y: 2, z: 3 },
|
|
107
|
+
],
|
|
108
|
+
};
|
|
217
109
|
|
|
218
|
-
const v2 = `{"id":
|
|
219
|
-
|
|
220
|
-
expect(JSON.stringify(v1)).toBe(v2);
|
|
221
|
-
expect(JSON.stringify(JSON.parse(v2))).toBe(v2);
|
|
110
|
+
const v2 = `{"id":2,"name":"Medium Object","age":18,"email":"me@jairus.dev","street":"I don't want to say my street","city":"I don't want to say this either","state":"It really depends","zip":"I forget what it is","tags":["me","dogs","mountains","bar","foo"],"theme":"Hyper Term Black","notifications":true,"language":"en-US","movement":[{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3},{"x":1,"y":2,"z":3}]}`;
|
|
222
111
|
|
|
223
112
|
bench(
|
|
224
113
|
"Serialize Large Object",
|
|
225
114
|
() => {
|
|
226
115
|
JSON.stringify(v1);
|
|
227
116
|
},
|
|
228
|
-
|
|
117
|
+
3_000_00,
|
|
229
118
|
);
|
|
230
119
|
|
|
231
120
|
bench(
|
|
@@ -233,5 +122,5 @@ bench(
|
|
|
233
122
|
() => {
|
|
234
123
|
JSON.parse(v2);
|
|
235
124
|
},
|
|
236
|
-
|
|
237
|
-
);
|
|
125
|
+
3_000_00,
|
|
126
|
+
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-as",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.13",
|
|
4
4
|
"author": "Jairus Tanaka",
|
|
5
5
|
"description": "The only JSON library you'll need for AssemblyScript. SIMD enabled",
|
|
6
6
|
"types": "assembly/index.ts",
|
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
"test": "bash ./run-tests.sh",
|
|
20
20
|
"bench:as": "bash ./run-bench.as.sh",
|
|
21
21
|
"bench:js": "bash ./run-bench.js.sh",
|
|
22
|
-
"build:test": "rm -rf ./build/ && JSON_DEBUG=1 asc assembly/test.ts --transform ./transform -o ./build/test.wasm --textFile ./build/test.wat --debug --config ./node_modules/@assemblyscript/wasi-shim/asconfig.json",
|
|
23
|
-
"build:test:simd": "rm -rf ./build/ && JSON_DEBUG=true asc assembly/test.ts --transform ./transform -o ./build/test.wasm --textFile ./build/test.wat --optimizeLevel 3 --shrinkLevel 0 --enable simd --config ./node_modules/@assemblyscript/wasi-shim/asconfig.json",
|
|
22
|
+
"build:test": "rm -rf ./build/ && JSON_DEBUG=1 JSON_WRITE=assembly/test.ts asc assembly/test.ts --transform ./transform -o ./build/test.wasm --textFile ./build/test.wat --debug --config ./node_modules/@assemblyscript/wasi-shim/asconfig.json",
|
|
24
23
|
"test:wasmtime": "wasmtime ./build/test.wasm",
|
|
25
24
|
"test:wasmer": "wasmer ./build/test.wasm",
|
|
26
25
|
"build:transform": "tsc -p ./transform",
|
package/run-bench.js.sh
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
RUNTIMES=${RUNTIMES:-"v8-liftoff v8-ignition v8-sparkplug v8-turbofan jsc-default"}
|
|
3
3
|
npx tsc -p ./bench > /dev/null 2>&1
|
|
4
|
-
for file in ./bench
|
|
4
|
+
for file in ./bench/*.bench.ts; do
|
|
5
5
|
filename=$(basename -- "$file")
|
|
6
6
|
file_js="${filename%.ts}.js"
|
|
7
7
|
|