json-as 1.0.0-alpha.1 → 1.0.0-alpha.3

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.
Files changed (57) hide show
  1. package/.gitmodules +0 -0
  2. package/.prettierignore +6 -0
  3. package/.prettierrc.json +0 -1
  4. package/CHANGELOG +20 -1
  5. package/README.md +4 -3
  6. package/as-test.config.json +1 -1
  7. package/asconfig.json +1 -29
  8. package/assembly/__benches__/misc.bench.ts +0 -19
  9. package/assembly/__tests__/array.spec.ts +67 -0
  10. package/assembly/__tests__/bool.spec.ts +4 -12
  11. package/assembly/__tests__/float.spec.ts +11 -21
  12. package/assembly/__tests__/integer.spec.ts +7 -9
  13. package/assembly/__tests__/null.spec.ts +12 -0
  14. package/assembly/__tests__/obj.spec.ts +137 -3
  15. package/assembly/__tests__/simd/string.spec.ts +21 -21
  16. package/assembly/__tests__/string.spec.ts +6 -4
  17. package/assembly/__tests__/test.spec.ts +120 -191
  18. package/assembly/deserialize/simple/bool.ts +1 -1
  19. package/assembly/deserialize/simple/map.ts +1 -1
  20. package/assembly/deserialize/simple/object.ts +2 -3
  21. package/assembly/deserialize/simple/string.ts +4 -3
  22. package/assembly/globals/tables.ts +74 -416
  23. package/assembly/index.ts +20 -25
  24. package/assembly/serialize/simd/string.ts +11 -11
  25. package/assembly/serialize/simple/array.ts +5 -5
  26. package/assembly/serialize/simple/bool.ts +3 -3
  27. package/assembly/serialize/simple/date.ts +2 -2
  28. package/assembly/serialize/simple/float.ts +2 -2
  29. package/assembly/serialize/simple/integer.ts +2 -2
  30. package/assembly/serialize/simple/map.ts +7 -7
  31. package/assembly/serialize/simple/string.ts +5 -5
  32. package/assembly/test.ts +4 -48
  33. package/assembly/util/bytes.ts +1 -1
  34. package/modules/as-bs/LICENSE +21 -0
  35. package/modules/as-bs/README.md +95 -0
  36. package/modules/as-bs/assembly/index.ts +116 -0
  37. package/modules/as-bs/assembly/tsconfig.json +97 -0
  38. package/modules/as-bs/index.ts +1 -0
  39. package/modules/as-bs/package.json +32 -0
  40. package/modules/test/assembly/index.ts +22 -0
  41. package/package.json +5 -10
  42. package/run-tests.sh +15 -0
  43. package/transform/lib/builder.js +1262 -1340
  44. package/transform/lib/index.js +512 -572
  45. package/transform/lib/index.js.map +1 -1
  46. package/transform/lib/linker.js +10 -12
  47. package/transform/lib/types.js +19 -18
  48. package/transform/lib/types.js.map +1 -1
  49. package/transform/lib/util.js +34 -34
  50. package/transform/lib/visitor.js +526 -529
  51. package/transform/package.json +2 -1
  52. package/transform/src/index.ts +20 -9
  53. package/transform/src/types.ts +1 -0
  54. package/modules/bs/index.ts +0 -167
  55. package/modules/tsconfig.json +0 -8
  56. package/transform/lib/index.old.js +0 -404
  57. package/transform/lib/index.old.js.map +0 -1
