seroval 0.11.1 → 0.11.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.
- package/dist/cjs/development/index.cjs +114 -97
- package/dist/cjs/development/index.cjs.map +3 -3
- package/dist/cjs/production/index.cjs +3 -3
- package/dist/esm/development/index.mjs +114 -97
- package/dist/esm/development/index.mjs.map +3 -3
- package/dist/esm/production/index.mjs +3 -3
- package/dist/types/core/shared.d.ts +1 -1
- package/package.json +2 -2
- package/src/core/cross/async.ts +5 -5
- package/src/core/cross/primitives.ts +0 -8
- package/src/core/cross/stream.ts +60 -58
- package/src/core/cross/sync.ts +5 -5
- package/src/core/shared.ts +44 -18
- package/src/core/tree/async.ts +5 -5
- package/src/core/tree/sync.ts +5 -5
|
@@ -700,30 +700,53 @@ function getErrorOptions(ctx, error) {
|
|
|
700
700
|
}
|
|
701
701
|
return options;
|
|
702
702
|
}
|
|
703
|
-
function isIterable(value) {
|
|
703
|
+
function isIterable(ctx, value) {
|
|
704
704
|
if (!value || typeof value !== "object") {
|
|
705
705
|
return false;
|
|
706
706
|
}
|
|
707
707
|
if (Array.isArray(value)) {
|
|
708
708
|
return false;
|
|
709
709
|
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
710
|
+
const currentClass = value.constructor;
|
|
711
|
+
if (ctx.features & 2048 /* TypedArray */) {
|
|
712
|
+
switch (currentClass) {
|
|
713
|
+
case Int8Array:
|
|
714
|
+
case Int16Array:
|
|
715
|
+
case Int32Array:
|
|
716
|
+
case Uint8Array:
|
|
717
|
+
case Uint16Array:
|
|
718
|
+
case Uint32Array:
|
|
719
|
+
case Uint8ClampedArray:
|
|
720
|
+
case Float32Array:
|
|
721
|
+
case Float64Array:
|
|
722
|
+
return false;
|
|
723
|
+
default:
|
|
724
|
+
break;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
if ((ctx.features & BIGINT_FLAG) === BIGINT_FLAG) {
|
|
728
|
+
switch (currentClass) {
|
|
729
|
+
case BigInt64Array:
|
|
730
|
+
case BigUint64Array:
|
|
731
|
+
return false;
|
|
732
|
+
default:
|
|
733
|
+
break;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
if (ctx.features & 32 /* Map */ && currentClass === Map) {
|
|
737
|
+
return false;
|
|
738
|
+
}
|
|
739
|
+
if (ctx.features & 512 /* Set */ && currentClass === Set) {
|
|
740
|
+
return false;
|
|
741
|
+
}
|
|
742
|
+
if (ctx.features & 8192 /* WebAPI */) {
|
|
743
|
+
switch (currentClass) {
|
|
744
|
+
case Headers:
|
|
745
|
+
case File:
|
|
746
|
+
return false;
|
|
747
|
+
default:
|
|
748
|
+
break;
|
|
749
|
+
}
|
|
727
750
|
}
|
|
728
751
|
return Symbol.iterator in value;
|
|
729
752
|
}
|
|
@@ -914,7 +937,7 @@ async function generateNodeList(ctx, current) {
|
|
|
914
937
|
for (let i = 0; i < size; i++) {
|
|
915
938
|
if (i in current) {
|
|
916
939
|
item = current[i];
|
|
917
|
-
if (isIterable(item)) {
|
|
940
|
+
if (isIterable(ctx, item)) {
|
|
918
941
|
deferred[i] = item;
|
|
919
942
|
} else {
|
|
920
943
|
nodes[i] = await parseAsync(ctx, item);
|
|
@@ -953,7 +976,7 @@ async function generateMapNode(ctx, id, current) {
|
|
|
953
976
|
let deferredSize = 0;
|
|
954
977
|
let nodeSize = 0;
|
|
955
978
|
for (const [key, value] of current.entries()) {
|
|
956
|
-
if (isIterable(key) || isIterable(value)) {
|
|
979
|
+
if (isIterable(ctx, key) || isIterable(ctx, value)) {
|
|
957
980
|
deferredKey[deferredSize] = key;
|
|
958
981
|
deferredValue[deferredSize] = value;
|
|
959
982
|
deferredSize++;
|
|
@@ -989,7 +1012,7 @@ async function generateSetNode(ctx, id, current) {
|
|
|
989
1012
|
let deferredSize = 0;
|
|
990
1013
|
let nodeSize = 0;
|
|
991
1014
|
for (const item of current.keys()) {
|
|
992
|
-
if (isIterable(item)) {
|
|
1015
|
+
if (isIterable(ctx, item)) {
|
|
993
1016
|
deferred[deferredSize++] = item;
|
|
994
1017
|
} else {
|
|
995
1018
|
nodes[nodeSize++] = await parseAsync(ctx, item);
|
|
@@ -1027,7 +1050,7 @@ async function generateProperties(ctx, properties) {
|
|
|
1027
1050
|
for (const key of keys) {
|
|
1028
1051
|
item = properties[key];
|
|
1029
1052
|
escaped = serializeString(key);
|
|
1030
|
-
if (isIterable(item)) {
|
|
1053
|
+
if (isIterable(ctx, item)) {
|
|
1031
1054
|
deferredKeys[deferredSize] = escaped;
|
|
1032
1055
|
deferredValues[deferredSize] = item;
|
|
1033
1056
|
deferredSize++;
|
|
@@ -1073,7 +1096,7 @@ async function generatePlainProperties(ctx, properties) {
|
|
|
1073
1096
|
for (const key of keys) {
|
|
1074
1097
|
item = properties[key];
|
|
1075
1098
|
escaped = serializeString(key);
|
|
1076
|
-
if (isIterable(item)) {
|
|
1099
|
+
if (isIterable(ctx, item)) {
|
|
1077
1100
|
deferredKeys[deferredSize] = escaped;
|
|
1078
1101
|
deferredValues[deferredSize] = item;
|
|
1079
1102
|
deferredSize++;
|
|
@@ -2472,7 +2495,7 @@ function generateNodeList2(ctx, current) {
|
|
|
2472
2495
|
for (let i = 0; i < size; i++) {
|
|
2473
2496
|
if (i in current) {
|
|
2474
2497
|
item = current[i];
|
|
2475
|
-
if (isIterable(item)) {
|
|
2498
|
+
if (isIterable(ctx, item)) {
|
|
2476
2499
|
deferred[i] = item;
|
|
2477
2500
|
} else {
|
|
2478
2501
|
nodes[i] = parseSync(ctx, item);
|
|
@@ -2511,7 +2534,7 @@ function generateMapNode2(ctx, id, current) {
|
|
|
2511
2534
|
let deferredSize = 0;
|
|
2512
2535
|
let nodeSize = 0;
|
|
2513
2536
|
for (const [key, value] of current.entries()) {
|
|
2514
|
-
if (isIterable(key) || isIterable(value)) {
|
|
2537
|
+
if (isIterable(ctx, key) || isIterable(ctx, value)) {
|
|
2515
2538
|
deferredKey[deferredSize] = key;
|
|
2516
2539
|
deferredValue[deferredSize] = value;
|
|
2517
2540
|
deferredSize++;
|
|
@@ -2547,7 +2570,7 @@ function generateSetNode2(ctx, id, current) {
|
|
|
2547
2570
|
let deferredSize = 0;
|
|
2548
2571
|
let nodeSize = 0;
|
|
2549
2572
|
for (const item of current.keys()) {
|
|
2550
|
-
if (isIterable(item)) {
|
|
2573
|
+
if (isIterable(ctx, item)) {
|
|
2551
2574
|
deferred[deferredSize++] = item;
|
|
2552
2575
|
} else {
|
|
2553
2576
|
nodes[nodeSize++] = parseSync(ctx, item);
|
|
@@ -2585,7 +2608,7 @@ function generateProperties2(ctx, properties) {
|
|
|
2585
2608
|
for (const key of keys) {
|
|
2586
2609
|
item = properties[key];
|
|
2587
2610
|
escaped = serializeString(key);
|
|
2588
|
-
if (isIterable(item)) {
|
|
2611
|
+
if (isIterable(ctx, item)) {
|
|
2589
2612
|
deferredKeys[deferredSize] = escaped;
|
|
2590
2613
|
deferredValues[deferredSize] = item;
|
|
2591
2614
|
deferredSize++;
|
|
@@ -2628,7 +2651,7 @@ function generatePlainProperties2(ctx, properties) {
|
|
|
2628
2651
|
for (const key of keys) {
|
|
2629
2652
|
item = properties[key];
|
|
2630
2653
|
escaped = serializeString(key);
|
|
2631
|
-
if (isIterable(item)) {
|
|
2654
|
+
if (isIterable(ctx, item)) {
|
|
2632
2655
|
deferredKeys[deferredSize] = escaped;
|
|
2633
2656
|
deferredValues[deferredSize] = item;
|
|
2634
2657
|
deferredSize++;
|
|
@@ -3092,12 +3115,7 @@ function createTypedArrayNode2(ctx, id, current) {
|
|
|
3092
3115
|
o: void 0
|
|
3093
3116
|
};
|
|
3094
3117
|
}
|
|
3095
|
-
var BIGINT_FLAG2 = 4096 /* BigIntTypedArray */ | 8 /* BigInt */;
|
|
3096
3118
|
function createBigIntTypedArrayNode2(ctx, id, current) {
|
|
3097
|
-
assert(
|
|
3098
|
-
(ctx.features & BIGINT_FLAG2) === BIGINT_FLAG2,
|
|
3099
|
-
new UnsupportedTypeError(current)
|
|
3100
|
-
);
|
|
3101
3119
|
return {
|
|
3102
3120
|
t: 16 /* BigIntTypedArray */,
|
|
3103
3121
|
i: id,
|
|
@@ -3195,7 +3213,7 @@ async function generateNodeList3(ctx, current) {
|
|
|
3195
3213
|
for (let i = 0; i < size; i++) {
|
|
3196
3214
|
if (i in current) {
|
|
3197
3215
|
item = current[i];
|
|
3198
|
-
if (isIterable(item)) {
|
|
3216
|
+
if (isIterable(ctx, item)) {
|
|
3199
3217
|
deferred[i] = item;
|
|
3200
3218
|
} else {
|
|
3201
3219
|
nodes[i] = await crossParseAsync(ctx, item);
|
|
@@ -3234,7 +3252,7 @@ async function generateMapNode3(ctx, id, current) {
|
|
|
3234
3252
|
let deferredSize = 0;
|
|
3235
3253
|
let nodeSize = 0;
|
|
3236
3254
|
for (const [key, value] of current.entries()) {
|
|
3237
|
-
if (isIterable(key) || isIterable(value)) {
|
|
3255
|
+
if (isIterable(ctx, key) || isIterable(ctx, value)) {
|
|
3238
3256
|
deferredKey[deferredSize] = key;
|
|
3239
3257
|
deferredValue[deferredSize] = value;
|
|
3240
3258
|
deferredSize++;
|
|
@@ -3270,7 +3288,7 @@ async function generateSetNode3(ctx, id, current) {
|
|
|
3270
3288
|
let deferredSize = 0;
|
|
3271
3289
|
let nodeSize = 0;
|
|
3272
3290
|
for (const item of current.keys()) {
|
|
3273
|
-
if (isIterable(item)) {
|
|
3291
|
+
if (isIterable(ctx, item)) {
|
|
3274
3292
|
deferred[deferredSize++] = item;
|
|
3275
3293
|
} else {
|
|
3276
3294
|
nodes[nodeSize++] = await crossParseAsync(ctx, item);
|
|
@@ -3308,7 +3326,7 @@ async function generateProperties3(ctx, properties) {
|
|
|
3308
3326
|
for (const key of keys) {
|
|
3309
3327
|
item = properties[key];
|
|
3310
3328
|
escaped = serializeString(key);
|
|
3311
|
-
if (isIterable(item)) {
|
|
3329
|
+
if (isIterable(ctx, item)) {
|
|
3312
3330
|
deferredKeys[deferredSize] = escaped;
|
|
3313
3331
|
deferredValues[deferredSize] = item;
|
|
3314
3332
|
deferredSize++;
|
|
@@ -3354,7 +3372,7 @@ async function generatePlainProperties3(ctx, properties) {
|
|
|
3354
3372
|
for (const key of keys) {
|
|
3355
3373
|
item = properties[key];
|
|
3356
3374
|
escaped = serializeString(key);
|
|
3357
|
-
if (isIterable(item)) {
|
|
3375
|
+
if (isIterable(ctx, item)) {
|
|
3358
3376
|
deferredKeys[deferredSize] = escaped;
|
|
3359
3377
|
deferredValues[deferredSize] = item;
|
|
3360
3378
|
deferredSize++;
|
|
@@ -4321,7 +4339,7 @@ function generateNodeList4(ctx, current) {
|
|
|
4321
4339
|
for (let i = 0; i < size; i++) {
|
|
4322
4340
|
if (i in current) {
|
|
4323
4341
|
item = current[i];
|
|
4324
|
-
if (isIterable(item)) {
|
|
4342
|
+
if (isIterable(ctx, item)) {
|
|
4325
4343
|
deferred[i] = item;
|
|
4326
4344
|
} else {
|
|
4327
4345
|
nodes[i] = crossParseStream(ctx, item);
|
|
@@ -4360,7 +4378,7 @@ function generateMapNode4(ctx, id, current) {
|
|
|
4360
4378
|
let deferredSize = 0;
|
|
4361
4379
|
let nodeSize = 0;
|
|
4362
4380
|
for (const [key, value] of current.entries()) {
|
|
4363
|
-
if (isIterable(key) || isIterable(value)) {
|
|
4381
|
+
if (isIterable(ctx, key) || isIterable(ctx, value)) {
|
|
4364
4382
|
deferredKey[deferredSize] = key;
|
|
4365
4383
|
deferredValue[deferredSize] = value;
|
|
4366
4384
|
deferredSize++;
|
|
@@ -4396,7 +4414,7 @@ function generateSetNode4(ctx, id, current) {
|
|
|
4396
4414
|
let deferredSize = 0;
|
|
4397
4415
|
let nodeSize = 0;
|
|
4398
4416
|
for (const item of current.keys()) {
|
|
4399
|
-
if (isIterable(item)) {
|
|
4417
|
+
if (isIterable(ctx, item)) {
|
|
4400
4418
|
deferred[deferredSize++] = item;
|
|
4401
4419
|
} else {
|
|
4402
4420
|
nodes[nodeSize++] = crossParseStream(ctx, item);
|
|
@@ -4434,7 +4452,7 @@ function generateProperties4(ctx, properties) {
|
|
|
4434
4452
|
for (const key of keys) {
|
|
4435
4453
|
item = properties[key];
|
|
4436
4454
|
escaped = serializeString(key);
|
|
4437
|
-
if (isIterable(item)) {
|
|
4455
|
+
if (isIterable(ctx, item)) {
|
|
4438
4456
|
deferredKeys[deferredSize] = escaped;
|
|
4439
4457
|
deferredValues[deferredSize] = item;
|
|
4440
4458
|
deferredSize++;
|
|
@@ -4480,7 +4498,7 @@ function generatePlainProperties4(ctx, properties) {
|
|
|
4480
4498
|
for (const key of keys) {
|
|
4481
4499
|
item = properties[key];
|
|
4482
4500
|
escaped = serializeString(key);
|
|
4483
|
-
if (isIterable(item)) {
|
|
4501
|
+
if (isIterable(ctx, item)) {
|
|
4484
4502
|
deferredKeys[deferredSize] = escaped;
|
|
4485
4503
|
deferredValues[deferredSize] = item;
|
|
4486
4504
|
deferredSize++;
|
|
@@ -4665,52 +4683,13 @@ function generateBoxedNode4(ctx, id, current) {
|
|
|
4665
4683
|
o: void 0
|
|
4666
4684
|
};
|
|
4667
4685
|
}
|
|
4668
|
-
function
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
(data) => {
|
|
4674
|
-
if (ctx.alive) {
|
|
4675
|
-
if (data.done) {
|
|
4676
|
-
ctx.onParse({
|
|
4677
|
-
t: 33 /* ReadableStreamClose */,
|
|
4678
|
-
i: id,
|
|
4679
|
-
s: void 0,
|
|
4680
|
-
l: void 0,
|
|
4681
|
-
c: void 0,
|
|
4682
|
-
m: void 0,
|
|
4683
|
-
p: void 0,
|
|
4684
|
-
e: void 0,
|
|
4685
|
-
a: void 0,
|
|
4686
|
-
f: void 0,
|
|
4687
|
-
b: void 0,
|
|
4688
|
-
o: void 0
|
|
4689
|
-
}, false);
|
|
4690
|
-
popPendingState(ctx);
|
|
4691
|
-
} else {
|
|
4692
|
-
ctx.onParse({
|
|
4693
|
-
t: 32 /* ReadableStreamEnqueue */,
|
|
4694
|
-
i: id,
|
|
4695
|
-
s: void 0,
|
|
4696
|
-
l: void 0,
|
|
4697
|
-
c: void 0,
|
|
4698
|
-
m: void 0,
|
|
4699
|
-
p: void 0,
|
|
4700
|
-
e: void 0,
|
|
4701
|
-
a: void 0,
|
|
4702
|
-
f: crossParseStream(ctx, data.value),
|
|
4703
|
-
b: void 0,
|
|
4704
|
-
o: void 0
|
|
4705
|
-
}, false);
|
|
4706
|
-
push();
|
|
4707
|
-
}
|
|
4708
|
-
}
|
|
4709
|
-
},
|
|
4710
|
-
(value) => {
|
|
4711
|
-
if (ctx.alive) {
|
|
4686
|
+
function pushReadableStreamState(ctx, id, reader) {
|
|
4687
|
+
reader.read().then(
|
|
4688
|
+
(data) => {
|
|
4689
|
+
if (ctx.alive) {
|
|
4690
|
+
if (data.done) {
|
|
4712
4691
|
ctx.onParse({
|
|
4713
|
-
t:
|
|
4692
|
+
t: 33 /* ReadableStreamClose */,
|
|
4714
4693
|
i: id,
|
|
4715
4694
|
s: void 0,
|
|
4716
4695
|
l: void 0,
|
|
@@ -4719,16 +4698,54 @@ function generateReadableStreamNode(ctx, id, current) {
|
|
|
4719
4698
|
p: void 0,
|
|
4720
4699
|
e: void 0,
|
|
4721
4700
|
a: void 0,
|
|
4722
|
-
f:
|
|
4701
|
+
f: void 0,
|
|
4723
4702
|
b: void 0,
|
|
4724
4703
|
o: void 0
|
|
4725
4704
|
}, false);
|
|
4726
4705
|
popPendingState(ctx);
|
|
4706
|
+
} else {
|
|
4707
|
+
ctx.onParse({
|
|
4708
|
+
t: 32 /* ReadableStreamEnqueue */,
|
|
4709
|
+
i: id,
|
|
4710
|
+
s: void 0,
|
|
4711
|
+
l: void 0,
|
|
4712
|
+
c: void 0,
|
|
4713
|
+
m: void 0,
|
|
4714
|
+
p: void 0,
|
|
4715
|
+
e: void 0,
|
|
4716
|
+
a: void 0,
|
|
4717
|
+
f: crossParseStream(ctx, data.value),
|
|
4718
|
+
b: void 0,
|
|
4719
|
+
o: void 0
|
|
4720
|
+
}, false);
|
|
4721
|
+
pushReadableStreamState(ctx, id, reader);
|
|
4727
4722
|
}
|
|
4728
4723
|
}
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4724
|
+
},
|
|
4725
|
+
(value) => {
|
|
4726
|
+
if (ctx.alive) {
|
|
4727
|
+
ctx.onParse({
|
|
4728
|
+
t: 34 /* ReadableStreamError */,
|
|
4729
|
+
i: id,
|
|
4730
|
+
s: void 0,
|
|
4731
|
+
l: void 0,
|
|
4732
|
+
c: void 0,
|
|
4733
|
+
m: void 0,
|
|
4734
|
+
p: void 0,
|
|
4735
|
+
e: void 0,
|
|
4736
|
+
a: void 0,
|
|
4737
|
+
f: crossParseStream(ctx, value),
|
|
4738
|
+
b: void 0,
|
|
4739
|
+
o: void 0
|
|
4740
|
+
}, false);
|
|
4741
|
+
popPendingState(ctx);
|
|
4742
|
+
}
|
|
4743
|
+
}
|
|
4744
|
+
);
|
|
4745
|
+
}
|
|
4746
|
+
function generateReadableStreamNode(ctx, id, current) {
|
|
4747
|
+
pushPendingState(ctx);
|
|
4748
|
+
pushReadableStreamState(ctx, id, current.getReader());
|
|
4732
4749
|
return {
|
|
4733
4750
|
t: 31 /* ReadableStreamConstructor */,
|
|
4734
4751
|
i: id,
|
|
@@ -4977,7 +4994,7 @@ function generateNodeList5(ctx, current) {
|
|
|
4977
4994
|
for (let i = 0; i < size; i++) {
|
|
4978
4995
|
if (i in current) {
|
|
4979
4996
|
item = current[i];
|
|
4980
|
-
if (isIterable(item)) {
|
|
4997
|
+
if (isIterable(ctx, item)) {
|
|
4981
4998
|
deferred[i] = item;
|
|
4982
4999
|
} else {
|
|
4983
5000
|
nodes[i] = crossParseSync(ctx, item);
|
|
@@ -5016,7 +5033,7 @@ function generateMapNode5(ctx, id, current) {
|
|
|
5016
5033
|
let deferredSize = 0;
|
|
5017
5034
|
let nodeSize = 0;
|
|
5018
5035
|
for (const [key, value] of current.entries()) {
|
|
5019
|
-
if (isIterable(key) || isIterable(value)) {
|
|
5036
|
+
if (isIterable(ctx, key) || isIterable(ctx, value)) {
|
|
5020
5037
|
deferredKey[deferredSize] = key;
|
|
5021
5038
|
deferredValue[deferredSize] = value;
|
|
5022
5039
|
deferredSize++;
|
|
@@ -5052,7 +5069,7 @@ function generateSetNode5(ctx, id, current) {
|
|
|
5052
5069
|
let deferredSize = 0;
|
|
5053
5070
|
let nodeSize = 0;
|
|
5054
5071
|
for (const item of current.keys()) {
|
|
5055
|
-
if (isIterable(item)) {
|
|
5072
|
+
if (isIterable(ctx, item)) {
|
|
5056
5073
|
deferred[deferredSize++] = item;
|
|
5057
5074
|
} else {
|
|
5058
5075
|
nodes[nodeSize++] = crossParseSync(ctx, item);
|
|
@@ -5090,7 +5107,7 @@ function generateProperties5(ctx, properties) {
|
|
|
5090
5107
|
for (const key of keys) {
|
|
5091
5108
|
item = properties[key];
|
|
5092
5109
|
escaped = serializeString(key);
|
|
5093
|
-
if (isIterable(item)) {
|
|
5110
|
+
if (isIterable(ctx, item)) {
|
|
5094
5111
|
deferredKeys[deferredSize] = escaped;
|
|
5095
5112
|
deferredValues[deferredSize] = item;
|
|
5096
5113
|
deferredSize++;
|
|
@@ -5132,7 +5149,7 @@ function generatePlainProperties5(ctx, properties) {
|
|
|
5132
5149
|
for (const key of keys) {
|
|
5133
5150
|
item = properties[key];
|
|
5134
5151
|
escaped = serializeString(key);
|
|
5135
|
-
if (isIterable(item)) {
|
|
5152
|
+
if (isIterable(ctx, item)) {
|
|
5136
5153
|
deferredKeys[deferredSize] = escaped;
|
|
5137
5154
|
deferredValues[deferredSize] = item;
|
|
5138
5155
|
deferredSize++;
|