json-as 0.5.54 → 0.5.56

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.
@@ -107,19 +107,19 @@ import { backSlashCode, quoteCode } from "./chars";
107
107
  // The first char (f) is E or e
108
108
  // We push the offset up by two and apply the notation.
109
109
  if (load<u16>(changetype<usize>(str) + <usize>offset + 2) == 45) {
110
- return -(val / (10 ** (atoi_fast<u32>(str, offset + 6) - 1))) as T;
110
+ return -(val / (10 ** (__atoi_fast<u32>(str, offset + 6, offset + 8) - 1))) as T;
111
111
  } else {
112
112
  // Inlined this operation instead of using a loop
113
- return -(val * (10 ** (atoi_fast<u32>(str, offset + 2) + 1))) as T;
113
+ return -(val * (10 ** (__atoi_fast<u32>(str, offset + 2, offset + 4) + 1))) as T;
114
114
  }
115
115
  } else if (high > 57) {
116
116
  // The first char (f) is E or e
117
117
  // We push the offset up by two and apply the notation.
118
118
  if (load<u16>(changetype<usize>(str) + <usize>offset + 4) == 45) {
119
- return -(val / (10 ** (atoi_fast<u32>(str, offset + 6) - 1))) as T;
119
+ return -(val / (10 ** (__atoi_fast<u32>(str, offset + 6, offset + 8) - 1))) as T;
120
120
  } else {
121
121
  // Inlined this operation instead of using a loop
122
- return -(val * (10 ** (atoi_fast<u32>(str, offset + 4) + 1))) as T;
122
+ return -(val * (10 ** (__atoi_fast<u32>(str, offset + 4, offset + 6) + 1))) as T;
123
123
  }
124
124
  } else {
125
125
  val = (val * 100 + ((low - 48) * 10) + (high - 48)) as T;
@@ -134,10 +134,10 @@ import { backSlashCode, quoteCode } from "./chars";
134
134
  // The first char (f) is E or e
135
135
  // We push the offset up by two and apply the notation.
136
136
  if (load<u16>(changetype<usize>(str) + <usize>offset + 2) == 45) {
137
- return -(val / (10 ** (atoi_fast<u32>(str, offset + 6) - 1))) as T;
137
+ return -(val / (10 ** (__atoi_fast<u32>(str, offset + 6, offset + 8) - 1))) as T;
138
138
  } else {
139
139
  // Inlined this operation instead of using a loop
140
- return -(val * (10 ** (atoi_fast<u32>(str, offset + 2) + 1))) as T;
140
+ return -(val * (10 ** (__atoi_fast<u32>(str, offset + 2, offset + 4) + 1))) as T;
141
141
  }
142
142
  } else {
143
143
  val = (val * 10) + (ch - 48) as T;
@@ -156,17 +156,17 @@ import { backSlashCode, quoteCode } from "./chars";
156
156
  // The first char (f) is E or e
157
157
  // We push the offset up by two and apply the notation.
158
158
  if (load<u16>(changetype<usize>(str) + <usize>offset + 2) == 45) {
159
- return (val / (10 ** (atoi_fast<u32>(str, offset + 6) - 1))) as T;
159
+ return (val / (10 ** (__atoi_fast<u32>(str, offset + 6, offset + 8) - 1))) as T;
160
160
  } else {
161
161
  // Inlined this operation instead of using a loop
162
- return (val * (10 ** (atoi_fast<u32>(str, offset + 2) + 1))) as T;
162
+ return (val * (10 ** (__atoi_fast<u32>(str, offset + 2, offset + 4) + 1))) as T;
163
163
  }
164
164
  } else if (high > 57) {
165
165
  if (load<u16>(changetype<usize>(str) + <usize>offset + 4) == 45) {
166
- return (val / (10 ** (atoi_fast<u32>(str, offset + 6) - 1))) as T;
166
+ return (val / (10 ** (__atoi_fast<u32>(str, offset + 6, offset + 8) - 1))) as T;
167
167
  } else {
168
168
  // Inlined this operation instead of using a loop
169
- return (val * (10 ** (atoi_fast<u32>(str, offset + 4) + 1))) as T;
169
+ return (val * (10 ** (__atoi_fast<u32>(str, offset + 4, offset + 6) + 1))) as T;
170
170
  }
171
171
  } else {
172
172
  // Optimized with multiplications and shifts.
@@ -181,10 +181,10 @@ import { backSlashCode, quoteCode } from "./chars";
181
181
  // e is 101 and E is 69.
182
182
  if (ch > 57) {
183
183
  if (load<u16>(changetype<usize>(str) + <usize>offset + 2) == 45) {
184
- val = (val / (10 ** (atoi_fast<u32>(str, offset + 6) - 1))) as T;
184
+ val = (val / (10 ** (__atoi_fast<u32>(str, offset + 6, offset + 8) - 1))) as T;
185
185
  } else {
186
186
  // Inlined this operation instead of using a loop
187
- val = (val * (10 ** (atoi_fast<u32>(str, offset + 2) + 1))) as T;
187
+ val = (val * (10 ** (__atoi_fast<u32>(str, offset + 2, offset + 4) + 1))) as T;
188
188
  }
189
189
  return val as T;
190
190
  } else {
@@ -209,17 +209,17 @@ import { backSlashCode, quoteCode } from "./chars";
209
209
  // The first char (f) is E or e
210
210
  // We push the offset up by two and apply the notation.
211
211
  if (load<u16>(changetype<usize>(str) + <usize>offset + 2) == 45) {
212
- return (val / (10 ** (atoi_fast<u32>(str, offset + 6) - 1))) as T;
212
+ return (val / (10 ** (__atoi_fast<u32>(str, offset + 6, offset + 8) - 1))) as T;
213
213
  } else {
214
214
  // Inlined this operation instead of using a loop
215
- return (val * (10 ** (atoi_fast<u32>(str, offset + 2) + 1))) as T;
215
+ return (val * (10 ** (__atoi_fast<u32>(str, offset + 2, offset + 4) + 1))) as T;
216
216
  }
217
217
  } else if (high > 57) {
218
218
  if (load<u16>(changetype<usize>(str) + <usize>offset + 4) == 45) {
219
- return (val / (10 ** (atoi_fast<u32>(str, offset + 6) - 1))) as T;
219
+ return (val / (10 ** (__atoi_fast<u32>(str, offset + 6, offset + 8) - 1))) as T;
220
220
  } else {
221
221
  // Inlined this operation instead of using a loop
222
- return (val * (10 ** (atoi_fast<u32>(str, offset + 4) + 1))) as T;
222
+ return (val * (10 ** (__atoi_fast<u32>(str, offset + 4, offset + 6) + 1))) as T;
223
223
  }
224
224
  } else {
225
225
  // Optimized with multiplications and shifts.
@@ -234,10 +234,10 @@ import { backSlashCode, quoteCode } from "./chars";
234
234
  // e is 101 and E is 69.
235
235
  if (ch > 57) {
236
236
  if (load<u16>(changetype<usize>(str) + <usize>offset + 2) == 45) {
237
- return (val / (10 ** (atoi_fast<u32>(str, offset + 6) - 1))) as T;
237
+ return (val / (10 ** (__atoi_fast<u32>(str, offset + 6, offset + 8) - 1))) as T;
238
238
  } else {
239
239
  // Inlined this operation instead of using a loop
240
- return (val * (10 ** (atoi_fast<u32>(str, offset + 2) + 1))) as T;
240
+ return (val * (10 ** (__atoi_fast<u32>(str, offset + 2, offset + 4) + 1))) as T;
241
241
  }
242
242
  } else {
243
243
  val = (val * 10) + (ch - 48) as T;
@@ -252,34 +252,34 @@ import { backSlashCode, quoteCode } from "./chars";
252
252
  */
253
253
 
254
254
  // @ts-ignore
255
- @inline export function atoi_fast<T extends number>(str: string, offset: u32 = 0): T {
255
+ @global @inline export function __atoi_fast<T extends number>(str: string, start: u32 = 0, end: u32 = 0): T {
256
256
  // @ts-ignore
257
257
  let val: T = 0;
258
- const len = u32(str.length << 1);
258
+ if (!end) end = start + u32(str.length << 1);
259
259
  if (isSigned<T>()) {
260
260
  // Negative path
261
- if (load<u16>(changetype<usize>(str) + <usize>offset) === 45) {
262
- offset += 2;
263
- for (; offset < len; offset += 2) {
264
- val = (val * 10) + (load<u16>(changetype<usize>(str) + <usize>offset) - 48) as T;
261
+ if (load<u16>(changetype<usize>(str) + <usize>start) === 45) {
262
+ start += 2;
263
+ for (; start < end; start += 2) {
264
+ val = (val * 10) + (load<u16>(changetype<usize>(str) + <usize>start) - 48) as T;
265
265
  }
266
266
  return -val as T;
267
267
  } else {
268
- for (; offset < len; offset += 2) {
269
- val = ((val * 10) + (load<u16>(changetype<usize>(str) + <usize>offset) - 48)) as T;
268
+ for (; start < end; start += 2) {
269
+ val = ((val * 10) + (load<u16>(changetype<usize>(str) + <usize>start) - 48)) as T;
270
270
  }
271
271
  return val as T;
272
272
  }
273
273
  } else {
274
- for (; offset < len; offset += 2) {
275
- val = ((val * 10) + (load<u16>(changetype<usize>(str) + <usize>offset) - 48)) as T;
274
+ for (; start < end; start += 2) {
275
+ val = ((val * 10) + (load<u16>(changetype<usize>(str) + <usize>start) - 48)) as T;
276
276
  }
277
277
  return val as T;
278
278
  }
279
279
  }
280
280
 
281
281
  /**
282
- * Parses an integer using atoi_fast and applies the appended exponential number to it as scientific notation.
282
+ * Parses an integer using __atoi_fast and applies the appended exponential number to it as scientific notation.
283
283
  * Benchmark: Hovers around 30m ops/s
284
284
  * Only safe if the string is valid.
285
285
  * @param str integer to parse. example: 123e1, 123e-1, 123E100
@@ -301,12 +301,12 @@ import { backSlashCode, quoteCode } from "./chars";
301
301
  const char = load<u16>(changetype<usize>(str) + <usize>(offset += 2));
302
302
  if (char === 45) {
303
303
  // @ts-ignore
304
- val /= sciNote<T>(atoi_fast<T>(str, (offset += 2)));
304
+ val /= sciNote<T>(__atoi_fast<T>(str, (offset += 2)));
305
305
  // @ts-ignore
306
306
  return val;
307
307
  } else {
308
308
  // @ts-ignore
309
- val *= sciNote<T>(atoi_fast<T>(str, offset));
309
+ val *= sciNote<T>(__atoi_fast<T>(str, offset));
310
310
  // @ts-ignore
311
311
  return val;
312
312
  }
@@ -336,4 +336,15 @@ import { backSlashCode, quoteCode } from "./chars";
336
336
  }
337
337
  // @ts-ignore
338
338
  return res;
339
+ }
340
+
341
+ // @ts-ignore
342
+ @inline function equalsSlice(p1_data: string, p1_start: i32, p1_end: i32, p2_data: string, p2_start: i32, p2_end: i32): boolean {
343
+ const p1_len = p1_end - p1_start;
344
+ const p2_len = p2_end - p2_start;
345
+ if (p1_len != p2_len) return false;
346
+ if (p1_len == 2) {
347
+ return load<u16>(changetype<usize>(p1_data) + p1_start) == load<u16>(changetype<usize>(p2_data) + p2_start)
348
+ }
349
+ return memory.compare(changetype<usize>(p1_data) + p1_start, changetype<usize>(p2_data) + p2_start, p1_len) === 0;
339
350
  }
package/assembly/test.ts CHANGED
@@ -1,6 +1,68 @@
1
- import { JSON } from "./src/json";
1
+ import { bench, blackbox } from "../../../WebAssembly/benchmark-wasm/assembly/bench";
2
+ import { JSON, serializeString } from "./src/json";
3
+ // @ts-ignore
4
+ @json
5
+ class Vec3 {
6
+ x: f64;
7
+ y: f64;
8
+ z: f64;
9
+ }
2
10
 
3
- console.log(JSON.parse<u32>("100").toString());
4
- console.log(JSON.stringify<u32>(100));
5
- console.log(JSON.stringify(JSON.parse<u32>(JSON.stringify(100))))
6
- console.log((100).toString())
11
+ // @ts-ignore
12
+ @json
13
+ class Player {
14
+ firstName: string;
15
+ lastName: string;
16
+ lastActive: i32[];
17
+ age: i32;
18
+ pos: Vec3 | null;
19
+ isVerified: boolean;
20
+ }
21
+
22
+ const vec: Vec3 = {
23
+ x: 3.4,
24
+ y: 1.2,
25
+ z: 8.3,
26
+ }
27
+
28
+ const player: Player = {
29
+ firstName: "Emmet",
30
+ lastName: "West",
31
+ lastActive: [8, 27, 2022],
32
+ age: 23,
33
+ pos: {
34
+ x: 3.4,
35
+ y: 1.2,
36
+ z: 8.3,
37
+ },
38
+ isVerified: true,
39
+ }
40
+
41
+ console.log("Original: " + JSON.stringify(vec));
42
+ //console.log("Revised: " + vec.__JSON_Deserialize('{"x":3,"y":1,"z":8}').__JSON_Serialize());
43
+ console.log("Implemented: " + JSON.stringify(JSON.parse<Vec3>('{"x":3.4,"y":1.2,"z":8.3}')));
44
+
45
+ console.log("Original: " + JSON.stringify(player));
46
+ //console.log("Revised: " + vec.__JSON_Deserialize('{"x":3,"y":1,"z":8}').__JSON_Serialize());
47
+ console.log("Implemented: " + JSON.stringify(JSON.parse<Player>('{"firstName":"Emmet","lastName":"West","lastActive":[8,27,2022],"age":23,"pos":{"x":3.4,"y":1.2,"z":8.3},"isVerified":true}')));
48
+
49
+ console.log("Serialized String: " + serializeString('st"ring" w""ith quotes"'));
50
+
51
+ bench("New Stringify String", () => {
52
+ blackbox<string>(serializeString(blackbox<string>('st"ring" w""ith quotes"')));
53
+ });
54
+ /*
55
+ // 9,325,755
56
+ bench("Stringify Object (Vec3)", () => {
57
+ blackbox<string>(vec.__JSON_Serialize());
58
+ });
59
+
60
+ // 17,747,531 -> 55,517,015
61
+ /*bench("New Parse Object (Vec3)", () => {
62
+ blackbox<Vec3>(vec.__JSON_Deserialize(blackbox<string>('{"x":0,"y":0,"z":0}')));
63
+ });
64
+
65
+ // 17,747,531
66
+ bench("Old Parse Object (Vec3)", () => {
67
+ blackbox<Vec3>(JSON.parse<Vec3>(blackbox<string>('{"x":3.4,"y":1.2,"z":8.3}')));
68
+ });*/
@@ -0,0 +1,206 @@
1
+ import { bench, blackbox } from "../../../WebAssembly/benchmark-wasm/assembly/bench";
2
+ import { __atoi_fast, snip_fast, unsafeCharCodeAt } from "../assembly/src/util";
3
+ import { JSON } from "../assembly";
4
+ import { backSlashCode, commaCode, eCode, fCode, leftBraceCode, leftBracketCode, nCode, nullWord, quoteCode, rCode, rightBraceCode, rightBracketCode, tCode, trueWord, uCode } from "../assembly/src/chars";
5
+ import { isSpace } from "util/string";
6
+ class Vec3 {
7
+ x: i32;
8
+ y: i32;
9
+ z: i32;
10
+ @inline
11
+ __JSON_Serialize(): string {
12
+ return `{"x":${this.x.toString()},"y":${this.y.toString()},"z":${this.z.toString()}}`;
13
+ }
14
+ @inline
15
+ __JSON_Set_Key(key: string, value: string): void {
16
+ if (key == "x") {
17
+ this.x = ____parseObjectValue<i32>(value);
18
+ return;
19
+ }
20
+ if (key == "y") {
21
+ this.y = ____parseObjectValue<i32>(value);
22
+ return;
23
+ }
24
+ if (key == "z") {
25
+ this.z = ____parseObjectValue<i32>(value);
26
+ return;
27
+ }
28
+ }
29
+ @inline
30
+ __JSON_Deserialize(data: string): Vec3 {
31
+ let schema: nonnull<Vec3> = changetype<nonnull<Vec3>>(
32
+ __new(offsetof<nonnull<Vec3>>(), idof<nonnull<Vec3>>())
33
+ );
34
+ let key = "";
35
+ let isKey = false;
36
+ let depth = 0;
37
+ let outerLoopIndex = 1;
38
+ for (; outerLoopIndex < data.length - 1; outerLoopIndex++) {
39
+ const char = unsafeCharCodeAt(data, outerLoopIndex);
40
+ if (char === leftBracketCode) {
41
+ for (
42
+ let arrayValueIndex = outerLoopIndex;
43
+ arrayValueIndex < data.length - 1;
44
+ arrayValueIndex++
45
+ ) {
46
+ const char = unsafeCharCodeAt(data, arrayValueIndex);
47
+ if (char === leftBracketCode) {
48
+ depth++;
49
+ } else if (char === rightBracketCode) {
50
+ depth--;
51
+ if (depth === 0) {
52
+ ++arrayValueIndex;
53
+ // @ts-ignore
54
+ schema.__JSON_Set_Key(
55
+ key,
56
+ data.slice(outerLoopIndex, arrayValueIndex)
57
+ );
58
+ outerLoopIndex = arrayValueIndex;
59
+ isKey = false;
60
+ break;
61
+ }
62
+ }
63
+ }
64
+ } else if (char === leftBraceCode) {
65
+ for (
66
+ let objectValueIndex = outerLoopIndex;
67
+ objectValueIndex < data.length - 1;
68
+ objectValueIndex++
69
+ ) {
70
+ const char = unsafeCharCodeAt(data, objectValueIndex);
71
+ if (char === leftBraceCode) {
72
+ depth++;
73
+ } else if (char === rightBraceCode) {
74
+ depth--;
75
+ if (depth === 0) {
76
+ ++objectValueIndex;
77
+ // @ts-ignore
78
+ schema.__JSON_Set_Key(
79
+ key,
80
+ data.slice(outerLoopIndex, objectValueIndex)
81
+ );
82
+ outerLoopIndex = objectValueIndex;
83
+ isKey = false;
84
+ break;
85
+ }
86
+ }
87
+ }
88
+ } else if (char === quoteCode) {
89
+ for (
90
+ let stringValueIndex = ++outerLoopIndex;
91
+ stringValueIndex < data.length - 1;
92
+ stringValueIndex++
93
+ ) {
94
+ const char = unsafeCharCodeAt(data, stringValueIndex);
95
+ if (
96
+ char === quoteCode &&
97
+ unsafeCharCodeAt(data, stringValueIndex - 1) !== backSlashCode
98
+ ) {
99
+ if (isKey === false) {
100
+ key = data.slice(outerLoopIndex, stringValueIndex);
101
+ isKey = true;
102
+ } else {
103
+ // @ts-ignore
104
+ schema.__JSON_Set_Key(
105
+ key,
106
+ data.slice(outerLoopIndex, stringValueIndex)
107
+ );
108
+ isKey = false;
109
+ }
110
+ outerLoopIndex = ++stringValueIndex;
111
+ break;
112
+ }
113
+ }
114
+ } else if (char == nCode) {
115
+ // @ts-ignore
116
+ schema.__JSON_Set_Key(key, nullWord);
117
+ isKey = false;
118
+ } else if (
119
+ char === tCode &&
120
+ unsafeCharCodeAt(data, ++outerLoopIndex) === rCode &&
121
+ unsafeCharCodeAt(data, ++outerLoopIndex) === uCode &&
122
+ unsafeCharCodeAt(data, ++outerLoopIndex) === eCode
123
+ ) {
124
+ // @ts-ignore
125
+ schema.__JSON_Set_Key(key, trueWord);
126
+ isKey = false;
127
+ } else if (
128
+ char === fCode &&
129
+ unsafeCharCodeAt(data, ++outerLoopIndex) === "a".charCodeAt(0) &&
130
+ unsafeCharCodeAt(data, ++outerLoopIndex) === "l".charCodeAt(0) &&
131
+ unsafeCharCodeAt(data, ++outerLoopIndex) === "s".charCodeAt(0) &&
132
+ unsafeCharCodeAt(data, ++outerLoopIndex) === eCode
133
+ ) {
134
+ // @ts-ignore
135
+ schema.__JSON_Set_Key(key, "false");
136
+ isKey = false;
137
+ } else if ((char >= 48 && char <= 57) || char === 45) {
138
+ let numberValueIndex = ++outerLoopIndex;
139
+ for (; numberValueIndex < data.length; numberValueIndex++) {
140
+ const char = unsafeCharCodeAt(data, numberValueIndex);
141
+ if (char === commaCode || char === rightBraceCode || isSpace(char)) {
142
+ // @ts-ignore
143
+ schema.__JSON_Set_Key(
144
+ key,
145
+ data.slice(outerLoopIndex - 1, numberValueIndex)
146
+ );
147
+ outerLoopIndex = numberValueIndex;
148
+ isKey = false;
149
+ break;
150
+ }
151
+ }
152
+ }
153
+ }
154
+ return schema;
155
+ }
156
+ }
157
+
158
+ const vec: Vec3 = {
159
+ x: 3,
160
+ y: 1,
161
+ z: 8,
162
+ }
163
+ /*
164
+ bench("Parse Number SNIP", () => {
165
+ blackbox<i32>(snip_fast<i32>("12345"));
166
+ });
167
+
168
+ bench("Parse Number ATOI", () => {
169
+ blackbox<i32>(__atoi_fast<i32>("12345"));
170
+ })
171
+
172
+ bench("Parse Number STDLIB", () => {
173
+ blackbox<i32>(i32.parse("12345"));
174
+ });
175
+
176
+ bench("Stringify Object (Vec3)", () => {
177
+ blackbox<string>(vec.__JSON_Serialize());
178
+ });*/
179
+
180
+ bench("Parse Object (Vec3)", () => {
181
+ blackbox<Vec3>(vec.__JSON_Deserialize('{"x":0,"y":0,"z":0}'));
182
+ });
183
+
184
+ bench("Stringify Number Array", () => {
185
+ blackbox<string>(JSON.stringify<i32[]>([1, 2, 3]));
186
+ });
187
+
188
+ bench("Parse Number Array", () => {
189
+ blackbox<i32[]>(JSON.parse<i32[]>(blackbox("[1,2,3]")));
190
+ });
191
+
192
+ bench("Stringify String", () => {
193
+ blackbox<string>(JSON.stringify(blackbox('Hello "World!')));
194
+ });
195
+
196
+ bench("Parse String", () => {
197
+ blackbox<string>(JSON.parse<string>(blackbox('"Hello "World!"')));
198
+ });
199
+
200
+ bench("Stringify Boolean Array", () => {
201
+ blackbox(JSON.stringify<boolean[]>([true, false, true]));
202
+ });
203
+
204
+ bench("Stringify String Array", () => {
205
+ blackbox(JSON.stringify<string[]>(["a", "b", "c"]));
206
+ });
@@ -0,0 +1,99 @@
1
+ {
2
+ "extends": "assemblyscript/std/assembly.json",
3
+ "include": [
4
+ "./**/*.ts"
5
+ ],
6
+ "compilerOptions": {
7
+ /* Visit https://aka.ms/tsconfig to read more about this file */
8
+ /* Projects */
9
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
10
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
11
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
12
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
13
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
14
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
15
+ /* Language and Environment */
16
+ "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
17
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
18
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
19
+ "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
20
+ "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
21
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
22
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
23
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
24
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
25
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
26
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
27
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
28
+ /* Modules */
29
+ "module": "commonjs" /* Specify what module code is generated. */,
30
+ // "rootDir": "./", /* Specify the root folder within your source files. */
31
+ // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
32
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
33
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
34
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
35
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
36
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
37
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
38
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
39
+ // "resolveJsonModule": true, /* Enable importing .json files. */
40
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
41
+ /* JavaScript Support */
42
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
43
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
44
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
45
+ /* Emit */
46
+ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
47
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
48
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
49
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
50
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
51
+ // "outDir": "./", /* Specify an output folder for all emitted files. */
52
+ // "removeComments": true, /* Disable emitting comments. */
53
+ // "noEmit": true, /* Disable emitting files from a compilation. */
54
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
55
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
56
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
57
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
58
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
59
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
60
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
61
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
62
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
63
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
64
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
65
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
66
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
67
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
68
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
69
+ /* Interop Constraints */
70
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
71
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
72
+ "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
73
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
74
+ "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
75
+ /* Type Checking */
76
+ "strict": false /* Enable all strict type-checking options. */,
77
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
78
+ "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
79
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
80
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
81
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
82
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
83
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
84
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
85
+ "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
86
+ "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
87
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
88
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
89
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
90
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
91
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
92
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
93
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
94
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
95
+ /* Completeness */
96
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
97
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
98
+ }
99
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-as",
3
- "version": "0.5.54",
3
+ "version": "0.5.56",
4
4
  "description": "JSON encoder/decoder for AssemblyScript",
5
5
  "types": "assembly/index.ts",
6
6
  "author": "Jairus Tanaka",
@@ -15,30 +15,36 @@
15
15
  "scripts": {
16
16
  "test:aspect": "asp",
17
17
  "bench:astral": "astral --optimizeLevel 3 --shrinkLevel 0 --converge --noAssert --uncheckedBehavior never --runtime stub",
18
- "build:test": "asc assembly/test.ts --target test",
18
+ "build:test": "asc assembly/test.ts -o build/test.wasm --transform ./transform/lib/index.js --config ./node_modules/@assemblyscript/wasi-shim/asconfig.json --optimizeLevel 3 --shrinkLevel 0 --noAssert --uncheckedBehavior always --converge --runtime stub",
19
+ "build:test:debug": "asc assembly/test.ts -o build/test.wasm --transform ./transform --config ./node_modules/@assemblyscript/wasi-shim/asconfig.json --optimizeLevel 0 --shrinkLevel 0 --noAssert --uncheckedBehavior always --runtime stub",
20
+ "build:bench": "asc bench/benchmark.ts -o bench/benchmark.wasm --transform ./transform --config ./node_modules/@assemblyscript/wasi-shim/asconfig.json --optimizeLevel 3 --shrinkLevel 0 --converge --noAssert --uncheckedBehavior always --runtime stub",
21
+ "bench:wasmtime": "wasmtime ./bench/benchmark.wasm",
22
+ "bench:wavm": "wavm run ./bench/benchmark.wasm",
19
23
  "build:transform": "tsc -p ./transform",
20
24
  "test:wasmtime": "wasmtime ./build/test.wasm",
25
+ "test:wavm": "wavm run ./build/test.wasm",
21
26
  "test:lunatic": "lunatic ./build/test.wasm",
22
27
  "test:wasm3": "wasm3 ./build/test.wasm",
23
28
  "prettier": "as-prettier -w ."
24
29
  },
25
30
  "devDependencies": {
26
31
  "@as-pect/cli": "^8.0.1",
27
- "@as-tral/cli": "^2.0.0",
32
+ "@as-tral/cli": "^2.0.1",
28
33
  "@assemblyscript/wasi-shim": "^0.1.0",
29
- "assemblyscript": "^0.27.8",
34
+ "assemblyscript": "^0.27.9",
30
35
  "assemblyscript-prettier": "^2.0.2",
31
36
  "benchmark": "^2.1.4",
32
37
  "kati": "^0.6.2",
33
38
  "microtime": "^3.1.1",
34
- "prettier": "^3.0.1",
39
+ "prettier": "^3.0.2",
35
40
  "tinybench": "^2.5.0",
36
41
  "typescript": "^5.1.6",
37
42
  "visitor-as": "^0.11.4"
38
43
  },
39
44
  "dependencies": {
40
45
  "as-string-sink": "^0.5.3",
41
- "as-variant": "^0.4.1"
46
+ "as-variant": "^0.4.1",
47
+ "as-virtual": "^0.1.8"
42
48
  },
43
49
  "repository": {
44
50
  "type": "git",