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
|
@@ -580,30 +580,33 @@ function generateSemiPrimitiveValue(ctx, current, id) {
|
|
|
580
580
|
}
|
|
581
581
|
return void 0;
|
|
582
582
|
}
|
|
583
|
-
function
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
for (let i = 0; i < deferredSize; i++) {
|
|
602
|
-
keyNodes.push(deferredKeys[i]);
|
|
603
|
-
valueNodes.push(generateTreeSync(ctx, deferredValues[i]));
|
|
583
|
+
function serializePropertiesSync(ctx, properties) {
|
|
584
|
+
const keys = Object.keys(properties);
|
|
585
|
+
const size = keys.length;
|
|
586
|
+
const keyNodes = new Array(size);
|
|
587
|
+
const valueNodes = new Array(size);
|
|
588
|
+
const deferredKeys = new Array(size);
|
|
589
|
+
const deferredValues = new Array(size);
|
|
590
|
+
let deferredSize = 0;
|
|
591
|
+
let nodesSize = 0;
|
|
592
|
+
for (const key of keys) {
|
|
593
|
+
if (isIterable(properties[key])) {
|
|
594
|
+
deferredKeys[deferredSize] = key;
|
|
595
|
+
deferredValues[deferredSize] = properties[key];
|
|
596
|
+
deferredSize++;
|
|
597
|
+
} else {
|
|
598
|
+
keyNodes[nodesSize] = key;
|
|
599
|
+
valueNodes[nodesSize] = generateTreeSync(ctx, properties[key]);
|
|
600
|
+
nodesSize++;
|
|
604
601
|
}
|
|
605
|
-
return [keyNodes, valueNodes, keys.length];
|
|
606
602
|
}
|
|
603
|
+
for (let i = 0; i < deferredSize; i++) {
|
|
604
|
+
keyNodes[nodesSize + i] = deferredKeys[i];
|
|
605
|
+
valueNodes[nodesSize + i] = generateTreeSync(ctx, deferredValues[i]);
|
|
606
|
+
}
|
|
607
|
+
return [keyNodes, valueNodes, size];
|
|
608
|
+
}
|
|
609
|
+
function generateTreeSync(ctx, current) {
|
|
607
610
|
if (isPrimitive(current)) {
|
|
608
611
|
return [0 /* Primitive */, current];
|
|
609
612
|
}
|
|
@@ -617,42 +620,48 @@ function generateTreeSync(ctx, current) {
|
|
|
617
620
|
}
|
|
618
621
|
if (constructorCheck(current, Set)) {
|
|
619
622
|
assert(ctx.features.has(8 /* Set */), 'Unsupported type "Set"');
|
|
620
|
-
const
|
|
621
|
-
const
|
|
623
|
+
const len = current.size;
|
|
624
|
+
const nodes = new Array(len);
|
|
625
|
+
const deferred = new Array(len);
|
|
626
|
+
let deferredSize = 0;
|
|
627
|
+
let nodeSize = 0;
|
|
622
628
|
for (const item of current.keys()) {
|
|
623
629
|
if (isIterable(item)) {
|
|
624
|
-
deferred
|
|
630
|
+
deferred[deferredSize++] = item;
|
|
625
631
|
} else {
|
|
626
|
-
nodes
|
|
632
|
+
nodes[nodeSize++] = generateTreeSync(ctx, item);
|
|
627
633
|
}
|
|
628
634
|
}
|
|
629
|
-
for (let i = 0
|
|
630
|
-
nodes
|
|
635
|
+
for (let i = 0; i < deferredSize; i++) {
|
|
636
|
+
nodes[nodeSize + i] = generateTreeSync(ctx, deferred[i]);
|
|
631
637
|
}
|
|
632
638
|
return [4 /* Set */, nodes, id];
|
|
633
639
|
}
|
|
634
640
|
if (constructorCheck(current, Map)) {
|
|
635
641
|
assert(ctx.features.has(4 /* Map */), 'Unsupported type "Map"');
|
|
636
|
-
const
|
|
637
|
-
const
|
|
638
|
-
const
|
|
639
|
-
const
|
|
642
|
+
const len = current.size;
|
|
643
|
+
const keyNodes = new Array(len);
|
|
644
|
+
const valueNodes = new Array(len);
|
|
645
|
+
const deferredKey = new Array(len);
|
|
646
|
+
const deferredValue = new Array(len);
|
|
640
647
|
let deferredSize = 0;
|
|
648
|
+
let nodeSize = 0;
|
|
641
649
|
for (const [key, value] of current.entries()) {
|
|
642
650
|
if (isIterable(key) || isIterable(value)) {
|
|
643
|
-
deferredKey
|
|
644
|
-
deferredValue
|
|
651
|
+
deferredKey[deferredSize] = key;
|
|
652
|
+
deferredValue[deferredSize] = value;
|
|
645
653
|
deferredSize++;
|
|
646
654
|
} else {
|
|
647
|
-
keyNodes
|
|
648
|
-
valueNodes
|
|
655
|
+
keyNodes[nodeSize] = generateTreeSync(ctx, key);
|
|
656
|
+
valueNodes[nodeSize] = generateTreeSync(ctx, value);
|
|
657
|
+
nodeSize++;
|
|
649
658
|
}
|
|
650
659
|
}
|
|
651
660
|
for (let i = 0; i < deferredSize; i++) {
|
|
652
|
-
keyNodes
|
|
653
|
-
valueNodes
|
|
661
|
+
keyNodes[nodeSize + i] = generateTreeSync(ctx, deferredKey[i]);
|
|
662
|
+
valueNodes[nodeSize + i] = generateTreeSync(ctx, deferredValue[i]);
|
|
654
663
|
}
|
|
655
|
-
return [5 /* Map */, [keyNodes, valueNodes,
|
|
664
|
+
return [5 /* Map */, [keyNodes, valueNodes, len], id];
|
|
656
665
|
}
|
|
657
666
|
if (Array.isArray(current)) {
|
|
658
667
|
const size = current.length;
|
|
@@ -676,13 +685,13 @@ function generateTreeSync(ctx, current) {
|
|
|
676
685
|
}
|
|
677
686
|
if (current instanceof AggregateError && ctx.features.has(0 /* AggregateError */)) {
|
|
678
687
|
const options = getErrorOptions(current);
|
|
679
|
-
const optionsNode = options ?
|
|
688
|
+
const optionsNode = options ? serializePropertiesSync(ctx, options) : void 0;
|
|
680
689
|
const errorsNode = generateTreeSync(ctx, current.errors);
|
|
681
690
|
return [11 /* AggregateError */, [current.message, optionsNode, errorsNode], id];
|
|
682
691
|
}
|
|
683
692
|
if (current instanceof Error) {
|
|
684
693
|
const options = getErrorOptions(current);
|
|
685
|
-
const optionsNode = options ?
|
|
694
|
+
const optionsNode = options ? serializePropertiesSync(ctx, options) : void 0;
|
|
686
695
|
return [
|
|
687
696
|
10 /* Error */,
|
|
688
697
|
[getErrorConstructor(current), current.message, optionsNode],
|
|
@@ -694,7 +703,7 @@ function generateTreeSync(ctx, current) {
|
|
|
694
703
|
const options = getIterableOptions(current);
|
|
695
704
|
return [12 /* Iterable */, [
|
|
696
705
|
// Parse options first before the items
|
|
697
|
-
options ?
|
|
706
|
+
options ? serializePropertiesSync(ctx, options) : void 0,
|
|
698
707
|
generateTreeSync(ctx, Array.from(current))
|
|
699
708
|
], id];
|
|
700
709
|
}
|
|
@@ -702,36 +711,39 @@ function generateTreeSync(ctx, current) {
|
|
|
702
711
|
if (current.constructor === Object || empty) {
|
|
703
712
|
return [
|
|
704
713
|
empty ? 8 /* NullConstructor */ : 7 /* Object */,
|
|
705
|
-
|
|
714
|
+
serializePropertiesSync(ctx, current),
|
|
706
715
|
id
|
|
707
716
|
];
|
|
708
717
|
}
|
|
709
718
|
throw new Error("Unsupported value");
|
|
710
719
|
}
|
|
711
|
-
async function
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
for (let i = 0; i < deferredSize; i++) {
|
|
730
|
-
keyNodes.push(deferredKeys[i]);
|
|
731
|
-
valueNodes.push(await generateTreeAsync(ctx, deferredValues[i]));
|
|
720
|
+
async function serializePropertiesAsync(ctx, properties) {
|
|
721
|
+
const keys = Object.keys(properties);
|
|
722
|
+
const size = keys.length;
|
|
723
|
+
const keyNodes = new Array(size);
|
|
724
|
+
const valueNodes = new Array(size);
|
|
725
|
+
const deferredKeys = new Array(size);
|
|
726
|
+
const deferredValues = new Array(size);
|
|
727
|
+
let deferredSize = 0;
|
|
728
|
+
let nodesSize = 0;
|
|
729
|
+
for (const key of keys) {
|
|
730
|
+
if (isIterable(properties[key])) {
|
|
731
|
+
deferredKeys[deferredSize] = key;
|
|
732
|
+
deferredValues[deferredSize] = properties[key];
|
|
733
|
+
deferredSize++;
|
|
734
|
+
} else {
|
|
735
|
+
keyNodes[nodesSize] = key;
|
|
736
|
+
valueNodes[nodesSize] = await generateTreeAsync(ctx, properties[key]);
|
|
737
|
+
nodesSize++;
|
|
732
738
|
}
|
|
733
|
-
return [keyNodes, valueNodes, keys.length];
|
|
734
739
|
}
|
|
740
|
+
for (let i = 0; i < deferredSize; i++) {
|
|
741
|
+
keyNodes[nodesSize + i] = deferredKeys[i];
|
|
742
|
+
valueNodes[nodesSize + i] = await generateTreeAsync(ctx, deferredValues[i]);
|
|
743
|
+
}
|
|
744
|
+
return [keyNodes, valueNodes, size];
|
|
745
|
+
}
|
|
746
|
+
async function generateTreeAsync(ctx, current) {
|
|
735
747
|
if (isPrimitive(current)) {
|
|
736
748
|
return [0 /* Primitive */, current];
|
|
737
749
|
}
|
|
@@ -753,42 +765,48 @@ async function generateTreeAsync(ctx, current) {
|
|
|
753
765
|
}
|
|
754
766
|
if (constructorCheck(current, Set)) {
|
|
755
767
|
assert(ctx.features.has(8 /* Set */), 'Unsupported type "Set"');
|
|
756
|
-
const
|
|
757
|
-
const
|
|
768
|
+
const len = current.size;
|
|
769
|
+
const nodes = new Array(len);
|
|
770
|
+
const deferred = new Array(len);
|
|
771
|
+
let deferredSize = 0;
|
|
772
|
+
let nodeSize = 0;
|
|
758
773
|
for (const item of current.keys()) {
|
|
759
774
|
if (isIterable(item)) {
|
|
760
|
-
deferred
|
|
775
|
+
deferred[deferredSize++] = item;
|
|
761
776
|
} else {
|
|
762
|
-
nodes
|
|
777
|
+
nodes[nodeSize++] = await generateTreeAsync(ctx, item);
|
|
763
778
|
}
|
|
764
779
|
}
|
|
765
|
-
for (let i = 0
|
|
766
|
-
nodes
|
|
780
|
+
for (let i = 0; i < deferredSize; i++) {
|
|
781
|
+
nodes[nodeSize + i] = await generateTreeAsync(ctx, deferred[i]);
|
|
767
782
|
}
|
|
768
783
|
return [4 /* Set */, nodes, id];
|
|
769
784
|
}
|
|
770
785
|
if (constructorCheck(current, Map)) {
|
|
771
786
|
assert(ctx.features.has(4 /* Map */), 'Unsupported type "Map"');
|
|
772
|
-
const
|
|
773
|
-
const
|
|
774
|
-
const
|
|
775
|
-
const
|
|
787
|
+
const len = current.size;
|
|
788
|
+
const keyNodes = new Array(len);
|
|
789
|
+
const valueNodes = new Array(len);
|
|
790
|
+
const deferredKey = new Array(len);
|
|
791
|
+
const deferredValue = new Array(len);
|
|
776
792
|
let deferredSize = 0;
|
|
793
|
+
let nodeSize = 0;
|
|
777
794
|
for (const [key, value] of current.entries()) {
|
|
778
795
|
if (isIterable(key) || isIterable(value)) {
|
|
779
|
-
deferredKey
|
|
780
|
-
deferredValue
|
|
796
|
+
deferredKey[deferredSize] = key;
|
|
797
|
+
deferredValue[deferredSize] = value;
|
|
781
798
|
deferredSize++;
|
|
782
799
|
} else {
|
|
783
|
-
keyNodes
|
|
784
|
-
valueNodes
|
|
800
|
+
keyNodes[nodeSize] = await generateTreeAsync(ctx, key);
|
|
801
|
+
valueNodes[nodeSize] = await generateTreeAsync(ctx, value);
|
|
802
|
+
nodeSize++;
|
|
785
803
|
}
|
|
786
804
|
}
|
|
787
805
|
for (let i = 0; i < deferredSize; i++) {
|
|
788
|
-
keyNodes
|
|
789
|
-
valueNodes
|
|
806
|
+
keyNodes[nodeSize + i] = await generateTreeAsync(ctx, deferredKey[i]);
|
|
807
|
+
valueNodes[nodeSize + i] = await generateTreeAsync(ctx, deferredValue[i]);
|
|
790
808
|
}
|
|
791
|
-
return [5 /* Map */, [keyNodes, valueNodes,
|
|
809
|
+
return [5 /* Map */, [keyNodes, valueNodes, len], id];
|
|
792
810
|
}
|
|
793
811
|
if (Array.isArray(current)) {
|
|
794
812
|
const size = current.length;
|
|
@@ -813,13 +831,13 @@ async function generateTreeAsync(ctx, current) {
|
|
|
813
831
|
}
|
|
814
832
|
if (current instanceof AggregateError) {
|
|
815
833
|
const options = getErrorOptions(current);
|
|
816
|
-
const optionsNode = options ? await
|
|
834
|
+
const optionsNode = options ? await serializePropertiesAsync(ctx, options) : void 0;
|
|
817
835
|
const errorsNode = await generateTreeAsync(ctx, current.errors);
|
|
818
836
|
return [11 /* AggregateError */, [current.message, optionsNode, errorsNode], id];
|
|
819
837
|
}
|
|
820
838
|
if (current instanceof Error) {
|
|
821
839
|
const options = getErrorOptions(current);
|
|
822
|
-
const optionsNode = options ? await
|
|
840
|
+
const optionsNode = options ? await serializePropertiesAsync(ctx, options) : void 0;
|
|
823
841
|
return [
|
|
824
842
|
10 /* Error */,
|
|
825
843
|
[getErrorConstructor(current), current.message, optionsNode],
|
|
@@ -830,7 +848,7 @@ async function generateTreeAsync(ctx, current) {
|
|
|
830
848
|
assert(ctx.features.has(9 /* SymbolIterator */), 'Unsupported type "Iterable"');
|
|
831
849
|
const options = getIterableOptions(current);
|
|
832
850
|
return [12 /* Iterable */, [
|
|
833
|
-
options ? await
|
|
851
|
+
options ? await serializePropertiesAsync(ctx, options) : void 0,
|
|
834
852
|
await generateTreeAsync(ctx, Array.from(current))
|
|
835
853
|
], id];
|
|
836
854
|
}
|
|
@@ -838,7 +856,7 @@ async function generateTreeAsync(ctx, current) {
|
|
|
838
856
|
if (current.constructor === Object || empty) {
|
|
839
857
|
return [
|
|
840
858
|
empty ? 8 /* NullConstructor */ : 7 /* Object */,
|
|
841
|
-
await
|
|
859
|
+
await serializePropertiesAsync(ctx, current),
|
|
842
860
|
id
|
|
843
861
|
];
|
|
844
862
|
}
|
|
@@ -875,61 +893,62 @@ function serializePrimitive(ctx, value) {
|
|
|
875
893
|
}
|
|
876
894
|
return String(value);
|
|
877
895
|
}
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
} else {
|
|
895
|
-
createObjectIdentifierAssign(ctx, targetRef, key, refParam);
|
|
896
|
-
}
|
|
896
|
+
var IDENTIFIER_CHECK = /^([$A-Z_][0-9A-Z_$]*)$/i;
|
|
897
|
+
function serializeAssignments(ctx, targetRef, [keys, values, size]) {
|
|
898
|
+
ctx.stack.push(targetRef);
|
|
899
|
+
const mainAssignments = [];
|
|
900
|
+
for (let i = 0; i < size; i++) {
|
|
901
|
+
const parentStack = ctx.stack;
|
|
902
|
+
ctx.stack = [];
|
|
903
|
+
const refParam = serializeTree(ctx, values[i]);
|
|
904
|
+
ctx.stack = parentStack;
|
|
905
|
+
const key = keys[i];
|
|
906
|
+
const check = Number(key);
|
|
907
|
+
const parentAssignment = ctx.assignments;
|
|
908
|
+
ctx.assignments = mainAssignments;
|
|
909
|
+
if (IDENTIFIER_CHECK.test(key) || check >= 0) {
|
|
910
|
+
if (!Number.isNaN(check)) {
|
|
911
|
+
createObjectComputedAssign(ctx, targetRef, key, refParam);
|
|
897
912
|
} else {
|
|
898
|
-
|
|
913
|
+
createObjectIdentifierAssign(ctx, targetRef, key, refParam);
|
|
899
914
|
}
|
|
900
|
-
|
|
915
|
+
} else {
|
|
916
|
+
createObjectComputedAssign(ctx, targetRef, quote(key), refParam);
|
|
901
917
|
}
|
|
902
|
-
ctx.
|
|
903
|
-
return resolveAssignments(mainAssignments);
|
|
918
|
+
ctx.assignments = parentAssignment;
|
|
904
919
|
}
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
+
ctx.stack.pop();
|
|
921
|
+
return resolveAssignments(mainAssignments);
|
|
922
|
+
}
|
|
923
|
+
function serializeObject(ctx, sourceID, [keys, values, size]) {
|
|
924
|
+
let result = "";
|
|
925
|
+
ctx.stack.push(sourceID);
|
|
926
|
+
for (let i = 0; i < size; i++) {
|
|
927
|
+
const key = keys[i];
|
|
928
|
+
const val = values[i];
|
|
929
|
+
const check = Number(key);
|
|
930
|
+
const isIdentifier = IDENTIFIER_CHECK.test(key) || check >= 0;
|
|
931
|
+
if (isReferenceInStack(ctx, val)) {
|
|
932
|
+
const refParam = getRefParam(ctx, val[1]);
|
|
933
|
+
if (isIdentifier) {
|
|
934
|
+
if (!Number.isNaN(check)) {
|
|
935
|
+
createObjectComputedAssign(ctx, sourceID, key, refParam);
|
|
920
936
|
} else {
|
|
921
|
-
|
|
937
|
+
createObjectIdentifierAssign(ctx, sourceID, key, refParam);
|
|
922
938
|
}
|
|
923
|
-
} else if (isReferenceInStack(ctx, val)) {
|
|
924
|
-
const refParam = getRefParam(ctx, val[1]);
|
|
925
|
-
createObjectComputedAssign(ctx, sourceID, quote(key), refParam);
|
|
926
939
|
} else {
|
|
927
|
-
|
|
940
|
+
createObjectComputedAssign(ctx, sourceID, quote(key), refParam);
|
|
928
941
|
}
|
|
942
|
+
} else if (isIdentifier) {
|
|
943
|
+
result += `${key}:${serializeTree(ctx, val)},`;
|
|
944
|
+
} else {
|
|
945
|
+
result += `${quote(key)}:${serializeTree(ctx, val)},`;
|
|
929
946
|
}
|
|
930
|
-
ctx.stack.pop();
|
|
931
|
-
return `{${result.substring(0, result.length - 1)}}`;
|
|
932
947
|
}
|
|
948
|
+
ctx.stack.pop();
|
|
949
|
+
return `{${result.substring(0, result.length - 1)}}`;
|
|
950
|
+
}
|
|
951
|
+
function serializeTree(ctx, [type, value, id]) {
|
|
933
952
|
switch (type) {
|
|
934
953
|
case 0 /* Primitive */:
|
|
935
954
|
return serializePrimitive(ctx, value);
|
|
@@ -1049,11 +1068,11 @@ function serializeTree(ctx, [type, value, id]) {
|
|
|
1049
1068
|
ctx.stack.pop();
|
|
1050
1069
|
if (value[1]) {
|
|
1051
1070
|
if (ctx.features.has(6 /* ObjectAssign */)) {
|
|
1052
|
-
const options = serializeObject(id, value[1]);
|
|
1071
|
+
const options = serializeObject(ctx, id, value[1]);
|
|
1053
1072
|
serialized = `Object.assign(${serialized},${options})`;
|
|
1054
1073
|
} else {
|
|
1055
1074
|
markRef(ctx, id);
|
|
1056
|
-
const assignments = serializeAssignments(id, value[1]);
|
|
1075
|
+
const assignments = serializeAssignments(ctx, id, value[1]);
|
|
1057
1076
|
if (assignments) {
|
|
1058
1077
|
const ref = getRefParam(ctx, id);
|
|
1059
1078
|
return `(${assignRef(ctx, id, serialized)},${assignments}${ref})`;
|
|
@@ -1066,11 +1085,11 @@ function serializeTree(ctx, [type, value, id]) {
|
|
|
1066
1085
|
let serialized = `new ${value[0]}(${quote(value[1])})`;
|
|
1067
1086
|
if (value[2]) {
|
|
1068
1087
|
if (ctx.features.has(6 /* ObjectAssign */)) {
|
|
1069
|
-
const options = serializeObject(id, value[2]);
|
|
1088
|
+
const options = serializeObject(ctx, id, value[2]);
|
|
1070
1089
|
serialized = `Object.assign(${serialized},${options})`;
|
|
1071
1090
|
} else {
|
|
1072
1091
|
markRef(ctx, id);
|
|
1073
|
-
const assignments = serializeAssignments(id, value[2]);
|
|
1092
|
+
const assignments = serializeAssignments(ctx, id, value[2]);
|
|
1074
1093
|
if (assignments) {
|
|
1075
1094
|
const ref = getRefParam(ctx, id);
|
|
1076
1095
|
return `(${assignRef(ctx, id, serialized)},${assignments}${ref})`;
|
|
@@ -1099,11 +1118,11 @@ function serializeTree(ctx, [type, value, id]) {
|
|
|
1099
1118
|
}
|
|
1100
1119
|
if (value[0]) {
|
|
1101
1120
|
if (ctx.features.has(6 /* ObjectAssign */)) {
|
|
1102
|
-
const options = serializeObject(id, value[0]);
|
|
1121
|
+
const options = serializeObject(ctx, id, value[0]);
|
|
1103
1122
|
serialized = `Object.assign(${serialized},${options})`;
|
|
1104
1123
|
} else {
|
|
1105
1124
|
markRef(ctx, id);
|
|
1106
|
-
const assignments = serializeAssignments(id, value[0]);
|
|
1125
|
+
const assignments = serializeAssignments(ctx, id, value[0]);
|
|
1107
1126
|
if (assignments) {
|
|
1108
1127
|
const ref = getRefParam(ctx, id);
|
|
1109
1128
|
return `(${assignRef(ctx, id, serialized)},${assignments}${ref})`;
|
|
@@ -1115,13 +1134,13 @@ function serializeTree(ctx, [type, value, id]) {
|
|
|
1115
1134
|
case 8 /* NullConstructor */: {
|
|
1116
1135
|
let serialized = "Object.create(null)";
|
|
1117
1136
|
if (ctx.features.has(6 /* ObjectAssign */)) {
|
|
1118
|
-
const fields = serializeObject(id, value);
|
|
1137
|
+
const fields = serializeObject(ctx, id, value);
|
|
1119
1138
|
if (fields !== "{}") {
|
|
1120
1139
|
serialized = `Object.assign(${serialized},${fields})`;
|
|
1121
1140
|
}
|
|
1122
1141
|
} else {
|
|
1123
1142
|
markRef(ctx, id);
|
|
1124
|
-
const assignments = serializeAssignments(id, value);
|
|
1143
|
+
const assignments = serializeAssignments(ctx, id, value);
|
|
1125
1144
|
if (assignments) {
|
|
1126
1145
|
const ref = getRefParam(ctx, id);
|
|
1127
1146
|
return `(${assignRef(ctx, id, serialized)},${assignments}${ref})`;
|
|
@@ -1130,7 +1149,7 @@ function serializeTree(ctx, [type, value, id]) {
|
|
|
1130
1149
|
return assignRef(ctx, id, serialized);
|
|
1131
1150
|
}
|
|
1132
1151
|
case 7 /* Object */:
|
|
1133
|
-
return assignRef(ctx, id, serializeObject(id, value));
|
|
1152
|
+
return assignRef(ctx, id, serializeObject(ctx, id, value));
|
|
1134
1153
|
default:
|
|
1135
1154
|
throw new Error("Unsupported type");
|
|
1136
1155
|
}
|