seroval 1.5.6 → 1.6.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 (117) hide show
  1. package/dist/dev/index.cjs +2954 -0
  2. package/dist/dev/index.d.cts +761 -0
  3. package/dist/dev/index.d.ts +761 -0
  4. package/dist/dev/index.js +2917 -0
  5. package/dist/index.cjs +2947 -0
  6. package/dist/index.d.cts +761 -0
  7. package/dist/index.d.ts +761 -0
  8. package/dist/index.js +2910 -0
  9. package/package.json +23 -21
  10. package/dist/cjs/development/index.cjs +0 -4232
  11. package/dist/cjs/development/index.cjs.map +0 -7
  12. package/dist/cjs/production/index.cjs +0 -3
  13. package/dist/esm/development/index.mjs +0 -4209
  14. package/dist/esm/development/index.mjs.map +0 -7
  15. package/dist/esm/production/index.mjs +0 -3
  16. package/dist/types/core/Serializer.d.ts +0 -28
  17. package/dist/types/core/Serializer.d.ts.map +0 -1
  18. package/dist/types/core/base-primitives.d.ts +0 -28
  19. package/dist/types/core/base-primitives.d.ts.map +0 -1
  20. package/dist/types/core/compat.d.ts +0 -15
  21. package/dist/types/core/compat.d.ts.map +0 -1
  22. package/dist/types/core/constants.d.ts +0 -105
  23. package/dist/types/core/constants.d.ts.map +0 -1
  24. package/dist/types/core/constructors.d.ts +0 -50
  25. package/dist/types/core/constructors.d.ts.map +0 -1
  26. package/dist/types/core/context/async-parser.d.ts +0 -20
  27. package/dist/types/core/context/async-parser.d.ts.map +0 -1
  28. package/dist/types/core/context/deserializer.d.ts +0 -52
  29. package/dist/types/core/context/deserializer.d.ts.map +0 -1
  30. package/dist/types/core/context/parser.d.ts +0 -62
  31. package/dist/types/core/context/parser.d.ts.map +0 -1
  32. package/dist/types/core/context/serializer.d.ts +0 -103
  33. package/dist/types/core/context/serializer.d.ts.map +0 -1
  34. package/dist/types/core/context/sync-parser.d.ts +0 -61
  35. package/dist/types/core/context/sync-parser.d.ts.map +0 -1
  36. package/dist/types/core/cross/index.d.ts +0 -24
  37. package/dist/types/core/cross/index.d.ts.map +0 -1
  38. package/dist/types/core/errors.d.ts +0 -47
  39. package/dist/types/core/errors.d.ts.map +0 -1
  40. package/dist/types/core/function-string.d.ts +0 -3
  41. package/dist/types/core/function-string.d.ts.map +0 -1
  42. package/dist/types/core/keys.d.ts +0 -4
  43. package/dist/types/core/keys.d.ts.map +0 -1
  44. package/dist/types/core/literals.d.ts +0 -10
  45. package/dist/types/core/literals.d.ts.map +0 -1
  46. package/dist/types/core/node.d.ts +0 -8
  47. package/dist/types/core/node.d.ts.map +0 -1
  48. package/dist/types/core/opaque-reference.d.ts +0 -9
  49. package/dist/types/core/opaque-reference.d.ts.map +0 -1
  50. package/dist/types/core/plugin.d.ts +0 -52
  51. package/dist/types/core/plugin.d.ts.map +0 -1
  52. package/dist/types/core/reference.d.ts +0 -6
  53. package/dist/types/core/reference.d.ts.map +0 -1
  54. package/dist/types/core/sequence.d.ts +0 -11
  55. package/dist/types/core/sequence.d.ts.map +0 -1
  56. package/dist/types/core/special-reference.d.ts +0 -16
  57. package/dist/types/core/special-reference.d.ts.map +0 -1
  58. package/dist/types/core/stream.d.ts +0 -17
  59. package/dist/types/core/stream.d.ts.map +0 -1
  60. package/dist/types/core/string.d.ts +0 -4
  61. package/dist/types/core/string.d.ts.map +0 -1
  62. package/dist/types/core/symbols.d.ts +0 -14
  63. package/dist/types/core/symbols.d.ts.map +0 -1
  64. package/dist/types/core/tree/index.d.ts +0 -21
  65. package/dist/types/core/tree/index.d.ts.map +0 -1
  66. package/dist/types/core/types.d.ts +0 -233
  67. package/dist/types/core/types.d.ts.map +0 -1
  68. package/dist/types/core/utils/error.d.ts +0 -6
  69. package/dist/types/core/utils/error.d.ts.map +0 -1
  70. package/dist/types/core/utils/get-identifier.d.ts +0 -2
  71. package/dist/types/core/utils/get-identifier.d.ts.map +0 -1
  72. package/dist/types/core/utils/get-object-flag.d.ts +0 -3
  73. package/dist/types/core/utils/get-object-flag.d.ts.map +0 -1
  74. package/dist/types/core/utils/is-valid-identifier.d.ts +0 -2
  75. package/dist/types/core/utils/is-valid-identifier.d.ts.map +0 -1
  76. package/dist/types/core/utils/promise-to-result.d.ts +0 -2
  77. package/dist/types/core/utils/promise-to-result.d.ts.map +0 -1
  78. package/dist/types/core/utils/typed-array.d.ts +0 -6
  79. package/dist/types/core/utils/typed-array.d.ts.map +0 -1
  80. package/dist/types/core/utils/valid-properties.d.ts +0 -3
  81. package/dist/types/core/utils/valid-properties.d.ts.map +0 -1
  82. package/dist/types/index.d.ts +0 -18
  83. package/dist/types/index.d.ts.map +0 -1
  84. package/src/core/Serializer.ts +0 -119
  85. package/src/core/base-primitives.ts +0 -537
  86. package/src/core/compat.ts +0 -23
  87. package/src/core/constants.ts +0 -202
  88. package/src/core/constructors.ts +0 -265
  89. package/src/core/context/async-parser.ts +0 -666
  90. package/src/core/context/deserializer.ts +0 -832
  91. package/src/core/context/parser.ts +0 -335
  92. package/src/core/context/serializer.ts +0 -1524
  93. package/src/core/context/sync-parser.ts +0 -943
  94. package/src/core/cross/index.ts +0 -190
  95. package/src/core/errors.ts +0 -196
  96. package/src/core/function-string.ts +0 -31
  97. package/src/core/keys.ts +0 -17
  98. package/src/core/literals.ts +0 -43
  99. package/src/core/node.ts +0 -40
  100. package/src/core/opaque-reference.ts +0 -9
  101. package/src/core/plugin.ts +0 -105
  102. package/src/core/reference.ts +0 -66
  103. package/src/core/sequence.ts +0 -59
  104. package/src/core/special-reference.ts +0 -42
  105. package/src/core/stream.ts +0 -71
  106. package/src/core/string.ts +0 -86
  107. package/src/core/symbols.ts +0 -20
  108. package/src/core/tree/index.ts +0 -134
  109. package/src/core/types.ts +0 -377
  110. package/src/core/utils/error.ts +0 -73
  111. package/src/core/utils/get-identifier.ts +0 -18
  112. package/src/core/utils/get-object-flag.ts +0 -14
  113. package/src/core/utils/is-valid-identifier.ts +0 -12
  114. package/src/core/utils/promise-to-result.ts +0 -9
  115. package/src/core/utils/typed-array.ts +0 -56
  116. package/src/core/utils/valid-properties.ts +0 -34
  117. package/src/index.ts +0 -36
