seroval 0.4.0-alpha.1 → 0.4.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.
- package/dist/cjs/development/index.cjs +159 -140
- package/dist/cjs/development/index.cjs.map +2 -2
- package/dist/cjs/production/index.cjs +2 -2
- package/dist/esm/development/index.mjs +159 -140
- package/dist/esm/development/index.mjs.map +2 -2
- package/dist/esm/production/index.mjs +2 -2
- package/package.json +2 -2
- package/src/tree.ts +190 -164
|
@@ -551,30 +551,33 @@ function generateSemiPrimitiveValue(ctx, current, id) {
|
|
|
551
551
|
}
|
|
552
552
|
return void 0;
|
|
553
553
|
}
|
|
554
|
-
function
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
for (let i = 0; i < deferredSize; i++) {
|
|
573
|
-
keyNodes.push(deferredKeys[i]);
|
|
574
|
-
valueNodes.push(generateTreeSync(ctx, deferredValues[i]));
|
|
554
|
+
function serializePropertiesSync(ctx, properties) {
|
|
555
|
+
const keys = Object.keys(properties);
|
|
556
|
+
const size = keys.length;
|
|
557
|
+
const keyNodes = new Array(size);
|
|
558
|
+
const valueNodes = new Array(size);
|
|
559
|
+
const deferredKeys = new Array(size);
|
|
560
|
+
const deferredValues = new Array(size);
|
|
561
|
+
let deferredSize = 0;
|
|
562
|
+
let nodesSize = 0;
|
|
563
|
+
for (const key of keys) {
|
|
564
|
+
if (isIterable(properties[key])) {
|
|
565
|
+
deferredKeys[deferredSize] = key;
|
|
566
|
+
deferredValues[deferredSize] = properties[key];
|
|
567
|
+
deferredSize++;
|
|
568
|
+
} else {
|
|
569
|
+
keyNodes[nodesSize] = key;
|
|
570
|
+
valueNodes[nodesSize] = generateTreeSync(ctx, properties[key]);
|
|
571
|
+
nodesSize++;
|
|
575
572
|
}
|
|
576
|
-
return [keyNodes, valueNodes, keys.length];
|
|
577
573
|
}
|
|
574
|
+
for (let i = 0; i < deferredSize; i++) {
|
|
575
|
+
keyNodes[nodesSize + i] = deferredKeys[i];
|
|
576
|
+
valueNodes[nodesSize + i] = generateTreeSync(ctx, deferredValues[i]);
|
|
577
|
+
}
|
|
578
|
+
return [keyNodes, valueNodes, size];
|
|
579
|
+
}
|
|
580
|
+
function generateTreeSync(ctx, current) {
|
|
578
581
|
if (isPrimitive(current)) {
|
|
579
582
|
return [0 /* Primitive */, current];
|
|
580
583
|
}
|
|
@@ -588,42 +591,48 @@ function generateTreeSync(ctx, current) {
|
|
|
588
591
|
}
|
|
589
592
|
if (constructorCheck(current, Set)) {
|
|
590
593
|
assert(ctx.features.has(8 /* Set */), 'Unsupported type "Set"');
|
|
591
|
-
const
|
|
592
|
-
const
|
|
594
|
+
const len = current.size;
|
|
595
|
+
const nodes = new Array(len);
|
|
596
|
+
const deferred = new Array(len);
|
|
597
|
+
let deferredSize = 0;
|
|
598
|
+
let nodeSize = 0;
|
|
593
599
|
for (const item of current.keys()) {
|
|
594
600
|
if (isIterable(item)) {
|
|
595
|
-
deferred
|
|
601
|
+
deferred[deferredSize++] = item;
|
|
596
602
|
} else {
|
|
597
|
-
nodes
|
|
603
|
+
nodes[nodeSize++] = generateTreeSync(ctx, item);
|
|
598
604
|
}
|
|
599
605
|
}
|
|
600
|
-
for (let i = 0
|
|
601
|
-
nodes
|
|
606
|
+
for (let i = 0; i < deferredSize; i++) {
|
|
607
|
+
nodes[nodeSize + i] = generateTreeSync(ctx, deferred[i]);
|
|
602
608
|
}
|
|
603
609
|
return [4 /* Set */, nodes, id];
|
|
604
610
|
}
|
|
605
611
|
if (constructorCheck(current, Map)) {
|
|
606
612
|
assert(ctx.features.has(4 /* Map */), 'Unsupported type "Map"');
|
|
607
|
-
const
|
|
608
|
-
const
|
|
609
|
-
const
|
|
610
|
-
const
|
|
613
|
+
const len = current.size;
|
|
614
|
+
const keyNodes = new Array(len);
|
|
615
|
+
const valueNodes = new Array(len);
|
|
616
|
+
const deferredKey = new Array(len);
|
|
617
|
+
const deferredValue = new Array(len);
|
|
611
618
|
let deferredSize = 0;
|
|
619
|
+
let nodeSize = 0;
|
|
612
620
|
for (const [key, value] of current.entries()) {
|
|
613
621
|
if (isIterable(key) || isIterable(value)) {
|
|
614
|
-
deferredKey
|
|
615
|
-
deferredValue
|
|
622
|
+
deferredKey[deferredSize] = key;
|
|
623
|
+
deferredValue[deferredSize] = value;
|
|
616
624
|
deferredSize++;
|
|
617
625
|
} else {
|
|
618
|
-
keyNodes
|
|
619
|
-
valueNodes
|
|
626
|
+
keyNodes[nodeSize] = generateTreeSync(ctx, key);
|
|
627
|
+
valueNodes[nodeSize] = generateTreeSync(ctx, value);
|
|
628
|
+
nodeSize++;
|
|
620
629
|
}
|
|
621
630
|
}
|
|
622
631
|
for (let i = 0; i < deferredSize; i++) {
|
|
623
|
-
keyNodes
|
|
624
|
-
valueNodes
|
|
632
|
+
keyNodes[nodeSize + i] = generateTreeSync(ctx, deferredKey[i]);
|
|
633
|
+
valueNodes[nodeSize + i] = generateTreeSync(ctx, deferredValue[i]);
|
|
625
634
|
}
|
|
626
|
-
return [5 /* Map */, [keyNodes, valueNodes,
|
|
635
|
+
return [5 /* Map */, [keyNodes, valueNodes, len], id];
|
|
627
636
|
}
|
|
628
637
|
if (Array.isArray(current)) {
|
|
629
638
|
const size = current.length;
|
|
@@ -647,13 +656,13 @@ function generateTreeSync(ctx, current) {
|
|
|
647
656
|
}
|
|
648
657
|
if (current instanceof AggregateError && ctx.features.has(0 /* AggregateError */)) {
|
|
649
658
|
const options = getErrorOptions(current);
|
|
650
|
-
const optionsNode = options ?
|
|
659
|
+
const optionsNode = options ? serializePropertiesSync(ctx, options) : void 0;
|
|
651
660
|
const errorsNode = generateTreeSync(ctx, current.errors);
|
|
652
661
|
return [11 /* AggregateError */, [current.message, optionsNode, errorsNode], id];
|
|
653
662
|
}
|
|
654
663
|
if (current instanceof Error) {
|
|
655
664
|
const options = getErrorOptions(current);
|
|
656
|
-
const optionsNode = options ?
|
|
665
|
+
const optionsNode = options ? serializePropertiesSync(ctx, options) : void 0;
|
|
657
666
|
return [
|
|
658
667
|
10 /* Error */,
|
|
659
668
|
[getErrorConstructor(current), current.message, optionsNode],
|
|
@@ -665,7 +674,7 @@ function generateTreeSync(ctx, current) {
|
|
|
665
674
|
const options = getIterableOptions(current);
|
|
666
675
|
return [12 /* Iterable */, [
|
|
667
676
|
// Parse options first before the items
|
|
668
|
-
options ?
|
|
677
|
+
options ? serializePropertiesSync(ctx, options) : void 0,
|
|
669
678
|
generateTreeSync(ctx, Array.from(current))
|
|
670
679
|
], id];
|
|
671
680
|
}
|
|
@@ -673,36 +682,39 @@ function generateTreeSync(ctx, current) {
|
|
|
673
682
|
if (current.constructor === Object || empty) {
|
|
674
683
|
return [
|
|
675
684
|
empty ? 8 /* NullConstructor */ : 7 /* Object */,
|
|
676
|
-
|
|
685
|
+
serializePropertiesSync(ctx, current),
|
|
677
686
|
id
|
|
678
687
|
];
|
|
679
688
|
}
|
|
680
689
|
throw new Error("Unsupported value");
|
|
681
690
|
}
|
|
682
|
-
async function
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
for (let i = 0; i < deferredSize; i++) {
|
|
701
|
-
keyNodes.push(deferredKeys[i]);
|
|
702
|
-
valueNodes.push(await generateTreeAsync(ctx, deferredValues[i]));
|
|
691
|
+
async function serializePropertiesAsync(ctx, properties) {
|
|
692
|
+
const keys = Object.keys(properties);
|
|
693
|
+
const size = keys.length;
|
|
694
|
+
const keyNodes = new Array(size);
|
|
695
|
+
const valueNodes = new Array(size);
|
|
696
|
+
const deferredKeys = new Array(size);
|
|
697
|
+
const deferredValues = new Array(size);
|
|
698
|
+
let deferredSize = 0;
|
|
699
|
+
let nodesSize = 0;
|
|
700
|
+
for (const key of keys) {
|
|
701
|
+
if (isIterable(properties[key])) {
|
|
702
|
+
deferredKeys[deferredSize] = key;
|
|
703
|
+
deferredValues[deferredSize] = properties[key];
|
|
704
|
+
deferredSize++;
|
|
705
|
+
} else {
|
|
706
|
+
keyNodes[nodesSize] = key;
|
|
707
|
+
valueNodes[nodesSize] = await generateTreeAsync(ctx, properties[key]);
|
|
708
|
+
nodesSize++;
|
|
703
709
|
}
|
|
704
|
-
return [keyNodes, valueNodes, keys.length];
|
|
705
710
|
}
|
|
711
|
+
for (let i = 0; i < deferredSize; i++) {
|
|
712
|
+
keyNodes[nodesSize + i] = deferredKeys[i];
|
|
713
|
+
valueNodes[nodesSize + i] = await generateTreeAsync(ctx, deferredValues[i]);
|
|
714
|
+
}
|
|
715
|
+
return [keyNodes, valueNodes, size];
|
|
716
|
+
}
|
|
717
|
+
async function generateTreeAsync(ctx, current) {
|
|
706
718
|
if (isPrimitive(current)) {
|
|
707
719
|
return [0 /* Primitive */, current];
|
|
708
720
|
}
|
|
@@ -724,42 +736,48 @@ async function generateTreeAsync(ctx, current) {
|
|
|
724
736
|
}
|
|
725
737
|
if (constructorCheck(current, Set)) {
|
|
726
738
|
assert(ctx.features.has(8 /* Set */), 'Unsupported type "Set"');
|
|
727
|
-
const
|
|
728
|
-
const
|
|
739
|
+
const len = current.size;
|
|
740
|
+
const nodes = new Array(len);
|
|
741
|
+
const deferred = new Array(len);
|
|
742
|
+
let deferredSize = 0;
|
|
743
|
+
let nodeSize = 0;
|
|
729
744
|
for (const item of current.keys()) {
|
|
730
745
|
if (isIterable(item)) {
|
|
731
|
-
deferred
|
|
746
|
+
deferred[deferredSize++] = item;
|
|
732
747
|
} else {
|
|
733
|
-
nodes
|
|
748
|
+
nodes[nodeSize++] = await generateTreeAsync(ctx, item);
|
|
734
749
|
}
|
|
735
750
|
}
|
|
736
|
-
for (let i = 0
|
|
737
|
-
nodes
|
|
751
|
+
for (let i = 0; i < deferredSize; i++) {
|
|
752
|
+
nodes[nodeSize + i] = await generateTreeAsync(ctx, deferred[i]);
|
|
738
753
|
}
|
|
739
754
|
return [4 /* Set */, nodes, id];
|
|
740
755
|
}
|
|
741
756
|
if (constructorCheck(current, Map)) {
|
|
742
757
|
assert(ctx.features.has(4 /* Map */), 'Unsupported type "Map"');
|
|
743
|
-
const
|
|
744
|
-
const
|
|
745
|
-
const
|
|
746
|
-
const
|
|
758
|
+
const len = current.size;
|
|
759
|
+
const keyNodes = new Array(len);
|
|
760
|
+
const valueNodes = new Array(len);
|
|
761
|
+
const deferredKey = new Array(len);
|
|
762
|
+
const deferredValue = new Array(len);
|
|
747
763
|
let deferredSize = 0;
|
|
764
|
+
let nodeSize = 0;
|
|
748
765
|
for (const [key, value] of current.entries()) {
|
|
749
766
|
if (isIterable(key) || isIterable(value)) {
|
|
750
|
-
deferredKey
|
|
751
|
-
deferredValue
|
|
767
|
+
deferredKey[deferredSize] = key;
|
|
768
|
+
deferredValue[deferredSize] = value;
|
|
752
769
|
deferredSize++;
|
|
753
770
|
} else {
|
|
754
|
-
keyNodes
|
|
755
|
-
valueNodes
|
|
771
|
+
keyNodes[nodeSize] = await generateTreeAsync(ctx, key);
|
|
772
|
+
valueNodes[nodeSize] = await generateTreeAsync(ctx, value);
|
|
773
|
+
nodeSize++;
|
|
756
774
|
}
|
|
757
775
|
}
|
|
758
776
|
for (let i = 0; i < deferredSize; i++) {
|
|
759
|
-
keyNodes
|
|
760
|
-
valueNodes
|
|
777
|
+
keyNodes[nodeSize + i] = await generateTreeAsync(ctx, deferredKey[i]);
|
|
778
|
+
valueNodes[nodeSize + i] = await generateTreeAsync(ctx, deferredValue[i]);
|
|
761
779
|
}
|
|
762
|
-
return [5 /* Map */, [keyNodes, valueNodes,
|
|
780
|
+
return [5 /* Map */, [keyNodes, valueNodes, len], id];
|
|
763
781
|
}
|
|
764
782
|
if (Array.isArray(current)) {
|
|
765
783
|
const size = current.length;
|
|
@@ -784,13 +802,13 @@ async function generateTreeAsync(ctx, current) {
|
|
|
784
802
|
}
|
|
785
803
|
if (current instanceof AggregateError) {
|
|
786
804
|
const options = getErrorOptions(current);
|
|
787
|
-
const optionsNode = options ? await
|
|
805
|
+
const optionsNode = options ? await serializePropertiesAsync(ctx, options) : void 0;
|
|
788
806
|
const errorsNode = await generateTreeAsync(ctx, current.errors);
|
|
789
807
|
return [11 /* AggregateError */, [current.message, optionsNode, errorsNode], id];
|
|
790
808
|
}
|
|
791
809
|
if (current instanceof Error) {
|
|
792
810
|
const options = getErrorOptions(current);
|
|
793
|
-
const optionsNode = options ? await
|
|
811
|
+
const optionsNode = options ? await serializePropertiesAsync(ctx, options) : void 0;
|
|
794
812
|
return [
|
|
795
813
|
10 /* Error */,
|
|
796
814
|
[getErrorConstructor(current), current.message, optionsNode],
|
|
@@ -801,7 +819,7 @@ async function generateTreeAsync(ctx, current) {
|
|
|
801
819
|
assert(ctx.features.has(9 /* SymbolIterator */), 'Unsupported type "Iterable"');
|
|
802
820
|
const options = getIterableOptions(current);
|
|
803
821
|
return [12 /* Iterable */, [
|
|
804
|
-
options ? await
|
|
822
|
+
options ? await serializePropertiesAsync(ctx, options) : void 0,
|
|
805
823
|
await generateTreeAsync(ctx, Array.from(current))
|
|
806
824
|
], id];
|
|
807
825
|
}
|
|
@@ -809,7 +827,7 @@ async function generateTreeAsync(ctx, current) {
|
|
|
809
827
|
if (current.constructor === Object || empty) {
|
|
810
828
|
return [
|
|
811
829
|
empty ? 8 /* NullConstructor */ : 7 /* Object */,
|
|
812
|
-
await
|
|
830
|
+
await serializePropertiesAsync(ctx, current),
|
|
813
831
|
id
|
|
814
832
|
];
|
|
815
833
|
}
|
|
@@ -846,61 +864,62 @@ function serializePrimitive(ctx, value) {
|
|
|
846
864
|
}
|
|
847
865
|
return String(value);
|
|
848
866
|
}
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
} else {
|
|
866
|
-
createObjectIdentifierAssign(ctx, targetRef, key, refParam);
|
|
867
|
-
}
|
|
867
|
+
var IDENTIFIER_CHECK = /^([$A-Z_][0-9A-Z_$]*)$/i;
|
|
868
|
+
function serializeAssignments(ctx, targetRef, [keys, values, size]) {
|
|
869
|
+
ctx.stack.push(targetRef);
|
|
870
|
+
const mainAssignments = [];
|
|
871
|
+
for (let i = 0; i < size; i++) {
|
|
872
|
+
const parentStack = ctx.stack;
|
|
873
|
+
ctx.stack = [];
|
|
874
|
+
const refParam = serializeTree(ctx, values[i]);
|
|
875
|
+
ctx.stack = parentStack;
|
|
876
|
+
const key = keys[i];
|
|
877
|
+
const check = Number(key);
|
|
878
|
+
const parentAssignment = ctx.assignments;
|
|
879
|
+
ctx.assignments = mainAssignments;
|
|
880
|
+
if (IDENTIFIER_CHECK.test(key) || check >= 0) {
|
|
881
|
+
if (!Number.isNaN(check)) {
|
|
882
|
+
createObjectComputedAssign(ctx, targetRef, key, refParam);
|
|
868
883
|
} else {
|
|
869
|
-
|
|
884
|
+
createObjectIdentifierAssign(ctx, targetRef, key, refParam);
|
|
870
885
|
}
|
|
871
|
-
|
|
886
|
+
} else {
|
|
887
|
+
createObjectComputedAssign(ctx, targetRef, quote(key), refParam);
|
|
872
888
|
}
|
|
873
|
-
ctx.
|
|
874
|
-
return resolveAssignments(mainAssignments);
|
|
889
|
+
ctx.assignments = parentAssignment;
|
|
875
890
|
}
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
+
ctx.stack.pop();
|
|
892
|
+
return resolveAssignments(mainAssignments);
|
|
893
|
+
}
|
|
894
|
+
function serializeObject(ctx, sourceID, [keys, values, size]) {
|
|
895
|
+
let result = "";
|
|
896
|
+
ctx.stack.push(sourceID);
|
|
897
|
+
for (let i = 0; i < size; i++) {
|
|
898
|
+
const key = keys[i];
|
|
899
|
+
const val = values[i];
|
|
900
|
+
const check = Number(key);
|
|
901
|
+
const isIdentifier = IDENTIFIER_CHECK.test(key) || check >= 0;
|
|
902
|
+
if (isReferenceInStack(ctx, val)) {
|
|
903
|
+
const refParam = getRefParam(ctx, val[1]);
|
|
904
|
+
if (isIdentifier) {
|
|
905
|
+
if (!Number.isNaN(check)) {
|
|
906
|
+
createObjectComputedAssign(ctx, sourceID, key, refParam);
|
|
891
907
|
} else {
|
|
892
|
-
|
|
908
|
+
createObjectIdentifierAssign(ctx, sourceID, key, refParam);
|
|
893
909
|
}
|
|
894
|
-
} else if (isReferenceInStack(ctx, val)) {
|
|
895
|
-
const refParam = getRefParam(ctx, val[1]);
|
|
896
|
-
createObjectComputedAssign(ctx, sourceID, quote(key), refParam);
|
|
897
910
|
} else {
|
|
898
|
-
|
|
911
|
+
createObjectComputedAssign(ctx, sourceID, quote(key), refParam);
|
|
899
912
|
}
|
|
913
|
+
} else if (isIdentifier) {
|
|
914
|
+
result += `${key}:${serializeTree(ctx, val)},`;
|
|
915
|
+
} else {
|
|
916
|
+
result += `${quote(key)}:${serializeTree(ctx, val)},`;
|
|
900
917
|
}
|
|
901
|
-
ctx.stack.pop();
|
|
902
|
-
return `{${result.substring(0, result.length - 1)}}`;
|
|
903
918
|
}
|
|
919
|
+
ctx.stack.pop();
|
|
920
|
+
return `{${result.substring(0, result.length - 1)}}`;
|
|
921
|
+
}
|
|
922
|
+
function serializeTree(ctx, [type, value, id]) {
|
|
904
923
|
switch (type) {
|
|
905
924
|
case 0 /* Primitive */:
|
|
906
925
|
return serializePrimitive(ctx, value);
|
|
@@ -1020,11 +1039,11 @@ function serializeTree(ctx, [type, value, id]) {
|
|
|
1020
1039
|
ctx.stack.pop();
|
|
1021
1040
|
if (value[1]) {
|
|
1022
1041
|
if (ctx.features.has(6 /* ObjectAssign */)) {
|
|
1023
|
-
const options = serializeObject(id, value[1]);
|
|
1042
|
+
const options = serializeObject(ctx, id, value[1]);
|
|
1024
1043
|
serialized = `Object.assign(${serialized},${options})`;
|
|
1025
1044
|
} else {
|
|
1026
1045
|
markRef(ctx, id);
|
|
1027
|
-
const assignments = serializeAssignments(id, value[1]);
|
|
1046
|
+
const assignments = serializeAssignments(ctx, id, value[1]);
|
|
1028
1047
|
if (assignments) {
|
|
1029
1048
|
const ref = getRefParam(ctx, id);
|
|
1030
1049
|
return `(${assignRef(ctx, id, serialized)},${assignments}${ref})`;
|
|
@@ -1037,11 +1056,11 @@ function serializeTree(ctx, [type, value, id]) {
|
|
|
1037
1056
|
let serialized = `new ${value[0]}(${quote(value[1])})`;
|
|
1038
1057
|
if (value[2]) {
|
|
1039
1058
|
if (ctx.features.has(6 /* ObjectAssign */)) {
|
|
1040
|
-
const options = serializeObject(id, value[2]);
|
|
1059
|
+
const options = serializeObject(ctx, id, value[2]);
|
|
1041
1060
|
serialized = `Object.assign(${serialized},${options})`;
|
|
1042
1061
|
} else {
|
|
1043
1062
|
markRef(ctx, id);
|
|
1044
|
-
const assignments = serializeAssignments(id, value[2]);
|
|
1063
|
+
const assignments = serializeAssignments(ctx, id, value[2]);
|
|
1045
1064
|
if (assignments) {
|
|
1046
1065
|
const ref = getRefParam(ctx, id);
|
|
1047
1066
|
return `(${assignRef(ctx, id, serialized)},${assignments}${ref})`;
|
|
@@ -1070,11 +1089,11 @@ function serializeTree(ctx, [type, value, id]) {
|
|
|
1070
1089
|
}
|
|
1071
1090
|
if (value[0]) {
|
|
1072
1091
|
if (ctx.features.has(6 /* ObjectAssign */)) {
|
|
1073
|
-
const options = serializeObject(id, value[0]);
|
|
1092
|
+
const options = serializeObject(ctx, id, value[0]);
|
|
1074
1093
|
serialized = `Object.assign(${serialized},${options})`;
|
|
1075
1094
|
} else {
|
|
1076
1095
|
markRef(ctx, id);
|
|
1077
|
-
const assignments = serializeAssignments(id, value[0]);
|
|
1096
|
+
const assignments = serializeAssignments(ctx, id, value[0]);
|
|
1078
1097
|
if (assignments) {
|
|
1079
1098
|
const ref = getRefParam(ctx, id);
|
|
1080
1099
|
return `(${assignRef(ctx, id, serialized)},${assignments}${ref})`;
|
|
@@ -1086,13 +1105,13 @@ function serializeTree(ctx, [type, value, id]) {
|
|
|
1086
1105
|
case 8 /* NullConstructor */: {
|
|
1087
1106
|
let serialized = "Object.create(null)";
|
|
1088
1107
|
if (ctx.features.has(6 /* ObjectAssign */)) {
|
|
1089
|
-
const fields = serializeObject(id, value);
|
|
1108
|
+
const fields = serializeObject(ctx, id, value);
|
|
1090
1109
|
if (fields !== "{}") {
|
|
1091
1110
|
serialized = `Object.assign(${serialized},${fields})`;
|
|
1092
1111
|
}
|
|
1093
1112
|
} else {
|
|
1094
1113
|
markRef(ctx, id);
|
|
1095
|
-
const assignments = serializeAssignments(id, value);
|
|
1114
|
+
const assignments = serializeAssignments(ctx, id, value);
|
|
1096
1115
|
if (assignments) {
|
|
1097
1116
|
const ref = getRefParam(ctx, id);
|
|
1098
1117
|
return `(${assignRef(ctx, id, serialized)},${assignments}${ref})`;
|
|
@@ -1101,7 +1120,7 @@ function serializeTree(ctx, [type, value, id]) {
|
|
|
1101
1120
|
return assignRef(ctx, id, serialized);
|
|
1102
1121
|
}
|
|
1103
1122
|
case 7 /* Object */:
|
|
1104
|
-
return assignRef(ctx, id, serializeObject(id, value));
|
|
1123
|
+
return assignRef(ctx, id, serializeObject(ctx, id, value));
|
|
1105
1124
|
default:
|
|
1106
1125
|
throw new Error("Unsupported type");
|
|
1107
1126
|
}
|