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.
@@ -48,65 +48,6 @@ function isIterable(obj) {
48
48
  return !!obj && typeof obj === "object" && !isIterableBuiltin(obj) && Symbol.iterator in obj && typeof obj[Symbol.iterator] === "function";
49
49
  }
50
50
 
51
- // src/quote.ts
52
- function quote(str) {
53
- let result = "";
54
- let lastPos = 0;
55
- for (let i = 0, len = str.length; i < len; i++) {
56
- let replacement;
57
- switch (str[i]) {
58
- case '"':
59
- replacement = '\\"';
60
- break;
61
- case "\\":
62
- replacement = "\\\\";
63
- break;
64
- case "<":
65
- replacement = "\\x3C";
66
- break;
67
- case "\n":
68
- replacement = "\\n";
69
- break;
70
- case "\r":
71
- replacement = "\\r";
72
- break;
73
- case "\u2028":
74
- replacement = "\\u2028";
75
- break;
76
- case "\u2029":
77
- replacement = "\\u2029";
78
- break;
79
- default:
80
- continue;
81
- }
82
- result += str.slice(lastPos, i) + replacement;
83
- lastPos = i + 1;
84
- }
85
- if (lastPos === 0) {
86
- result = str;
87
- } else {
88
- result += str.slice(lastPos);
89
- }
90
- return `"${result}"`;
91
- }
92
-
93
- // src/get-identifier.ts
94
- var REF_START_CHARS = "hjkmoquxzABCDEFGHIJKLNPQRTUVWXYZ$_";
95
- var REF_START_CHARS_LEN = REF_START_CHARS.length;
96
- var REF_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_";
97
- var REF_CHARS_LEN = REF_CHARS.length;
98
- function getIdentifier(index) {
99
- let mod = index % REF_START_CHARS_LEN;
100
- let ref = REF_START_CHARS[mod];
101
- index = (index - mod) / REF_START_CHARS_LEN;
102
- while (index > 0) {
103
- mod = index % REF_CHARS_LEN;
104
- ref += REF_CHARS[mod];
105
- index = (index - mod) / REF_CHARS_LEN;
106
- }
107
- return ref;
108
- }
109
-
110
51
  // src/assert.ts
