seroval 0.4.0-alpha.0 → 0.4.0-alpha.2

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.
@@ -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
- "aggregate-error": {
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
- "array-values": {
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
- "arrow-function": {
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
- bigint: {
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
- map: {
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
- "method-shorthand": {
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
- "object-assign": {
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
- promise: {
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
- set: {
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
- "symbol-iterator": {
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
- "typed-arrays": {
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
- if (isFeatureSupported(key, parsed)) {
276
- flags.add(key);
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,81 +500,81 @@ 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("typed-arrays"), 'Unsupported value type "Int8Array"');
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("typed-arrays"), 'Unsupported value type "Int16Array"');
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("typed-arrays"), 'Unsupported value type "Int32Array"');
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("typed-arrays"), 'Unsupported value type "Uint8Array"');
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("typed-arrays"), 'Unsupported value type "Uint16Array"');
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("typed-arrays"), 'Unsupported value type "Uint32Array"');
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("typed-arrays"), 'Unsupported value type "Uint8ClampedArray"');
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("typed-arrays"), 'Unsupported value type "Float32Array"');
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("typed-arrays"), 'Unsupported value type "Float64Array"');
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("typed-arrays") && ctx.features.has("bigint"),
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("typed-arrays") && ctx.features.has("bigint"),
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];
554
551
  }
555
552
  return void 0;
556
553
  }