@@ -1,537 +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
- SerovalSequenceNode,
33
- SerovalSetNode,
34
- SerovalStreamConstructorNode,
35
- SerovalStreamNextNode,
36
- SerovalStreamReturnNode,
37
- SerovalStreamThrowNode,
38
- SerovalStringNode,
39
- SerovalTypedArrayNode,
40
- SerovalWKSymbolNode,
41
- } from './types';
42
- import { getErrorConstructor } from './utils/error';
43
- import { getObjectFlag } from './utils/get-object-flag';
44
- import type {
45
- BigIntTypedArrayValue,
46
- TypedArrayValue,
47
- } from './utils/typed-array';
48
-
49
- export function createNumberNode(
50
- value: number,
51
- ): SerovalConstantNode | SerovalNumberNode {
52
- switch (value) {
53
- case Number.POSITIVE_INFINITY:
54
- return INFINITY_NODE;
55
- case Number.NEGATIVE_INFINITY:
56
- return NEG_INFINITY_NODE;
57
- }
58
- if (value !== value) {
59
- return NAN_NODE;
60
- }
61
- if (Object.is(value, -0)) {
62
- return NEG_ZERO_NODE;
63
- }
64
- return createSerovalNode(
65
- SerovalNodeType.Number,
66
- NIL,
67
- value,
68
- NIL,
69
- NIL,
70
- NIL,
71
- NIL,
72
- NIL,
73
- NIL,
74
- NIL,
75
- NIL,
76
- NIL,
77
- );
78
- }
79
-
80
- export function createStringNode(value: string): SerovalStringNode {
81
- return createSerovalNode(
82
- SerovalNodeType.String,
83
- NIL,
84
- serializeString(value),
85
- NIL,
86
- NIL,
87
- NIL,
88
- NIL,
89
- NIL,
90
- NIL,
91
- NIL,
92
- NIL,
93
- NIL,
94
- );
95
- }
96
-
97
- export function createBigIntNode(current: bigint): SerovalBigIntNode {
98
- return createSerovalNode(
99
- SerovalNodeType.BigInt,
100
- NIL,
101
- '' + current,
102
- NIL,
103
- NIL,
104
- NIL,
105
- NIL,
106
- NIL,
107
- NIL,
108
- NIL,
109
- NIL,
110
- NIL,
111
- );
112
- }
113
-
114
- export function createIndexedValueNode(id: number): SerovalIndexedValueNode {
115
- return createSerovalNode(
116
- SerovalNodeType.IndexedValue,
117
- id,
118
- NIL,
119
- NIL,
120
- NIL,
121
- NIL,
122
- NIL,
123
- NIL,
124
- NIL,
125
- NIL,
126
- NIL,
127
- NIL,
128
- );
129
- }
130
-
131
- export function createDateNode(id: number, current: Date): SerovalDateNode {
132
- const timestamp = current.valueOf();
133
- return createSerovalNode(
134
- SerovalNodeType.Date,
135
- id,
136
- timestamp !== timestamp ? '' : current.toISOString(),
137
- NIL,
138
- NIL,
139
- NIL,
140
- NIL,
141
- NIL,
142
- NIL,
143
- NIL,
144
- NIL,
145
- NIL,
146
- );
147
- }
148
-
149
- export function createRegExpNode(
150
- id: number,
151
- current: RegExp,
152
- ): SerovalRegExpNode {
153
- return createSerovalNode(
154
- SerovalNodeType.RegExp,
155
- id,
156
- NIL,
157
- serializeString(current.source),
158
- current.flags,
159
- NIL,
160
- NIL,
161
- NIL,
162
- NIL,
163
- NIL,
164
- NIL,
165
- NIL,
166
- );
167
- }
168
-
169
- export function createWKSymbolNode(
170
- id: number,
171
- current: WellKnownSymbols,
172
- ): SerovalWKSymbolNode {
173
- return createSerovalNode(
174
- SerovalNodeType.WKSymbol,
175
- id,
176
- INV_SYMBOL_REF[current],
177
- NIL,
178
- NIL,
179
- NIL,
180
- NIL,
181
- NIL,
182
- NIL,
183
- NIL,
184
- NIL,
185
- NIL,
186
- );
187
- }
188
-
189
- export function createReferenceNode<T>(
190
- id: number,
191
- ref: T,
192
- ): SerovalReferenceNode {
193
- return createSerovalNode(
194
- SerovalNodeType.Reference,
195
- id,
196
- serializeString(getReferenceID(ref)),
197
- NIL,
198
- NIL,
199
- NIL,
200
- NIL,
201
- NIL,
202
- NIL,
203
- NIL,
204
- NIL,
205
- NIL,
206
- );
207
- }
208
-
209
- export function createPluginNode(
210
- id: number,
211
- tag: string,
212
- value: Record<string, SerovalNode>,
213
- ): SerovalPluginNode {
214
- return createSerovalNode(
215
- SerovalNodeType.Plugin,
216
- id,
217
- value,
218
- serializeString(tag),
219
- NIL,
220
- NIL,
221
- NIL,
222
- NIL,
223
- NIL,
224
- NIL,
225
- NIL,
226
- NIL,
227
- );
228
- }
229
-
230
- export function createArrayNode(
231
- id: number,
232
- current: unknown[],
233
- parsedItems: SerovalArrayNode['a'],
234
- ): SerovalArrayNode {
235
- return createSerovalNode(
236
- SerovalNodeType.Array,
237
- id,
238
- NIL,
239
- NIL,
240
- NIL,
241
- NIL,
242
- NIL,
243
- parsedItems,
244
- NIL,
245
- NIL,
246
- getObjectFlag(current),
247
- NIL,
248
- );
249
- }
250
-
251
- export function createBoxedNode(
252
- id: number,
253
- boxed: SerovalNode,
254
- ): SerovalBoxedNode {
255
- return createSerovalNode(
256
- SerovalNodeType.Boxed,
257
- id,
258
- NIL,
259
- NIL,
260
- NIL,
261
- NIL,
262
- NIL,
263
- NIL,
264
- boxed,
265
- NIL,
266
- NIL,
267
- NIL,
268
- );
269
- }
270
-
271
- export function createTypedArrayNode(
272
- id: number,
273
- current: TypedArrayValue,
274
- buffer: SerovalNode,
275
- ): SerovalTypedArrayNode {
276
- return createSerovalNode(
277
- SerovalNodeType.TypedArray,
278
- id,
279
- NIL,
280
- current.constructor.name,
281
- NIL,
282
- NIL,
283
- NIL,
284
- NIL,
285
- buffer,
286
- current.byteOffset,
287
- NIL,
288
- current.length,
289
- );
290
- }
291
-
292
- export function createBigIntTypedArrayNode(
293
- id: number,
294
- current: BigIntTypedArrayValue,
295
- buffer: SerovalNode,
296
- ): SerovalBigIntTypedArrayNode {
297
- return createSerovalNode(
298
- SerovalNodeType.BigIntTypedArray,
299
- id,
300
- NIL,
301
- current.constructor.name,
302
- NIL,
303
- NIL,
304
- NIL,
305
- NIL,
306
- buffer,
307
- current.byteOffset,
308
- NIL,
309
- current.length,
310
- );
311
- }
312
-
313
- export function createDataViewNode(
314
- id: number,
315
- current: DataView,
316
- buffer: SerovalNode,
317
- ): SerovalDataViewNode {
318
- return createSerovalNode(
319
- SerovalNodeType.DataView,
320
- id,
321
- NIL,
322
- NIL,
323
- NIL,
324
- NIL,
325
- NIL,
326
- NIL,
327
- buffer,
328
- current.byteOffset,
329
- NIL,
330
- current.byteLength,
331
- );
332
- }
333
-
334
- export function createErrorNode(
335
- id: number,
336
- current: Error,
337
- options: SerovalObjectRecordNode | undefined,
338
- ): SerovalErrorNode {
339
- return createSerovalNode(
340
- SerovalNodeType.Error,
341
- id,
342
- getErrorConstructor(current),
343
- NIL,
344
- serializeString(current.message),
345
- options,
346
- NIL,
347
- NIL,
348
- NIL,
349
- NIL,
350
- NIL,
351
- NIL,
352
- );
353
- }
354
-
355
- export function createAggregateErrorNode(
356
- id: number,
357
- current: AggregateError,
358
- options: SerovalObjectRecordNode | undefined,
359
- ): SerovalAggregateErrorNode {
360
- return createSerovalNode(
361
- SerovalNodeType.AggregateError,
362
- id,
363
- getErrorConstructor(current),
364
- NIL,
365
- serializeString(current.message),
366
- options,
367
- NIL,
368
- NIL,
369
- NIL,
370
- NIL,
371
- NIL,
372
- NIL,
373
- );
374
- }
375
-
376
- export function createSetNode(
377
- id: number,
378
- items: SerovalNode[],
379
- ): SerovalSetNode {
380
- return createSerovalNode(
381
- SerovalNodeType.Set,
382
- id,
383
- NIL,
384
- NIL,
385
- NIL,
386
- NIL,
387
- NIL,
388
- items,
389
- NIL,
390
- NIL,
391
- NIL,
392
- NIL,
393
- );
394
- }
395
-
396
- export function createIteratorFactoryInstanceNode(
397
- factory: SerovalNodeWithID,
398
- items: SerovalNodeWithID,
399
- ): SerovalIteratorFactoryInstanceNode {
400
- return createSerovalNode(
401
- SerovalNodeType.IteratorFactoryInstance,
402
- NIL,
403
- NIL,
404
- NIL,
405
- NIL,
406
- NIL,
407
- NIL,
408
- [factory, items],
409
- NIL,
410
- NIL,
411
- NIL,
412
- NIL,
413
- );
414
- }
415
-
416
- export function createAsyncIteratorFactoryInstanceNode(
417
- factory: SerovalNodeWithID,
418
- items: SerovalNodeWithID,
419
- ): SerovalAsyncIteratorFactoryInstanceNode {
420
- return createSerovalNode(
421
- SerovalNodeType.AsyncIteratorFactoryInstance,
422
- NIL,
423
- NIL,
424
- NIL,
425
- NIL,
426
- NIL,
427
- NIL,
428
- [factory, items],
429
- NIL,
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
- sequence,
450
- factory,
451
- NIL,
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
- parsed,
471
- NIL,
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
- parsed,
491
- NIL,
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
- parsed,
511
- NIL,
512
- NIL,
513
- NIL,
514
- );
515
- }
516
-
517
- export function createSequenceNode(
518
- id: number,
519
- sequence: SerovalNode[],
520
- throwAt: number,
521
- doneAt: number,
522
- ): SerovalSequenceNode {
523
- return createSerovalNode(
524
- SerovalNodeType.Sequence,
525
- id,
526
- throwAt,
527
- NIL,
528
- NIL,
529
- NIL,
530
- NIL,
531
- sequence,
532
- NIL,
533
- NIL,
534
- NIL,
535
- doneAt,
536
- );
537
- }
@@ -1,23 +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
- RegExp = 0x20,
15
- }
16
-
17
- export const ALL_ENABLED =
18
- Feature.AggregateError |
19
- Feature.ArrowFunction |
20
- Feature.ErrorPrototypeStack |
21
- Feature.ObjectAssign |
22
- Feature.BigIntTypedArray |
23
- Feature.RegExp;