seroval 1.4.0 → 1.4.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.
Files changed (68) hide show
  1. package/dist/cjs/development/index.cjs +524 -364
  2. package/dist/cjs/development/index.cjs.map +3 -3
  3. package/dist/cjs/production/index.cjs +3 -3
  4. package/dist/esm/development/index.mjs +524 -364
  5. package/dist/esm/development/index.mjs.map +3 -3
  6. package/dist/esm/production/index.mjs +3 -3
  7. package/dist/types/core/base-primitives.d.ts +2 -2
  8. package/dist/types/core/base-primitives.d.ts.map +1 -1
  9. package/dist/types/core/compat.d.ts +2 -1
  10. package/dist/types/core/compat.d.ts.map +1 -1
  11. package/dist/types/core/constants.d.ts +2 -2
  12. package/dist/types/core/constants.d.ts.map +1 -1
  13. package/dist/types/core/constructors.d.ts +1 -1
  14. package/dist/types/core/constructors.d.ts.map +1 -1
  15. package/dist/types/core/context/async-parser.d.ts +5 -4
  16. package/dist/types/core/context/async-parser.d.ts.map +1 -1
  17. package/dist/types/core/context/deserializer.d.ts +7 -2
  18. package/dist/types/core/context/deserializer.d.ts.map +1 -1
  19. package/dist/types/core/context/parser.d.ts +3 -1
  20. package/dist/types/core/context/parser.d.ts.map +1 -1
  21. package/dist/types/core/context/serializer.d.ts.map +1 -1
  22. package/dist/types/core/context/sync-parser.d.ts +5 -5
  23. package/dist/types/core/context/sync-parser.d.ts.map +1 -1
  24. package/dist/types/core/cross/index.d.ts.map +1 -1
  25. package/dist/types/core/errors.d.ts +9 -0
  26. package/dist/types/core/errors.d.ts.map +1 -1
  27. package/dist/types/core/literals.d.ts.map +1 -1
  28. package/dist/types/core/node.d.ts +1 -1
  29. package/dist/types/core/node.d.ts.map +1 -1
  30. package/dist/types/core/string.d.ts.map +1 -1
  31. package/dist/types/core/tree/index.d.ts +4 -1
  32. package/dist/types/core/tree/index.d.ts.map +1 -1
  33. package/dist/types/core/types.d.ts +2 -11
  34. package/dist/types/core/types.d.ts.map +1 -1
  35. package/package.json +2 -3
  36. package/src/core/Serializer.ts +0 -119
  37. package/src/core/base-primitives.ts +0 -515
  38. package/src/core/compat.ts +0 -21
  39. package/src/core/constants.ts +0 -187
  40. package/src/core/constructors.ts +0 -269
  41. package/src/core/context/async-parser.ts +0 -586
  42. package/src/core/context/deserializer.ts +0 -646
  43. package/src/core/context/parser.ts +0 -333
  44. package/src/core/context/serializer.ts +0 -1411
  45. package/src/core/context/sync-parser.ts +0 -833
  46. package/src/core/cross/index.ts +0 -186
  47. package/src/core/errors.ts +0 -163
  48. package/src/core/function-string.ts +0 -32
  49. package/src/core/keys.ts +0 -17
  50. package/src/core/literals.ts +0 -43
  51. package/src/core/node.ts +0 -40
  52. package/src/core/opaque-reference.ts +0 -9
  53. package/src/core/plugin.ts +0 -100
  54. package/src/core/reference.ts +0 -66
  55. package/src/core/special-reference.ts +0 -42
  56. package/src/core/stream.ts +0 -71
  57. package/src/core/string.ts +0 -84
  58. package/src/core/symbols.ts +0 -18
  59. package/src/core/tree/index.ts +0 -125
  60. package/src/core/types.ts +0 -375
  61. package/src/core/utils/error.ts +0 -73
  62. package/src/core/utils/get-identifier.ts +0 -18
  63. package/src/core/utils/get-object-flag.ts +0 -14
  64. package/src/core/utils/is-valid-identifier.ts +0 -12
  65. package/src/core/utils/iterator-to-sequence.ts +0 -44
  66. package/src/core/utils/promise-to-result.ts +0 -9
  67. package/src/core/utils/typed-array.ts +0 -56
  68. package/src/index.ts +0 -36