111
52
  function assert(cond, error) {
112
53
  if (!cond) {
@@ -127,7 +68,7 @@ function compareVersion(left, right) {
127
68
  }
128
69
  var VERSION_TABLE = {
129
70
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError#browser_compatibility
130
- "aggregate-error": {
71
+ [0 /* AggregateError */]: {
131
72
  es: [2021, 0, 0],
132
73
  chrome: [85, 0, 0],
133
74
  edge: [85, 0, 0],
@@ -140,7 +81,7 @@ var VERSION_TABLE = {
140
81
  node: [15, 0, 0]
141
82
  },
142
83
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values#browser_compatibility
143
- "array-values": {
84
+ [1 /* ArrayPrototypeValues */]: {
144
85
  es: [6, 0, 0],
145
86
  chrome: [66, 0, 0],
146
87
  edge: [14, 0, 0],
@@ -153,7 +94,7 @@ var VERSION_TABLE = {
153
94
  node: [10, 9, 0]
154
95
  },
155
96
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#browser_compatibility
156
- "arrow-function": {
97
+ [2 /* ArrowFunction */]: {
157
98
  es: [6, 0, 0],
158
99
  chrome: [45, 0, 0],
159
100
  edge: [12, 0, 0],
@@ -166,7 +107,7 @@ var VERSION_TABLE = {
166
107
  node: [4, 0, 0]
167
108
  },
168
109
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#browser_compatibility
169
- bigint: {
110
+ [3 /* BigInt */]: {
170
111
  es: [2020, 0, 0],
171
112
  chrome: [67, 0, 0],
172
113
  edge: [79, 0, 0],
@@ -179,7 +120,7 @@ var VERSION_TABLE = {
179
120
  node: [10, 4, 0]
180
121
  },
181
122
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#browser_compatibility
182
- map: {
123
+ [4 /* Map */]: {
183
124
  es: [6, 0, 0],
184
125
  chrome: [38, 0, 0],
185
126
  edge: [12, 0, 0],
@@ -192,7 +133,7 @@ var VERSION_TABLE = {
192
133
  node: [0, 12, 0]
193
134
  },
194
135
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions#browser_compatibility
195
- "method-shorthand": {
136
+ [5 /* MethodShorthand */]: {
196
137
  es: [6, 0, 0],
197
138
  chrome: [39, 0, 0],
198
139
  edge: [12, 0, 0],
@@ -205,7 +146,7 @@ var VERSION_TABLE = {
205
146
  node: [4, 0, 0]
206
147
  },
207
148
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#browser_compatibility
208
- "object-assign": {
149
+ [6 /* ObjectAssign */]: {
209
150
  es: [6, 0, 0],
210
151
  chrome: [45, 0, 0],
211
152
  edge: [12, 0, 0],
@@ -218,7 +159,7 @@ var VERSION_TABLE = {
218
159
  node: [4, 0, 0]
219
160
  },
220
161
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#browser_compatibility
221
- promise: {
162
+ [7 /* Promise */]: {
222
163
  es: [6, 0, 0],
223
164
  chrome: [32, 0, 0],
224
165
  edge: [12, 0, 0],
@@ -231,7 +172,7 @@ var VERSION_TABLE = {
231
172
  node: [0, 12, 0]
232
173
  },
233
174
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#browser_compatibility
234
- set: {
175
+ [8 /* Set */]: {
235
176
  es: [6, 0, 0],
236
177
  chrome: [38, 0, 0],
237
178
  edge: [12, 0, 0],
@@ -244,7 +185,7 @@ var VERSION_TABLE = {
244
185
  node: [0, 12, 0]
245
186
  },
246
187
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/iterator#browser_compatibility
247
- "symbol-iterator": {
188
+ [9 /* SymbolIterator */]: {
248
189
  es: [6, 0, 0],
249
190
  chrome: [43, 0, 0],
250
191
  edge: [12, 0, 0],
@@ -257,7 +198,7 @@ var VERSION_TABLE = {
257
198
  node: [0, 12, 0]
258
199
  },
259
200
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#browser_compatibility
260
- "typed-arrays": {
201
+ [10 /* TypedArray */]: {
261
202
  es: [6, 0, 0],
262
203
  chrome: [7, 0, 0],
263
204
  edge: [12, 0, 0],
@@ -288,26 +229,82 @@ function getTargetVersions(targets) {
288
229
  }
289
230
  return [parseTarget(targets)];
290
231
  }
291
- function isFeatureSupported(key, targets) {
292
- const base = VERSION_TABLE[key];
293
- let flag = true;
294
- for (const [platform, version] of targets) {
295
- const baseVersion = base[platform];
296
- flag = flag && !!baseVersion && compareVersion(baseVersion, version) <= 0;
297
- }
298
- return flag;
299
- }
300
232
  function parseTargets(targets) {
301
233
  const parsed = getTargetVersions(targets);
302
234
  const flags = /* @__PURE__ */ new Set();
303
235
  for (const key in VERSION_TABLE) {
304
- if (isFeatureSupported(key, parsed)) {
305
- flags.add(key);
236
+ const base = VERSION_TABLE[key];
237
+ let flag = true;
238
+ for (const [platform, version] of parsed) {
239
+ const baseVersion = base[platform];
240
+ flag = flag && !!baseVersion && compareVersion(baseVersion, version) <= 0;
241
+ }
242
+ if (flag) {
243
+ flags.add(Number(key));
306
244
  }
307
245
  }
308
246
  return flags;
309
247
  }
310
248
 
249
+ // src/quote.ts
250
+ function quote(str) {
251
+ let result = "";
252
+ let lastPos = 0;
253
+ for (let i = 0, len = str.length; i < len; i++) {
254
+ let replacement;
255
+ switch (str[i]) {
256
+ case '"':
257
+ replacement = '\\"';
258
+ break;
259
+ case "\\":
260
+ replacement = "\\\\";
261
+ break;
262
+ case "<":
263
+ replacement = "\\x3C";
264
+ break;
265
+ case "\n":
266
+ replacement = "\\n";
267
+ break;
268
+ case "\r":
269
+ replacement = "\\r";
270
+ break;
271
+ case "\u2028":
272
+ replacement = "\\u2028";
273
+ break;
274
+ case "\u2029":
275
+ replacement = "\\u2029";
276
+ break;
277
+ default:
278
+ continue;
279
+ }
280
+ result += str.slice(lastPos, i) + replacement;
281
+ lastPos = i + 1;
282
+ }
283
+ if (lastPos === 0) {
284
+ result = str;
285
+ } else {
286
+ result += str.slice(lastPos);
287
+ }
288
+ return `"${result}"`;
289
+ }
290
+
291
+ // src/get-identifier.ts
292
+ var REF_START_CHARS = "hjkmoquxzABCDEFGHIJKLNPQRTUVWXYZ$_";
293
+ var REF_START_CHARS_LEN = REF_START_CHARS.length;
294
+ var REF_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_";
295
+ var REF_CHARS_LEN = REF_CHARS.length;
296
+ function getIdentifier(index) {
297
+ let mod = index % REF_START_CHARS_LEN;
298
+ let ref = REF_START_CHARS[mod];
299
+ index = (index - mod) / REF_START_CHARS_LEN;
300
+ while (index > 0) {
301
+ mod = index % REF_CHARS_LEN;
302
+ ref += REF_CHARS[mod];
303
+ index = (index - mod) / REF_CHARS_LEN;
304
+ }
305
+ return ref;
306
+ }
307
+
311
308
  // src/tree.ts
312
309
  var DEFAULT_OPTIONS = {
313
310
  target: "es2023"
@@ -532,81 +529,81 @@ function generateSemiPrimitiveValue(ctx, current, id) {
532
529
  return [3 /* RegExp */, current, id];
533
530
  }
534
531
  if (constructorCheck(current, Int8Array)) {
535
- assert(ctx.features.has("typed-arrays"), 'Unsupported value type "Int8Array"');
532
+ assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Int8Array"');
536
533
  return [13 /* TypedArray */, ["Int8Array", current], id];
537
534
  }
538
535
  if (constructorCheck(current, Int16Array)) {
539
- assert(ctx.features.has("typed-arrays"), 'Unsupported value type "Int16Array"');
536
+ assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Int16Array"');
540
537
  return [13 /* TypedArray */, ["Int16Array", current], id];
541
538
  }
542
539
  if (constructorCheck(current, Int32Array)) {
543
- assert(ctx.features.has("typed-arrays"), 'Unsupported value type "Int32Array"');
540
+ assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Int32Array"');
544
541
  return [13 /* TypedArray */, ["Int32Array", current], id];
545
542
  }
546
543
  if (constructorCheck(current, Uint8Array)) {
547
- assert(ctx.features.has("typed-arrays"), 'Unsupported value type "Uint8Array"');
544
+ assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Uint8Array"');
548
545
  return [13 /* TypedArray */, ["Uint8Array", current], id];
549
546
  }
550
547
  if (constructorCheck(current, Uint16Array)) {
551
- assert(ctx.features.has("typed-arrays"), 'Unsupported value type "Uint16Array"');
548
+ assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Uint16Array"');
552
549
  return [13 /* TypedArray */, ["Uint16Array", current], id];
553
550
  }
554
551
  if (constructorCheck(current, Uint32Array)) {
555
- assert(ctx.features.has("typed-arrays"), 'Unsupported value type "Uint32Array"');
552
+ assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Uint32Array"');
556
553
  return [13 /* TypedArray */, ["Uint32Array", current], id];
557
554
  }
558
555
  if (constructorCheck(current, Uint8ClampedArray)) {
559
- assert(ctx.features.has("typed-arrays"), 'Unsupported value type "Uint8ClampedArray"');
556
+ assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Uint8ClampedArray"');
560
557
  return [13 /* TypedArray */, ["Uint8ClampedArray", current], id];
561
558
  }
562
559
  if (constructorCheck(current, Float32Array)) {
563
- assert(ctx.features.has("typed-arrays"), 'Unsupported value type "Float32Array"');
560
+ assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Float32Array"');
564
561
  return [13 /* TypedArray */, ["Float32Array", current], id];
565
562
  }
566
563
  if (constructorCheck(current, Float64Array)) {
567
- assert(ctx.features.has("typed-arrays"), 'Unsupported value type "Float64Array"');
564
+ assert(ctx.features.has(10 /* TypedArray */), 'Unsupported value type "Float64Array"');
568
565
  return [13 /* TypedArray */, ["Float64Array", current], id];
569
566
  }
570
567
  if (constructorCheck(current, BigInt64Array)) {
571
568
  assert(
572
- ctx.features.has("typed-arrays") && ctx.features.has("bigint"),
569
+ ctx.features.has(10 /* TypedArray */) && ctx.features.has(3 /* BigInt */),
573
570
  'Unsupported value type "BigInt64Array"'
574
571
  );
575
572
  return [13 /* TypedArray */, ["BigInt64Array", current], id];
576
573
  }
577
574
  if (constructorCheck(current, BigUint64Array)) {
578
575
  assert(
579
- ctx.features.has("typed-arrays") && ctx.features.has("bigint"),
576
+ ctx.features.has(10 /* TypedArray */) && ctx.features.has(3 /* BigInt */),
580
577
  'Unsupported value type "BigUint64Array"'
581
578
  );
582
579
  return [13 /* TypedArray */, ["BigUint64Array", current], id];
583
580
  }
584
581
  return void 0;
585
582
  }
586
- function generateTreeSync(ctx, current) {
587
- function serializeProperties(properties) {
588
- const keyNodes = [];
589
- const valueNodes = [];
590
- const deferredKeys = [];
591
- const deferredValues = [];
592
- const keys = Object.keys(properties);
593
- let deferredSize = 0;
594
- for (const key of keys) {
595
- if (isIterable(properties[key])) {
596
- deferredKeys.push(key);
597
- deferredValues.push(properties[key]);
598
- deferredSize++;
599
- } else {
600
- keyNodes.push(key);
601
- valueNodes.push(generateTreeSync(ctx, properties[key]));
602
- }
603
- }
604
- for (let i = 0; i < deferredSize; i++) {
605
- keyNodes.push(deferredKeys[i]);
606
- valueNodes.push(generateTreeSync(ctx, deferredValues[i]));
583
+ function serializePropertiesSync(ctx, properties) {
584
+ const keyNodes = [];
585
+ const valueNodes = [];
586
+ const deferredKeys = [];
587
+ const deferredValues = [];
588
+ const keys = Object.keys(properties);
589
+ let deferredSize = 0;
590
+ for (const key of keys) {
591
+ if (isIterable(properties[key])) {
592
+ deferredKeys.push(key);
593
+ deferredValues.push(properties[key]);
594
+ deferredSize++;
595
+ } else {
596
+ keyNodes.push(key);
597
+ valueNodes.push(generateTreeSync(ctx, properties[key]));
607
598
  }
608
- return [keyNodes, valueNodes, keys.length];
609
599
  }
600
+ for (let i = 0; i < deferredSize; i++) {
601
+ keyNodes.push(deferredKeys[i]);
602
+ valueNodes.push(generateTreeSync(ctx, deferredValues[i]));
603
+ }
604
+ return [keyNodes, valueNodes, keys.length];
605
+ }
606
+ function generateTreeSync(ctx, current) {
610
607
  if (isPrimitive(current)) {
611
608
  return [0 /* Primitive */, current];
612
609
  }
@@ -619,7 +616,7 @@ function generateTreeSync(ctx, current) {
619
616
  return semiPrimitive;
620
617
  }
621
618
  if (constructorCheck(current, Set)) {
622
- assert(ctx.features.has("set"), 'Unsupported type "Set"');
619
+ assert(ctx.features.has(8 /* Set */), 'Unsupported type "Set"');
623
620
  const nodes = [];
624
621
  const deferred = [];
625
622
  for (const item of current.keys()) {
@@ -635,7 +632,7 @@ function generateTreeSync(ctx, current) {
635
632
  return [4 /* Set */, nodes, id];
636
633
  }
637
634
  if (constructorCheck(current, Map)) {
638
- assert(ctx.features.has("map"), 'Unsupported type "Map"');
635
+ assert(ctx.features.has(4 /* Map */), 'Unsupported type "Map"');
639
636
  const keyNodes = [];
640
637
  const valueNodes = [];
641
638
  const deferredKey = [];
@@ -677,15 +674,15 @@ function generateTreeSync(ctx, current) {
677
674
  }
678
675
  return [6 /* Array */, nodes, id];
679
676
  }
680
- if (current instanceof AggregateError && ctx.features.has("aggregate-error")) {
677
+ if (current instanceof AggregateError && ctx.features.has(0 /* AggregateError */)) {
681
678
  const options = getErrorOptions(current);
682
- const optionsNode = options ? serializeProperties(options) : void 0;
679
+ const optionsNode = options ? serializePropertiesSync(ctx, options) : void 0;
683
680
  const errorsNode = generateTreeSync(ctx, current.errors);
684
681
  return [11 /* AggregateError */, [current.message, optionsNode, errorsNode], id];
685
682
  }
686
683
  if (current instanceof Error) {
687
684
  const options = getErrorOptions(current);
688
- const optionsNode = options ? serializeProperties(options) : void 0;
685
+ const optionsNode = options ? serializePropertiesSync(ctx, options) : void 0;
689
686
  return [
690
687
  10 /* Error */,
691
688
  [getErrorConstructor(current), current.message, optionsNode],
@@ -693,11 +690,11 @@ function generateTreeSync(ctx, current) {
693
690
  ];
694
691
  }
695
692
  if (isIterable(current)) {
696
- assert(ctx.features.has("symbol-iterator"), 'Unsupported type "Iterable"');
693
+ assert(ctx.features.has(9 /* SymbolIterator */), 'Unsupported type "Iterable"');
697
694
  const options = getIterableOptions(current);
698
695
  return [12 /* Iterable */, [
699
696
  // Parse options first before the items
700
- options ? serializeProperties(options) : void 0,
697
+ options ? serializePropertiesSync(ctx, options) : void 0,
701
698
  generateTreeSync(ctx, Array.from(current))
702
699
  ], id];
703
700
  }
@@ -705,36 +702,36 @@ function generateTreeSync(ctx, current) {
705
702
  if (current.constructor === Object || empty) {
706
703
  return [
707
704
  empty ? 8 /* NullConstructor */ : 7 /* Object */,
708
- serializeProperties(current),
705
+ serializePropertiesSync(ctx, current),
709
706
  id
710
707
  ];
711
708
  }
712
709
  throw new Error("Unsupported value");
713
710
  }
714
- async function generateTreeAsync(ctx, current) {
715
- async function serializeProperties(properties) {
716
- const keyNodes = [];
717
- const valueNodes = [];
718
- const deferredKeys = [];
719
- const deferredValues = [];
720
- const keys = Object.keys(properties);
721
- let deferredSize = 0;
722
- for (const key of keys) {
723
- if (isIterable(properties[key])) {
724
- deferredKeys.push(key);
725
- deferredValues.push(properties[key]);
726
- deferredSize++;
727
- } else {
728
- keyNodes.push(key);
729
- valueNodes.push(await generateTreeAsync(ctx, properties[key]));
730
- }
731
- }
732
- for (let i = 0; i < deferredSize; i++) {
733
- keyNodes.push(deferredKeys[i]);
734
- valueNodes.push(await generateTreeAsync(ctx, deferredValues[i]));
711
+ async function serializePropertiesAsync(ctx, properties) {
712
+ const keyNodes = [];
713
+ const valueNodes = [];
714
+ const deferredKeys = [];
715
+ const deferredValues = [];
716
+ const keys = Object.keys(properties);
717
+ let deferredSize = 0;
718
+ for (const key of keys) {
719
+ if (isIterable(properties[key])) {
720
+ deferredKeys.push(key);
721
+ deferredValues.push(properties[key]);
722
+ deferredSize++;
723
+ } else {
724
+ keyNodes.push(key);
725
+ valueNodes.push(await generateTreeAsync(ctx, properties[key]));
735
726
  }
736
- return [keyNodes, valueNodes, keys.length];
737
727
  }
728
+ for (let i = 0; i < deferredSize; i++) {
729
+ keyNodes.push(deferredKeys[i]);
730
+ valueNodes.push(await generateTreeAsync(ctx, deferredValues[i]));
731
+ }
732
+ return [keyNodes, valueNodes, keys.length];
733
+ }
734
+ async function generateTreeAsync(ctx, current) {
738
735
  if (isPrimitive(current)) {
739
736
  return [0 /* Primitive */, current];
740
737
  }
@@ -747,7 +744,7 @@ async function generateTreeAsync(ctx, current) {
747
744
  return semiPrimitive;
748
745
  }
749
746
  if (isPromise(current)) {
750
- assert(ctx.features.has("promise"), 'Unsupported type "Promise"');
747
+ assert(ctx.features.has(7 /* Promise */), 'Unsupported type "Promise"');
751
748
  return current.then(async (value) => [
752
749
  9 /* Promise */,
753
750
  await generateTreeAsync(ctx, value),
@@ -755,7 +752,7 @@ async function generateTreeAsync(ctx, current) {
755
752
  ]);
756
753
  }
757
754
  if (constructorCheck(current, Set)) {
758
- assert(ctx.features.has("set"), 'Unsupported type "Set"');
755
+ assert(ctx.features.has(8 /* Set */), 'Unsupported type "Set"');
759
756
  const nodes = [];
760
757
  const deferred = [];
761
758
  for (const item of current.keys()) {
@@ -771,7 +768,7 @@ async function generateTreeAsync(ctx, current) {
771
768
  return [4 /* Set */, nodes, id];
772
769
  }
773
770
  if (constructorCheck(current, Map)) {
774
- assert(ctx.features.has("map"), 'Unsupported type "Map"');
771
+ assert(ctx.features.has(4 /* Map */), 'Unsupported type "Map"');
775
772
  const keyNodes = [];
776
773
  const valueNodes = [];
777
774
  const deferredKey = [];
@@ -816,13 +813,13 @@ async function generateTreeAsync(ctx, current) {
816
813
  }
817
814
  if (current instanceof AggregateError) {
818
815
  const options = getErrorOptions(current);
819
- const optionsNode = options ? await serializeProperties(options) : void 0;
816
+ const optionsNode = options ? await serializePropertiesAsync(ctx, options) : void 0;
820
817
  const errorsNode = await generateTreeAsync(ctx, current.errors);
821
818
  return [11 /* AggregateError */, [current.message, optionsNode, errorsNode], id];
822
819
  }
823
820
  if (current instanceof Error) {
824
821
  const options = getErrorOptions(current);
825
- const optionsNode = options ? await serializeProperties(options) : void 0;
822
+ const optionsNode = options ? await serializePropertiesAsync(ctx, options) : void 0;
826
823
  return [
827
824
  10 /* Error */,
828
825
  [getErrorConstructor(current), current.message, optionsNode],
@@ -830,10 +827,10 @@ async function generateTreeAsync(ctx, current) {
830
827
  ];
831
828
  }
832
829
  if (isIterable(current)) {
833
- assert(ctx.features.has("symbol-iterator"), 'Unsupported type "Iterable"');
830
+ assert(ctx.features.has(9 /* SymbolIterator */), 'Unsupported type "Iterable"');
834
831
  const options = getIterableOptions(current);
835
832
  return [12 /* Iterable */, [
836
- options ? await serializeProperties(options) : void 0,
833
+ options ? await serializePropertiesAsync(ctx, options) : void 0,
837
834
  await generateTreeAsync(ctx, Array.from(current))
838
835
  ], id];
839
836
  }
@@ -841,7 +838,7 @@ async function generateTreeAsync(ctx, current) {
841
838
  if (current.constructor === Object || empty) {
842
839
  return [
843
840
  empty ? 8 /* NullConstructor */ : 7 /* Object */,
844
- await serializeProperties(current),
841
+ await serializePropertiesAsync(ctx, current),
845
842
  id
846
843
  ];
847
844
  }
@@ -861,7 +858,7 @@ function serializePrimitive(ctx, value) {
861
858
  return "null";
862
859
  }
863
860
  if (typeof value === "bigint") {
864
- assert(ctx.features.has("bigint"), 'Unsupported type "BigInt"');
861
+ assert(ctx.features.has(3 /* BigInt */), 'Unsupported type "BigInt"');
865
862
  return `${value}n`;
866
863
  }
867
864
  if (typeof value === "string") {
@@ -878,61 +875,62 @@ function serializePrimitive(ctx, value) {
878
875
  }
879
876
  return String(value);
880
877
  }
881
- function serializeTree(ctx, [type, value, id]) {
882
- function serializeAssignments(targetRef, [keys, values, size]) {
883
- ctx.stack.push(targetRef);
884
- const mainAssignments = [];
885
- for (let i = 0; i < size; i++) {
886
- const parentStack = ctx.stack;
887
- ctx.stack = [];
888
- const refParam = serializeTree(ctx, values[i]);
889
- ctx.stack = parentStack;
890
- const key = keys[i];
891
- const check = Number(key);
892
- const parentAssignment = ctx.assignments;
893
- ctx.assignments = mainAssignments;
894
- if (check >= 0 || Number.isNaN(check) && /^([$A-Z_][0-9A-Z_$]*)$/i.test(key)) {
895
- if (!Number.isNaN(check)) {
896
- createObjectComputedAssign(ctx, targetRef, key, refParam);
897
- } else {
898
- createObjectIdentifierAssign(ctx, targetRef, key, refParam);
899
- }
878
+ var IDENTIFIER_CHECK = /^([$A-Z_][0-9A-Z_$]*)$/i;
879
+ function serializeAssignments(ctx, targetRef, [keys, values, size]) {
880
+ ctx.stack.push(targetRef);
881
+ const mainAssignments = [];
882
+ for (let i = 0; i < size; i++) {
883
+ const parentStack = ctx.stack;
884
+ ctx.stack = [];
885
+ const refParam = serializeTree(ctx, values[i]);
886
+ ctx.stack = parentStack;
887
+ const key = keys[i];
888
+ const check = Number(key);
889
+ const parentAssignment = ctx.assignments;
890
+ ctx.assignments = mainAssignments;
891
+ if (check >= 0 || Number.isNaN(check) && IDENTIFIER_CHECK.test(key)) {
892
+ if (!Number.isNaN(check)) {
893
+ createObjectComputedAssign(ctx, targetRef, key, refParam);
900
894
  } else {
901
- createObjectComputedAssign(ctx, targetRef, quote(key), refParam);
895
+ createObjectIdentifierAssign(ctx, targetRef, key, refParam);
902
896
  }
903
- ctx.assignments = parentAssignment;
897
+ } else {
898
+ createObjectComputedAssign(ctx, targetRef, quote(key), refParam);
904
899
  }
905
- ctx.stack.pop();
906
- return resolveAssignments(mainAssignments);
900
+ ctx.assignments = parentAssignment;
907
901
  }
908
- function serializeObject(sourceID, [keys, values, size]) {
909
- let result = "";
910
- ctx.stack.push(sourceID);
911
- for (let i = 0; i < size; i++) {
912
- const key = keys[i];
913
- const val = values[i];
914
- const check = Number(key);
915
- if (check >= 0 || Number.isNaN(check) && /^([$A-Z_][0-9A-Z_$]*)$/i.test(key)) {
916
- if (isReferenceInStack(ctx, val)) {
917
- const refParam = getRefParam(ctx, val[1]);
918
- if (!Number.isNaN(check)) {
919
- createObjectComputedAssign(ctx, sourceID, key, refParam);
920
- } else {
921
- createObjectIdentifierAssign(ctx, sourceID, key, refParam);
922
- }
902
+ ctx.stack.pop();
903
+ return resolveAssignments(mainAssignments);
904
+ }
905
+ function serializeObject(ctx, sourceID, [keys, values, size]) {
906
+ let result = "";
907
+ ctx.stack.push(sourceID);
908
+ for (let i = 0; i < size; i++) {
909
+ const key = keys[i];
910
+ const val = values[i];
911
+ const check = Number(key);
912
+ if (check >= 0 || Number.isNaN(check) && IDENTIFIER_CHECK.test(key)) {
913
+ if (isReferenceInStack(ctx, val)) {
914
+ const refParam = getRefParam(ctx, val[1]);
915
+ if (!Number.isNaN(check)) {
916
+ createObjectComputedAssign(ctx, sourceID, key, refParam);
923
917
  } else {
924
- result += `${key}:${serializeTree(ctx, val)},`;
918
+ createObjectIdentifierAssign(ctx, sourceID, key, refParam);
925
919
  }
926
- } else if (isReferenceInStack(ctx, val)) {
927
- const refParam = getRefParam(ctx, val[1]);
928
- createObjectComputedAssign(ctx, sourceID, quote(key), refParam);
929
920
  } else {
930
- result += `${quote(key)}:${serializeTree(ctx, val)},`;
921
+ result += `${key}:${serializeTree(ctx, val)},`;
931
922
  }
923
+ } else if (isReferenceInStack(ctx, val)) {
924
+ const refParam = getRefParam(ctx, val[1]);
925
+ createObjectComputedAssign(ctx, sourceID, quote(key), refParam);
926
+ } else {
927
+ result += `${quote(key)}:${serializeTree(ctx, val)},`;
932
928
  }
933
- ctx.stack.pop();
934
- return `{${result.substring(0, result.length - 1)}}`;
935
929
  }
930
+ ctx.stack.pop();
931
+ return `{${result.substring(0, result.length - 1)}}`;
932
+ }
933
+ function serializeTree(ctx, [type, value, id]) {
936
934
  switch (type) {
937
935
  case 0 /* Primitive */:
938
936
  return serializePrimitive(ctx, value);
@@ -1051,12 +1049,12 @@ function serializeTree(ctx, [type, value, id]) {
1051
1049
  let serialized = `new AggregateError(${serializeTree(ctx, value[2])},${quote(value[0])})`;
1052
1050
  ctx.stack.pop();
1053
1051
  if (value[1]) {
1054
- if (ctx.features.has("object-assign")) {
1055
- const options = serializeObject(id, value[1]);
1052
+ if (ctx.features.has(6 /* ObjectAssign */)) {
1053
+ const options = serializeObject(ctx, id, value[1]);
1056
1054
  serialized = `Object.assign(${serialized},${options})`;
1057
1055
  } else {
1058
1056
  markRef(ctx, id);
1059
- const assignments = serializeAssignments(id, value[1]);
1057
+ const assignments = serializeAssignments(ctx, id, value[1]);
1060
1058
  if (assignments) {
1061
1059
  const ref = getRefParam(ctx, id);
1062
1060
  return `(${assignRef(ctx, id, serialized)},${assignments}${ref})`;
@@ -1068,12 +1066,12 @@ function serializeTree(ctx, [type, value, id]) {
1068
1066
  case 10 /* Error */: {
1069
1067
  let serialized = `new ${value[0]}(${quote(value[1])})`;
1070
1068
  if (value[2]) {
1071
- if (ctx.features.has("object-assign")) {
1072
- const options = serializeObject(id, value[2]);
1069
+ if (ctx.features.has(6 /* ObjectAssign */)) {
1070
+ const options = serializeObject(ctx, id, value[2]);
1073
1071
  serialized = `Object.assign(${serialized},${options})`;
1074
1072
  } else {
1075
1073
  markRef(ctx, id);
1076
- const assignments = serializeAssignments(id, value[2]);
1074
+ const assignments = serializeAssignments(ctx, id, value[2]);
1077
1075
  if (assignments) {
1078
1076
  const ref = getRefParam(ctx, id);
1079
1077
  return `(${assignRef(ctx, id, serialized)},${assignments}${ref})`;
@@ -1088,25 +1086,25 @@ function serializeTree(ctx, [type, value, id]) {
1088
1086
  const values = serializeTree(ctx, value[1]);
1089
1087
  ctx.stack = parent;
1090
1088
  let serialized;
1091
- if (ctx.features.has("array-values")) {
1089
+ if (ctx.features.has(1 /* ArrayPrototypeValues */)) {
1092
1090
  serialized = `${values}.values()`;
1093
1091
  } else {
1094
1092
  serialized = `${values}[Symbol.iterator]()`;
1095
1093
  }
1096
- if (ctx.features.has("arrow-function")) {
1094
+ if (ctx.features.has(2 /* ArrowFunction */)) {
1097
1095
  serialized = `{[Symbol.iterator]:()=>${serialized}}`;
1098
- } else if (ctx.features.has("method-shorthand")) {
1096
+ } else if (ctx.features.has(5 /* MethodShorthand */)) {
1099
1097
  serialized = `{[Symbol.iterator](){return ${serialized}}}`;
1100
1098
  } else {
1101
1099
  serialized = `{[Symbol.iterator]:function(){return ${serialized}}}`;
1102
1100
  }
1103
1101
  if (value[0]) {
1104
- if (ctx.features.has("object-assign")) {
1105
- const options = serializeObject(id, value[0]);
1102
+ if (ctx.features.has(6 /* ObjectAssign */)) {
1103
+ const options = serializeObject(ctx, id, value[0]);
1106
1104
  serialized = `Object.assign(${serialized},${options})`;
1107
1105
  } else {
1108
1106
  markRef(ctx, id);
1109
- const assignments = serializeAssignments(id, value[0]);
1107
+ const assignments = serializeAssignments(ctx, id, value[0]);
1110
1108
  if (assignments) {
1111
1109
  const ref = getRefParam(ctx, id);
1112
1110
  return `(${assignRef(ctx, id, serialized)},${assignments}${ref})`;
@@ -1117,14 +1115,14 @@ function serializeTree(ctx, [type, value, id]) {
1117
1115
  }
1118
1116
  case 8 /* NullConstructor */: {
1119
1117
  let serialized = "Object.create(null)";
1120
- if (ctx.features.has("object-assign")) {
1121
- const fields = serializeObject(id, value);
1118
+ if (ctx.features.has(6 /* ObjectAssign */)) {
1119
+ const fields = serializeObject(ctx, id, value);
1122
1120
  if (fields !== "{}") {
1123
1121
  serialized = `Object.assign(${serialized},${fields})`;
1124
1122
  }
1125
1123
  } else {
1126
1124
  markRef(ctx, id);
1127
- const assignments = serializeAssignments(id, value);
1125
+ const assignments = serializeAssignments(ctx, id, value);
1128
1126
  if (assignments) {
1129
1127
  const ref = getRefParam(ctx, id);
1130
1128
  return `(${assignRef(ctx, id, serialized)},${assignments}${ref})`;
@@ -1133,7 +1131,7 @@ function serializeTree(ctx, [type, value, id]) {
1133
1131
  return assignRef(ctx, id, serialized);
1134
1132
  }
1135
1133
  case 7 /* Object */:
1136
- return assignRef(ctx, id, serializeObject(id, value));
1134
+ return assignRef(ctx, id, serializeObject(ctx, id, value));
1137
1135
  default:
1138
1136
  throw new Error("Unsupported type");
1139
1137
  }
@@ -1153,7 +1151,7 @@ function finalize(ctx, source, result) {
1153
1151
  }
1154
1152
  }
1155
1153
  let params = ctx.vars.length > 1 ? ctx.vars.join(",") : ctx.vars[0];
1156
- if (ctx.features.has("arrow-function")) {
1154
+ if (ctx.features.has(2 /* ArrowFunction */)) {
1157
1155
  params = ctx.vars.length > 1 || ctx.vars.length === 0 ? `(${params})` : params;
1158
1156
  return `(${params}=>(${body}))()`;
1159
1157
  }