@@ -1,417 +1,75 @@
1
1
  export const SERIALIZE_ESCAPE_TABLE = memory.data<u16>([
2
- 48,
3
- 48,
4
- 48,
5
- 49,
6
- 48,
7
- 50,
8
- 48,
9
- 51, // Pair 0-3
10
- 48,
11
- 52,
12
- 48,
13
- 53,
14
- 48,
15
- 54,
16
- 48,
17
- 55, // Pair 4-7
18
-
19
- 92,
20
- 98,
21
- 92,
22
- 116,
23
- 92,
24
- 110,
25
- 48,
26
- 98, // Pair 8-11
27
- 92,
28
- 102,
29
- 92,
30
- 114,
31
- 48,
32
- 101,
33
- 48,
34
- 102, // Pair 12-15
35
-
36
- 49,
37
- 48,
38
- 49,
39
- 49,
40
- 49,
41
- 50,
42
- 49,
43
- 51, // Pair 16-19
44
- 49,
45
- 52,
46
- 49,
47
- 53,
48
- 49,
49
- 54,
50
- 49,
51
- 55, // Pair 20-23
52
-
53
- 49,
54
- 56,
55
- 49,
56
- 57,
57
- 49,
58
- 97,
59
- 49,
60
- 98, // Pair 24-27
61
- 49,
62
- 99,
63
- 49,
64
- 100,
65
- 49,
66
- 101,
67
- 49,
68
- 102, // Pair 28-31
69
-
70
- 0,
71
- 0,
72
- 0,
73
- 0,
74
- 92,
75
- 34,
76
- 0,
77
- 0, // Pair 32-35
78
- 0,
79
- 0,
80
- 0,
81
- 0,
82
- 0,
83
- 0,
84
- 0,
85
- 0, // Pair 36-39
86
-
87
- 0,
88
- 0,
89
- 0,
90
- 0,
91
- 0,
92
- 0,
93
- 0,
94
- 0, // Pair 40-43
95
- 0,
96
- 0,
97
- 0,
98
- 0,
99
- 0,
100
- 0,
101
- 0,
102
- 0, // Pair 44-47
103
-
104
- 0,
105
- 0,
106
- 0,
107
- 0,
108
- 0,
109
- 0,
110
- 0,
111
- 0, // Pair 48-51
112
- 0,
113
- 0,
114
- 0,
115
- 0,
116
- 0,
117
- 0,
118
- 0,
119
- 0, // Pair 52-55
120
-
121
- 0,
122
- 0,
123
- 0,
124
- 0,
125
- 0,
126
- 0,
127
- 0,
128
- 0, // Pair 56-59
129
- 0,
130
- 0,
131
- 0,
132
- 0,
133
- 0,
134
- 0,
135
- 0,
136
- 0, // Pair 60-63
137
-
138
- 0,
139
- 0,
140
- 0,
141
- 0,
142
- 0,
143
- 0,
144
- 0,
145
- 0, // Pair 64-67
146
- 0,
147
- 0,
148
- 0,
149
- 0,
150
- 0,
151
- 0,
152
- 0,
153
- 0, // Pair 68-71
154
-
155
- 0,
156
- 0,
157
- 0,
158
- 0,
159
- 0,
160
- 0,
161
- 0,
162
- 0, // Pair 72-75
163
- 0,
164
- 0,
165
- 0,
166
- 0,
167
- 0,
168
- 0,
169
- 0,
170
- 0, // Pair 76-79
171
-
172
- 0,
173
- 0,
174
- 0,
175
- 0,
176
- 0,
177
- 0,
178
- 0,
179
- 0, // Pair 80-83
180
- 0,
181
- 0,
182
- 0,
183
- 0,
184
- 0,
185
- 0,
186
- 0,
187
- 0, // Pair 84-87
188
-
189
- 0,
190
- 0,
191
- 0,
192
- 0,
193
- 0,
194
- 0,
195
- 0,
196
- 0, // Pair 88-91
197
- 92,
198
- 92, // Pair 92-93
199
- ]);
200
-
201
- export const DESERIALIZE_ESCAPE_TABLE = memory.data<u8>([
202
- 0,
203
- 0,
204
- 0,
205
- 0,
206
- 0,
207
- 0,
208
- 0,
209
- 0, // 0-7
210
- 0,
211
- 0,
212
- 0,
213
- 0,
214
- 0,
215
- 0,
216
- 0,
217
- 0, // 8-15
218
- 0,
219
- 0,
220
- 0,
221
- 0,
222
- 0,
223
- 0,
224
- 0,
225
- 0, // 16-23
226
- 0,
227
- 0,
228
- 0,
229
- 0,
230
- 0,
231
- 0,
232
- 0,
233
- 0, // 24-31
234
- 0,
235
- 0,
236
- 34,
237
- 0,
238
- 0,
239
- 0,
240
- 0,
241
- 0, // 32-39
242
- 0,
243
- 0,
244
- 0,
245
- 0,
246
- 0,
247
- 0,
248
- 0,
249
- 0, // 40-47
250
- 0,
251
- 0,
252
- 0,
253
- 0,
254
- 0,
255
- 0,
256
- 0,
257
- 0, // 48-55
258
- 0,
259
- 0,
260
- 0,
261
- 0,
262
- 0,
263
- 0,
264
- 0,
265
- 0, // 56-63
266
- 0,
267
- 0,
268
- 0,
269
- 0,
270
- 0,
271
- 0,
272
- 0,
273
- 0, // 64-71
274
- 0,
275
- 0,
276
- 0,
277
- 0,
278
- 0,
279
- 0,
280
- 0,
281
- 0, // 72-79
282
- 0,
283
- 0,
284
- 0,
285
- 0,
286
- 0,
287
- 0,
288
- 0,
289
- 0, // 80-87
290
- 0,
291
- 0,
292
- 0,
293
- 0,
294
- 92,
295
- 0,
296
- 0,
297
- 0, // 88-95
298
- 0,
299
- 0,
300
- 8,
301
- 0,
302
- 0,
303
- 0,
304
- 12,
305
- 0, // 96-103
306
- 0,
307
- 0,
308
- 0,
309
- 0,
310
- 0,
311
- 0,
312
- 10,
313
- 0, // 104-111
314
- 0,
315
- 0,
316
- 13,
317
- 0,
318
- 9,
319
- 117,
320
- 0,
321
- 0, // 112-119
322
- 0,
323
- 0,
324
- 0,
325
- 0,
326
- 0,
327
- 0,
328
- 0,
329
- 0, // 120-127
330
- 0,
331
- 0,
332
- 0,
333
- 0,
334
- 0,
335
- 0,
336
- 0,
337
- 0, // 128-135
338
- 0,
339
- 0,
340
- 0,
341
- 0,
342
- 0,
343
- 0,
344
- 0,
345
- 0, // 136-143
346
- 0,
347
- 0,
348
- 0,
349
- 0,
350
- 0,
351
- 0,
352
- 0,
353
- 0, // 144-151
354
- ]);
355
-
356
- export const ESCAPE_HEX_TABLE =
357
- memory.data<u8>([
358
- 0,
359
- 1,
360
- 2,
361
- 3,
362
- 4,
363
- 5,
364
- 6,
365
- 7, // 0-7
366
- 8,
367
- 9,
368
- 0,
369
- 0,
370
- 0,
371
- 0,
372
- 0,
373
- 0, // 8-15
374
- 0,
375
- 0,
376
- 0,
377
- 0,
378
- 0,
379
- 0,
380
- 0,
381
- 0, // 16-23
382
- 0,
383
- 0,
384
- 0,
385
- 0,
386
- 0,
387
- 0,
388
- 0,
389
- 0, // 24-31
390
- 0,
391
- 0,
392
- 0,
393
- 0,
394
- 0,
395
- 0,
396
- 0,
397
- 0, // 32-39
398
- 0,
399
- 0,
400
- 0,
401
- 0,
402
- 0,
403
- 0,
404
- 0,
405
- 0, // 40-47
406
- 0,
407
- 10,
408
- 11,
409
- 12,
410
- 13,
411
- 14,
412
- 15, // 48-54
413
- ]) - 48;
414
-
415
- export const POW_TEN_TABLE_32 = memory.data<u32>([1, 10, 1_000, 10_000, 100_000, 1_000_000, 10_000_000, 100_000_000, 1_000_000_000]);
416
-
417
- export const POW_TEN_TABLE_64 = memory.data<u64>([1, 10, 1_000, 10_000, 100_000, 1_000_000, 10_000_000, 100_000_000, 1_000_000_000, 10_000_000_000, 100_000_000_000, 1_000_000_000_000, 10_000_000_000_000, 100_000_000_000_000, 1_000_000_000_000_000, 10_000_000_000_000_000, 100_000_000_000_000_000, 1_000_000_000_000_000_000, 10_000_000_000_000_000_000]);
2
+ 48, 48, 48, 49, 48, 50, 48, 51, // Pair 0-3
3
+ 48, 52, 48, 53, 48, 54, 48, 55, // Pair 4-7
4
+
5
+ 92, 98, 92, 116, 92, 110, 48, 98, // Pair 8-11
6
+ 92, 102, 92, 114, 48, 101, 48, 102, // Pair 12-15
7
+
8
+ 49, 48, 49, 49, 49, 50, 49, 51, // Pair 16-19
9
+ 49, 52, 49, 53, 49, 54, 49, 55, // Pair 20-23
10
+
11
+ 49, 56, 49, 57, 49, 97, 49, 98, // Pair 24-27
12
+ 49, 99, 49, 100, 49, 101, 49, 102, // Pair 28-31
13
+
14
+ 0, 0, 0, 0, 92, 34, 0, 0, // Pair 32-35
15
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 36-39
16
+
17
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 40-43
18
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 44-47
19
+
20
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 48-51
21
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 52-55
22
+
23
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 56-59
24
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 60-63
25
+
26
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 64-67
27
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 68-71
28
+
29
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 72-75
30
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 76-79
31
+
32
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 80-83
33
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 84-87
34
+
35
+ 0, 0, 0, 0, 0, 0, 0, 0, // Pair 88-91
36
+ 92, 92, // Pair 92-93
37
+ ]);
38
+
39
+ export const DESERIALIZE_ESCAPE_TABLE = memory.data<u8>([
40
+ 0, 0, 0, 0, 0, 0, 0, 0, // 0-7
41
+ 0, 0, 0, 0, 0, 0, 0, 0, // 8-15
42
+ 0, 0, 0, 0, 0, 0, 0, 0, // 16-23
43
+ 0, 0, 0, 0, 0, 0, 0, 0, // 24-31
44
+ 0, 0, 34, 0, 0, 0, 0, 0, // 32-39
45
+ 0, 0, 0, 0, 0, 0, 0, 0, // 40-47
46
+ 0, 0, 0, 0, 0, 0, 0, 0, // 48-55
47
+ 0, 0, 0, 0, 0, 0, 0, 0, // 56-63
48
+ 0, 0, 0, 0, 0, 0, 0, 0, // 64-71
49
+ 0, 0, 0, 0, 0, 0, 0, 0, // 72-79
50
+ 0, 0, 0, 0, 0, 0, 0, 0, // 80-87
51
+ 0, 0, 0, 0, 92, 0, 0, 0, // 88-95
52
+ 0, 0, 8, 0, 0, 0, 12, 0, // 96-103
53
+ 0, 0, 0, 0, 0, 0, 10, 0, // 104-111
54
+ 0, 0, 13, 0, 9, 117, 0, 0, // 112-119
55
+ 0, 0, 0, 0, 0, 0, 0, 0, // 120-127
56
+ 0, 0, 0, 0, 0, 0, 0, 0, // 128-135
57
+ 0, 0, 0, 0, 0, 0, 0, 0, // 136-143
58
+ 0, 0, 0, 0, 0, 0, 0, 0, // 144-151
59
+ ]);
60
+
61
+ export const ESCAPE_HEX_TABLE =
62
+ memory.data<u8>([
63
+ 0, 1, 2, 3, 4, 5, 6, 7, // 0-7
64
+ 8, 9, 0, 0, 0, 0, 0, 0, // 8-15
65
+ 0, 0, 0, 0, 0, 0, 0, 0, // 16-23
66
+ 0, 0, 0, 0, 0, 0, 0, 0, // 24-31
67
+ 0, 0, 0, 0, 0, 0, 0, 0, // 32-39
68
+ 0, 0, 0, 0, 0, 0, 0, 0, // 40-47
69
+ 0, 10, 11, 12, 13, 14, 15, // 48-54
70
+ ]) - 48;
71
+
72
+ export const POW_TEN_TABLE_32 = memory.data<u32>([1, 10, 1_000, 10_000, 100_000, 1_000_000, 10_000_000, 100_000_000, 1_000_000_000]);
73
+
74
+ export const POW_TEN_TABLE_64 = memory.data<u64>([1, 10, 1_000, 10_000, 100_000, 1_000_000, 10_000_000, 100_000_000, 1_000_000_000, 10_000_000_000, 100_000_000_000, 1_000_000_000_000, 10_000_000_000_000, 100_000_000_000_000, 1_000_000_000_000_000, 10_000_000_000_000_000, 100_000_000_000_000_000, 1_000_000_000_000_000_000, 10_000_000_000_000_000_000]);
75
+
package/assembly/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference path="./index.d.ts" />
2
- import { bs } from "../modules/bs";
2
+ import { bs } from "../modules/as-bs";
3
3
 