@@ -1,515 +0,0 @@
1
- import type { WellKnownSymbols } from './constants';
2
- import { INV_SYMBOL_REF, NIL, SerovalNodeType } from './constants';
3
- import {
4
- INFINITY_NODE,
5
- NAN_NODE,
6
- NEG_INFINITY_NODE,
7
- NEG_ZERO_NODE,
8
- } from './literals';
9
- import { createSerovalNode } from './node';
10
- import { getReferenceID } from './reference';
11
- import { serializeString } from './string';
12
- import type {
13
- SerovalAggregateErrorNode,
14
- SerovalArrayNode,
15
- SerovalAsyncIteratorFactoryInstanceNode,
16
- SerovalBigIntNode,
17
- SerovalBigIntTypedArrayNode,
18
- SerovalBoxedNode,
19
- SerovalConstantNode,
20
- SerovalDataViewNode,
21
- SerovalDateNode,
22
- SerovalErrorNode,
23
- SerovalIndexedValueNode,
24
- SerovalIteratorFactoryInstanceNode,
25
- SerovalNode,
26
- SerovalNodeWithID,
27
- SerovalNumberNode,
28
- SerovalObjectRecordNode,
29
- SerovalPluginNode,
30
- SerovalReferenceNode,
31
- SerovalRegExpNode,
32
- SerovalSetNode,
33
- SerovalStreamConstructorNode,
34
- SerovalStreamNextNode,
35
- SerovalStreamReturnNode,
36
- SerovalStreamThrowNode,
37
- SerovalStringNode,
38
- SerovalTypedArrayNode,
39
- SerovalWKSymbolNode,
40
- } from './types';
41
- import { getErrorConstructor } from './utils/error';
42
- import { getObjectFlag } from './utils/get-object-flag';
43
- import type {
44
- BigIntTypedArrayValue,
45
- TypedArrayValue,
46
- } from './utils/typed-array';
47
-
48
- export function createNumberNode(
49
- value: number,
50
- ): SerovalConstantNode | SerovalNumberNode {
51
- switch (value) {
52
- case Number.POSITIVE_INFINITY:
53
- return INFINITY_NODE;
54
- case Number.NEGATIVE_INFINITY:
55
- return NEG_INFINITY_NODE;
56
- }
57
- if (value !== value) {
58
- return NAN_NODE;
59
- }
60
- if (Object.is(value, -0)) {
61
- return NEG_ZERO_NODE;
62
- }
63
- return createSerovalNode(
64
- SerovalNodeType.Number,
65
- NIL,
66
- value,
67
- NIL,
68
- NIL,
69
- NIL,
70
- NIL,
71
- NIL,
72
- NIL,
73
- NIL,
74
- NIL,
75
- NIL,
76
- );
77
- }
78
-
79
- export function createStringNode(value: string): SerovalStringNode {
80
- return createSerovalNode(
81
- SerovalNodeType.String,
82
- NIL,
83
- serializeString(value),
84
- NIL,
85
- NIL,
86
- NIL,
87
- NIL,
88
- NIL,
89
- NIL,
90
- NIL,
91
- NIL,
92
- NIL,
93
- );
94
- }
95
-
96
- export function createBigIntNode(current: bigint): SerovalBigIntNode {
97
- return createSerovalNode(
98
- SerovalNodeType.BigInt,
99
- NIL,
100
- '' + current,
101
- NIL,
102
- NIL,
103
- NIL,
104
- NIL,
105
- NIL,
106
- NIL,
107
- NIL,
108
- NIL,
109
- NIL,
110
- );
111
- }
112
-
113
- export function createIndexedValueNode(id: number): SerovalIndexedValueNode {
114
- return createSerovalNode(
115
- SerovalNodeType.IndexedValue,
116
- id,
117
- NIL,
118
- NIL,
119
- NIL,
120
- NIL,
121
- NIL,
122
- NIL,
123
- NIL,
124
- NIL,
125
- NIL,
126
- NIL,
127
- );
128
- }
129
-
130
- export function createDateNode(id: number, current: Date): SerovalDateNode {
131
- const timestamp = current.valueOf();
132
- return createSerovalNode(
133
- SerovalNodeType.Date,
134
- id,
135
- timestamp !== timestamp ? '' : current.toISOString(),
136
- NIL,
137
- NIL,
138
- NIL,
139
- NIL,
140
- NIL,
141
- NIL,
142
- NIL,
143
- NIL,
144
- NIL,
145
- );
146
- }
147
-
148
- export function createRegExpNode(
149
- id: number,
150
- current: RegExp,
151
- ): SerovalRegExpNode {
152
- return createSerovalNode(
153
- SerovalNodeType.RegExp,
154
- id,
155
- NIL,
156
- NIL,
157
- serializeString(current.source),
158
- current.flags,
159
- NIL,
160
- NIL,
161
- NIL,
162
- NIL,
163
- NIL,
164
- NIL,
165
- );
166
- }
167
-
168
- export function createWKSymbolNode(
169
- id: number,
170
- current: WellKnownSymbols,
171
- ): SerovalWKSymbolNode {
172
- return createSerovalNode(
173
- SerovalNodeType.WKSymbol,
174
- id,
175
- INV_SYMBOL_REF[current],
176
- NIL,
177
- NIL,
178
- NIL,
179
- NIL,
180
- NIL,
181
- NIL,
182
- NIL,
183
- NIL,
184
- NIL,
185
- );
186
- }
187
-
188
- export function createReferenceNode<T>(
189
- id: number,
190
- ref: T,
191
- ): SerovalReferenceNode {
192
- return createSerovalNode(
193
- SerovalNodeType.Reference,
194
- id,
195
- serializeString(getReferenceID(ref)),
196
- NIL,
197
- NIL,
198
- NIL,
199
- NIL,
200
- NIL,
201
- NIL,
202
- NIL,
203
- NIL,
204
- NIL,
205
- );
206
- }
207
-
208
- export function createPluginNode(
209
- id: number,
210
- tag: string,
211
- value: unknown,
212
- ): SerovalPluginNode {
213
- return createSerovalNode(
214
- SerovalNodeType.Plugin,
215
- id,
216
- value,
217
- NIL,
218
- serializeString(tag),
219
- NIL,
220
- NIL,
221
- NIL,
222
- NIL,
223
- NIL,
224
- NIL,
225
- NIL,
226
- );
227
- }
228
-
229
- export function createArrayNode(
230
- id: number,
231
- current: unknown[],
232
- parsedItems: SerovalNode[],
233
- ): SerovalArrayNode {
234
- return createSerovalNode(
235
- SerovalNodeType.Array,
236
- id,
237
- NIL,
238
- current.length,
239
- NIL,
240
- NIL,
241
- NIL,
242
- NIL,
243
- parsedItems,
244
- NIL,
245
- NIL,
246
- getObjectFlag(current),
247
- );
248
- }
249
-
250
- export function createBoxedNode(
251
- id: number,
252
- boxed: SerovalNode,
253
- ): SerovalBoxedNode {
254
- return createSerovalNode(
255
- SerovalNodeType.Boxed,
256
- id,
257
- NIL,
258
- NIL,
259
- NIL,
260
- NIL,
261
- NIL,
262
- NIL,
263
- NIL,
264
- boxed,
265
- NIL,
266
- NIL,
267
- );
268
- }
269
-
270
- export function createTypedArrayNode(
271
- id: number,
272
- current: TypedArrayValue,
273
- buffer: SerovalNode,
274
- ): SerovalTypedArrayNode {
275
- return createSerovalNode(
276
- SerovalNodeType.TypedArray,
277
- id,
278
- NIL,
279
- current.length,
280
- current.constructor.name,
281
- NIL,
282
- NIL,
283
- NIL,
284
- NIL,
285
- buffer,
286
- current.byteOffset,
287
- NIL,
288
- );
289
- }
290
-
291
- export function createBigIntTypedArrayNode(
292
- id: number,
293
- current: BigIntTypedArrayValue,
294
- buffer: SerovalNode,
295
- ): SerovalBigIntTypedArrayNode {
296
- return createSerovalNode(
297
- SerovalNodeType.BigIntTypedArray,
298
- id,
299
- NIL,
300
- current.length,
301
- current.constructor.name,
302
- NIL,
303
- NIL,
304
- NIL,
305
- NIL,
306
- buffer,
307
- current.byteOffset,
308
- NIL,
309
- );
310
- }
311
-
312
- export function createDataViewNode(
313
- id: number,
314
- current: DataView,
315
- buffer: SerovalNode,
316
- ): SerovalDataViewNode {
317
- return createSerovalNode(
318
- SerovalNodeType.DataView,
319
- id,
320
- NIL,
321
- current.byteLength,
322
- NIL,
323
- NIL,
324
- NIL,
325
- NIL,
326
- NIL,
327
- buffer,
328
- current.byteOffset,
329
- NIL,
330
- );
331
- }
332
-
333
- export function createErrorNode(
334
- id: number,
335
- current: Error,
336
- options: SerovalObjectRecordNode | undefined,
337
- ): SerovalErrorNode {
338
- return createSerovalNode(
339
- SerovalNodeType.Error,
340
- id,
341
- getErrorConstructor(current),
342
- NIL,
343
- NIL,
344
- serializeString(current.message),
345
- options,
346
- NIL,
347
- NIL,
348
- NIL,
349
- NIL,
350
- NIL,
351
- );
352
- }
353
-
354
- export function createAggregateErrorNode(
355
- id: number,
356
- current: AggregateError,
357
- options: SerovalObjectRecordNode | undefined,
358
- ): SerovalAggregateErrorNode {
359
- return createSerovalNode(
360
- SerovalNodeType.AggregateError,
361
- id,
362
- getErrorConstructor(current),
363
- NIL,
364
- NIL,
365
- serializeString(current.message),
366
- options,
367
- NIL,
368
- NIL,
369
- NIL,
370
- NIL,
371
- NIL,
372
- );
373
- }
374
-
375
- export function createSetNode(
376
- id: number,
377
- size: number,
378
- items: SerovalNode[],
379
- ): SerovalSetNode {
380
- return createSerovalNode(
381
- SerovalNodeType.Set,
382
- id,
383
- NIL,
384
- size,
385
- NIL,
386
- NIL,
387
- NIL,
388
- NIL,
389
- items,
390
- NIL,
391
- NIL,
392
- NIL,
393
- );
394
- }
395
-
396
- export function createIteratorFactoryInstanceNode(
397
- factory: SerovalNodeWithID,
398
- items: SerovalNode,
399
- ): SerovalIteratorFactoryInstanceNode {
400
- return createSerovalNode(
401
- SerovalNodeType.IteratorFactoryInstance,
402
- NIL,
403
- NIL,
404
- NIL,
405
- NIL,
406
- NIL,
407
- NIL,
408
- NIL,
409
- [factory, items],
410
- NIL,
411
- NIL,
412
- NIL,
413
- );
414
- }
415
-
416
- export function createAsyncIteratorFactoryInstanceNode(
417
- factory: SerovalNodeWithID,
418
- items: SerovalNode,
419
- ): SerovalAsyncIteratorFactoryInstanceNode {
420
- return createSerovalNode(
421
- SerovalNodeType.AsyncIteratorFactoryInstance,
422
- NIL,
423
- NIL,
424
- NIL,
425
- NIL,
426
- NIL,
427
- NIL,
428
- NIL,
429
- [factory, items],
430
- NIL,
431
- NIL,
432
- NIL,
433
- );
434
- }
435
-
436
- export function createStreamConstructorNode(
437
- id: number,
438
- factory: SerovalNodeWithID,
439
- sequence: SerovalNode[],
440
- ): SerovalStreamConstructorNode {
441
- return createSerovalNode(
442
- SerovalNodeType.StreamConstructor,
443
- id,
444
- NIL,
445
- NIL,
446
- NIL,
447
- NIL,
448
- NIL,
449
- NIL,
450
- sequence,
451
- factory,
452
- NIL,
453
- NIL,
454
- );
455
- }
456
-
457
- export function createStreamNextNode(
458
- id: number,
459
- parsed: SerovalNode,
460
- ): SerovalStreamNextNode {
461
- return createSerovalNode(
462
- SerovalNodeType.StreamNext,
463
- id,
464
- NIL,
465
- NIL,
466
- NIL,
467
- NIL,
468
- NIL,
469
- NIL,
470
- NIL,
471
- parsed,
472
- NIL,
473
- NIL,
474
- );
475
- }
476
-
477
- export function createStreamThrowNode(
478
- id: number,
479
- parsed: SerovalNode,
480
- ): SerovalStreamThrowNode {
481
- return createSerovalNode(
482
- SerovalNodeType.StreamThrow,
483
- id,
484
- NIL,
485
- NIL,
486
- NIL,
487
- NIL,
488
- NIL,
489
- NIL,
490
- NIL,
491
- parsed,
492
- NIL,
493
- NIL,
494
- );
495
- }
496
-
497
- export function createStreamReturnNode(
498
- id: number,
499
- parsed: SerovalNode,
500
- ): SerovalStreamReturnNode {
501
- return createSerovalNode(
502
- SerovalNodeType.StreamReturn,
503
- id,
504
- NIL,
505
- NIL,
506
- NIL,
507
- NIL,
508
- NIL,
509
- NIL,
510
- NIL,
511
- parsed,
512
- NIL,
513
- NIL,
514
- );
515
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * References
3
- * - https://compat-table.github.io/compat-table/es6/
4
- * - MDN
5
- */
6
-
7
- export enum Feature {
8
- AggregateError = 0x01,
9
- // @deprecated
10
- ArrowFunction = 0x02,
11
- ErrorPrototypeStack = 0x04,
12
- ObjectAssign = 0x08,
13
- BigIntTypedArray = 0x10,
14
- }
15
-
16
- export const ALL_ENABLED =
17
- Feature.AggregateError |
18
- Feature.ArrowFunction |
19
- Feature.ErrorPrototypeStack |
20
- Feature.ObjectAssign |
21
- Feature.BigIntTypedArray;
@@ -1,187 +0,0 @@
1
- import { SYM_ASYNC_ITERATOR, SYM_HAS_INSTANCE, SYM_IS_CONCAT_SPREADABLE, SYM_ITERATOR, SYM_MATCH, SYM_MATCH_ALL, SYM_REPLACE, SYM_SEARCH, SYM_SPECIES, SYM_SPLIT, SYM_TO_PRIMITIVE, SYM_TO_STRING_TAG, SYM_UNSCOPABLES } from "./symbols";
2
-
3
- export const enum SerovalConstant {
4
- Null = 0,
5
- Undefined = 1,
6
- True = 2,
7
- False = 3,
8
- NegZero = 4,
9
- Inf = 5,
10
- NegInf = 6,
11
- Nan = 7,
12
- }
13
-
14
- export const enum SerovalNodeType {
15
- Number = 0,
16
- String = 1,
17
- Constant = 2,
18
- BigInt = 3,
19
- IndexedValue = 4,
20
- Date = 5,
21
- RegExp = 6,
22
- Set = 7,
23
- Map = 8,
24
- Array = 9,
25
- Object = 10,
26
- NullConstructor = 11,
27
- Promise = 12,
28
- Error = 13,
29
- AggregateError = 14,
30
- TypedArray = 15,
31
- BigIntTypedArray = 16,
32
- WKSymbol = 17,
33
- Reference = 18,
34
- ArrayBuffer = 19,
35
- DataView = 20,
36
- Boxed = 21,
37
- PromiseConstructor = 22,
38
- PromiseSuccess = 23,
39
- PromiseFailure = 24,
40
- Plugin = 25,
41
- SpecialReference = 26,
42
- IteratorFactory = 27,
43
- IteratorFactoryInstance = 28,
44
- AsyncIteratorFactory = 29,
45
- AsyncIteratorFactoryInstance = 30,
46
- StreamConstructor = 31,
47
- StreamNext = 32,
48
- StreamThrow = 33,
49
- StreamReturn = 34,
50
- }
51
-
52
- export const enum SerovalObjectFlags {
53
- None = 0,
54
- NonExtensible = 1,
55
- Sealed = 2,
56
- Frozen = 3,
57
- }
58
-
59
- export const enum Symbols {
60
- AsyncIterator = 0,
61
- HasInstance = 1,
62
- IsConcatSpreadable = 2,
63
- Iterator = 3,
64
- Match = 4,
65
- MatchAll = 5,
66
- Replace = 6,
67
- Search = 7,
68
- Species = 8,
69
- Split = 9,
70
- ToPrimitive = 10,
71
- ToStringTag = 11,
72
- Unscopables = 12,
73
- }
74
-
75
- export const SYMBOL_STRING: Record<Symbols, string> = {
76
- [Symbols.AsyncIterator]: 'Symbol.asyncIterator',
77
- [Symbols.HasInstance]: 'Symbol.hasInstance',
78
- [Symbols.IsConcatSpreadable]: 'Symbol.isConcatSpreadable',
79
- [Symbols.Iterator]: 'Symbol.iterator',
80
- [Symbols.Match]: 'Symbol.match',
81
- [Symbols.MatchAll]: 'Symbol.matchAll',
82
- [Symbols.Replace]: 'Symbol.replace',
83
- [Symbols.Search]: 'Symbol.search',
84
- [Symbols.Species]: 'Symbol.species',
85
- [Symbols.Split]: 'Symbol.split',
86
- [Symbols.ToPrimitive]: 'Symbol.toPrimitive',
87
- [Symbols.ToStringTag]: 'Symbol.toStringTag',
88
- [Symbols.Unscopables]: 'Symbol.unscopables',
89
- };
90
-
91
- export const INV_SYMBOL_REF = /* @__PURE__ */ {
92
- [SYM_ASYNC_ITERATOR]: Symbols.AsyncIterator,
93
- [SYM_HAS_INSTANCE]: Symbols.HasInstance,
94
- [SYM_IS_CONCAT_SPREADABLE]: Symbols.IsConcatSpreadable,
95
- [SYM_ITERATOR]: Symbols.Iterator,
96
- [SYM_MATCH]: Symbols.Match,
97
- [SYM_MATCH_ALL]: Symbols.MatchAll,
98
- [SYM_REPLACE]: Symbols.Replace,
99
- [SYM_SEARCH]: Symbols.Search,
100
- [SYM_SPECIES]: Symbols.Species,
101
- [SYM_SPLIT]: Symbols.Split,
102
- [SYM_TO_PRIMITIVE]: Symbols.ToPrimitive,
103
- [SYM_TO_STRING_TAG]: Symbols.ToStringTag,
104
- [SYM_UNSCOPABLES]: Symbols.Unscopables,
105
- };
106
-
107
- export type WellKnownSymbols = keyof typeof INV_SYMBOL_REF;
108
-
109
- export const SYMBOL_REF: Record<Symbols, WellKnownSymbols> = {
110
- [Symbols.AsyncIterator]: SYM_ASYNC_ITERATOR,
111
- [Symbols.HasInstance]: SYM_HAS_INSTANCE,
112
- [Symbols.IsConcatSpreadable]: SYM_IS_CONCAT_SPREADABLE,
113
- [Symbols.Iterator]: SYM_ITERATOR,
114
- [Symbols.Match]: SYM_MATCH,
115
- [Symbols.MatchAll]: SYM_MATCH_ALL,
116
- [Symbols.Replace]: SYM_REPLACE,
117
- [Symbols.Search]: SYM_SEARCH,
118
- [Symbols.Species]: SYM_SPECIES,
119
- [Symbols.Split]: SYM_SPLIT,
120
- [Symbols.ToPrimitive]: SYM_TO_PRIMITIVE,
121
- [Symbols.ToStringTag]: SYM_TO_STRING_TAG,
122
- [Symbols.Unscopables]: SYM_UNSCOPABLES,
123
- };
124
-
125
- export const CONSTANT_STRING: Record<SerovalConstant, string> = {
126
- [SerovalConstant.True]: '!0',
127
- [SerovalConstant.False]: '!1',
128
- [SerovalConstant.Undefined]: 'void 0',
129
- [SerovalConstant.Null]: 'null',
130
- [SerovalConstant.NegZero]: '-0',
131
- [SerovalConstant.Inf]: '1/0',
132
- [SerovalConstant.NegInf]: '-1/0',
133
- [SerovalConstant.Nan]: '0/0',
134
- };
135
-
136
- export const CONSTANT_VAL: Record<SerovalConstant, unknown> = {
137
- [SerovalConstant.True]: true,
138
- [SerovalConstant.False]: false,
139
- [SerovalConstant.Undefined]: undefined,
140
- [SerovalConstant.Null]: null,
141
- [SerovalConstant.NegZero]: -0,
142
- [SerovalConstant.Inf]: Number.POSITIVE_INFINITY,
143
- [SerovalConstant.NegInf]: Number.NEGATIVE_INFINITY,
144
- [SerovalConstant.Nan]: Number.NaN,
145
- };
146
-
147
- export const enum ErrorConstructorTag {
148
- Error = 0,
149
- EvalError = 1,
150
- RangeError = 2,
151
- ReferenceError = 3,
152
- SyntaxError = 4,
153
- TypeError = 5,
154
- URIError = 6,
155
- }
156
-
157
- export const ERROR_CONSTRUCTOR_STRING: Record<ErrorConstructorTag, string> = {
158
- [ErrorConstructorTag.Error]: 'Error',
159
- [ErrorConstructorTag.EvalError]: 'EvalError',
160
- [ErrorConstructorTag.RangeError]: 'RangeError',
161
- [ErrorConstructorTag.ReferenceError]: 'ReferenceError',
162
- [ErrorConstructorTag.SyntaxError]: 'SyntaxError',
163
- [ErrorConstructorTag.TypeError]: 'TypeError',
164
- [ErrorConstructorTag.URIError]: 'URIError',
165
- };
166
-
167
- type ErrorConstructors =
168
- | ErrorConstructor
169
- | EvalErrorConstructor
170
- | RangeErrorConstructor
171
- | ReferenceErrorConstructor
172
- | SyntaxErrorConstructor
173
- | TypeErrorConstructor
174
- | URIErrorConstructor;
175
-
176
- export const ERROR_CONSTRUCTOR: Record<ErrorConstructorTag, ErrorConstructors> =
177
- {
178
- [ErrorConstructorTag.Error]: Error,
179
- [ErrorConstructorTag.EvalError]: EvalError,
180
- [ErrorConstructorTag.RangeError]: RangeError,
181
- [ErrorConstructorTag.ReferenceError]: ReferenceError,
182
- [ErrorConstructorTag.SyntaxError]: SyntaxError,
183
- [ErrorConstructorTag.TypeError]: TypeError,
184
- [ErrorConstructorTag.URIError]: URIError,
185
- };
186
-
187
- export const NIL = undefined;