json-as 1.1.9 → 1.1.11
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 +16 -0
- package/README.md +8 -1
- package/assembly/__benches__/large.bench.ts +19 -22
- package/assembly/__tests__/lib/index.ts +7 -3
- package/assembly/index.ts +2 -0
- package/assembly/test.ts +129 -4
- package/assembly/types.ts +70 -0
- package/bench/large.bench.ts +215 -104
- package/bench/lib/test.ts +37 -0
- package/package.json +6 -6
- package/run-bench.as.sh +1 -1
- package/run-bench.js.sh +1 -1
- package/transform/lib/builder.js +3 -0
- package/transform/lib/builder.js.map +1 -1
- package/transform/lib/index.js +412 -206
- package/transform/lib/index.js.map +1 -1
- package/transform/lib/linker.js +38 -6
- package/transform/lib/linker.js.map +1 -1
- package/transform/lib/util.js +5 -0
- package/transform/lib/util.js.map +1 -1
- package/transform/src/builder.ts +4 -0
- package/transform/src/index.ts +499 -280
- package/transform/src/linker.ts +56 -7
- package/transform/src/util.ts +6 -0
package/bench/large.bench.ts
CHANGED
|
@@ -1,120 +1,231 @@
|
|
|
1
1
|
import { bench } from "./lib/bench.js";
|
|
2
|
+
import { expect } from "./lib/test.js";
|
|
2
3
|
|
|
3
|
-
class
|
|
4
|
-
public
|
|
5
|
-
public
|
|
6
|
-
public
|
|
4
|
+
class RepoOwner {
|
|
5
|
+
public login!: string;
|
|
6
|
+
public id!: number;
|
|
7
|
+
public node_id!: string;
|
|
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;
|
|
7
32
|
}
|
|
8
33
|
|
|
9
|
-
class
|
|
34
|
+
class Repo {
|
|
10
35
|
public id!: number;
|
|
36
|
+
public node_id!: string;
|
|
11
37
|
public name!: string;
|
|
12
|
-
public
|
|
13
|
-
public
|
|
14
|
-
public
|
|
15
|
-
public
|
|
16
|
-
public
|
|
17
|
-
public
|
|
18
|
-
public
|
|
19
|
-
public
|
|
20
|
-
public
|
|
21
|
-
public
|
|
22
|
-
public
|
|
38
|
+
public full_name!: string;
|
|
39
|
+
public private!: boolean;
|
|
40
|
+
public owner: RepoOwner = new RepoOwner();
|
|
41
|
+
public html_url!: string;
|
|
42
|
+
public description!: string | null;
|
|
43
|
+
public fork!: boolean;
|
|
44
|
+
public url!: string;
|
|
45
|
+
public forks_url!: string;
|
|
46
|
+
public keys_url!: string;
|
|
47
|
+
public collaborators_url!: string;
|
|
48
|
+
public teams_url!: string;
|
|
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;
|
|
23
114
|
}
|
|
24
115
|
|
|
25
|
-
|
|
26
|
-
id:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
116
|
+
let v1: Repo = {
|
|
117
|
+
id: 132935648,
|
|
118
|
+
node_id: "MDEwOlJlcG9zaXRvcnkxMzI5MzU2NDg=",
|
|
119
|
+
name: "boysenberry-repo-1",
|
|
120
|
+
full_name: "octocat/boysenberry-repo-1",
|
|
121
|
+
private: true,
|
|
122
|
+
owner: {
|
|
123
|
+
login: "octocat",
|
|
124
|
+
id: 583231,
|
|
125
|
+
node_id: "MDQ6VXNlcjU4MzIzMQ==",
|
|
126
|
+
avatar_url: "https://avatars.githubusercontent.com/u/583231?v=4",
|
|
127
|
+
gravatar_id: "",
|
|
128
|
+
url: "https://api.github.com/users/octocat",
|
|
129
|
+
html_url: "https://github.com/octocat",
|
|
130
|
+
followers_url: "https://api.github.com/users/octocat/followers",
|
|
131
|
+
following_url: "https://api.github.com/users/octocat/following{/other_user}",
|
|
132
|
+
gists_url: "https://api.github.com/users/octocat/gists{/gist_id}",
|
|
133
|
+
starred_url: "https://api.github.com/users/octocat/starred{/owner}{/repo}",
|
|
134
|
+
subscriptions_url: "https://api.github.com/users/octocat/subscriptions",
|
|
135
|
+
organizations_url: "https://api.github.com/users/octocat/orgs",
|
|
136
|
+
repos_url: "https://api.github.com/users/octocat/repos",
|
|
137
|
+
events_url: "https://api.github.com/users/octocat/events{/privacy}",
|
|
138
|
+
received_events_url: "https://api.github.com/users/octocat/received_events",
|
|
139
|
+
type: "User",
|
|
140
|
+
user_view_type: "public",
|
|
141
|
+
site_admin: false
|
|
142
|
+
},
|
|
143
|
+
html_url: "https://github.com/octocat/boysenberry-repo-1",
|
|
144
|
+
description: "Testing",
|
|
145
|
+
fork: true,
|
|
146
|
+
url: "https://api.github.com/repos/octocat/boysenberry-repo-1",
|
|
147
|
+
forks_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/forks",
|
|
148
|
+
keys_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/keys{/key_id}",
|
|
149
|
+
collaborators_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/collaborators{/collaborator}",
|
|
150
|
+
teams_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/teams",
|
|
151
|
+
hooks_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/hooks",
|
|
152
|
+
issue_events_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/issues/events{/number}",
|
|
153
|
+
events_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/events",
|
|
154
|
+
assignees_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/assignees{/user}",
|
|
155
|
+
branches_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/branches{/branch}",
|
|
156
|
+
tags_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/tags",
|
|
157
|
+
blobs_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/git/blobs{/sha}",
|
|
158
|
+
git_tags_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/git/tags{/sha}",
|
|
159
|
+
git_refs_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/git/refs{/sha}",
|
|
160
|
+
trees_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/git/trees{/sha}",
|
|
161
|
+
statuses_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/statuses/{sha}",
|
|
162
|
+
languages_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/languages",
|
|
163
|
+
stargazers_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/stargazers",
|
|
164
|
+
contributors_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/contributors",
|
|
165
|
+
subscribers_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/subscribers",
|
|
166
|
+
subscription_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/subscription",
|
|
167
|
+
commits_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/commits{/sha}",
|
|
168
|
+
git_commits_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/git/commits{/sha}",
|
|
169
|
+
comments_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/comments{/number}",
|
|
170
|
+
issue_comment_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/issues/comments{/number}",
|
|
171
|
+
contents_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/contents/{+path}",
|
|
172
|
+
compare_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/compare/{base}...{head}",
|
|
173
|
+
merges_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/merges",
|
|
174
|
+
archive_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/{archive_format}{/ref}",
|
|
175
|
+
downloads_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/downloads",
|
|
176
|
+
issues_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/issues{/number}",
|
|
177
|
+
pulls_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/pulls{/number}",
|
|
178
|
+
milestones_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/milestones{/number}",
|
|
179
|
+
notifications_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/notifications{?since,all,participating}",
|
|
180
|
+
labels_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/labels{/name}",
|
|
181
|
+
releases_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/releases{/id}",
|
|
182
|
+
deployments_url: "https://api.github.com/repos/octocat/boysenberry-repo-1/deployments",
|
|
183
|
+
created_at: "2018-05-10T17:51:29Z",
|
|
184
|
+
updated_at: "2025-05-24T02:01:19Z",
|
|
185
|
+
pushed_at: "2024-05-26T07:02:05Z",
|
|
186
|
+
git_url: "git://github.com/octocat/boysenberry-repo-1.git",
|
|
187
|
+
ssh_url: "git@github.com:octocat/boysenberry-repo-1.git",
|
|
188
|
+
clone_url: "https://github.com/octocat/boysenberry-repo-1.git",
|
|
189
|
+
svn_url: "https://github.com/octocat/boysenberry-repo-1",
|
|
190
|
+
homepage: "",
|
|
191
|
+
size: 4,
|
|
192
|
+
stargazers_count: 332,
|
|
193
|
+
watchers_count: 332,
|
|
194
|
+
language: null,
|
|
195
|
+
has_issues: false,
|
|
196
|
+
has_projects: true,
|
|
197
|
+
has_downloads: true,
|
|
198
|
+
has_wiki: true,
|
|
199
|
+
has_pages: false,
|
|
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
|
+
}
|
|
109
217
|
|
|
110
|
-
const v2 = `{"id":
|
|
218
|
+
const v2 = `{"id":132935648,"node_id":"MDEwOlJlcG9zaXRvcnkxMzI5MzU2NDg=","name":"boysenberry-repo-1","full_name":"octocat/boysenberry-repo-1","private":true,"owner":{"login":"octocat","id":583231,"node_id":"MDQ6VXNlcjU4MzIzMQ==","avatar_url":"https://avatars.githubusercontent.com/u/583231?v=4","gravatar_id":"","url":"https://api.github.com/users/octocat","html_url":"https://github.com/octocat","followers_url":"https://api.github.com/users/octocat/followers","following_url":"https://api.github.com/users/octocat/following{/other_user}","gists_url":"https://api.github.com/users/octocat/gists{/gist_id}","starred_url":"https://api.github.com/users/octocat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/octocat/subscriptions","organizations_url":"https://api.github.com/users/octocat/orgs","repos_url":"https://api.github.com/users/octocat/repos","events_url":"https://api.github.com/users/octocat/events{/privacy}","received_events_url":"https://api.github.com/users/octocat/received_events","type":"User","user_view_type":"public","site_admin":false},"html_url":"https://github.com/octocat/boysenberry-repo-1","description":"Testing","fork":true,"url":"https://api.github.com/repos/octocat/boysenberry-repo-1","forks_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/forks","keys_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/teams","hooks_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/hooks","issue_events_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/issues/events{/number}","events_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/events","assignees_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/assignees{/user}","branches_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/branches{/branch}","tags_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/tags","blobs_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/statuses/{sha}","languages_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/languages","stargazers_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/stargazers","contributors_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/contributors","subscribers_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/subscribers","subscription_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/subscription","commits_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/contents/{+path}","compare_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/merges","archive_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/downloads","issues_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/issues{/number}","pulls_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/pulls{/number}","milestones_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/milestones{/number}","notifications_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/labels{/name}","releases_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/releases{/id}","deployments_url":"https://api.github.com/repos/octocat/boysenberry-repo-1/deployments","created_at":"2018-05-10T17:51:29Z","updated_at":"2025-05-24T02:01:19Z","pushed_at":"2024-05-26T07:02:05Z","git_url":"git://github.com/octocat/boysenberry-repo-1.git","ssh_url":"git@github.com:octocat/boysenberry-repo-1.git","clone_url":"https://github.com/octocat/boysenberry-repo-1.git","svn_url":"https://github.com/octocat/boysenberry-repo-1","homepage":"","size":4,"stargazers_count":332,"watchers_count":332,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"has_discussions":false,"forks_count":20,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":1,"license":null,"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"public","forks":20,"open_issues":1,"watchers":332,"default_branch":"master"}`;
|
|
219
|
+
|
|
220
|
+
expect(JSON.stringify(v1)).toBe(v2);
|
|
221
|
+
expect(JSON.stringify(JSON.parse(v2))).toBe(v2);
|
|
111
222
|
|
|
112
223
|
bench(
|
|
113
224
|
"Serialize Large Object",
|
|
114
225
|
() => {
|
|
115
226
|
JSON.stringify(v1);
|
|
116
227
|
},
|
|
117
|
-
|
|
228
|
+
1_000_000,
|
|
118
229
|
);
|
|
119
230
|
|
|
120
231
|
bench(
|
|
@@ -122,5 +233,5 @@ bench(
|
|
|
122
233
|
() => {
|
|
123
234
|
JSON.parse(v2);
|
|
124
235
|
},
|
|
125
|
-
|
|
126
|
-
);
|
|
236
|
+
1_000_000,
|
|
237
|
+
);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
let currentDescription: string = "";
|
|
2
|
+
export function describe(description: string, routine: () => void): void {
|
|
3
|
+
currentDescription = description;
|
|
4
|
+
routine();
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function it(description: string, routine: () => void): void {
|
|
8
|
+
currentDescription = description;
|
|
9
|
+
routine();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function expect<T>(left: T): Expectation {
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
if (!left.toString) throw new Error("Expected left to have a toString method, but it does not.");
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
return new Expectation(left == null ? "null" : left.toString());
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class Expectation {
|
|
20
|
+
public left: string;
|
|
21
|
+
|
|
22
|
+
constructor(left: string) {
|
|
23
|
+
this.left = left;
|
|
24
|
+
}
|
|
25
|
+
toBe<T>(right: T): void {
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
if (!right.toString) throw new Error("Expected right to have a toString method, but it does not.");
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
if (this.left != (right == null ? "null" : right.toString())) {
|
|
30
|
+
console.log(" " + currentDescription + "\n");
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
console.log(" (expected) -> " + (right == null ? "null" : right.toString()));
|
|
33
|
+
console.log(" (received) -> " + this.left);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-as",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
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,7 +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=
|
|
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
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",
|
|
24
24
|
"test:wasmtime": "wasmtime ./build/test.wasm",
|
|
25
25
|
"test:wasmer": "wasmer ./build/test.wasm",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@assemblyscript/wasi-shim": "^0.1.0",
|
|
32
|
-
"@types/node": "^22.
|
|
33
|
-
"assemblyscript": "^0.27.
|
|
32
|
+
"@types/node": "^22.15.24",
|
|
33
|
+
"assemblyscript": "^0.27.36",
|
|
34
34
|
"assemblyscript-prettier": "^3.0.1",
|
|
35
35
|
"prettier": "^3.5.3",
|
|
36
|
-
"tsx": "^4.19.
|
|
37
|
-
"typescript": "^5.8.
|
|
36
|
+
"tsx": "^4.19.4",
|
|
37
|
+
"typescript": "^5.8.3"
|
|
38
38
|
},
|
|
39
39
|
"contributors": [
|
|
40
40
|
"DogWhich",
|
package/run-bench.as.sh
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
RUNTIMES=${RUNTIMES:-"minimal stub"}
|
|
3
3
|
ENGINES=${ENGINES:-"liftoff ignition sparkplug turbofan llvm"}
|
|
4
|
-
for file in ./assembly/__benches__
|
|
4
|
+
for file in ./assembly/__benches__/large.bench.ts; do
|
|
5
5
|
filename=$(basename -- "$file")
|
|
6
6
|
output_wasi=
|
|
7
7
|
for runtime in $RUNTIMES; do
|
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/large.bench.ts; do
|
|
5
5
|
filename=$(basename -- "$file")
|
|
6
6
|
file_js="${filename%.ts}.js"
|
|
7
7
|
|
package/transform/lib/builder.js
CHANGED