4
4
  import { serializeString } from "./serialize/simple/string";
5
5
  import { serializeArray } from "./serialize/simple/array";
@@ -23,7 +23,6 @@ import { serializeFloat } from "./serialize/simple/float";
23
23
  import { serializeObject } from "./serialize/simple/object";
24
24
  import { ptrToStr } from "./util/ptrToStr";
25
25
  import { bytes } from "./util";
26
- import { serializeString_SIMD } from "./serialize/simd/string";
27
26
 
28
27
  export type Raw = string;
29
28
 
@@ -94,23 +93,23 @@ export namespace JSON {
94
93
  return NULL_WORD;
95
94
  // @ts-ignore
96
95
  } else if (isString<nonnull<T>>()) {
97
- if (out) {
98
- out = changetype<string>(__renew(changetype<usize>(out), bytes(data) + 4));
99
- // const oldSize = bs.byteLength;
100
- const oldBuf = bs.buffer;
101
- const newSize = bytes(data) + 4;
102
- const newBuf = __new(newSize, idof<string>());
103
- bs.setBuffer(newBuf);
104
- serializeString(changetype<string>(data));
105
- bs.setBuffer(oldBuf);
106
- return changetype<string>(newBuf);
107
- }
96
+ // if (out) {
97
+ // out = changetype<string>(__renew(changetype<usize>(out), bytes(data) + 4));
98
+ // // const oldSize = bs.byteLength;
99
+ // const oldBuf = bs.buffer;
100
+ // const newSize = bytes(data) + 4;
101
+ // const newBuf = __new(newSize, idof<string>());
102
+ // bs.setBuffer(newBuf);
103
+ // serializeString(changetype<string>(data));
104
+ // bs.setBuffer(oldBuf);
105
+ // return changetype<string>(newBuf);
106
+ // }
108
107
  serializeString(changetype<string>(data));
109
108
  return bs.out<string>();
110
109
  // @ts-ignore: Supplied by transform
111
110
  } else if (isDefined(data.__SERIALIZE) && isDefined(data.__ALLOCATE)) {
112
111
  // @ts-ignore
113
- data.__ALLOCATE();
112
+ // data.__ALLOCATE();
114
113
  // @ts-ignore
115
114
  data.__SERIALIZE(changetype<usize>(data));
116
115
  return bs.out<string>();
@@ -136,7 +135,7 @@ export namespace JSON {
136
135
  } else if (data instanceof JSON.Box) {
137
136
  return JSON.stringify(data.value);
138
137
  } else {
139
- ERROR(`Could not serialize data of type ${nameof<T>()}. Make sure to add the correct decorators to classes.`);
138
+ throw new Error(`Could not serialize data of type ${nameof<T>()}. Make sure to add the correct decorators to classes.`);
140
139
  }
141
140
  }
