seroval 0.4.0-alpha.11 → 0.4.0-alpha.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/dist/cjs/development/index.cjs +694 -708
- package/dist/cjs/development/index.cjs.map +4 -4
- package/dist/cjs/production/index.cjs +2 -2
- package/dist/esm/development/index.mjs +696 -708
- package/dist/esm/development/index.mjs.map +4 -4
- package/dist/esm/production/index.mjs +2 -2
- package/dist/types/context.d.ts +11 -11
- package/dist/types/tree/primitives.d.ts +1 -10
- package/dist/types/tree/types.d.ts +57 -38
- package/package.json +2 -2
- package/src/context.ts +37 -39
- package/src/index.ts +8 -9
- package/src/tree/async.ts +298 -366
- package/src/tree/primitives.ts +7 -143
- package/src/tree/sync.ts +266 -326
- package/src/tree/types.ts +202 -53
|
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
7
|
var __export = (target, all) => {
|
|
7
8
|
for (var name in all)
|
|
8
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
17
|
return to;
|
|
17
18
|
};
|
|
18
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var __publicField = (obj, key, value) => {
|
|
21
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
22
|
+
return value;
|
|
23
|
+
};
|
|
19
24
|
|
|
20
25
|
// src/index.ts
|
|
21
26
|
var src_exports = {};
|
|
@@ -275,25 +280,33 @@ function getIdentifier(index) {
|
|
|
275
280
|
var DEFAULT_OPTIONS = {
|
|
276
281
|
target: "es2023"
|
|
277
282
|
};
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
markedRefs
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
validRefs
|
|
292
|
-
refSize
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
283
|
+
var ParserContext = class {
|
|
284
|
+
constructor(options = {}) {
|
|
285
|
+
__publicField(this, "refs", /* @__PURE__ */ new Map());
|
|
286
|
+
__publicField(this, "markedRefs", {});
|
|
287
|
+
__publicField(this, "features");
|
|
288
|
+
const result = Object.assign({}, DEFAULT_OPTIONS, options || {});
|
|
289
|
+
this.features = parseTargets(result.target);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
var SerializationContext = class {
|
|
293
|
+
constructor(options) {
|
|
294
|
+
__publicField(this, "stack", []);
|
|
295
|
+
// Map tree refs to actual refs
|
|
296
|
+
__publicField(this, "validRefs", []);
|
|
297
|
+
__publicField(this, "refSize", 0);
|
|
298
|
+
// Variables
|
|
299
|
+
__publicField(this, "vars", []);
|
|
300
|
+
// Array of assignments to be done (used for recursion)
|
|
301
|
+
__publicField(this, "assignments", []);
|
|
302
|
+
// Supported features
|
|
303
|
+
__publicField(this, "features");
|
|
304
|
+
// Refs that are...referenced
|
|
305
|
+
__publicField(this, "markedRefs");
|
|
306
|
+
this.features = options.features;
|
|
307
|
+
this.markedRefs = options.markedRefs;
|
|
308
|
+
}
|
|
309
|
+
};
|
|
297
310
|
function markRef(ctx, current) {
|
|
298
311
|
ctx.markedRefs[current] = 1;
|
|
299
312
|
}
|
|
@@ -377,119 +390,198 @@ function quote(str) {
|
|
|
377
390
|
return `"${result}"`;
|
|
378
391
|
}
|
|
379
392
|
|
|
393
|
+
// src/tree/types.ts
|
|
394
|
+
var SerovalObjectRecordNode = class {
|
|
395
|
+
constructor(k, v, s) {
|
|
396
|
+
__publicField(this, "k");
|
|
397
|
+
__publicField(this, "v");
|
|
398
|
+
__publicField(this, "s");
|
|
399
|
+
this.k = k;
|
|
400
|
+
this.v = v;
|
|
401
|
+
this.s = s;
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
var SerovalMapRecordNode = class {
|
|
405
|
+
constructor(k, v, s) {
|
|
406
|
+
__publicField(this, "k");
|
|
407
|
+
__publicField(this, "v");
|
|
408
|
+
__publicField(this, "s");
|
|
409
|
+
this.k = k;
|
|
410
|
+
this.v = v;
|
|
411
|
+
this.s = s;
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
var SerovalPrimitiveNode = class {
|
|
415
|
+
constructor(current) {
|
|
416
|
+
__publicField(this, "t", 0 /* Primitive */);
|
|
417
|
+
__publicField(this, "s");
|
|
418
|
+
this.s = current;
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
var SerovalReferenceNode = class {
|
|
422
|
+
constructor(id) {
|
|
423
|
+
__publicField(this, "t", 2 /* Reference */);
|
|
424
|
+
__publicField(this, "i");
|
|
425
|
+
this.i = id;
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
var SerovalBigIntNode = class {
|
|
429
|
+
constructor(current) {
|
|
430
|
+
__publicField(this, "t", 1 /* BigInt */);
|
|
431
|
+
__publicField(this, "s");
|
|
432
|
+
this.s = `${current}n`;
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
var SerovalDateNode = class {
|
|
436
|
+
constructor(id, current) {
|
|
437
|
+
__publicField(this, "t", 3 /* Date */);
|
|
438
|
+
__publicField(this, "i");
|
|
439
|
+
__publicField(this, "s");
|
|
440
|
+
this.i = id;
|
|
441
|
+
this.s = current.toISOString();
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
var SerovalRegExpNode = class {
|
|
445
|
+
constructor(id, current) {
|
|
446
|
+
__publicField(this, "t", 4 /* RegExp */);
|
|
447
|
+
__publicField(this, "i");
|
|
448
|
+
__publicField(this, "s");
|
|
449
|
+
this.i = id;
|
|
450
|
+
this.s = String(current);
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
var SerovalTypedArrayNode = class {
|
|
454
|
+
constructor(id, current) {
|
|
455
|
+
__publicField(this, "t", 14 /* TypedArray */);
|
|
456
|
+
__publicField(this, "i");
|
|
457
|
+
__publicField(this, "s");
|
|
458
|
+
__publicField(this, "l");
|
|
459
|
+
__publicField(this, "c");
|
|
460
|
+
this.i = id;
|
|
461
|
+
this.s = current.toString();
|
|
462
|
+
this.l = current.byteOffset;
|
|
463
|
+
this.c = current.constructor.name;
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
var SerovalBigIntTypedArrayNode = class {
|
|
467
|
+
constructor(id, current) {
|
|
468
|
+
__publicField(this, "t", 15 /* BigIntTypedArray */);
|
|
469
|
+
__publicField(this, "i");
|
|
470
|
+
__publicField(this, "s");
|
|
471
|
+
__publicField(this, "l");
|
|
472
|
+
__publicField(this, "c");
|
|
473
|
+
let result = "";
|
|
474
|
+
const cap = current.length - 1;
|
|
475
|
+
for (let i = 0; i < cap; i++) {
|
|
476
|
+
result += `${current[i]}n,`;
|
|
477
|
+
}
|
|
478
|
+
result += `"${current[cap]}"`;
|
|
479
|
+
this.i = id;
|
|
480
|
+
this.s = result;
|
|
481
|
+
this.l = current.byteOffset;
|
|
482
|
+
this.c = current.constructor.name;
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
var SerovalSetNode = class {
|
|
486
|
+
constructor(id, a) {
|
|
487
|
+
__publicField(this, "t", 5 /* Set */);
|
|
488
|
+
__publicField(this, "i");
|
|
489
|
+
__publicField(this, "a");
|
|
490
|
+
this.i = id;
|
|
491
|
+
this.a = a;
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
var SerovalMapNode = class {
|
|
495
|
+
constructor(id, d) {
|
|
496
|
+
__publicField(this, "t", 6 /* Map */);
|
|
497
|
+
__publicField(this, "i");
|
|
498
|
+
__publicField(this, "d");
|
|
499
|
+
this.i = id;
|
|
500
|
+
this.d = d;
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
var SerovalArrayNode = class {
|
|
504
|
+
constructor(id, a) {
|
|
505
|
+
__publicField(this, "t", 7 /* Array */);
|
|
506
|
+
__publicField(this, "i");
|
|
507
|
+
__publicField(this, "a");
|
|
508
|
+
this.i = id;
|
|
509
|
+
this.a = a;
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
var SerovalObjectNode = class {
|
|
513
|
+
constructor(id, d) {
|
|
514
|
+
__publicField(this, "t", 8 /* Object */);
|
|
515
|
+
__publicField(this, "i");
|
|
516
|
+
__publicField(this, "d");
|
|
517
|
+
this.i = id;
|
|
518
|
+
this.d = d;
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
var SerovalNullConstructorNode = class {
|
|
522
|
+
constructor(id, d) {
|
|
523
|
+
__publicField(this, "t", 9 /* NullConstructor */);
|
|
524
|
+
__publicField(this, "i");
|
|
525
|
+
__publicField(this, "d");
|
|
526
|
+
this.i = id;
|
|
527
|
+
this.d = d;
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
var SerovalPromiseNode = class {
|
|
531
|
+
constructor(id, n) {
|
|
532
|
+
__publicField(this, "t", 10 /* Promise */);
|
|
533
|
+
__publicField(this, "i");
|
|
534
|
+
__publicField(this, "n");
|
|
535
|
+
this.i = id;
|
|
536
|
+
this.n = n;
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
var SerovalErrorNode = class {
|
|
540
|
+
constructor(id, c, m, d) {
|
|
541
|
+
__publicField(this, "t", 11 /* Error */);
|
|
542
|
+
__publicField(this, "i");
|
|
543
|
+
__publicField(this, "c");
|
|
544
|
+
__publicField(this, "m");
|
|
545
|
+
__publicField(this, "d");
|
|
546
|
+
this.i = id;
|
|
547
|
+
this.c = c;
|
|
548
|
+
this.m = m;
|
|
549
|
+
this.d = d;
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
var SerovalAggregateErrorNode = class {
|
|
553
|
+
constructor(id, m, d, n) {
|
|
554
|
+
__publicField(this, "t", 12 /* AggregateError */);
|
|
555
|
+
__publicField(this, "i");
|
|
556
|
+
__publicField(this, "m");
|
|
557
|
+
__publicField(this, "d");
|
|
558
|
+
__publicField(this, "n");
|
|
559
|
+
this.i = id;
|
|
560
|
+
this.m = m;
|
|
561
|
+
this.d = d;
|
|
562
|
+
this.n = n;
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
var SerovalIterableNode = class {
|
|
566
|
+
constructor(id, d, a) {
|
|
567
|
+
__publicField(this, "t", 13 /* Iterable */);
|
|
568
|
+
__publicField(this, "i");
|
|
569
|
+
__publicField(this, "d");
|
|
570
|
+
__publicField(this, "a");
|
|
571
|
+
this.i = id;
|
|
572
|
+
this.d = d;
|
|
573
|
+
this.a = a;
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
|
|
380
577
|
// src/tree/primitives.ts
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
c: void 0,
|
|
389
|
-
d: void 0,
|
|
390
|
-
a: void 0,
|
|
391
|
-
n: void 0
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
var TRUE_NODE = createPrimitiveNode("!0");
|
|
395
|
-
var FALSE_NODE = createPrimitiveNode("!1");
|
|
396
|
-
var UNDEFINED_NODE = createPrimitiveNode("void 0");
|
|
397
|
-
var NULL_NODE = createPrimitiveNode(null);
|
|
398
|
-
var NEG_ZERO_NODE = createPrimitiveNode("-0");
|
|
399
|
-
var INFINITY_NODE = createPrimitiveNode("1/0");
|
|
400
|
-
var NEG_INFINITY_NODE = createPrimitiveNode("-1/0");
|
|
401
|
-
function createBigIntNode(ctx, current) {
|
|
402
|
-
assert(ctx.features & 8 /* BigInt */, 'Unsupported type "BigInt"');
|
|
403
|
-
return {
|
|
404
|
-
t: 1 /* BigInt */,
|
|
405
|
-
i: void 0,
|
|
406
|
-
a: void 0,
|
|
407
|
-
s: `${current}n`,
|
|
408
|
-
l: void 0,
|
|
409
|
-
m: void 0,
|
|
410
|
-
c: void 0,
|
|
411
|
-
d: void 0,
|
|
412
|
-
n: void 0
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
function createReferenceNode(id) {
|
|
416
|
-
return {
|
|
417
|
-
t: 2 /* Reference */,
|
|
418
|
-
i: id,
|
|
419
|
-
a: void 0,
|
|
420
|
-
s: void 0,
|
|
421
|
-
l: void 0,
|
|
422
|
-
m: void 0,
|
|
423
|
-
c: void 0,
|
|
424
|
-
d: void 0,
|
|
425
|
-
n: void 0
|
|
426
|
-
};
|
|
427
|
-
}
|
|
428
|
-
function createDateNode(id, current) {
|
|
429
|
-
return {
|
|
430
|
-
t: 3 /* Date */,
|
|
431
|
-
i: id,
|
|
432
|
-
a: void 0,
|
|
433
|
-
s: current.toISOString(),
|
|
434
|
-
l: void 0,
|
|
435
|
-
m: void 0,
|
|
436
|
-
c: void 0,
|
|
437
|
-
d: void 0,
|
|
438
|
-
n: void 0
|
|
439
|
-
};
|
|
440
|
-
}
|
|
441
|
-
function createRegExpNode(id, current) {
|
|
442
|
-
return {
|
|
443
|
-
t: 4 /* RegExp */,
|
|
444
|
-
i: id,
|
|
445
|
-
a: void 0,
|
|
446
|
-
s: String(current),
|
|
447
|
-
l: void 0,
|
|
448
|
-
m: void 0,
|
|
449
|
-
c: void 0,
|
|
450
|
-
d: void 0,
|
|
451
|
-
n: void 0
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
function createTypedArrayNode(ctx, id, current) {
|
|
455
|
-
const constructor = current.constructor.name;
|
|
456
|
-
assert(ctx.features & 1024 /* TypedArray */, `Unsupported value type "${constructor}"`);
|
|
457
|
-
return {
|
|
458
|
-
t: 14 /* TypedArray */,
|
|
459
|
-
i: id,
|
|
460
|
-
a: void 0,
|
|
461
|
-
s: current.toString(),
|
|
462
|
-
l: current.byteOffset,
|
|
463
|
-
m: void 0,
|
|
464
|
-
c: constructor,
|
|
465
|
-
d: void 0,
|
|
466
|
-
n: void 0
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
|
-
function createBigIntTypedArrayNode(ctx, id, current) {
|
|
470
|
-
const constructor = current.constructor.name;
|
|
471
|
-
assert(
|
|
472
|
-
ctx.features & 2048 /* BigIntTypedArray */,
|
|
473
|
-
`Unsupported value type "${constructor}"`
|
|
474
|
-
);
|
|
475
|
-
let result = "";
|
|
476
|
-
const cap = current.length - 1;
|
|
477
|
-
for (let i = 0; i < cap; i++) {
|
|
478
|
-
result += `${current[i]}n,`;
|
|
479
|
-
}
|
|
480
|
-
result += `"${current[cap]}"`;
|
|
481
|
-
return {
|
|
482
|
-
t: 15 /* BigIntTypedArray */,
|
|
483
|
-
i: id,
|
|
484
|
-
a: void 0,
|
|
485
|
-
s: result,
|
|
486
|
-
l: current.byteOffset,
|
|
487
|
-
m: void 0,
|
|
488
|
-
c: constructor,
|
|
489
|
-
d: void 0,
|
|
490
|
-
n: void 0
|
|
491
|
-
};
|
|
492
|
-
}
|
|
578
|
+
var TRUE_NODE = new SerovalPrimitiveNode("!0");
|
|
579
|
+
var FALSE_NODE = new SerovalPrimitiveNode("!1");
|
|
580
|
+
var UNDEFINED_NODE = new SerovalPrimitiveNode("void 0");
|
|
581
|
+
var NULL_NODE = new SerovalPrimitiveNode(null);
|
|
582
|
+
var NEG_ZERO_NODE = new SerovalPrimitiveNode("-0");
|
|
583
|
+
var INFINITY_NODE = new SerovalPrimitiveNode("1/0");
|
|
584
|
+
var NEG_INFINITY_NODE = new SerovalPrimitiveNode("-1/0");
|
|
493
585
|
|
|
494
586
|
// src/tree/shared.ts
|
|
495
587
|
function getErrorConstructor(error) {
|
|
@@ -573,317 +665,257 @@ function isIterable(value) {
|
|
|
573
665
|
}
|
|
574
666
|
|
|
575
667
|
// src/tree/async.ts
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
nodesSize++;
|
|
668
|
+
var AsyncParser = class {
|
|
669
|
+
constructor(ctx) {
|
|
670
|
+
__publicField(this, "ctx");
|
|
671
|
+
this.ctx = ctx;
|
|
672
|
+
}
|
|
673
|
+
async generateNodeList(current) {
|
|
674
|
+
const size = current.length;
|
|
675
|
+
const nodes = new Array(size);
|
|
676
|
+
const deferred = new Array(size);
|
|
677
|
+
let item;
|
|
678
|
+
for (let i = 0; i < size; i++) {
|
|
679
|
+
if (i in current) {
|
|
680
|
+
item = current[i];
|
|
681
|
+
if (isIterable(item)) {
|
|
682
|
+
deferred[i] = item;
|
|
683
|
+
} else {
|
|
684
|
+
nodes[i] = await this.parse(item);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
596
687
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
}
|
|
602
|
-
return {
|
|
603
|
-
k: keyNodes,
|
|
604
|
-
v: valueNodes,
|
|
605
|
-
s: size
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
async function generateSetNode(ctx, current, id) {
|
|
609
|
-
assert(ctx.features & 256 /* Set */, 'Unsupported type "Set"');
|
|
610
|
-
const len = current.size;
|
|
611
|
-
const nodes = new Array(len);
|
|
612
|
-
const deferred = new Array(len);
|
|
613
|
-
let deferredSize = 0;
|
|
614
|
-
let nodeSize = 0;
|
|
615
|
-
for (const item of current.keys()) {
|
|
616
|
-
if (isIterable(item)) {
|
|
617
|
-
deferred[deferredSize++] = item;
|
|
618
|
-
} else {
|
|
619
|
-
nodes[nodeSize++] = await generateTreeAsync(ctx, item);
|
|
688
|
+
for (let i = 0; i < size; i++) {
|
|
689
|
+
if (i in deferred) {
|
|
690
|
+
nodes[i] = await this.parse(deferred[i]);
|
|
691
|
+
}
|
|
620
692
|
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
let nodeSize = 0;
|
|
646
|
-
for (const [key, value] of current.entries()) {
|
|
647
|
-
if (isIterable(key) || isIterable(value)) {
|
|
648
|
-
deferredKey[deferredSize] = key;
|
|
649
|
-
deferredValue[deferredSize] = value;
|
|
650
|
-
deferredSize++;
|
|
651
|
-
} else {
|
|
652
|
-
keyNodes[nodeSize] = await generateTreeAsync(ctx, key);
|
|
653
|
-
valueNodes[nodeSize] = await generateTreeAsync(ctx, value);
|
|
654
|
-
nodeSize++;
|
|
693
|
+
return nodes;
|
|
694
|
+
}
|
|
695
|
+
async generateArrayNode(id, current) {
|
|
696
|
+
return new SerovalArrayNode(id, await this.generateNodeList(current));
|
|
697
|
+
}
|
|
698
|
+
async generateMapNode(id, current) {
|
|
699
|
+
assert(this.ctx.features & 16 /* Map */, 'Unsupported type "Map"');
|
|
700
|
+
const len = current.size;
|
|
701
|
+
const keyNodes = new Array(len);
|
|
702
|
+
const valueNodes = new Array(len);
|
|
703
|
+
const deferredKey = new Array(len);
|
|
704
|
+
const deferredValue = new Array(len);
|
|
705
|
+
let deferredSize = 0;
|
|
706
|
+
let nodeSize = 0;
|
|
707
|
+
for (const [key, value] of current.entries()) {
|
|
708
|
+
if (isIterable(key) || isIterable(value)) {
|
|
709
|
+
deferredKey[deferredSize] = key;
|
|
710
|
+
deferredValue[deferredSize] = value;
|
|
711
|
+
deferredSize++;
|
|
712
|
+
} else {
|
|
713
|
+
keyNodes[nodeSize] = await this.parse(key);
|
|
714
|
+
valueNodes[nodeSize] = await this.parse(value);
|
|
715
|
+
nodeSize++;
|
|
716
|
+
}
|
|
655
717
|
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
n: void 0
|
|
671
|
-
};
|
|
672
|
-
}
|
|
673
|
-
async function generateNodeList(ctx, current) {
|
|
674
|
-
const size = current.length;
|
|
675
|
-
const nodes = new Array(size);
|
|
676
|
-
const deferred = new Array(size);
|
|
677
|
-
let item;
|
|
678
|
-
for (let i = 0; i < size; i++) {
|
|
679
|
-
if (i in current) {
|
|
680
|
-
item = current[i];
|
|
718
|
+
for (let i = 0; i < deferredSize; i++) {
|
|
719
|
+
keyNodes[nodeSize + i] = await this.parse(deferredKey[i]);
|
|
720
|
+
valueNodes[nodeSize + i] = await this.parse(deferredValue[i]);
|
|
721
|
+
}
|
|
722
|
+
return new SerovalMapNode(id, new SerovalMapRecordNode(keyNodes, valueNodes, len));
|
|
723
|
+
}
|
|
724
|
+
async generateSetNode(id, current) {
|
|
725
|
+
assert(this.ctx.features & 256 /* Set */, 'Unsupported type "Set"');
|
|
726
|
+
const len = current.size;
|
|
727
|
+
const nodes = new Array(len);
|
|
728
|
+
const deferred = new Array(len);
|
|
729
|
+
let deferredSize = 0;
|
|
730
|
+
let nodeSize = 0;
|
|
731
|
+
for (const item of current.keys()) {
|
|
681
732
|
if (isIterable(item)) {
|
|
682
|
-
deferred[
|
|
733
|
+
deferred[deferredSize++] = item;
|
|
683
734
|
} else {
|
|
684
|
-
nodes[
|
|
735
|
+
nodes[nodeSize++] = await this.parse(item);
|
|
685
736
|
}
|
|
686
737
|
}
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
if (i in deferred) {
|
|
690
|
-
nodes[i] = await generateTreeAsync(ctx, deferred[i]);
|
|
738
|
+
for (let i = 0; i < deferredSize; i++) {
|
|
739
|
+
nodes[nodeSize + i] = await this.parse(deferred[i]);
|
|
691
740
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
a: void 0,
|
|
715
|
-
s: void 0,
|
|
716
|
-
l: void 0,
|
|
717
|
-
m: current.message,
|
|
718
|
-
c: void 0,
|
|
719
|
-
d: optionsNode,
|
|
720
|
-
n: await generateTreeAsync(ctx, current.errors)
|
|
721
|
-
};
|
|
722
|
-
}
|
|
723
|
-
async function generateErrorNode(ctx, current, id) {
|
|
724
|
-
const options = getErrorOptions(current);
|
|
725
|
-
const optionsNode = options ? await serializePropertiesAsync(ctx, options) : void 0;
|
|
726
|
-
return {
|
|
727
|
-
t: 11 /* Error */,
|
|
728
|
-
i: id,
|
|
729
|
-
a: void 0,
|
|
730
|
-
s: void 0,
|
|
731
|
-
l: void 0,
|
|
732
|
-
m: current.message,
|
|
733
|
-
c: getErrorConstructor(current),
|
|
734
|
-
d: optionsNode,
|
|
735
|
-
n: void 0
|
|
736
|
-
};
|
|
737
|
-
}
|
|
738
|
-
async function generateIterableNode(ctx, current, id) {
|
|
739
|
-
assert(ctx.features & 512 /* SymbolIterator */, 'Unsupported type "Iterable"');
|
|
740
|
-
const options = getIterableOptions(current);
|
|
741
|
-
return {
|
|
742
|
-
t: 13 /* Iterable */,
|
|
743
|
-
i: id,
|
|
744
|
-
s: void 0,
|
|
745
|
-
l: void 0,
|
|
746
|
-
m: void 0,
|
|
747
|
-
c: void 0,
|
|
748
|
-
// Parse options first before the items
|
|
749
|
-
d: options ? await serializePropertiesAsync(ctx, options) : void 0,
|
|
750
|
-
a: await generateNodeList(ctx, Array.from(current)),
|
|
751
|
-
n: void 0
|
|
752
|
-
};
|
|
753
|
-
}
|
|
754
|
-
async function generateObjectNode(ctx, current, id, empty) {
|
|
755
|
-
if (Symbol.iterator in current) {
|
|
756
|
-
return generateIterableNode(ctx, current, id);
|
|
757
|
-
}
|
|
758
|
-
if ("then" in current && typeof current.then === "function") {
|
|
759
|
-
return generatePromiseNode(ctx, current, id);
|
|
760
|
-
}
|
|
761
|
-
return {
|
|
762
|
-
t: empty ? 9 /* NullConstructor */ : 8 /* Object */,
|
|
763
|
-
i: id,
|
|
764
|
-
s: void 0,
|
|
765
|
-
l: void 0,
|
|
766
|
-
m: void 0,
|
|
767
|
-
c: void 0,
|
|
768
|
-
d: await serializePropertiesAsync(ctx, current),
|
|
769
|
-
a: void 0,
|
|
770
|
-
n: void 0
|
|
771
|
-
};
|
|
772
|
-
}
|
|
773
|
-
async function generatePromiseNode(ctx, current, id) {
|
|
774
|
-
assert(ctx.features & 128 /* Promise */, 'Unsupported type "Promise"');
|
|
775
|
-
return current.then(async (value) => ({
|
|
776
|
-
t: 10 /* Promise */,
|
|
777
|
-
i: id,
|
|
778
|
-
s: void 0,
|
|
779
|
-
l: void 0,
|
|
780
|
-
m: void 0,
|
|
781
|
-
c: void 0,
|
|
782
|
-
// Parse options first before the items
|
|
783
|
-
d: void 0,
|
|
784
|
-
a: void 0,
|
|
785
|
-
n: await generateTreeAsync(ctx, value)
|
|
786
|
-
}));
|
|
787
|
-
}
|
|
788
|
-
async function generateTreeAsync(ctx, current) {
|
|
789
|
-
switch (typeof current) {
|
|
790
|
-
case "boolean":
|
|
791
|
-
return current ? TRUE_NODE : FALSE_NODE;
|
|
792
|
-
case "undefined":
|
|
793
|
-
return UNDEFINED_NODE;
|
|
794
|
-
case "string":
|
|
795
|
-
return createPrimitiveNode(quote(current));
|
|
796
|
-
case "number":
|
|
797
|
-
if (Object.is(current, -0)) {
|
|
798
|
-
return NEG_ZERO_NODE;
|
|
799
|
-
}
|
|
800
|
-
if (Object.is(current, Infinity)) {
|
|
801
|
-
return createPrimitiveNode("1/0");
|
|
802
|
-
}
|
|
803
|
-
if (Object.is(current, -Infinity)) {
|
|
804
|
-
return createPrimitiveNode("-1/0");
|
|
805
|
-
}
|
|
806
|
-
return createPrimitiveNode(current);
|
|
807
|
-
case "bigint":
|
|
808
|
-
return createBigIntNode(ctx, current);
|
|
809
|
-
case "object": {
|
|
810
|
-
if (!current) {
|
|
811
|
-
return NULL_NODE;
|
|
812
|
-
}
|
|
813
|
-
const id = createRef(ctx, current, true);
|
|
814
|
-
if (ctx.markedRefs[id]) {
|
|
815
|
-
return createReferenceNode(id);
|
|
816
|
-
}
|
|
817
|
-
if (Array.isArray(current)) {
|
|
818
|
-
return generateArrayNode(ctx, current, id);
|
|
819
|
-
}
|
|
820
|
-
switch (current.constructor) {
|
|
821
|
-
case Date:
|
|
822
|
-
return createDateNode(id, current);
|
|
823
|
-
case RegExp:
|
|
824
|
-
return createRegExpNode(id, current);
|
|
825
|
-
case Promise:
|
|
826
|
-
return generatePromiseNode(ctx, current, id);
|
|
827
|
-
case Map:
|
|
828
|
-
return generateMapNode(ctx, current, id);
|
|
829
|
-
case Set:
|
|
830
|
-
return generateSetNode(ctx, current, id);
|
|
831
|
-
case Object:
|
|
832
|
-
return generateObjectNode(ctx, current, id, false);
|
|
833
|
-
case void 0:
|
|
834
|
-
return generateObjectNode(ctx, current, id, true);
|
|
835
|
-
case Int8Array:
|
|
836
|
-
case Int16Array:
|
|
837
|
-
case Int32Array:
|
|
838
|
-
case Uint8Array:
|
|
839
|
-
case Uint16Array:
|
|
840
|
-
case Uint32Array:
|
|
841
|
-
case Uint8ClampedArray:
|
|
842
|
-
case Float32Array:
|
|
843
|
-
case Float64Array:
|
|
844
|
-
return createTypedArrayNode(ctx, id, current);
|
|
845
|
-
case BigInt64Array:
|
|
846
|
-
case BigUint64Array:
|
|
847
|
-
return createBigIntTypedArrayNode(ctx, id, current);
|
|
848
|
-
case AggregateError:
|
|
849
|
-
if (ctx.features & 1 /* AggregateError */) {
|
|
850
|
-
return generateAggregateErrorNode(ctx, current, id);
|
|
851
|
-
}
|
|
852
|
-
return generateErrorNode(ctx, current, id);
|
|
853
|
-
case Error:
|
|
854
|
-
case EvalError:
|
|
855
|
-
case RangeError:
|
|
856
|
-
case ReferenceError:
|
|
857
|
-
case SyntaxError:
|
|
858
|
-
case TypeError:
|
|
859
|
-
case URIError:
|
|
860
|
-
return generateErrorNode(ctx, current, id);
|
|
861
|
-
default:
|
|
862
|
-
break;
|
|
863
|
-
}
|
|
864
|
-
if (current instanceof AggregateError && ctx.features & 1 /* AggregateError */) {
|
|
865
|
-
return generateAggregateErrorNode(ctx, current, id);
|
|
866
|
-
}
|
|
867
|
-
if (current instanceof Error) {
|
|
868
|
-
return generateErrorNode(ctx, current, id);
|
|
869
|
-
}
|
|
870
|
-
if (current instanceof Promise) {
|
|
871
|
-
return generatePromiseNode(ctx, current, id);
|
|
872
|
-
}
|
|
873
|
-
if (Symbol.iterator in current) {
|
|
874
|
-
return generateIterableNode(ctx, current, id);
|
|
741
|
+
return new SerovalSetNode(id, nodes);
|
|
742
|
+
}
|
|
743
|
+
async generateProperties(properties) {
|
|
744
|
+
const keys = Object.keys(properties);
|
|
745
|
+
const size = keys.length;
|
|
746
|
+
const keyNodes = new Array(size);
|
|
747
|
+
const valueNodes = new Array(size);
|
|
748
|
+
const deferredKeys = new Array(size);
|
|
749
|
+
const deferredValues = new Array(size);
|
|
750
|
+
let deferredSize = 0;
|
|
751
|
+
let nodesSize = 0;
|
|
752
|
+
let item;
|
|
753
|
+
for (const key of keys) {
|
|
754
|
+
item = properties[key];
|
|
755
|
+
if (isIterable(item)) {
|
|
756
|
+
deferredKeys[deferredSize] = key;
|
|
757
|
+
deferredValues[deferredSize] = item;
|
|
758
|
+
deferredSize++;
|
|
759
|
+
} else {
|
|
760
|
+
keyNodes[nodesSize] = key;
|
|
761
|
+
valueNodes[nodesSize] = await this.parse(item);
|
|
762
|
+
nodesSize++;
|
|
875
763
|
}
|
|
876
|
-
|
|
877
|
-
|
|
764
|
+
}
|
|
765
|
+
for (let i = 0; i < deferredSize; i++) {
|
|
766
|
+
keyNodes[nodesSize + i] = deferredKeys[i];
|
|
767
|
+
valueNodes[nodesSize + i] = await this.parse(deferredValues[i]);
|
|
768
|
+
}
|
|
769
|
+
return new SerovalObjectRecordNode(keyNodes, valueNodes, size);
|
|
770
|
+
}
|
|
771
|
+
async generateIterableNode(id, current) {
|
|
772
|
+
assert(this.ctx.features & 512 /* SymbolIterator */, 'Unsupported type "Iterable"');
|
|
773
|
+
const options = getIterableOptions(current);
|
|
774
|
+
return new SerovalIterableNode(
|
|
775
|
+
id,
|
|
776
|
+
// Parse options first before the items
|
|
777
|
+
options ? await this.generateProperties(options) : void 0,
|
|
778
|
+
await this.generateNodeList(Array.from(current))
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
async generatePromiseNode(id, current) {
|
|
782
|
+
assert(this.ctx.features & 128 /* Promise */, 'Unsupported type "Promise"');
|
|
783
|
+
return current.then(async (value) => new SerovalPromiseNode(id, await this.parse(value)));
|
|
784
|
+
}
|
|
785
|
+
async generateObjectNode(id, current, empty) {
|
|
786
|
+
if (Symbol.iterator in current) {
|
|
787
|
+
return this.generateIterableNode(id, current);
|
|
788
|
+
}
|
|
789
|
+
if ("then" in current && typeof current.then === "function") {
|
|
790
|
+
return this.generatePromiseNode(id, current);
|
|
791
|
+
}
|
|
792
|
+
const properties = await this.generateProperties(current);
|
|
793
|
+
if (empty) {
|
|
794
|
+
return new SerovalNullConstructorNode(id, properties);
|
|
795
|
+
}
|
|
796
|
+
return new SerovalObjectNode(id, properties);
|
|
797
|
+
}
|
|
798
|
+
async generateAggregateErrorNode(id, current) {
|
|
799
|
+
const options = getErrorOptions(current);
|
|
800
|
+
const optionsNode = options ? await this.generateProperties(options) : void 0;
|
|
801
|
+
return new SerovalAggregateErrorNode(
|
|
802
|
+
id,
|
|
803
|
+
current.message,
|
|
804
|
+
optionsNode,
|
|
805
|
+
await this.parse(current.errors)
|
|
806
|
+
);
|
|
807
|
+
}
|
|
808
|
+
async generateErrorNode(id, current) {
|
|
809
|
+
const options = getErrorOptions(current);
|
|
810
|
+
const optionsNode = options ? await this.generateProperties(options) : void 0;
|
|
811
|
+
return new SerovalErrorNode(id, getErrorConstructor(current), current.message, optionsNode);
|
|
812
|
+
}
|
|
813
|
+
async parse(current) {
|
|
814
|
+
switch (typeof current) {
|
|
815
|
+
case "boolean":
|
|
816
|
+
return current ? TRUE_NODE : FALSE_NODE;
|
|
817
|
+
case "undefined":
|
|
818
|
+
return UNDEFINED_NODE;
|
|
819
|
+
case "string":
|
|
820
|
+
return new SerovalPrimitiveNode(quote(current));
|
|
821
|
+
case "number":
|
|
822
|
+
if (Object.is(current, -0)) {
|
|
823
|
+
return NEG_ZERO_NODE;
|
|
824
|
+
}
|
|
825
|
+
if (Object.is(current, Infinity)) {
|
|
826
|
+
return INFINITY_NODE;
|
|
827
|
+
}
|
|
828
|
+
if (Object.is(current, -Infinity)) {
|
|
829
|
+
return NEG_INFINITY_NODE;
|
|
830
|
+
}
|
|
831
|
+
return new SerovalPrimitiveNode(current);
|
|
832
|
+
case "bigint":
|
|
833
|
+
assert(this.ctx.features & 8 /* BigInt */, 'Unsupported type "BigInt"');
|
|
834
|
+
return new SerovalBigIntNode(current);
|
|
835
|
+
case "object": {
|
|
836
|
+
if (!current) {
|
|
837
|
+
return NULL_NODE;
|
|
838
|
+
}
|
|
839
|
+
const id = createRef(this.ctx, current, true);
|
|
840
|
+
if (this.ctx.markedRefs[id]) {
|
|
841
|
+
return new SerovalReferenceNode(id);
|
|
842
|
+
}
|
|
843
|
+
if (Array.isArray(current)) {
|
|
844
|
+
return this.generateArrayNode(id, current);
|
|
845
|
+
}
|
|
846
|
+
switch (current.constructor) {
|
|
847
|
+
case Date:
|
|
848
|
+
return new SerovalDateNode(id, current);
|
|
849
|
+
case RegExp:
|
|
850
|
+
return new SerovalRegExpNode(id, current);
|
|
851
|
+
case Promise:
|
|
852
|
+
return this.generatePromiseNode(id, current);
|
|
853
|
+
case Int8Array:
|
|
854
|
+
case Int16Array:
|
|
855
|
+
case Int32Array:
|
|
856
|
+
case Uint8Array:
|
|
857
|
+
case Uint16Array:
|
|
858
|
+
case Uint32Array:
|
|
859
|
+
case Uint8ClampedArray:
|
|
860
|
+
case Float32Array:
|
|
861
|
+
case Float64Array:
|
|
862
|
+
assert(this.ctx.features & 1024 /* TypedArray */, `Unsupported value type "${current.constructor.name}"`);
|
|
863
|
+
return new SerovalTypedArrayNode(id, current);
|
|
864
|
+
case BigInt64Array:
|
|
865
|
+
case BigUint64Array:
|
|
866
|
+
assert(
|
|
867
|
+
this.ctx.features & 2048 /* BigIntTypedArray */,
|
|
868
|
+
`Unsupported value type "${current.constructor.name}"`
|
|
869
|
+
);
|
|
870
|
+
return new SerovalBigIntTypedArrayNode(id, current);
|
|
871
|
+
case Map:
|
|
872
|
+
return this.generateMapNode(id, current);
|
|
873
|
+
case Set:
|
|
874
|
+
return this.generateSetNode(id, current);
|
|
875
|
+
case Object:
|
|
876
|
+
return this.generateObjectNode(id, current, false);
|
|
877
|
+
case void 0:
|
|
878
|
+
return this.generateObjectNode(id, current, true);
|
|
879
|
+
case AggregateError:
|
|
880
|
+
if (this.ctx.features & 1 /* AggregateError */) {
|
|
881
|
+
return this.generateAggregateErrorNode(id, current);
|
|
882
|
+
}
|
|
883
|
+
return this.generateErrorNode(id, current);
|
|
884
|
+
case Error:
|
|
885
|
+
case EvalError:
|
|
886
|
+
case RangeError:
|
|
887
|
+
case ReferenceError:
|
|
888
|
+
case SyntaxError:
|
|
889
|
+
case TypeError:
|
|
890
|
+
case URIError:
|
|
891
|
+
return this.generateErrorNode(id, current);
|
|
892
|
+
default:
|
|
893
|
+
break;
|
|
894
|
+
}
|
|
895
|
+
if (current instanceof AggregateError && this.ctx.features & 1 /* AggregateError */) {
|
|
896
|
+
return this.generateAggregateErrorNode(id, current);
|
|
897
|
+
}
|
|
898
|
+
if (current instanceof Error) {
|
|
899
|
+
return this.generateErrorNode(id, current);
|
|
900
|
+
}
|
|
901
|
+
if (current instanceof Promise) {
|
|
902
|
+
return this.generatePromiseNode(id, current);
|
|
903
|
+
}
|
|
904
|
+
if (Symbol.iterator in current) {
|
|
905
|
+
return this.generateIterableNode(id, current);
|
|
906
|
+
}
|
|
907
|
+
if ("then" in current && typeof current.then === "function") {
|
|
908
|
+
return this.generatePromiseNode(id, current);
|
|
909
|
+
}
|
|
910
|
+
throw new Error("Unsupported type");
|
|
878
911
|
}
|
|
879
|
-
|
|
912
|
+
default:
|
|
913
|
+
throw new Error("Unsupported type");
|
|
880
914
|
}
|
|
881
|
-
default:
|
|
882
|
-
throw new Error("Unsupported type");
|
|
883
915
|
}
|
|
884
|
-
}
|
|
916
|
+
};
|
|
885
917
|
async function parseAsync(ctx, current) {
|
|
886
|
-
const result = await
|
|
918
|
+
const result = await new AsyncParser(ctx).parse(current);
|
|
887
919
|
const isObject = result.t === 8 /* Object */ || result.t === 13 /* Iterable */;
|
|
888
920
|
return [result, createRef(ctx, current, false), isObject];
|
|
889
921
|
}
|
|
@@ -1270,291 +1302,245 @@ function serializeTree(ctx, node) {
|
|
|
1270
1302
|
}
|
|
1271
1303
|
|
|
1272
1304
|
// src/tree/sync.ts
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
nodesSize++;
|
|
1305
|
+
var SyncParser = class {
|
|
1306
|
+
constructor(ctx) {
|
|
1307
|
+
__publicField(this, "ctx");
|
|
1308
|
+
this.ctx = ctx;
|
|
1309
|
+
}
|
|
1310
|
+
generateNodeList(current) {
|
|
1311
|
+
const size = current.length;
|
|
1312
|
+
const nodes = new Array(size);
|
|
1313
|
+
const deferred = new Array(size);
|
|
1314
|
+
let item;
|
|
1315
|
+
for (let i = 0; i < size; i++) {
|
|
1316
|
+
if (i in current) {
|
|
1317
|
+
item = current[i];
|
|
1318
|
+
if (isIterable(item)) {
|
|
1319
|
+
deferred[i] = item;
|
|
1320
|
+
} else {
|
|
1321
|
+
nodes[i] = this.parse(item);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1293
1324
|
}
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
}
|
|
1299
|
-
return {
|
|
1300
|
-
k: keyNodes,
|
|
1301
|
-
v: valueNodes,
|
|
1302
|
-
s: size
|
|
1303
|
-
};
|
|
1304
|
-
}
|
|
1305
|
-
function generateSetNode2(ctx, current, id) {
|
|
1306
|
-
assert(ctx.features & 256 /* Set */, 'Unsupported type "Set"');
|
|
1307
|
-
const len = current.size;
|
|
1308
|
-
const nodes = new Array(len);
|
|
1309
|
-
const deferred = new Array(len);
|
|
1310
|
-
let deferredSize = 0;
|
|
1311
|
-
let nodeSize = 0;
|
|
1312
|
-
for (const item of current.keys()) {
|
|
1313
|
-
if (isIterable(item)) {
|
|
1314
|
-
deferred[deferredSize++] = item;
|
|
1315
|
-
} else {
|
|
1316
|
-
nodes[nodeSize++] = generateTreeSync(ctx, item);
|
|
1325
|
+
for (let i = 0; i < size; i++) {
|
|
1326
|
+
if (i in deferred) {
|
|
1327
|
+
nodes[i] = this.parse(deferred[i]);
|
|
1328
|
+
}
|
|
1317
1329
|
}
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
let nodeSize = 0;
|
|
1343
|
-
for (const [key, value] of current.entries()) {
|
|
1344
|
-
if (isIterable(key) || isIterable(value)) {
|
|
1345
|
-
deferredKey[deferredSize] = key;
|
|
1346
|
-
deferredValue[deferredSize] = value;
|
|
1347
|
-
deferredSize++;
|
|
1348
|
-
} else {
|
|
1349
|
-
keyNodes[nodeSize] = generateTreeSync(ctx, key);
|
|
1350
|
-
valueNodes[nodeSize] = generateTreeSync(ctx, value);
|
|
1351
|
-
nodeSize++;
|
|
1330
|
+
return nodes;
|
|
1331
|
+
}
|
|
1332
|
+
generateArrayNode(id, current) {
|
|
1333
|
+
return new SerovalArrayNode(id, this.generateNodeList(current));
|
|
1334
|
+
}
|
|
1335
|
+
generateMapNode(id, current) {
|
|
1336
|
+
assert(this.ctx.features & 16 /* Map */, 'Unsupported type "Map"');
|
|
1337
|
+
const len = current.size;
|
|
1338
|
+
const keyNodes = new Array(len);
|
|
1339
|
+
const valueNodes = new Array(len);
|
|
1340
|
+
const deferredKey = new Array(len);
|
|
1341
|
+
const deferredValue = new Array(len);
|
|
1342
|
+
let deferredSize = 0;
|
|
1343
|
+
let nodeSize = 0;
|
|
1344
|
+
for (const [key, value] of current.entries()) {
|
|
1345
|
+
if (isIterable(key) || isIterable(value)) {
|
|
1346
|
+
deferredKey[deferredSize] = key;
|
|
1347
|
+
deferredValue[deferredSize] = value;
|
|
1348
|
+
deferredSize++;
|
|
1349
|
+
} else {
|
|
1350
|
+
keyNodes[nodeSize] = this.parse(key);
|
|
1351
|
+
valueNodes[nodeSize] = this.parse(value);
|
|
1352
|
+
nodeSize++;
|
|
1353
|
+
}
|
|
1352
1354
|
}
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
n: void 0
|
|
1368
|
-
};
|
|
1369
|
-
}
|
|
1370
|
-
function generateNodeList2(ctx, current) {
|
|
1371
|
-
const size = current.length;
|
|
1372
|
-
const nodes = new Array(size);
|
|
1373
|
-
const deferred = new Array(size);
|
|
1374
|
-
let item;
|
|
1375
|
-
for (let i = 0; i < size; i++) {
|
|
1376
|
-
if (i in current) {
|
|
1377
|
-
item = current[i];
|
|
1355
|
+
for (let i = 0; i < deferredSize; i++) {
|
|
1356
|
+
keyNodes[nodeSize + i] = this.parse(deferredKey[i]);
|
|
1357
|
+
valueNodes[nodeSize + i] = this.parse(deferredValue[i]);
|
|
1358
|
+
}
|
|
1359
|
+
return new SerovalMapNode(id, new SerovalMapRecordNode(keyNodes, valueNodes, len));
|
|
1360
|
+
}
|
|
1361
|
+
generateSetNode(id, current) {
|
|
1362
|
+
assert(this.ctx.features & 256 /* Set */, 'Unsupported type "Set"');
|
|
1363
|
+
const len = current.size;
|
|
1364
|
+
const nodes = new Array(len);
|
|
1365
|
+
const deferred = new Array(len);
|
|
1366
|
+
let deferredSize = 0;
|
|
1367
|
+
let nodeSize = 0;
|
|
1368
|
+
for (const item of current.keys()) {
|
|
1378
1369
|
if (isIterable(item)) {
|
|
1379
|
-
deferred[
|
|
1370
|
+
deferred[deferredSize++] = item;
|
|
1380
1371
|
} else {
|
|
1381
|
-
nodes[
|
|
1372
|
+
nodes[nodeSize++] = this.parse(item);
|
|
1382
1373
|
}
|
|
1383
1374
|
}
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
if (i in deferred) {
|
|
1387
|
-
nodes[i] = generateTreeSync(ctx, deferred[i]);
|
|
1375
|
+
for (let i = 0; i < deferredSize; i++) {
|
|
1376
|
+
nodes[nodeSize + i] = this.parse(deferred[i]);
|
|
1388
1377
|
}
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
a: void 0,
|
|
1412
|
-
s: void 0,
|
|
1413
|
-
l: void 0,
|
|
1414
|
-
m: current.message,
|
|
1415
|
-
c: void 0,
|
|
1416
|
-
d: optionsNode,
|
|
1417
|
-
n: generateTreeSync(ctx, current.errors)
|
|
1418
|
-
};
|
|
1419
|
-
}
|
|
1420
|
-
function generateErrorNode2(ctx, current, id) {
|
|
1421
|
-
const options = getErrorOptions(current);
|
|
1422
|
-
const optionsNode = options ? serializePropertiesSync(ctx, options) : void 0;
|
|
1423
|
-
return {
|
|
1424
|
-
t: 11 /* Error */,
|
|
1425
|
-
i: id,
|
|
1426
|
-
a: void 0,
|
|
1427
|
-
s: void 0,
|
|
1428
|
-
l: void 0,
|
|
1429
|
-
m: current.message,
|
|
1430
|
-
c: getErrorConstructor(current),
|
|
1431
|
-
d: optionsNode,
|
|
1432
|
-
n: void 0
|
|
1433
|
-
};
|
|
1434
|
-
}
|
|
1435
|
-
function generateIterableNode2(ctx, current, id) {
|
|
1436
|
-
assert(ctx.features & 512 /* SymbolIterator */, 'Unsupported type "Iterable"');
|
|
1437
|
-
const options = getIterableOptions(current);
|
|
1438
|
-
return {
|
|
1439
|
-
t: 13 /* Iterable */,
|
|
1440
|
-
i: id,
|
|
1441
|
-
s: void 0,
|
|
1442
|
-
l: void 0,
|
|
1443
|
-
m: void 0,
|
|
1444
|
-
c: void 0,
|
|
1445
|
-
// Parse options first before the items
|
|
1446
|
-
d: options ? serializePropertiesSync(ctx, options) : void 0,
|
|
1447
|
-
a: generateNodeList2(ctx, Array.from(current)),
|
|
1448
|
-
n: void 0
|
|
1449
|
-
};
|
|
1450
|
-
}
|
|
1451
|
-
function generateObjectNode2(ctx, current, id, empty) {
|
|
1452
|
-
if (Symbol.iterator in current) {
|
|
1453
|
-
return generateIterableNode2(ctx, current, id);
|
|
1454
|
-
}
|
|
1455
|
-
return {
|
|
1456
|
-
t: empty ? 9 /* NullConstructor */ : 8 /* Object */,
|
|
1457
|
-
i: id,
|
|
1458
|
-
s: void 0,
|
|
1459
|
-
l: void 0,
|
|
1460
|
-
m: void 0,
|
|
1461
|
-
c: void 0,
|
|
1462
|
-
d: serializePropertiesSync(ctx, current),
|
|
1463
|
-
a: void 0,
|
|
1464
|
-
n: void 0
|
|
1465
|
-
};
|
|
1466
|
-
}
|
|
1467
|
-
function generateTreeSync(ctx, current) {
|
|
1468
|
-
switch (typeof current) {
|
|
1469
|
-
case "boolean":
|
|
1470
|
-
return current ? TRUE_NODE : FALSE_NODE;
|
|
1471
|
-
case "undefined":
|
|
1472
|
-
return UNDEFINED_NODE;
|
|
1473
|
-
case "string":
|
|
1474
|
-
return createPrimitiveNode(quote(current));
|
|
1475
|
-
case "number":
|
|
1476
|
-
if (Object.is(current, -0)) {
|
|
1477
|
-
return NEG_ZERO_NODE;
|
|
1478
|
-
}
|
|
1479
|
-
if (Object.is(current, Infinity)) {
|
|
1480
|
-
return createPrimitiveNode("1/0");
|
|
1481
|
-
}
|
|
1482
|
-
if (Object.is(current, -Infinity)) {
|
|
1483
|
-
return createPrimitiveNode("-1/0");
|
|
1484
|
-
}
|
|
1485
|
-
return createPrimitiveNode(current);
|
|
1486
|
-
case "bigint":
|
|
1487
|
-
return createBigIntNode(ctx, current);
|
|
1488
|
-
case "object": {
|
|
1489
|
-
if (!current) {
|
|
1490
|
-
return NULL_NODE;
|
|
1491
|
-
}
|
|
1492
|
-
const id = createRef(ctx, current, true);
|
|
1493
|
-
if (ctx.markedRefs[id]) {
|
|
1494
|
-
return createReferenceNode(id);
|
|
1495
|
-
}
|
|
1496
|
-
if (Array.isArray(current)) {
|
|
1497
|
-
return generateArrayNode2(ctx, current, id);
|
|
1498
|
-
}
|
|
1499
|
-
switch (current.constructor) {
|
|
1500
|
-
case Date:
|
|
1501
|
-
return createDateNode(id, current);
|
|
1502
|
-
case RegExp:
|
|
1503
|
-
return createRegExpNode(id, current);
|
|
1504
|
-
case Map:
|
|
1505
|
-
return generateMapNode2(ctx, current, id);
|
|
1506
|
-
case Set:
|
|
1507
|
-
return generateSetNode2(ctx, current, id);
|
|
1508
|
-
case Object:
|
|
1509
|
-
return generateObjectNode2(ctx, current, id, false);
|
|
1510
|
-
case void 0:
|
|
1511
|
-
return generateObjectNode2(ctx, current, id, true);
|
|
1512
|
-
case Int8Array:
|
|
1513
|
-
case Int16Array:
|
|
1514
|
-
case Int32Array:
|
|
1515
|
-
case Uint8Array:
|
|
1516
|
-
case Uint16Array:
|
|
1517
|
-
case Uint32Array:
|
|
1518
|
-
case Uint8ClampedArray:
|
|
1519
|
-
case Float32Array:
|
|
1520
|
-
case Float64Array:
|
|
1521
|
-
return createTypedArrayNode(ctx, id, current);
|
|
1522
|
-
case BigInt64Array:
|
|
1523
|
-
case BigUint64Array:
|
|
1524
|
-
return createBigIntTypedArrayNode(ctx, id, current);
|
|
1525
|
-
case AggregateError:
|
|
1526
|
-
if (ctx.features & 1 /* AggregateError */) {
|
|
1527
|
-
return generateAggregateErrorNode2(ctx, current, id);
|
|
1528
|
-
}
|
|
1529
|
-
return generateErrorNode2(ctx, current, id);
|
|
1530
|
-
case Error:
|
|
1531
|
-
case EvalError:
|
|
1532
|
-
case RangeError:
|
|
1533
|
-
case ReferenceError:
|
|
1534
|
-
case SyntaxError:
|
|
1535
|
-
case TypeError:
|
|
1536
|
-
case URIError:
|
|
1537
|
-
return generateErrorNode2(ctx, current, id);
|
|
1538
|
-
default:
|
|
1539
|
-
break;
|
|
1540
|
-
}
|
|
1541
|
-
if (current instanceof AggregateError && ctx.features & 1 /* AggregateError */) {
|
|
1542
|
-
return generateAggregateErrorNode2(ctx, current, id);
|
|
1543
|
-
}
|
|
1544
|
-
if (current instanceof Error) {
|
|
1545
|
-
return generateErrorNode2(ctx, current, id);
|
|
1378
|
+
return new SerovalSetNode(id, nodes);
|
|
1379
|
+
}
|
|
1380
|
+
generateProperties(properties) {
|
|
1381
|
+
const keys = Object.keys(properties);
|
|
1382
|
+
const size = keys.length;
|
|
1383
|
+
const keyNodes = new Array(size);
|
|
1384
|
+
const valueNodes = new Array(size);
|
|
1385
|
+
const deferredKeys = new Array(size);
|
|
1386
|
+
const deferredValues = new Array(size);
|
|
1387
|
+
let deferredSize = 0;
|
|
1388
|
+
let nodesSize = 0;
|
|
1389
|
+
let item;
|
|
1390
|
+
for (const key of keys) {
|
|
1391
|
+
item = properties[key];
|
|
1392
|
+
if (isIterable(item)) {
|
|
1393
|
+
deferredKeys[deferredSize] = key;
|
|
1394
|
+
deferredValues[deferredSize] = item;
|
|
1395
|
+
deferredSize++;
|
|
1396
|
+
} else {
|
|
1397
|
+
keyNodes[nodesSize] = key;
|
|
1398
|
+
valueNodes[nodesSize] = this.parse(item);
|
|
1399
|
+
nodesSize++;
|
|
1546
1400
|
}
|
|
1547
|
-
|
|
1548
|
-
|
|
1401
|
+
}
|
|
1402
|
+
for (let i = 0; i < deferredSize; i++) {
|
|
1403
|
+
keyNodes[nodesSize + i] = deferredKeys[i];
|
|
1404
|
+
valueNodes[nodesSize + i] = this.parse(deferredValues[i]);
|
|
1405
|
+
}
|
|
1406
|
+
return {
|
|
1407
|
+
k: keyNodes,
|
|
1408
|
+
v: valueNodes,
|
|
1409
|
+
s: size
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
1412
|
+
generateIterableNode(id, current) {
|
|
1413
|
+
assert(this.ctx.features & 512 /* SymbolIterator */, 'Unsupported type "Iterable"');
|
|
1414
|
+
const options = getIterableOptions(current);
|
|
1415
|
+
return new SerovalIterableNode(
|
|
1416
|
+
id,
|
|
1417
|
+
// Parse options first before the items
|
|
1418
|
+
options ? this.generateProperties(options) : void 0,
|
|
1419
|
+
this.generateNodeList(Array.from(current))
|
|
1420
|
+
);
|
|
1421
|
+
}
|
|
1422
|
+
generateObjectNode(id, current, empty) {
|
|
1423
|
+
if (Symbol.iterator in current) {
|
|
1424
|
+
return this.generateIterableNode(id, current);
|
|
1425
|
+
}
|
|
1426
|
+
if (empty) {
|
|
1427
|
+
return new SerovalNullConstructorNode(id, this.generateProperties(current));
|
|
1428
|
+
}
|
|
1429
|
+
return new SerovalObjectNode(id, this.generateProperties(current));
|
|
1430
|
+
}
|
|
1431
|
+
generateAggregateErrorNode(id, current) {
|
|
1432
|
+
const options = getErrorOptions(current);
|
|
1433
|
+
const optionsNode = options ? this.generateProperties(options) : void 0;
|
|
1434
|
+
return new SerovalAggregateErrorNode(
|
|
1435
|
+
id,
|
|
1436
|
+
current.message,
|
|
1437
|
+
optionsNode,
|
|
1438
|
+
this.parse(current.errors)
|
|
1439
|
+
);
|
|
1440
|
+
}
|
|
1441
|
+
generateErrorNode(id, current) {
|
|
1442
|
+
const options = getErrorOptions(current);
|
|
1443
|
+
const optionsNode = options ? this.generateProperties(options) : void 0;
|
|
1444
|
+
return new SerovalErrorNode(id, getErrorConstructor(current), current.message, optionsNode);
|
|
1445
|
+
}
|
|
1446
|
+
parse(current) {
|
|
1447
|
+
switch (typeof current) {
|
|
1448
|
+
case "boolean":
|
|
1449
|
+
return current ? TRUE_NODE : FALSE_NODE;
|
|
1450
|
+
case "undefined":
|
|
1451
|
+
return UNDEFINED_NODE;
|
|
1452
|
+
case "string":
|
|
1453
|
+
return new SerovalPrimitiveNode(quote(current));
|
|
1454
|
+
case "number":
|
|
1455
|
+
if (Object.is(current, -0)) {
|
|
1456
|
+
return NEG_ZERO_NODE;
|
|
1457
|
+
}
|
|
1458
|
+
if (Object.is(current, Infinity)) {
|
|
1459
|
+
return INFINITY_NODE;
|
|
1460
|
+
}
|
|
1461
|
+
if (Object.is(current, -Infinity)) {
|
|
1462
|
+
return NEG_INFINITY_NODE;
|
|
1463
|
+
}
|
|
1464
|
+
return new SerovalPrimitiveNode(current);
|
|
1465
|
+
case "bigint":
|
|
1466
|
+
assert(this.ctx.features & 8 /* BigInt */, 'Unsupported type "BigInt"');
|
|
1467
|
+
return new SerovalBigIntNode(current);
|
|
1468
|
+
case "object": {
|
|
1469
|
+
if (!current) {
|
|
1470
|
+
return NULL_NODE;
|
|
1471
|
+
}
|
|
1472
|
+
const id = createRef(this.ctx, current, true);
|
|
1473
|
+
if (this.ctx.markedRefs[id]) {
|
|
1474
|
+
return new SerovalReferenceNode(id);
|
|
1475
|
+
}
|
|
1476
|
+
if (Array.isArray(current)) {
|
|
1477
|
+
return this.generateArrayNode(id, current);
|
|
1478
|
+
}
|
|
1479
|
+
switch (current.constructor) {
|
|
1480
|
+
case Date:
|
|
1481
|
+
return new SerovalDateNode(id, current);
|
|
1482
|
+
case RegExp:
|
|
1483
|
+
return new SerovalRegExpNode(id, current);
|
|
1484
|
+
case Int8Array:
|
|
1485
|
+
case Int16Array:
|
|
1486
|
+
case Int32Array:
|
|
1487
|
+
case Uint8Array:
|
|
1488
|
+
case Uint16Array:
|
|
1489
|
+
case Uint32Array:
|
|
1490
|
+
case Uint8ClampedArray:
|
|
1491
|
+
case Float32Array:
|
|
1492
|
+
case Float64Array:
|
|
1493
|
+
assert(this.ctx.features & 1024 /* TypedArray */, `Unsupported value type "${current.constructor.name}"`);
|
|
1494
|
+
return new SerovalTypedArrayNode(id, current);
|
|
1495
|
+
case BigInt64Array:
|
|
1496
|
+
case BigUint64Array:
|
|
1497
|
+
assert(
|
|
1498
|
+
this.ctx.features & 2048 /* BigIntTypedArray */,
|
|
1499
|
+
`Unsupported value type "${current.constructor.name}"`
|
|
1500
|
+
);
|
|
1501
|
+
return new SerovalBigIntTypedArrayNode(id, current);
|
|
1502
|
+
case Map:
|
|
1503
|
+
return this.generateMapNode(id, current);
|
|
1504
|
+
case Set:
|
|
1505
|
+
return this.generateSetNode(id, current);
|
|
1506
|
+
case Object:
|
|
1507
|
+
return this.generateObjectNode(id, current, false);
|
|
1508
|
+
case void 0:
|
|
1509
|
+
return this.generateObjectNode(id, current, true);
|
|
1510
|
+
case AggregateError:
|
|
1511
|
+
if (this.ctx.features & 1 /* AggregateError */) {
|
|
1512
|
+
return this.generateAggregateErrorNode(id, current);
|
|
1513
|
+
}
|
|
1514
|
+
return this.generateErrorNode(id, current);
|
|
1515
|
+
case Error:
|
|
1516
|
+
case EvalError:
|
|
1517
|
+
case RangeError:
|
|
1518
|
+
case ReferenceError:
|
|
1519
|
+
case SyntaxError:
|
|
1520
|
+
case TypeError:
|
|
1521
|
+
case URIError:
|
|
1522
|
+
return this.generateErrorNode(id, current);
|
|
1523
|
+
default:
|
|
1524
|
+
break;
|
|
1525
|
+
}
|
|
1526
|
+
if (current instanceof AggregateError && this.ctx.features & 1 /* AggregateError */) {
|
|
1527
|
+
return this.generateAggregateErrorNode(id, current);
|
|
1528
|
+
}
|
|
1529
|
+
if (current instanceof Error) {
|
|
1530
|
+
return this.generateErrorNode(id, current);
|
|
1531
|
+
}
|
|
1532
|
+
if (Symbol.iterator in current) {
|
|
1533
|
+
return this.generateIterableNode(id, current);
|
|
1534
|
+
}
|
|
1535
|
+
throw new Error("Unsupported type");
|
|
1549
1536
|
}
|
|
1550
|
-
|
|
1537
|
+
default:
|
|
1538
|
+
throw new Error("Unsupported type");
|
|
1551
1539
|
}
|
|
1552
|
-
default:
|
|
1553
|
-
throw new Error("Unsupported type");
|
|
1554
1540
|
}
|
|
1555
|
-
}
|
|
1541
|
+
};
|
|
1556
1542
|
function parseSync(ctx, current) {
|
|
1557
|
-
const result =
|
|
1543
|
+
const result = new SyncParser(ctx).parse(current);
|
|
1558
1544
|
const isObject = result.t === 8 /* Object */ || result.t === 13 /* Iterable */;
|
|
1559
1545
|
return [result, createRef(ctx, current, false), isObject];
|
|
1560
1546
|
}
|
|
@@ -1585,16 +1571,16 @@ function finalize(ctx, rootID, isObject, result) {
|
|
|
1585
1571
|
return result;
|
|
1586
1572
|
}
|
|
1587
1573
|
function serialize(source, options) {
|
|
1588
|
-
const ctx =
|
|
1574
|
+
const ctx = new ParserContext(options);
|
|
1589
1575
|
const [tree, rootID, isObject] = parseSync(ctx, source);
|
|
1590
|
-
const serial =
|
|
1576
|
+
const serial = new SerializationContext(ctx);
|
|
1591
1577
|
const result = serializeTree(serial, tree);
|
|
1592
1578
|
return finalize(serial, rootID, isObject, result);
|
|
1593
1579
|
}
|
|
1594
1580
|
async function serializeAsync(source, options) {
|
|
1595
|
-
const ctx =
|
|
1581
|
+
const ctx = new ParserContext(options);
|
|
1596
1582
|
const [tree, rootID, isObject] = await parseAsync(ctx, source);
|
|
1597
|
-
const serial =
|
|
1583
|
+
const serial = new SerializationContext(ctx);
|
|
1598
1584
|
const result = serializeTree(serial, tree);
|
|
1599
1585
|
return finalize(serial, rootID, isObject, result);
|
|
1600
1586
|
}
|
|
@@ -1602,7 +1588,7 @@ function deserialize(source) {
|
|
|
1602
1588
|
return (0, eval)(source);
|
|
1603
1589
|
}
|
|
1604
1590
|
function toJSON(source, options) {
|
|
1605
|
-
const ctx =
|
|
1591
|
+
const ctx = new ParserContext(options);
|
|
1606
1592
|
const [tree, root, isObject] = parseSync(ctx, source);
|
|
1607
1593
|
return JSON.stringify([
|
|
1608
1594
|
tree,
|
|
@@ -1613,7 +1599,7 @@ function toJSON(source, options) {
|
|
|
1613
1599
|
]);
|
|
1614
1600
|
}
|
|
1615
1601
|
async function toJSONAsync(source, options) {
|
|
1616
|
-
const ctx =
|
|
1602
|
+
const ctx = new ParserContext(options);
|
|
1617
1603
|
const [tree, root, isObject] = await parseAsync(ctx, source);
|
|
1618
1604
|
return JSON.stringify([
|
|
1619
1605
|
tree,
|
|
@@ -1625,7 +1611,7 @@ async function toJSONAsync(source, options) {
|
|
|
1625
1611
|
}
|
|
1626
1612
|
function compileJSON(source) {
|
|
1627
1613
|
const parsed = JSON.parse(source);
|
|
1628
|
-
const serial =
|
|
1614
|
+
const serial = new SerializationContext({
|
|
1629
1615
|
features: parsed[3],
|
|
1630
1616
|
markedRefs: parsed[4]
|
|
1631
1617
|
});
|