557
- function generateTreeSync(ctx, current) {
558
- function serializeProperties(properties) {
559
- const keyNodes = [];
560
- const valueNodes = [];
561
- const deferredKeys = [];
562
- const deferredValues = [];
563
- const keys = Object.keys(properties);
564
- let deferredSize = 0;
565
- for (const key of keys) {
566
- if (isIterable(properties[key])) {
567
- deferredKeys.push(key);
568
- deferredValues.push(properties[key]);
569
- deferredSize++;
570
- } else {
571
- keyNodes.push(key);
572
- valueNodes.push(generateTreeSync(ctx, properties[key]));
573
- }
574
- }
575
- for (let i = 0; i < deferredSize; i++) {
576
- keyNodes.push(deferredKeys[i]);
577
- valueNodes.push(generateTreeSync(ctx, deferredValues[i]));
554
+ function serializePropertiesSync(ctx, properties) {
555
+ const keyNodes = [];
556
+ const valueNodes = [];
557
+ const deferredKeys = [];
558
+ const deferredValues = [];
559
+ const keys = Object.keys(properties);
560
+ let deferredSize = 0;
561
+ for (const key of keys) {
562
+ if (isIterable(properties[key])) {
563
+ deferredKeys.push(key);
564
+ deferredValues.push(properties[key]);
565
+ deferredSize++;
566
+ } else {
567
+ keyNodes.push(key);
568
+ valueNodes.push(generateTreeSync(ctx, properties[key]));
578
569
  }
579
- return [keyNodes, valueNodes, keys.length];
580
570
  }
571
+ for (let i = 0; i < deferredSize; i++) {
572
+ keyNodes.push(deferredKeys[i]);
573
+ valueNodes.push(generateTreeSync(ctx, deferredValues[i]));
574
+ }
575
+ return [keyNodes, valueNodes, keys.length];
576
+ }
577
+ function generateTreeSync(ctx, current) {
581
578
  if (isPrimitive(current)) {
582
579
  return [0 /* Primitive */, current];
583
580
  }
@@ -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("set"), 'Unsupported type "Set"');
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("map"), 'Unsupported type "Map"');
606
+ assert(ctx.features.has(4 /* Map */), 'Unsupported type "Map"');
610
607
  const keyNodes = [];
611
608
  const valueNodes = [];
612
609
  const deferredKey = [];
@@ -648,15 +645,15 @@ function generateTreeSync(ctx, current) {
648
645
  }
649
646
  return [6 /* Array */, nodes, id];
650
647
  }
651
- if (current instanceof AggregateError && ctx.features.has("aggregate-error")) {
648
+ if (current instanceof AggregateError && ctx.features.has(0 /* AggregateError */)) {
652
649
  const options = getErrorOptions(current);
653
- const optionsNode = options ? serializeProperties(options) : void 0;
650
+ const optionsNode = options ? serializePropertiesSync(ctx, options) : void 0;
654
651
  const errorsNode = generateTreeSync(ctx, current.errors);
655
652
  return [11 /* AggregateError */, [current.message, optionsNode, errorsNode], id];
656
653
  }
657
654
  if (current instanceof Error) {
658
655
  const options = getErrorOptions(current);
659
- const optionsNode = options ? serializeProperties(options) : void 0;
656
+ const optionsNode = options ? serializePropertiesSync(ctx, options) : void 0;
660
657
  return [
661
658
  10 /* Error */,
662
659
  [getErrorConstructor(current), current.message, optionsNode],
@@ -664,11 +661,11 @@ function generateTreeSync(ctx, current) {
664
661
  ];
665
662
  }
666
663
  if (isIterable(current)) {
667
- assert(ctx.features.has("symbol-iterator"), 'Unsupported type "Iterable"');
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
671
- options ? serializeProperties(options) : void 0,
668
+ options ? serializePropertiesSync(ctx, options) : void 0,
672
669
  generateTreeSync(ctx, Array.from(current))
673
670
  ], id];
674
671
  }
@@ -676,36 +673,36 @@ function generateTreeSync(ctx, current) {
676
673
  if (current.constructor === Object || empty) {
677
674
  return [
678
675
  empty ? 8 /* NullConstructor */ : 7 /* Object */,
679
- serializeProperties(current),
676
+ serializePropertiesSync(ctx, current),
680
677
  id
681
678
  ];
682
679
  }
683
680
  throw new Error("Unsupported value");
684
681
  }
685
- async function generateTreeAsync(ctx, current) {
686
- async function serializeProperties(properties) {
687
- const keyNodes = [];
688
- const valueNodes = [];
689
- const deferredKeys = [];
690
- const deferredValues = [];
691
- const keys = Object.keys(properties);
692
- let deferredSize = 0;
693
- for (const key of keys) {
694
- if (isIterable(properties[key])) {
695
- deferredKeys.push(key);
696
- deferredValues.push(properties[key]);
697
- deferredSize++;
698
- } else {
699
- keyNodes.push(key);
700
- valueNodes.push(await generateTreeAsync(ctx, properties[key]));
701
- }
702
- }
703
- for (let i = 0; i < deferredSize; i++) {
704
- keyNodes.push(deferredKeys[i]);
705
- valueNodes.push(await generateTreeAsync(ctx, deferredValues[i]));
682
+ async function serializePropertiesAsync(ctx, properties) {
683
+ const keyNodes = [];
684
+ const valueNodes = [];
685
+ const deferredKeys = [];
686
+ const deferredValues = [];
687
+ const keys = Object.keys(properties);
688
+ let deferredSize = 0;
689
+ for (const key of keys) {
690
+ if (isIterable(properties[key])) {
691
+ deferredKeys.push(key);
692
+ deferredValues.push(properties[key]);
693
+ deferredSize++;
694
+ } else {
695
+ keyNodes.push(key);
696
+ valueNodes.push(await generateTreeAsync(ctx, properties[key]));
706
697
  }
707
- return [keyNodes, valueNodes, keys.length];
708
698
  }
699
+ for (let i = 0; i < deferredSize; i++) {
700
+ keyNodes.push(deferredKeys[i]);
701
+ valueNodes.push(await generateTreeAsync(ctx, deferredValues[i]));
702
+ }
703
+ return [keyNodes, valueNodes, keys.length];
704
+ }
705
+ async function generateTreeAsync(ctx, current) {
709
706
  if (isPrimitive(current)) {
710
707
  return [0 /* Primitive */, current];
711
708
  }
@@ -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("promise"), 'Unsupported type "Promise"');
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("set"), 'Unsupported type "Set"');
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("map"), 'Unsupported type "Map"');
742
+ assert(ctx.features.has(4 /* Map */), 'Unsupported type "Map"');
746
743
  const keyNodes = [];
747
744
  const valueNodes = [];
748
745
  const deferredKey = [];
@@ -787,13 +784,13 @@ async function generateTreeAsync(ctx, current) {
787
784
  }
788
785
  if (current instanceof AggregateError) {
789
786
  const options = getErrorOptions(current);
790
- const optionsNode = options ? await serializeProperties(options) : void 0;
787
+ const optionsNode = options ? await serializePropertiesAsync(ctx, options) : void 0;
791
788
  const errorsNode = await generateTreeAsync(ctx, current.errors);
792
789
  return [11 /* AggregateError */, [current.message, optionsNode, errorsNode], id];
793
790
  }
794
791
  if (current instanceof Error) {
795
792
  const options = getErrorOptions(current);
796
- const optionsNode = options ? await serializeProperties(options) : void 0;
793
+ const optionsNode = options ? await serializePropertiesAsync(ctx, options) : void 0;
797
794
  return [
798
795
  10 /* Error */,
799
796
  [getErrorConstructor(current), current.message, optionsNode],
@@ -801,10 +798,10 @@ async function generateTreeAsync(ctx, current) {
801
798
  ];
802
799
  }
803
800
  if (isIterable(current)) {
804
- assert(ctx.features.has("symbol-iterator"), 'Unsupported type "Iterable"');
801
+ assert(ctx.features.has(9 /* SymbolIterator */), 'Unsupported type "Iterable"');
805
802
  const options = getIterableOptions(current);
806
803
  return [12 /* Iterable */, [
807
- options ? await serializeProperties(options) : void 0,
804
+ options ? await serializePropertiesAsync(ctx, options) : void 0,
808
805
  await generateTreeAsync(ctx, Array.from(current))
809
806
  ], id];
810
807
  }
@@ -812,7 +809,7 @@ async function generateTreeAsync(ctx, current) {
812
809
  if (current.constructor === Object || empty) {
813
810
  return [
814
811
  empty ? 8 /* NullConstructor */ : 7 /* Object */,
815
- await serializeProperties(current),
812
+ await serializePropertiesAsync(ctx, current),
816
813
  id
817
814
  ];
818
815
  }
@@ -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("bigint"), 'Unsupported type "BigInt"');
832
+ assert(ctx.features.has(3 /* BigInt */), 'Unsupported type "BigInt"');
836
833
  return `${value}n`;
837
834
  }
838
835
  if (typeof value === "string") {
@@ -849,61 +846,62 @@ function serializePrimitive(ctx, value) {
849
846
  }
850
847
  return String(value);
851
848
  }
852
- function serializeTree(ctx, [type, value, id]) {
853
- function serializeAssignments(targetRef, [keys, values, size]) {
854
- ctx.stack.push(targetRef);
855
- const mainAssignments = [];
856
- for (let i = 0; i < size; i++) {
857
- const parentStack = ctx.stack;
858
- ctx.stack = [];
859
- const refParam = serializeTree(ctx, values[i]);
860
- ctx.stack = parentStack;
861
- const key = keys[i];
862
- const check = Number(key);
863
- const parentAssignment = ctx.assignments;
864
- ctx.assignments = mainAssignments;
865
- if (check >= 0 || Number.isNaN(check) && /^([$A-Z_][0-9A-Z_$]*)$/i.test(key)) {
866
- if (!Number.isNaN(check)) {
867
- createObjectComputedAssign(ctx, targetRef, key, refParam);
868
- } else {
869
- createObjectIdentifierAssign(ctx, targetRef, key, refParam);
870
- }
849
+ var IDENTIFIER_CHECK = /^([$A-Z_][0-9A-Z_$]*)$/i;
850
+ function serializeAssignments(ctx, targetRef, [keys, values, size]) {
851
+ ctx.stack.push(targetRef);
852
+ const mainAssignments = [];
853
+ for (let i = 0; i < size; i++) {
854
+ const parentStack = ctx.stack;
855
+ ctx.stack = [];
856
+ const refParam = serializeTree(ctx, values[i]);
857
+ ctx.stack = parentStack;
858
+ const key = keys[i];
859
+ const check = Number(key);
860
+ const parentAssignment = ctx.assignments;
861
+ ctx.assignments = mainAssignments;
862
+ if (check >= 0 || Number.isNaN(check) && IDENTIFIER_CHECK.test(key)) {
863
+ if (!Number.isNaN(check)) {
864
+ createObjectComputedAssign(ctx, targetRef, key, refParam);
871
865
  } else {
872
- createObjectComputedAssign(ctx, targetRef, quote(key), refParam);
866
+ createObjectIdentifierAssign(ctx, targetRef, key, refParam);
873
867
  }
874
- ctx.assignments = parentAssignment;
868
+ } else {
869
+ createObjectComputedAssign(ctx, targetRef, quote(key), refParam);
875
870
  }
876
- ctx.stack.pop();
877
- return resolveAssignments(mainAssignments);
871
+ ctx.assignments = parentAssignment;
878
872
  }
879
- function serializeObject(sourceID, [keys, values, size]) {
880
- let result = "";
881
- ctx.stack.push(sourceID);
882
- for (let i = 0; i < size; i++) {
883
- const key = keys[i];
884
- const val = values[i];
885
- const check = Number(key);
886
- if (check >= 0 || Number.isNaN(check) && /^([$A-Z_][0-9A-Z_$]*)$/i.test(key)) {
887
- if (isReferenceInStack(ctx, val)) {
888
- const refParam = getRefParam(ctx, val[1]);
889
- if (!Number.isNaN(check)) {
890
- createObjectComputedAssign(ctx, sourceID, key, refParam);
891
- } else {
892
- createObjectIdentifierAssign(ctx, sourceID, key, refParam);
893
- }
873
+ ctx.stack.pop();
874
+ return resolveAssignments(mainAssignments);
875
+ }
876
+ function serializeObject(ctx, sourceID, [keys, values, size]) {
877
+ let result = "";
878
+ ctx.stack.push(sourceID);
879
+ for (let i = 0; i < size; i++) {
880
+ const key = keys[i];
881
+ const val = values[i];
882
+ const check = Number(key);
883
+ if (check >= 0 || Number.isNaN(check) && IDENTIFIER_CHECK.test(key)) {
884
+ if (isReferenceInStack(ctx, val)) {
885
+ const refParam = getRefParam(ctx, val[1]);
886
+ if (!Number.isNaN(check)) {
887
+ createObjectComputedAssign(ctx, sourceID, key, refParam);
894
888
  } else {
895
- result += `${key}:${serializeTree(ctx, val)},`;
889
+ createObjectIdentifierAssign(ctx, sourceID, key, refParam);
896
890
  }
897
- } else if (isReferenceInStack(ctx, val)) {
898
- const refParam = getRefParam(ctx, val[1]);
899
- createObjectComputedAssign(ctx, sourceID, quote(key), refParam);
900
891
  } else {
901
- result += `${quote(key)}:${serializeTree(ctx, val)},`;
892
+ result += `${key}:${serializeTree(ctx, val)},`;
902
893
  }
894
+ } else if (isReferenceInStack(ctx, val)) {
895
+ const refParam = getRefParam(ctx, val[1]);
896
+ createObjectComputedAssign(ctx, sourceID, quote(key), refParam);
897
+ } else {
898
+ result += `${quote(key)}:${serializeTree(ctx, val)},`;
903
899
  }
904
- ctx.stack.pop();
905
- return `{${result.substring(0, result.length - 1)}}`;
906
900
  }
901
+ ctx.stack.pop();
902
+ return `{${result.substring(0, result.length - 1)}}`;
903
+ }
904
+ function serializeTree(ctx, [type, value, id]) {
907
905
  switch (type) {
908
906
  case 0 /* Primitive */:
909
907
  return serializePrimitive(ctx, value);
@@ -1022,12 +1020,12 @@ function serializeTree(ctx, [type, value, id]) {
1022
1020
  let serialized = `new AggregateError(${serializeTree(ctx, value[2])},${quote(value[0])})`;
1023
1021
  ctx.stack.pop();
1024
1022
  if (value[1]) {
1025
- if (ctx.features.has("object-assign")) {
1026
- const options = serializeObject(id, value[1]);
1023
+ if (ctx.features.has(6 /* ObjectAssign */)) {
1024
+ const options = serializeObject(ctx, id, value[1]);
1027
1025
  serialized = `Object.assign(${serialized},${options})`;
1028
1026
  } else {
1029
1027
  markRef(ctx, id);
1030
- const assignments = serializeAssignments(id, value[1]);
1028
+ const assignments = serializeAssignments(ctx, id, value[1]);
1031
1029
  if (assignments) {
1032
1030
  const ref = getRefParam(ctx, id);
1033
1031
  return `(${assignRef(ctx, id, serialized)},${assignments}${ref})`;
@@ -1039,12 +1037,12 @@ function serializeTree(ctx, [type, value, id]) {
1039
1037
  case 10 /* Error */: {
1040
1038
  let serialized = `new ${value[0]}(${quote(value[1])})`;
1041
1039
  if (value[2]) {
1042
- if (ctx.features.has("object-assign")) {
1043
- const options = serializeObject(id, value[2]);
1040
+ if (ctx.features.has(6 /* ObjectAssign */)) {
1041
+ const options = serializeObject(ctx, id, value[2]);
1044
1042
  serialized = `Object.assign(${serialized},${options})`;
1045
1043
  } else {
1046
1044
  markRef(ctx, id);
1047
- const assignments = serializeAssignments(id, value[2]);
1045
+ const assignments = serializeAssignments(ctx, id, value[2]);
1048
1046
  if (assignments) {
1049
1047
  const ref = getRefParam(ctx, id);
1050
1048
  return `(${assignRef(ctx, id, serialized)},${assignments}${ref})`;
@@ -1059,25 +1057,25 @@ function serializeTree(ctx, [type, value, id]) {
1059
1057
  const values = serializeTree(ctx, value[1]);
1060
1058
  ctx.stack = parent;
1061
1059
  let serialized;
1062
- if (ctx.features.has("array-values")) {
1060
+ if (ctx.features.has(1 /* ArrayPrototypeValues */)) {
1063
1061
  serialized = `${values}.values()`;
1064
1062
  } else {
1065
1063
  serialized = `${values}[Symbol.iterator]()`;
1066
1064
  }
1067
- if (ctx.features.has("arrow-function")) {
1065
+ if (ctx.features.has(2 /* ArrowFunction */)) {
1068
1066
  serialized = `{[Symbol.iterator]:()=>${serialized}}`;
1069
- } else if (ctx.features.has("method-shorthand")) {
1067
+ } else if (ctx.features.has(5 /* MethodShorthand */)) {
1070
1068
  serialized = `{[Symbol.iterator](){return ${serialized}}}`;
1071
1069
  } else {
1072
1070
  serialized = `{[Symbol.iterator]:function(){return ${serialized}}}`;
1073
1071
  }
1074
1072
  if (value[0]) {
1075
- if (ctx.features.has("object-assign")) {
1076
- const options = serializeObject(id, value[0]);
1073
+ if (ctx.features.has(6 /* ObjectAssign */)) {
1074
+ const options = serializeObject(ctx, id, value[0]);
1077
1075
  serialized = `Object.assign(${serialized},${options})`;
1078
1076
  } else {
1079
1077
  markRef(ctx, id);
1080
- const assignments = serializeAssignments(id, value[0]);
1078
+ const assignments = serializeAssignments(ctx, id, value[0]);
1081
1079
  if (assignments) {
1082
1080
  const ref = getRefParam(ctx, id);
1083
1081
  return `(${assignRef(ctx, id, serialized)},${assignments}${ref})`;
@@ -1088,14 +1086,14 @@ function serializeTree(ctx, [type, value, id]) {
1088
1086
  }
1089
1087
  case 8 /* NullConstructor */: {
1090
1088
  let serialized = "Object.create(null)";
1091
- if (ctx.features.has("object-assign")) {
1092
- const fields = serializeObject(id, value);
1089
+ if (ctx.features.has(6 /* ObjectAssign */)) {
1090
+ const fields = serializeObject(ctx, id, value);
1093
1091
  if (fields !== "{}") {
1094
1092
  serialized = `Object.assign(${serialized},${fields})`;
1095
1093
  }
1096
1094
  } else {
1097
1095
  markRef(ctx, id);
1098
- const assignments = serializeAssignments(id, value);
1096
+ const assignments = serializeAssignments(ctx, id, value);
1099
1097
  if (assignments) {
1100
1098
  const ref = getRefParam(ctx, id);
1101
1099
  return `(${assignRef(ctx, id, serialized)},${assignments}${ref})`;
@@ -1104,7 +1102,7 @@ function serializeTree(ctx, [type, value, id]) {
1104
1102
  return assignRef(ctx, id, serialized);
1105
1103
  }
1106
1104
  case 7 /* Object */:
1107
- return assignRef(ctx, id, serializeObject(id, value));
1105
+ return assignRef(ctx, id, serializeObject(ctx, id, value));
1108
1106
  default:
1109
1107
  throw new Error("Unsupported type");
1110
1108
  }
@@ -1124,7 +1122,7 @@ function finalize(ctx, source, result) {
1124
1122
  }
1125
1123
  }
1126
1124
  let params = ctx.vars.length > 1 ? ctx.vars.join(",") : ctx.vars[0];
1127
- if (ctx.features.has("arrow-function")) {
1125
+ if (ctx.features.has(2 /* ArrowFunction */)) {
1128
1126
  params = ctx.vars.length > 1 || ctx.vars.length === 0 ? `(${params})` : params;
1129
1127
  return `(${params}=>(${body}))()`;
1130
1128
  }