142
141
 
@@ -162,7 +161,7 @@ export namespace JSON {
162
161
  return null;
163
162
  } else if (isString<T>()) {
164
163
  // @ts-ignore
165
- return deserializeString(dataPtr, dataPtr + dataSize);
164
+ return deserializeString(dataPtr, dataPtr + dataSize, __new(dataSize - 4, idof<string>()));
166
165
  } else if (isArray<T>()) {
167
166
  // @ts-ignore
168
167
  return deserializeArray<nonnull<T>>(dataPtr, dataPtr + dataSize, changetype<usize>(instantiate<T>()));
@@ -185,7 +184,7 @@ export namespace JSON {
185
184
  // @ts-ignore
186
185
  return new JSON.Box(JSON.parse<indexof<T>>(data));
187
186
  } else {
188
- ERROR(`Could not deserialize data ${data} to type ${nameof<T>()}. Make sure to add the correct decorators to classes.`);
187
+ throw new Error(`Could not deserialize data ${data} to type ${nameof<T>()}. Make sure to add the correct decorators to classes.`);
189
188
  }
190
189
  }
191
190
 
@@ -360,7 +359,7 @@ export namespace JSON {
360
359
  if (isBoolean<T>()) {
361
360
  serializeBool(src as bool);
362
361
  } else if (isInteger<T>() && nameof<T>() == "usize" && src == 0) {
363
- bs.ensureSize(8);
362
+ bs.proposeSize(8);
364
363
  store<u64>(bs.offset, 30399761348886638);
365
364
  bs.offset += 8;
366
365
  } else if (isInteger<T>()) {
@@ -371,15 +370,11 @@ export namespace JSON {
371
370
  serializeFloat<T>(src);
372
371
  // @ts-ignore: Function is generated by transform
373
372
  } else if (isNullable<T>() && changetype<usize>(src) == <usize>0) {
374
- bs.ensureSize(8);
373
+ bs.proposeSize(8);
375
374
  store<u64>(bs.offset, 30399761348886638);
376
375
  bs.offset += 8;
377
376
  } else if (isString<nonnull<T>>()) {
378
- if (ASC_FEATURE_SIMD) {
379
- serializeString_SIMD(src as string);
380
- } else {
381
- serializeString(src as string);
382
- }
377
+ serializeString(src as string);
383
378
  // @ts-ignore: Supplied by transform
384
379
  } else if (isDefined(src.__SERIALIZE)) {
385
380
  // @ts-ignore
@@ -398,7 +393,7 @@ export namespace JSON {
398
393
  } else if (src instanceof JSON.Box) {
399
394
  __serialize(src.value);
400
395
  } else {
401
- ERROR(`Could not serialize provided data. Make sure to add the correct decorators to classes.`);
396
+ throw new Error(`Could not serialize provided data. Make sure to add the correct decorators to classes.`);
402
397
  }
403
398
  }
404
399
  export function __deserialize<T>(srcStart: usize, srcEnd: usize, dst: usize = 0): T {
@@ -1,4 +1,4 @@
1
- import { bs } from "../../../modules/bs";
1
+ import { bs } from "../../../modules/as-bs";
2
2
  import { BACK_SLASH } from "../../custom/chars";
3
3
  import { SERIALIZE_ESCAPE_TABLE } from "../../globals/tables";
4
4
  import { OBJECT, TOTAL_OVERHEAD } from "rt/common";
@@ -45,13 +45,13 @@ export function serializeString_SIMD(src: string): void {
45
45
  mask &= mask - 1;
46
46
 
47
47
  if ((escaped & 0xffff) != BACK_SLASH) {
48
- bs.ensureSize(10);
48
+ bs.addSize(10);
49
49
  store<u64>(dst_offset, 13511005048209500);
50
50
  store<u32>(dst_offset, escaped, 8);
51
51
  v128.store(dst_offset, v128.load(src_offset, 2), 12);
52
52
  bs.offset += 10;
53
53
  } else {
54
- bs.ensureSize(2);
54
+ bs.addSize(2);
55
55
  store<u32>(dst_offset, escaped);
56
56
  v128.store(dst_offset, v128.load(src_offset, 2), 4);
57
57
  bs.offset += 2;
@@ -84,7 +84,7 @@ export function serializeString_SIMD(src: string): void {
84
84
  mask &= mask - 1;
85
85
 
86
86
  if ((escaped & 0xffff) != BACK_SLASH) {
87
- bs.ensureSize(10);
87
+ bs.addSize(10);
88
88
  store<u64>(dst_offset, 13511005048209500);
89
89
  store<u32>(dst_offset, escaped, 8);
90
90
  while (lane_index < 6) {
@@ -93,7 +93,7 @@ export function serializeString_SIMD(src: string): void {
93
93
  }
94
94
  bs.offset += 10;
95
95
  } else {
96
- bs.ensureSize(2);
96
+ bs.addSize(2);
97
97
  store<u32>(dst_offset, escaped);
98
98
 
99
99
  while (lane_index < 6) {
@@ -116,12 +116,12 @@ export function serializeString_SIMD(src: string): void {
116
116
  const escaped = load<u32>(SERIALIZE_ESCAPE_TABLE + (codeA << 2));
117
117
 
118
118
  if ((escaped & 0xffff) != BACK_SLASH) {
119
- bs.ensureSize(10);
119
+ bs.addSize(10);
120
120
  store<u64>(bs.offset, 13511005048209500);
121
121
  store<u32>(bs.offset, escaped, 8);
122
122
  bs.offset += 12;
123
123
  } else {
124
- bs.ensureSize(2);
124
+ bs.addSize(2);
125
125
  store<u32>(bs.offset, escaped);
126
126
  bs.offset += 4;
127
127
  }
@@ -134,12 +134,12 @@ export function serializeString_SIMD(src: string): void {
134
134
  const escaped = load<u32>(SERIALIZE_ESCAPE_TABLE + (codeB << 2));
135
135
 
136
136
  if ((escaped & 0xffff) != BACK_SLASH) {
137
- bs.ensureSize(10);
137
+ bs.addSize(10);
138
138
  store<u64>(bs.offset, 13511005048209500);
139
139
  store<u32>(bs.offset, escaped, 8);
140
140
  bs.offset += 12;
141
141
  } else {
142
- bs.ensureSize(2);
142
+ bs.addSize(2);
143
143
  store<u32>(bs.offset, escaped);
144
144
  bs.offset += 4;
145
145
  }
@@ -156,12 +156,12 @@ export function serializeString_SIMD(src: string): void {
156
156
  const escaped = load<u32>(SERIALIZE_ESCAPE_TABLE + (code << 2));
157
157
 
158
158
  if ((escaped & 0xffff) != BACK_SLASH) {
159
- bs.ensureSize(10);
159
+ bs.addSize(10);
160
160
  store<u64>(bs.offset, 13511005048209500);
161
161
  store<u32>(bs.offset, escaped, 8);
162
162
  bs.offset += 12;
163
163
  } else {
164
- bs.ensureSize(2);
164
+ bs.addSize(2);
165
165
  store<u32>(bs.offset, escaped);
166
166
  bs.offset += 4;
167
167
  }