seroval 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/development/index.cjs +184 -44
- package/dist/cjs/development/index.cjs.map +4 -4
- package/dist/cjs/production/index.cjs +3 -3
- package/dist/esm/development/index.mjs +184 -44
- package/dist/esm/development/index.mjs.map +4 -4
- package/dist/esm/production/index.mjs +3 -3
- package/dist/types/core/base-primitives.d.ts +5 -4
- package/dist/types/core/base-primitives.d.ts.map +1 -1
- package/dist/types/core/constants.d.ts +2 -1
- package/dist/types/core/constants.d.ts.map +1 -1
- package/dist/types/core/constructors.d.ts +1 -5
- package/dist/types/core/constructors.d.ts.map +1 -1
- package/dist/types/core/context/async-parser.d.ts.map +1 -1
- package/dist/types/core/context/deserializer.d.ts.map +1 -1
- package/dist/types/core/context/parser.d.ts.map +1 -1
- package/dist/types/core/context/serializer.d.ts.map +1 -1
- package/dist/types/core/context/sync-parser.d.ts.map +1 -1
- package/dist/types/core/errors.d.ts +5 -5
- package/dist/types/core/errors.d.ts.map +1 -1
- package/dist/types/core/literals.d.ts.map +1 -1
- package/dist/types/core/node.d.ts +1 -1
- package/dist/types/core/node.d.ts.map +1 -1
- package/dist/types/core/plugin.d.ts +11 -7
- package/dist/types/core/plugin.d.ts.map +1 -1
- package/dist/types/core/sequence.d.ts +11 -0
- package/dist/types/core/sequence.d.ts.map +1 -0
- package/dist/types/core/types.d.ts +15 -4
- package/dist/types/core/types.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/core/Serializer.ts +119 -0
- package/src/core/base-primitives.ts +537 -0
- package/src/core/compat.ts +23 -0
- package/src/core/constants.ts +202 -0
- package/src/core/constructors.ts +265 -0
- package/src/core/context/async-parser.ts +663 -0
- package/src/core/context/deserializer.ts +828 -0
- package/src/core/context/parser.ts +335 -0
- package/src/core/context/serializer.ts +1460 -0
- package/src/core/context/sync-parser.ts +932 -0
- package/src/core/cross/index.ts +188 -0
- package/src/core/errors.ts +196 -0
- package/src/core/function-string.ts +32 -0
- package/src/core/keys.ts +17 -0
- package/src/core/literals.ts +43 -0
- package/src/core/node.ts +40 -0
- package/src/core/opaque-reference.ts +9 -0
- package/src/core/plugin.ts +105 -0
- package/src/core/reference.ts +66 -0
- package/src/core/sequence.ts +55 -0
- package/src/core/special-reference.ts +42 -0
- package/src/core/stream.ts +71 -0
- package/src/core/string.ts +86 -0
- package/src/core/symbols.ts +18 -0
- package/src/core/tree/index.ts +134 -0
- package/src/core/types.ts +377 -0
- package/src/core/utils/error.ts +73 -0
- package/src/core/utils/get-identifier.ts +18 -0
- package/src/core/utils/get-object-flag.ts +14 -0
- package/src/core/utils/is-valid-identifier.ts +12 -0
- package/src/core/utils/promise-to-result.ts +9 -0
- package/src/core/utils/typed-array.ts +56 -0
- package/src/index.ts +36 -0
- package/dist/types/core/utils/iterator-to-sequence.d.ts +0 -8
- package/dist/types/core/utils/iterator-to-sequence.d.ts.map +0 -1
|
@@ -112,7 +112,7 @@ var ERROR_CONSTRUCTOR = {
|
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
// src/core/node.ts
|
|
115
|
-
function createSerovalNode(t, i, s, c, m, p, e, a, f, b, o) {
|
|
115
|
+
function createSerovalNode(t, i, s, c, m, p, e, a, f, b, o, l) {
|
|
116
116
|
return {
|
|
117
117
|
t,
|
|
118
118
|
i,
|
|
@@ -124,7 +124,8 @@ function createSerovalNode(t, i, s, c, m, p, e, a, f, b, o) {
|
|
|
124
124
|
a,
|
|
125
125
|
f,
|
|
126
126
|
b,
|
|
127
|
-
o
|
|
127
|
+
o,
|
|
128
|
+
l
|
|
128
129
|
};
|
|
129
130
|
}
|
|
130
131
|
|
|
@@ -141,6 +142,7 @@ function createConstantNode(value) {
|
|
|
141
142
|
NIL,
|
|
142
143
|
NIL,
|
|
143
144
|
NIL,
|
|
145
|
+
NIL,
|
|
144
146
|
NIL
|
|
145
147
|
);
|
|
146
148
|
}
|
|
@@ -405,6 +407,7 @@ function createNumberNode(value) {
|
|
|
405
407
|
NIL,
|
|
406
408
|
NIL,
|
|
407
409
|
NIL,
|
|
410
|
+
NIL,
|
|
408
411
|
NIL
|
|
409
412
|
);
|
|
410
413
|
}
|
|
@@ -420,6 +423,7 @@ function createStringNode(value) {
|
|
|
420
423
|
NIL,
|
|
421
424
|
NIL,
|
|
422
425
|
NIL,
|
|
426
|
+
NIL,
|
|
423
427
|
NIL
|
|
424
428
|
);
|
|
425
429
|
}
|
|
@@ -435,6 +439,7 @@ function createBigIntNode(current) {
|
|
|
435
439
|
NIL,
|
|
436
440
|
NIL,
|
|
437
441
|
NIL,
|
|
442
|
+
NIL,
|
|
438
443
|
NIL
|
|
439
444
|
);
|
|
440
445
|
}
|
|
@@ -450,6 +455,7 @@ function createIndexedValueNode(id) {
|
|
|
450
455
|
NIL,
|
|
451
456
|
NIL,
|
|
452
457
|
NIL,
|
|
458
|
+
NIL,
|
|
453
459
|
NIL
|
|
454
460
|
);
|
|
455
461
|
}
|
|
@@ -466,6 +472,7 @@ function createDateNode(id, current) {
|
|
|
466
472
|
NIL,
|
|
467
473
|
NIL,
|
|
468
474
|
NIL,
|
|
475
|
+
NIL,
|
|
469
476
|
NIL
|
|
470
477
|
);
|
|
471
478
|
}
|
|
@@ -481,6 +488,7 @@ function createRegExpNode(id, current) {
|
|
|
481
488
|
NIL,
|
|
482
489
|
NIL,
|
|
483
490
|
NIL,
|
|
491
|
+
NIL,
|
|
484
492
|
NIL
|
|
485
493
|
);
|
|
486
494
|
}
|
|
@@ -496,6 +504,7 @@ function createWKSymbolNode(id, current) {
|
|
|
496
504
|
NIL,
|
|
497
505
|
NIL,
|
|
498
506
|
NIL,
|
|
507
|
+
NIL,
|
|
499
508
|
NIL
|
|
500
509
|
);
|
|
501
510
|
}
|
|
@@ -511,6 +520,7 @@ function createReferenceNode(id, ref) {
|
|
|
511
520
|
NIL,
|
|
512
521
|
NIL,
|
|
513
522
|
NIL,
|
|
523
|
+
NIL,
|
|
514
524
|
NIL
|
|
515
525
|
);
|
|
516
526
|
}
|
|
@@ -526,6 +536,7 @@ function createPluginNode(id, tag, value) {
|
|
|
526
536
|
NIL,
|
|
527
537
|
NIL,
|
|
528
538
|
NIL,
|
|
539
|
+
NIL,
|
|
529
540
|
NIL
|
|
530
541
|
);
|
|
531
542
|
}
|
|
@@ -541,7 +552,8 @@ function createArrayNode(id, current, parsedItems) {
|
|
|
541
552
|
parsedItems,
|
|
542
553
|
NIL,
|
|
543
554
|
NIL,
|
|
544
|
-
getObjectFlag(current)
|
|
555
|
+
getObjectFlag(current),
|
|
556
|
+
NIL
|
|
545
557
|
);
|
|
546
558
|
}
|
|
547
559
|
function createBoxedNode(id, boxed) {
|
|
@@ -556,6 +568,7 @@ function createBoxedNode(id, boxed) {
|
|
|
556
568
|
NIL,
|
|
557
569
|
boxed,
|
|
558
570
|
NIL,
|
|
571
|
+
NIL,
|
|
559
572
|
NIL
|
|
560
573
|
);
|
|
561
574
|
}
|
|
@@ -571,7 +584,8 @@ function createTypedArrayNode(id, current, buffer) {
|
|
|
571
584
|
NIL,
|
|
572
585
|
buffer,
|
|
573
586
|
current.byteOffset,
|
|
574
|
-
NIL
|
|
587
|
+
NIL,
|
|
588
|
+
current.length
|
|
575
589
|
);
|
|
576
590
|
}
|
|
577
591
|
function createBigIntTypedArrayNode(id, current, buffer) {
|
|
@@ -586,7 +600,8 @@ function createBigIntTypedArrayNode(id, current, buffer) {
|
|
|
586
600
|
NIL,
|
|
587
601
|
buffer,
|
|
588
602
|
current.byteOffset,
|
|
589
|
-
NIL
|
|
603
|
+
NIL,
|
|
604
|
+
current.byteLength
|
|
590
605
|
);
|
|
591
606
|
}
|
|
592
607
|
function createDataViewNode(id, current, buffer) {
|
|
@@ -601,7 +616,8 @@ function createDataViewNode(id, current, buffer) {
|
|
|
601
616
|
NIL,
|
|
602
617
|
buffer,
|
|
603
618
|
current.byteOffset,
|
|
604
|
-
NIL
|
|
619
|
+
NIL,
|
|
620
|
+
current.byteLength
|
|
605
621
|
);
|
|
606
622
|
}
|
|
607
623
|
function createErrorNode(id, current, options) {
|
|
@@ -616,6 +632,7 @@ function createErrorNode(id, current, options) {
|
|
|
616
632
|
NIL,
|
|
617
633
|
NIL,
|
|
618
634
|
NIL,
|
|
635
|
+
NIL,
|
|
619
636
|
NIL
|
|
620
637
|
);
|
|
621
638
|
}
|
|
@@ -631,6 +648,7 @@ function createAggregateErrorNode(id, current, options) {
|
|
|
631
648
|
NIL,
|
|
632
649
|
NIL,
|
|
633
650
|
NIL,
|
|
651
|
+
NIL,
|
|
634
652
|
NIL
|
|
635
653
|
);
|
|
636
654
|
}
|
|
@@ -646,6 +664,7 @@ function createSetNode(id, items) {
|
|
|
646
664
|
items,
|
|
647
665
|
NIL,
|
|
648
666
|
NIL,
|
|
667
|
+
NIL,
|
|
649
668
|
NIL
|
|
650
669
|
);
|
|
651
670
|
}
|
|
@@ -661,6 +680,7 @@ function createIteratorFactoryInstanceNode(factory, items) {
|
|
|
661
680
|
[factory, items],
|
|
662
681
|
NIL,
|
|
663
682
|
NIL,
|
|
683
|
+
NIL,
|
|
664
684
|
NIL
|
|
665
685
|
);
|
|
666
686
|
}
|
|
@@ -676,6 +696,7 @@ function createAsyncIteratorFactoryInstanceNode(factory, items) {
|
|
|
676
696
|
[factory, items],
|
|
677
697
|
NIL,
|
|
678
698
|
NIL,
|
|
699
|
+
NIL,
|
|
679
700
|
NIL
|
|
680
701
|
);
|
|
681
702
|
}
|
|
@@ -691,6 +712,7 @@ function createStreamConstructorNode(id, factory, sequence) {
|
|
|
691
712
|
sequence,
|
|
692
713
|
factory,
|
|
693
714
|
NIL,
|
|
715
|
+
NIL,
|
|
694
716
|
NIL
|
|
695
717
|
);
|
|
696
718
|
}
|
|
@@ -706,6 +728,7 @@ function createStreamNextNode(id, parsed) {
|
|
|
706
728
|
NIL,
|
|
707
729
|
parsed,
|
|
708
730
|
NIL,
|
|
731
|
+
NIL,
|
|
709
732
|
NIL
|
|
710
733
|
);
|
|
711
734
|
}
|
|
@@ -721,6 +744,7 @@ function createStreamThrowNode(id, parsed) {
|
|
|
721
744
|
NIL,
|
|
722
745
|
parsed,
|
|
723
746
|
NIL,
|
|
747
|
+
NIL,
|
|
724
748
|
NIL
|
|
725
749
|
);
|
|
726
750
|
}
|
|
@@ -736,16 +760,33 @@ function createStreamReturnNode(id, parsed) {
|
|
|
736
760
|
NIL,
|
|
737
761
|
parsed,
|
|
738
762
|
NIL,
|
|
763
|
+
NIL,
|
|
739
764
|
NIL
|
|
740
765
|
);
|
|
741
766
|
}
|
|
767
|
+
function createSequenceNode(id, sequence, throwAt, doneAt) {
|
|
768
|
+
return createSerovalNode(
|
|
769
|
+
35 /* Sequence */,
|
|
770
|
+
id,
|
|
771
|
+
throwAt,
|
|
772
|
+
NIL,
|
|
773
|
+
NIL,
|
|
774
|
+
NIL,
|
|
775
|
+
NIL,
|
|
776
|
+
sequence,
|
|
777
|
+
NIL,
|
|
778
|
+
NIL,
|
|
779
|
+
NIL,
|
|
780
|
+
doneAt
|
|
781
|
+
);
|
|
782
|
+
}
|
|
742
783
|
|
|
743
784
|
// src/core/errors.ts
|
|
744
785
|
var { toString: objectToString } = Object.prototype;
|
|
745
786
|
function getErrorMessageDev(type, cause) {
|
|
746
787
|
if (cause instanceof Error) {
|
|
747
788
|
return `Seroval caught an error during the ${type} process.
|
|
748
|
-
|
|
789
|
+
|
|
749
790
|
${cause.name}
|
|
750
791
|
${cause.message}
|
|
751
792
|
|
|
@@ -1076,6 +1117,43 @@ var ARRAY_BUFFER_CONSTRUCTOR = (b64) => {
|
|
|
1076
1117
|
};
|
|
1077
1118
|
var SERIALIZED_ARRAY_BUFFER_CONSTRUCTOR = /* @__PURE__ */ ARRAY_BUFFER_CONSTRUCTOR.toString();
|
|
1078
1119
|
|
|
1120
|
+
// src/core/sequence.ts
|
|
1121
|
+
function isSequence(value) {
|
|
1122
|
+
return "__SEROVAL_SEQUENCE__" in value;
|
|
1123
|
+
}
|
|
1124
|
+
function createSequence(values, throwAt, doneAt) {
|
|
1125
|
+
return {
|
|
1126
|
+
__SEROVAL_SEQUENCE__: true,
|
|
1127
|
+
v: values,
|
|
1128
|
+
t: throwAt,
|
|
1129
|
+
d: doneAt
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
function createSequenceFromIterable(source) {
|
|
1133
|
+
const values = [];
|
|
1134
|
+
let throwsAt = -1;
|
|
1135
|
+
let doneAt = -1;
|
|
1136
|
+
const iterator = source[SYM_ITERATOR]();
|
|
1137
|
+
while (true) {
|
|
1138
|
+
try {
|
|
1139
|
+
const value = iterator.next();
|
|
1140
|
+
values.push(value.value);
|
|
1141
|
+
if (value.done) {
|
|
1142
|
+
doneAt = values.length - 1;
|
|
1143
|
+
break;
|
|
1144
|
+
}
|
|
1145
|
+
} catch (error) {
|
|
1146
|
+
throwsAt = values.length;
|
|
1147
|
+
values.push(error);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
return createSequence(values, throwsAt, doneAt);
|
|
1151
|
+
}
|
|
1152
|
+
var createIterator = ITERATOR_CONSTRUCTOR(SYM_ITERATOR);
|
|
1153
|
+
function sequenceToIterator(sequence) {
|
|
1154
|
+
return createIterator(sequence);
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1079
1157
|
// src/core/special-reference.ts
|
|
1080
1158
|
var ITERATOR = {};
|
|
1081
1159
|
var ASYNC_ITERATOR = {};
|
|
@@ -1133,36 +1211,6 @@ function streamToAsyncIterable(stream) {
|
|
|
1133
1211
|
);
|
|
1134
1212
|
}
|
|
1135
1213
|
|
|
1136
|
-
// src/core/utils/iterator-to-sequence.ts
|
|
1137
|
-
function iteratorToSequence(source) {
|
|
1138
|
-
const values = [];
|
|
1139
|
-
let throwsAt = -1;
|
|
1140
|
-
let doneAt = -1;
|
|
1141
|
-
const iterator = source[SYM_ITERATOR]();
|
|
1142
|
-
while (true) {
|
|
1143
|
-
try {
|
|
1144
|
-
const value = iterator.next();
|
|
1145
|
-
values.push(value.value);
|
|
1146
|
-
if (value.done) {
|
|
1147
|
-
doneAt = values.length - 1;
|
|
1148
|
-
break;
|
|
1149
|
-
}
|
|
1150
|
-
} catch (error) {
|
|
1151
|
-
throwsAt = values.length;
|
|
1152
|
-
values.push(error);
|
|
1153
|
-
}
|
|
1154
|
-
}
|
|
1155
|
-
return {
|
|
1156
|
-
v: values,
|
|
1157
|
-
t: throwsAt,
|
|
1158
|
-
d: doneAt
|
|
1159
|
-
};
|
|
1160
|
-
}
|
|
1161
|
-
var createIterator = ITERATOR_CONSTRUCTOR(SYM_ITERATOR);
|
|
1162
|
-
function sequenceToIterator(sequence) {
|
|
1163
|
-
return createIterator(sequence);
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
1214
|
// src/core/utils/promise-to-result.ts
|
|
1167
1215
|
async function promiseToResult(current) {
|
|
1168
1216
|
try {
|
|
@@ -1244,6 +1292,7 @@ function parseSpecialReference(ctx, ref) {
|
|
|
1244
1292
|
NIL,
|
|
1245
1293
|
NIL,
|
|
1246
1294
|
NIL,
|
|
1295
|
+
NIL,
|
|
1247
1296
|
NIL
|
|
1248
1297
|
);
|
|
1249
1298
|
}
|
|
@@ -1263,6 +1312,7 @@ function parseIteratorFactory(ctx) {
|
|
|
1263
1312
|
NIL,
|
|
1264
1313
|
parseWellKnownSymbol(ctx, SYM_ITERATOR),
|
|
1265
1314
|
NIL,
|
|
1315
|
+
NIL,
|
|
1266
1316
|
NIL
|
|
1267
1317
|
);
|
|
1268
1318
|
}
|
|
@@ -1285,6 +1335,7 @@ function parseAsyncIteratorFactory(ctx) {
|
|
|
1285
1335
|
],
|
|
1286
1336
|
NIL,
|
|
1287
1337
|
NIL,
|
|
1338
|
+
NIL,
|
|
1288
1339
|
NIL
|
|
1289
1340
|
);
|
|
1290
1341
|
}
|
|
@@ -1300,7 +1351,8 @@ function createObjectNode(id, current, empty, record) {
|
|
|
1300
1351
|
NIL,
|
|
1301
1352
|
NIL,
|
|
1302
1353
|
NIL,
|
|
1303
|
-
getObjectFlag(current)
|
|
1354
|
+
getObjectFlag(current),
|
|
1355
|
+
NIL
|
|
1304
1356
|
);
|
|
1305
1357
|
}
|
|
1306
1358
|
function createMapNode(ctx, id, k, v) {
|
|
@@ -1315,6 +1367,7 @@ function createMapNode(ctx, id, k, v) {
|
|
|
1315
1367
|
NIL,
|
|
1316
1368
|
parseSpecialReference(ctx, 0 /* MapSentinel */),
|
|
1317
1369
|
NIL,
|
|
1370
|
+
NIL,
|
|
1318
1371
|
NIL
|
|
1319
1372
|
);
|
|
1320
1373
|
}
|
|
@@ -1330,6 +1383,7 @@ function createPromiseConstructorNode(ctx, id, resolver) {
|
|
|
1330
1383
|
NIL,
|
|
1331
1384
|
parseSpecialReference(ctx, 1 /* PromiseConstructor */),
|
|
1332
1385
|
NIL,
|
|
1386
|
+
NIL,
|
|
1333
1387
|
NIL
|
|
1334
1388
|
);
|
|
1335
1389
|
}
|
|
@@ -1350,6 +1404,7 @@ function createArrayBufferNode(ctx, id, current) {
|
|
|
1350
1404
|
NIL,
|
|
1351
1405
|
parseSpecialReference(ctx, 5 /* ArrayBufferConstructor */),
|
|
1352
1406
|
NIL,
|
|
1407
|
+
NIL,
|
|
1353
1408
|
NIL
|
|
1354
1409
|
);
|
|
1355
1410
|
}
|
|
@@ -1400,7 +1455,9 @@ async function parseProperties(ctx, depth, properties) {
|
|
|
1400
1455
|
await parseAsync(
|
|
1401
1456
|
ctx,
|
|
1402
1457
|
depth,
|
|
1403
|
-
|
|
1458
|
+
createSequenceFromIterable(
|
|
1459
|
+
properties
|
|
1460
|
+
)
|
|
1404
1461
|
)
|
|
1405
1462
|
)
|
|
1406
1463
|
);
|
|
@@ -1534,6 +1591,7 @@ async function parsePromise(ctx, depth, id, current) {
|
|
|
1534
1591
|
NIL,
|
|
1535
1592
|
await parseAsync(ctx, depth, result),
|
|
1536
1593
|
NIL,
|
|
1594
|
+
NIL,
|
|
1537
1595
|
NIL
|
|
1538
1596
|
);
|
|
1539
1597
|
}
|
|
@@ -1591,6 +1649,13 @@ async function parseStream(ctx, depth, id, current) {
|
|
|
1591
1649
|
)
|
|
1592
1650
|
);
|
|
1593
1651
|
}
|
|
1652
|
+
async function parseSequence(ctx, depth, id, current) {
|
|
1653
|
+
const nodes = [];
|
|
1654
|
+
for (let i = 0, len = current.v.length; i < len; i++) {
|
|
1655
|
+
nodes[i] = await parseAsync(ctx, depth, current.v[i]);
|
|
1656
|
+
}
|
|
1657
|
+
return createSequenceNode(id, nodes, current.t, current.d);
|
|
1658
|
+
}
|
|
1594
1659
|
async function parseObjectAsync(ctx, depth, id, current) {
|
|
1595
1660
|
if (Array.isArray(current)) {
|
|
1596
1661
|
return parseArray(ctx, depth, id, current);
|
|
@@ -1598,6 +1663,9 @@ async function parseObjectAsync(ctx, depth, id, current) {
|
|
|
1598
1663
|
if (isStream(current)) {
|
|
1599
1664
|
return parseStream(ctx, depth, id, current);
|
|
1600
1665
|
}
|
|
1666
|
+
if (isSequence(current)) {
|
|
1667
|
+
return parseSequence(ctx, depth, id, current);
|
|
1668
|
+
}
|
|
1601
1669
|
const currentClass = current.constructor;
|
|
1602
1670
|
if (currentClass === OpaqueReference) {
|
|
1603
1671
|
return parseAsync(
|
|
@@ -2053,7 +2121,11 @@ function deserializeTypedArray(ctx, depth, node) {
|
|
|
2053
2121
|
if (offset < 0 || offset > source.byteLength) {
|
|
2054
2122
|
throw new SerovalMalformedNodeError(node);
|
|
2055
2123
|
}
|
|
2056
|
-
const result = assignIndexedValue(
|
|
2124
|
+
const result = assignIndexedValue(
|
|
2125
|
+
ctx,
|
|
2126
|
+
node.i,
|
|
2127
|
+
new construct(source, offset, node.l)
|
|
2128
|
+
);
|
|
2057
2129
|
return result;
|
|
2058
2130
|
}
|
|
2059
2131
|
function deserializeDataView(ctx, depth, node) {
|
|
@@ -2063,7 +2135,11 @@ function deserializeDataView(ctx, depth, node) {
|
|
|
2063
2135
|
if (offset < 0 || offset > source.byteLength) {
|
|
2064
2136
|
throw new SerovalMalformedNodeError(node);
|
|
2065
2137
|
}
|
|
2066
|
-
const result = assignIndexedValue(
|
|
2138
|
+
const result = assignIndexedValue(
|
|
2139
|
+
ctx,
|
|
2140
|
+
node.i,
|
|
2141
|
+
new DataView(source, offset, node.l)
|
|
2142
|
+
);
|
|
2067
2143
|
return result;
|
|
2068
2144
|
}
|
|
2069
2145
|
function deserializeDictionary(ctx, depth, node, result) {
|
|
@@ -2204,6 +2280,17 @@ function deserializeAsyncIteratorFactory(ctx, depth, node) {
|
|
|
2204
2280
|
deserialize(ctx, depth, node.a[1]);
|
|
2205
2281
|
return NIL;
|
|
2206
2282
|
}
|
|
2283
|
+
function deserializeSequence(ctx, depth, node) {
|
|
2284
|
+
const result = assignIndexedValue(
|
|
2285
|
+
ctx,
|
|
2286
|
+
node.i,
|
|
2287
|
+
createSequence([], node.s, node.l)
|
|
2288
|
+
);
|
|
2289
|
+
for (let i = 0, len = node.a.length; i < len; i++) {
|
|
2290
|
+
result.v[i] = deserialize(ctx, depth, node.a[i]);
|
|
2291
|
+
}
|
|
2292
|
+
return result;
|
|
2293
|
+
}
|
|
2207
2294
|
function deserialize(ctx, depth, node) {
|
|
2208
2295
|
if (depth > ctx.base.depthLimit) {
|
|
2209
2296
|
throw new SerovalDepthLimitError(ctx.base.depthLimit);
|
|
@@ -2280,6 +2367,8 @@ function deserialize(ctx, depth, node) {
|
|
|
2280
2367
|
case 29 /* AsyncIteratorFactory */:
|
|
2281
2368
|
return deserializeAsyncIteratorFactory(ctx, depth, node);
|
|
2282
2369
|
// case SerovalNodeType.SpecialReference:
|
|
2370
|
+
case 35 /* Sequence */:
|
|
2371
|
+
return deserializeSequence(ctx, depth, node);
|
|
2283
2372
|
default:
|
|
2284
2373
|
throw new SerovalUnsupportedNodeError(node);
|
|
2285
2374
|
}
|
|
@@ -2544,6 +2633,9 @@ function createArrayAssign(ctx, ref, index, value) {
|
|
|
2544
2633
|
function createObjectAssign(ctx, ref, key, value) {
|
|
2545
2634
|
createAssignment(ctx.base, getRefParam(ctx, ref) + "." + key, value);
|
|
2546
2635
|
}
|
|
2636
|
+
function createSequenceAssign(ctx, ref, index, value) {
|
|
2637
|
+
createAssignment(ctx.base, getRefParam(ctx, ref) + ".v[" + index + "]", value);
|
|
2638
|
+
}
|
|
2547
2639
|
function isIndexedValueInStack(ctx, node) {
|
|
2548
2640
|
return node.t === 4 /* IndexedValue */ && ctx.stack.includes(node.i);
|
|
2549
2641
|
}
|
|
@@ -2855,10 +2947,10 @@ function serializeArrayBuffer(ctx, node) {
|
|
|
2855
2947
|
return getConstructor(ctx, node.f) + '("' + node.s + '")';
|
|
2856
2948
|
}
|
|
2857
2949
|
function serializeTypedArray(ctx, node) {
|
|
2858
|
-
return "new " + node.c + "(" + serialize(ctx, node.f) + "," + node.b + ")";
|
|
2950
|
+
return "new " + node.c + "(" + serialize(ctx, node.f) + "," + node.b + "," + node.l + ")";
|
|
2859
2951
|
}
|
|
2860
2952
|
function serializeDataView(ctx, node) {
|
|
2861
|
-
return "new DataView(" + serialize(ctx, node.f) + "," + node.b + ")";
|
|
2953
|
+
return "new DataView(" + serialize(ctx, node.f) + "," + node.b + "," + node.l + ")";
|
|
2862
2954
|
}
|
|
2863
2955
|
function serializeAggregateError(ctx, node) {
|
|
2864
2956
|
const id = node.i;
|
|
@@ -3017,6 +3109,38 @@ function serializeStreamThrow(ctx, node) {
|
|
|
3017
3109
|
function serializeStreamReturn(ctx, node) {
|
|
3018
3110
|
return getRefParam(ctx, node.i) + ".return(" + serialize(ctx, node.f) + ")";
|
|
3019
3111
|
}
|
|
3112
|
+
function serializeSequenceItem(ctx, id, index, item) {
|
|
3113
|
+
const base = ctx.base;
|
|
3114
|
+
if (isIndexedValueInStack(base, item)) {
|
|
3115
|
+
markSerializerRef(base, id);
|
|
3116
|
+
createSequenceAssign(
|
|
3117
|
+
ctx,
|
|
3118
|
+
id,
|
|
3119
|
+
index,
|
|
3120
|
+
getRefParam(ctx, item.i)
|
|
3121
|
+
);
|
|
3122
|
+
return "";
|
|
3123
|
+
}
|
|
3124
|
+
return serialize(ctx, item);
|
|
3125
|
+
}
|
|
3126
|
+
function serializeSequence(ctx, node) {
|
|
3127
|
+
const items = node.a;
|
|
3128
|
+
const size = items.length;
|
|
3129
|
+
const id = node.i;
|
|
3130
|
+
if (size > 0) {
|
|
3131
|
+
ctx.base.stack.push(id);
|
|
3132
|
+
let result = serializeSequenceItem(ctx, id, 0, items[0]);
|
|
3133
|
+
for (let i = 1, item = result; i < size; i++) {
|
|
3134
|
+
item = serializeSequenceItem(ctx, id, i, items[i]);
|
|
3135
|
+
result += (item && result && ",") + item;
|
|
3136
|
+
}
|
|
3137
|
+
ctx.base.stack.pop();
|
|
3138
|
+
if (result) {
|
|
3139
|
+
return "{__SEROVAL_SEQUENCE__:!0,v:[" + result + "],t:" + node.s + ",d:" + node.l + "}";
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3142
|
+
return "{__SEROVAL_SEQUENCE__:!0,v:[],t:-1,d:0}";
|
|
3143
|
+
}
|
|
3020
3144
|
function serializeAssignable(ctx, node) {
|
|
3021
3145
|
switch (node.t) {
|
|
3022
3146
|
case 17 /* WKSymbol */:
|
|
@@ -3058,6 +3182,8 @@ function serializeAssignable(ctx, node) {
|
|
|
3058
3182
|
return serializePlugin(ctx, node);
|
|
3059
3183
|
case 26 /* SpecialReference */:
|
|
3060
3184
|
return SPECIAL_REF_STRING[node.s];
|
|
3185
|
+
case 35 /* Sequence */:
|
|
3186
|
+
return serializeSequence(ctx, node);
|
|
3061
3187
|
default:
|
|
3062
3188
|
throw new SerovalUnsupportedNodeError(node);
|
|
3063
3189
|
}
|
|
@@ -3231,7 +3357,9 @@ function parseProperties2(ctx, depth, properties) {
|
|
|
3231
3357
|
parseSOS(
|
|
3232
3358
|
ctx,
|
|
3233
3359
|
depth,
|
|
3234
|
-
|
|
3360
|
+
createSequenceFromIterable(
|
|
3361
|
+
properties
|
|
3362
|
+
)
|
|
3235
3363
|
)
|
|
3236
3364
|
)
|
|
3237
3365
|
);
|
|
@@ -3386,6 +3514,7 @@ function handlePromiseSuccess(id, depth, data) {
|
|
|
3386
3514
|
],
|
|
3387
3515
|
NIL,
|
|
3388
3516
|
NIL,
|
|
3517
|
+
NIL,
|
|
3389
3518
|
NIL
|
|
3390
3519
|
)
|
|
3391
3520
|
);
|
|
@@ -3413,6 +3542,7 @@ function handlePromiseFailure(id, depth, data) {
|
|
|
3413
3542
|
],
|
|
3414
3543
|
NIL,
|
|
3415
3544
|
NIL,
|
|
3545
|
+
NIL,
|
|
3416
3546
|
NIL
|
|
3417
3547
|
)
|
|
3418
3548
|
);
|
|
@@ -3468,6 +3598,13 @@ function parsePlugin2(ctx, depth, id, current) {
|
|
|
3468
3598
|
}
|
|
3469
3599
|
return NIL;
|
|
3470
3600
|
}
|
|
3601
|
+
function parseSequence2(ctx, depth, id, current) {
|
|
3602
|
+
const nodes = [];
|
|
3603
|
+
for (let i = 0, len = current.v.length; i < len; i++) {
|
|
3604
|
+
nodes[i] = parseSOS(ctx, depth, current.v[i]);
|
|
3605
|
+
}
|
|
3606
|
+
return createSequenceNode(id, nodes, current.t, current.d);
|
|
3607
|
+
}
|
|
3471
3608
|
function parseObjectPhase2(ctx, depth, id, current, currentClass) {
|
|
3472
3609
|
switch (currentClass) {
|
|
3473
3610
|
case Object:
|
|
@@ -3580,6 +3717,9 @@ function parseObject(ctx, depth, id, current) {
|
|
|
3580
3717
|
if (isStream(current)) {
|
|
3581
3718
|
return parseStream2(ctx, depth, id, current);
|
|
3582
3719
|
}
|
|
3720
|
+
if (isSequence(current)) {
|
|
3721
|
+
return parseSequence2(ctx, depth, id, current);
|
|
3722
|
+
}
|
|
3583
3723
|
const currentClass = current.constructor;
|
|
3584
3724
|
if (currentClass === OpaqueReference) {
|
|
3585
3725
|
return parseSOS(
|