seroval 0.4.0-alpha.0 → 0.4.0-alpha.1
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 +106 -109
- package/dist/cjs/development/index.cjs.map +3 -3
- package/dist/cjs/production/index.cjs +2 -2
- package/dist/esm/development/index.mjs +106 -109
- package/dist/esm/development/index.mjs.map +3 -3
- package/dist/esm/production/index.mjs +2 -2
- package/dist/types/compat.d.ts +12 -14
- package/package.json +2 -2
- package/src/compat.ts +35 -36
- package/src/index.ts +2 -1
- package/src/tree.ts +29 -29
|
@@ -19,65 +19,6 @@ function isIterable(obj) {
|
|
|
19
19
|
return !!obj && typeof obj === "object" && !isIterableBuiltin(obj) && Symbol.iterator in obj && typeof obj[Symbol.iterator] === "function";
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
// src/quote.ts
|
|
23
|
-
function quote(str) {
|
|
24
|
-
let result = "";
|
|
25
|
-
let lastPos = 0;
|
|
26
|
-
for (let i = 0, len = str.length; i < len; i++) {
|
|
27
|
-
let replacement;
|
|
28
|
-
switch (str[i]) {
|
|
29
|
-
case '"':
|
|
30
|
-
replacement = '\\"';
|
|
31
|
-
break;
|
|
32
|
-
case "\\":
|
|
33
|
-
replacement = "\\\\";
|
|
34
|
-
break;
|
|
35
|
-
case "<":
|
|
36
|
-
replacement = "\\x3C";
|
|
37
|
-
break;
|
|
38
|
-
case "\n":
|
|
39
|
-
replacement = "\\n";
|
|
40
|
-
break;
|
|
41
|
-
case "\r":
|
|
42
|
-
replacement = "\\r";
|
|
43
|
-
break;
|
|
44
|
-
case "\u2028":
|
|
45
|
-
replacement = "\\u2028";
|
|
46
|
-
break;
|
|
47
|
-
case "\u2029":
|
|
48
|
-
replacement = "\\u2029";
|
|
49
|
-
break;
|
|
50
|
-
default:
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
result += str.slice(lastPos, i) + replacement;
|
|
54
|
-
lastPos = i + 1;
|
|
55
|
-
}
|
|
56
|
-
if (lastPos === 0) {
|
|
57
|
-
result = str;
|
|
58
|
-
} else {
|
|
59
|
-
result += str.slice(lastPos);
|
|
60
|
-
}
|
|
61
|
-
return `"${result}"`;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// src/get-identifier.ts
|
|
65
|
-
var REF_START_CHARS = "hjkmoquxzABCDEFGHIJKLNPQRTUVWXYZ$_";
|
|
66
|
-
var REF_START_CHARS_LEN = REF_START_CHARS.length;
|
|
67
|
-
var REF_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_";
|
|
68
|
-
var REF_CHARS_LEN = REF_CHARS.length;
|
|
69
|
-
function getIdentifier(index) {
|
|
70
|
-
let mod = index % REF_START_CHARS_LEN;
|
|
71
|
-
let ref = REF_START_CHARS[mod];
|
|
72
|
-
index = (index - mod) / REF_START_CHARS_LEN;
|
|
73
|
-
while (index > 0) {
|
|
74
|
-
mod = index % REF_CHARS_LEN;
|
|
75
|
-
ref += REF_CHARS[mod];
|
|
76
|
-
index = (index - mod) / REF_CHARS_LEN;
|
|
77
|
-
}
|
|
78
|
-
return ref;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
22
|
// src/assert.ts
|
|
82
23
|
function assert(cond, error) {
|
|
83
24
|
if (!cond) {
|
|
@@ -98,7 +39,7 @@ function compareVersion(left, right) {
|
|
|
98
39
|
}
|
|
99
40
|
var VERSION_TABLE = {
|
|
100
41
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError#browser_compatibility
|
|
101
|
-
|
|
42
|
+
[0 /* AggregateError */]: {
|
|
102
43
|
es: [2021, 0, 0],
|
|
103
44
|
chrome: [85, 0, 0],
|
|
104
45
|
edge: [85, 0, 0],
|
|
@@ -111,7 +52,7 @@ var VERSION_TABLE = {
|
|
|
111
52
|
node: [15, 0, 0]
|
|
112
53
|
},
|
|
113
54
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values#browser_compatibility
|
|
114
|
-
|
|
55
|
+
[1 /* ArrayPrototypeValues */]: {
|
|
115
56
|
es: [6, 0, 0],
|
|
116
57
|
chrome: [66, 0, 0],
|
|
117
58
|
edge: [14, 0, 0],
|
|
@@ -124,7 +65,7 @@ var VERSION_TABLE = {
|
|
|
124
65
|
node: [10, 9, 0]
|
|
125
66
|
},
|
|
126
67
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#browser_compatibility
|
|
127
|
-
|
|
68
|
+
[2 /* ArrowFunction */]: {
|
|
128
69
|
es: [6, 0, 0],
|
|
129
70
|
chrome: [45, 0, 0],
|
|
130
71
|
edge: [12, 0, 0],
|
|
@@ -137,7 +78,7 @@ var VERSION_TABLE = {
|
|
|
137
78
|
node: [4, 0, 0]
|
|
138
79
|
},
|
|
139
80
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#browser_compatibility
|
|
140
|
-
|
|
81
|
+
[3 /* BigInt */]: {
|
|
141
82
|
es: [2020, 0, 0],
|
|
142
83
|
chrome: [67, 0, 0],
|
|
143
84
|
edge: [79, 0, 0],
|
|
@@ -150,7 +91,7 @@ var VERSION_TABLE = {
|
|
|
150
91
|
node: [10, 4, 0]
|
|
151
92
|
},
|
|
152
93
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#browser_compatibility
|
|
153
|
-
|
|
94
|
+
[4 /* Map */]: {
|
|
154
95
|
es: [6, 0, 0],
|
|
155
96
|
chrome: [38, 0, 0],
|
|
156
97
|
edge: [12, 0, 0],
|
|
@@ -163,7 +104,7 @@ var VERSION_TABLE = {
|
|
|
163
104
|
node: [0, 12, 0]
|
|
164
105
|
},
|
|
165
106
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions#browser_compatibility
|
|
166
|
-
|
|
107
|
+
[5 /* MethodShorthand */]: {
|
|
167
108
|
es: [6, 0, 0],
|
|
168
109
|
chrome: [39, 0, 0],
|
|
169
110
|
edge: [12, 0, 0],
|
|
@@ -176,7 +117,7 @@ var VERSION_TABLE = {
|
|
|
176
117
|
node: [4, 0, 0]
|
|
177
118
|
},
|
|
178
119
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#browser_compatibility
|
|
179
|
-
|
|
120
|
+
[6 /* ObjectAssign */]: {
|
|
180
121
|
es: [6, 0, 0],
|
|
181
122
|
chrome: [45, 0, 0],
|
|
182
123
|
edge: [12, 0, 0],
|
|
@@ -189,7 +130,7 @@ var VERSION_TABLE = {
|
|
|
189
130
|
node: [4, 0, 0]
|
|
190
131
|
},
|
|
191
132
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#browser_compatibility
|
|
192
|
-
|
|
133
|
+
[7 /* Promise */]: {
|
|
193
134
|
es: [6, 0, 0],
|
|
194
135
|
chrome: [32, 0, 0],
|
|
195
136
|
edge: [12, 0, 0],
|
|
@@ -202,7 +143,7 @@ var VERSION_TABLE = {
|
|
|
202
143
|
node: [0, 12, 0]
|
|
203
144
|
},
|
|
204
145
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#browser_compatibility
|
|
205
|
-
|
|
146
|
+
[8 /* Set */]: {
|
|
206
147
|
es: [6, 0, 0],
|
|
207
148
|
chrome: [38, 0, 0],
|
|
208
149
|
edge: [12, 0, 0],
|
|
@@ -215,7 +156,7 @@ var VERSION_TABLE = {
|
|
|
215
156
|
node: [0, 12, 0]
|
|
216
157
|
},
|
|
217
158
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator#browser_compatibility
|
|
218
|
-
|
|
159
|
+
[9 /* SymbolIterator */]: {
|
|
219
160
|
es: [6, 0, 0],
|
|
220
161
|
chrome: [43, 0, 0],
|
|
221
162
|
edge: [12, 0, 0],
|
|
@@ -228,7 +169,7 @@ var VERSION_TABLE = {
|
|
|
228
169
|
node: [0, 12, 0]
|
|
229
170
|
},
|
|
230
171
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#browser_compatibility
|
|
231
|
-
|
|
172
|
+
[10 /* TypedArray */]: {
|
|
232
173
|
es: [6, 0, 0],
|
|
233
174
|
chrome: [7, 0, 0],
|
|
234
175
|
edge: [12, 0, 0],
|
|
@@ -259,26 +200,82 @@ function getTargetVersions(targets) {
|
|
|
259
200
|
}
|
|
260
201
|
return [parseTarget(targets)];
|
|
261
202
|
}
|
|
262
|
-
function isFeatureSupported(key, targets) {
|
|
263
|
-
const base = VERSION_TABLE[key];
|
|
264
|
-
let flag = true;
|
|
265
|
-
for (const [platform, version] of targets) {
|
|
266
|
-
const baseVersion = base[platform];
|
|
267
|
-
flag = flag && !!baseVersion && compareVersion(baseVersion, version) <= 0;
|
|
268
|
-
}
|
|
269
|
-
return flag;
|
|
270
|
-
}
|
|
271
203
|
function parseTargets(targets) {
|
|
272
204
|
const parsed = getTargetVersions(targets);
|
|
273
205
|
const flags = /* @__PURE__ */ new Set();
|
|
274
206
|
for (const key in VERSION_TABLE) {
|
|
275
|
-
|
|
276
|
-
|
|
207
|
+
const base = VERSION_TABLE[key];
|
|
208
|
+
let flag = true;
|
|
209
|
+
for (const [platform, version] of parsed) {
|
|
210
|
+
const baseVersion = base[platform];
|
|
211
|
+
flag = flag && !!baseVersion && compareVersion(baseVersion, version) <= 0;
|
|
212
|
+
}
|
|
213
|
+
if (flag) {
|
|
214
|
+
flags.add(Number(key));
|
|
277
215
|
}
|
|
278
216
|
}
|
|
279
217
|
return flags;
|
|
280
218
|
}
|
|
281
219
|
|
|
220
|
+
// src/quote.ts
|
|
221
|
+
function quote(str) {
|
|
222
|
+
let result = "";
|
|
223
|
+
let lastPos = 0;
|
|
224
|
+
for (let i = 0, len = str.length; i < len; i++) {
|
|
225
|
+
let replacement;
|
|
226
|
+
switch (str[i]) {
|
|
227
|
+
case '"':
|
|
228
|
+
replacement = '\\"';
|
|
229
|
+
break;
|
|
230
|
+
case "\\":
|
|
231
|
+
replacement = "\\\\";
|
|
232
|
+
break;
|
|
233
|
+
case "<":
|
|
234
|
+
replacement = "\\x3C";
|
|
235
|
+
break;
|
|
236
|
+
case "\n":
|
|
237
|
+
replacement = "\\n";
|
|
238
|
+
break;
|
|
239
|
+
case "\r":
|
|
240
|
+
replacement = "\\r";
|
|
241
|
+
break;
|
|
242
|
+
case "\u2028":
|
|
243
|
+
replacement = "\\u2028";
|
|
244
|
+
break;
|
|
245
|
+
case "\u2029":
|
|
246
|
+
replacement = "\\u2029";
|
|
247
|
+
break;
|
|
248
|
+
default:
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
result += str.slice(lastPos, i) + replacement;
|
|
252
|
+
lastPos = i + 1;
|
|
253
|
+
}
|
|
254
|
+
if (lastPos === 0) {
|
|
255
|
+
result = str;
|
|
256
|
+
} else {
|
|
257
|
+
result += str.slice(lastPos);
|
|
258
|
+
}
|
|
259
|
+
return `"${result}"`;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// src/get-identifier.ts
|
|
263
|
+
var REF_START_CHARS = "hjkmoquxzABCDEFGHIJKLNPQRTUVWXYZ$_";
|
|
264
|
+
var REF_START_CHARS_LEN = REF_START_CHARS.length;
|
|
265
|
+
var REF_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_";
|
|
266
|
+
var REF_CHARS_LEN = REF_CHARS.length;
|
|
267
|
+
function getIdentifier(index) {
|
|
268
|
+
let mod = index % REF_START_CHARS_LEN;
|
|
269
|
+
let ref = REF_START_CHARS[mod];
|
|
270
|
+
index = (index - mod) / REF_START_CHARS_LEN;
|
|
271
|
+
while (index > 0) {
|
|
272
|
+
mod = index % REF_CHARS_LEN;
|
|
273
|
+
ref += REF_CHARS[mod];
|
|
274
|
+
index = (index - mod) / REF_CHARS_LEN;
|
|
275
|
+
}
|
|
276
|
+
return ref;
|
|
277
|
+
}
|
|
278
|
+
|
|
282
279
|
// src/tree.ts
|
|
283
280
|
var DEFAULT_OPTIONS = {
|
|
284
281
|
target: "es2023"
|
|
@@ -503,51 +500,51 @@ function generateSemiPrimitiveValue(ctx, current, id) {
|
|
|
503
500
|
return [3 /* RegExp */, current, id];
|
|
504
501
|
}
|
|
505
502
|
if (constructorCheck(current, Int8Array)) {
|
|
506
|
-
assert(ctx.features.has(
|
|
503
|
+
assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Int8Array"');
|
|
507
504
|
return [13 /* TypedArray */, ["Int8Array", current], id];
|
|
508
505
|
}
|
|
509
506
|
if (constructorCheck(current, Int16Array)) {
|
|
510
|
-
assert(ctx.features.has(
|
|
507
|
+
assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Int16Array"');
|
|
511
508
|
return [13 /* TypedArray */, ["Int16Array", current], id];
|
|
512
509
|
}
|
|
513
510
|
if (constructorCheck(current, Int32Array)) {
|
|
514
|
-
assert(ctx.features.has(
|
|
511
|
+
assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Int32Array"');
|
|
515
512
|
return [13 /* TypedArray */, ["Int32Array", current], id];
|
|
516
513
|
}
|
|
517
514
|
if (constructorCheck(current, Uint8Array)) {
|
|
518
|
-
assert(ctx.features.has(
|
|
515
|
+
assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Uint8Array"');
|
|
519
516
|
return [13 /* TypedArray */, ["Uint8Array", current], id];
|
|
520
517
|
}
|
|
521
518
|
if (constructorCheck(current, Uint16Array)) {
|
|
522
|
-
assert(ctx.features.has(
|
|
519
|
+
assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Uint16Array"');
|
|
523
520
|
return [13 /* TypedArray */, ["Uint16Array", current], id];
|
|
524
521
|
}
|
|
525
522
|
if (constructorCheck(current, Uint32Array)) {
|
|
526
|
-
assert(ctx.features.has(
|
|
523
|
+
assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Uint32Array"');
|
|
527
524
|
return [13 /* TypedArray */, ["Uint32Array", current], id];
|
|
528
525
|
}
|
|
529
526
|
if (constructorCheck(current, Uint8ClampedArray)) {
|
|
530
|
-
assert(ctx.features.has(
|
|
527
|
+
assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Uint8ClampedArray"');
|
|
531
528
|
return [13 /* TypedArray */, ["Uint8ClampedArray", current], id];
|
|
532
529
|
}
|
|
533
530
|
if (constructorCheck(current, Float32Array)) {
|
|
534
|
-
assert(ctx.features.has(
|
|
531
|
+
assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Float32Array"');
|
|
535
532
|
return [13 /* TypedArray */, ["Float32Array", current], id];
|
|
536
533
|
}
|
|
537
534
|
if (constructorCheck(current, Float64Array)) {
|
|
538
|
-
assert(ctx.features.has(
|
|
535
|
+
assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Float64Array"');
|
|
539
536
|
return [13 /* TypedArray */, ["Float64Array", current], id];
|
|
540
537
|
}
|
|
541
538
|
if (constructorCheck(current, BigInt64Array)) {
|
|
542
539
|
assert(
|
|
543
|
-
ctx.features.has(
|
|
540
|
+
ctx.features.has(10 /* TypedArray */) && ctx.features.has(3 /* BigInt */),
|
|
544
541
|
'Unsupported value type "BigInt64Array"'
|
|
545
542
|
);
|
|
546
543
|
return [13 /* TypedArray */, ["BigInt64Array", current], id];
|
|
547
544
|
}
|
|
548
545
|
if (constructorCheck(current, BigUint64Array)) {
|
|
549
546
|
assert(
|
|
550
|
-
ctx.features.has(
|
|
547
|
+
ctx.features.has(10 /* TypedArray */) && ctx.features.has(3 /* BigInt */),
|
|
551
548
|
'Unsupported value type "BigUint64Array"'
|
|
552
549
|
);
|
|
553
550
|
return [13 /* TypedArray */, ["BigUint64Array", current], id];
|
|
@@ -590,7 +587,7 @@ function generateTreeSync(ctx, current) {
|
|
|
590
587
|
return semiPrimitive;
|
|
591
588
|
}
|
|
592
589
|
if (constructorCheck(current, Set)) {
|
|
593
|
-
assert(ctx.features.has(
|
|
590
|
+
assert(ctx.features.has(8 /* Set */), 'Unsupported type "Set"');
|
|
594
591
|
const nodes = [];
|
|
595
592
|
const deferred = [];
|
|
596
593
|
for (const item of current.keys()) {
|
|
@@ -606,7 +603,7 @@ function generateTreeSync(ctx, current) {
|
|
|
606
603
|
return [4 /* Set */, nodes, id];
|
|
607
604
|
}
|
|
608
605
|
if (constructorCheck(current, Map)) {
|
|
609
|
-
assert(ctx.features.has(
|
|
606
|
+
assert(ctx.features.has(4 /* Map */), 'Unsupported type "Map"');
|
|
610
607
|
const keyNodes = [];
|
|
611
608
|
const valueNodes = [];
|
|
612
609
|
const deferredKey = [];
|
|
@@ -648,7 +645,7 @@ function generateTreeSync(ctx, current) {
|
|
|
648
645
|
}
|
|
649
646
|
return [6 /* Array */, nodes, id];
|
|
650
647
|
}
|
|
651
|
-
if (current instanceof AggregateError && ctx.features.has(
|
|
648
|
+
if (current instanceof AggregateError && ctx.features.has(0 /* AggregateError */)) {
|
|
652
649
|
const options = getErrorOptions(current);
|
|
653
650
|
const optionsNode = options ? serializeProperties(options) : void 0;
|
|
654
651
|
const errorsNode = generateTreeSync(ctx, current.errors);
|
|
@@ -664,7 +661,7 @@ function generateTreeSync(ctx, current) {
|
|
|
664
661
|
];
|
|
665
662
|
}
|
|
666
663
|
if (isIterable(current)) {
|
|
667
|
-
assert(ctx.features.has(
|
|
664
|
+
assert(ctx.features.has(9 /* SymbolIterator */), 'Unsupported type "Iterable"');
|
|
668
665
|
const options = getIterableOptions(current);
|
|
669
666
|
return [12 /* Iterable */, [
|
|
670
667
|
// Parse options first before the items
|
|
@@ -718,7 +715,7 @@ async function generateTreeAsync(ctx, current) {
|
|
|
718
715
|
return semiPrimitive;
|
|
719
716
|
}
|
|
720
717
|
if (isPromise(current)) {
|
|
721
|
-
assert(ctx.features.has(
|
|
718
|
+
assert(ctx.features.has(7 /* Promise */), 'Unsupported type "Promise"');
|
|
722
719
|
return current.then(async (value) => [
|
|
723
720
|
9 /* Promise */,
|
|
724
721
|
await generateTreeAsync(ctx, value),
|
|
@@ -726,7 +723,7 @@ async function generateTreeAsync(ctx, current) {
|
|
|
726
723
|
]);
|
|
727
724
|
}
|
|
728
725
|
if (constructorCheck(current, Set)) {
|
|
729
|
-
assert(ctx.features.has(
|
|
726
|
+
assert(ctx.features.has(8 /* Set */), 'Unsupported type "Set"');
|
|
730
727
|
const nodes = [];
|
|
731
728
|
const deferred = [];
|
|
732
729
|
for (const item of current.keys()) {
|
|
@@ -742,7 +739,7 @@ async function generateTreeAsync(ctx, current) {
|
|
|
742
739
|
return [4 /* Set */, nodes, id];
|
|
743
740
|
}
|
|
744
741
|
if (constructorCheck(current, Map)) {
|
|
745
|
-
assert(ctx.features.has(
|
|
742
|
+
assert(ctx.features.has(4 /* Map */), 'Unsupported type "Map"');
|
|
746
743
|
const keyNodes = [];
|
|
747
744
|
const valueNodes = [];
|
|
748
745
|
const deferredKey = [];
|
|
@@ -801,7 +798,7 @@ async function generateTreeAsync(ctx, current) {
|
|
|
801
798
|
];
|
|
802
799
|
}
|
|
803
800
|
if (isIterable(current)) {
|
|
804
|
-
assert(ctx.features.has(
|
|
801
|
+
assert(ctx.features.has(9 /* SymbolIterator */), 'Unsupported type "Iterable"');
|
|
805
802
|
const options = getIterableOptions(current);
|
|
806
803
|
return [12 /* Iterable */, [
|
|
807
804
|
options ? await serializeProperties(options) : void 0,
|
|
@@ -832,7 +829,7 @@ function serializePrimitive(ctx, value) {
|
|
|
832
829
|
return "null";
|
|
833
830
|
}
|
|
834
831
|
if (typeof value === "bigint") {
|
|
835
|
-
assert(ctx.features.has(
|
|
832
|
+
assert(ctx.features.has(3 /* BigInt */), 'Unsupported type "BigInt"');
|
|
836
833
|
return `${value}n`;
|
|
837
834
|
}
|
|
838
835
|
if (typeof value === "string") {
|
|
@@ -1022,7 +1019,7 @@ function serializeTree(ctx, [type, value, id]) {
|
|
|
1022
1019
|
let serialized = `new AggregateError(${serializeTree(ctx, value[2])},${quote(value[0])})`;
|
|
1023
1020
|
ctx.stack.pop();
|
|
1024
1021
|
if (value[1]) {
|
|
1025
|
-
if (ctx.features.has(
|
|
1022
|
+
if (ctx.features.has(6 /* ObjectAssign */)) {
|
|
1026
1023
|
const options = serializeObject(id, value[1]);
|
|
1027
1024
|
serialized = `Object.assign(${serialized},${options})`;
|
|
1028
1025
|
} else {
|
|
@@ -1039,7 +1036,7 @@ function serializeTree(ctx, [type, value, id]) {
|
|
|
1039
1036
|
case 10 /* Error */: {
|
|
1040
1037
|
let serialized = `new ${value[0]}(${quote(value[1])})`;
|
|
1041
1038
|
if (value[2]) {
|
|
1042
|
-
if (ctx.features.has(
|
|
1039
|
+
if (ctx.features.has(6 /* ObjectAssign */)) {
|
|
1043
1040
|
const options = serializeObject(id, value[2]);
|
|
1044
1041
|
serialized = `Object.assign(${serialized},${options})`;
|
|
1045
1042
|
} else {
|
|
@@ -1059,20 +1056,20 @@ function serializeTree(ctx, [type, value, id]) {
|
|
|
1059
1056
|
const values = serializeTree(ctx, value[1]);
|
|
1060
1057
|
ctx.stack = parent;
|
|
1061
1058
|
let serialized;
|
|
1062
|
-
if (ctx.features.has(
|
|
1059
|
+
if (ctx.features.has(1 /* ArrayPrototypeValues */)) {
|
|
1063
1060
|
serialized = `${values}.values()`;
|
|
1064
1061
|
} else {
|
|
1065
1062
|
serialized = `${values}[Symbol.iterator]()`;
|
|
1066
1063
|
}
|
|
1067
|
-
if (ctx.features.has(
|
|
1064
|
+
if (ctx.features.has(2 /* ArrowFunction */)) {
|
|
1068
1065
|
serialized = `{[Symbol.iterator]:()=>${serialized}}`;
|
|
1069
|
-
} else if (ctx.features.has(
|
|
1066
|
+
} else if (ctx.features.has(5 /* MethodShorthand */)) {
|
|
1070
1067
|
serialized = `{[Symbol.iterator](){return ${serialized}}}`;
|
|
1071
1068
|
} else {
|
|
1072
1069
|
serialized = `{[Symbol.iterator]:function(){return ${serialized}}}`;
|
|
1073
1070
|
}
|
|
1074
1071
|
if (value[0]) {
|
|
1075
|
-
if (ctx.features.has(
|
|
1072
|
+
if (ctx.features.has(6 /* ObjectAssign */)) {
|
|
1076
1073
|
const options = serializeObject(id, value[0]);
|
|
1077
1074
|
serialized = `Object.assign(${serialized},${options})`;
|
|
1078
1075
|
} else {
|
|
@@ -1088,7 +1085,7 @@ function serializeTree(ctx, [type, value, id]) {
|
|
|
1088
1085
|
}
|
|
1089
1086
|
case 8 /* NullConstructor */: {
|
|
1090
1087
|
let serialized = "Object.create(null)";
|
|
1091
|
-
if (ctx.features.has(
|
|
1088
|
+
if (ctx.features.has(6 /* ObjectAssign */)) {
|
|
1092
1089
|
const fields = serializeObject(id, value);
|
|
1093
1090
|
if (fields !== "{}") {
|
|
1094
1091
|
serialized = `Object.assign(${serialized},${fields})`;
|
|
@@ -1124,7 +1121,7 @@ function finalize(ctx, source, result) {
|
|
|
1124
1121
|
}
|
|
1125
1122
|
}
|
|
1126
1123
|
let params = ctx.vars.length > 1 ? ctx.vars.join(",") : ctx.vars[0];
|
|
1127
|
-
if (ctx.features.has(
|
|
1124
|
+
if (ctx.features.has(2 /* ArrowFunction */)) {
|
|
1128
1125
|
params = ctx.vars.length > 1 || ctx.vars.length === 0 ? `(${params})` : params;
|
|
1129
1126
|
return `(${params}=>(${body}))()`;
|
|
1130
1127
|
}
|