seroval 0.13.0 → 0.13.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/README.md +17 -15
- package/dist/cjs/development/index.cjs +38 -38
- package/dist/cjs/development/index.cjs.map +2 -2
- package/dist/cjs/production/index.cjs +1 -1
- package/dist/esm/development/index.mjs +38 -38
- package/dist/esm/development/index.mjs.map +2 -2
- package/dist/esm/production/index.mjs +1 -1
- package/dist/types/core/context/parser.d.ts +1 -1
- package/dist/types/core/context/parser.d.ts.map +1 -1
- package/dist/types/core/context/serializer.d.ts +2 -0
- package/dist/types/core/context/serializer.d.ts.map +1 -1
- package/dist/types/core/cross/serializer.d.ts +1 -2
- package/dist/types/core/cross/serializer.d.ts.map +1 -1
- package/dist/types/core/types.d.ts +1 -0
- package/dist/types/core/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/core/context/parser/async.ts +1 -1
- package/src/core/context/parser/stream.ts +4 -4
- package/src/core/context/parser.ts +4 -2
- package/src/core/context/serializer.ts +37 -14
- package/src/core/cross/serializer.ts +0 -20
- package/src/core/types.ts +1 -0
package/README.md
CHANGED
|
@@ -59,12 +59,12 @@ console.log(result);
|
|
|
59
59
|
Output (as a string):
|
|
60
60
|
|
|
61
61
|
```js
|
|
62
|
-
((h,j,k,m)=>(
|
|
62
|
+
((h,j,k,m,o)=>(o={number:[0.3325212548332517,-0,0/0,1/0,-1/0],string:["hello world","\x3Cscript>Hello World\x3C/script>"],boolean:[!0,!1],null:null,undefined:void 0,bigint:9007199254740991n,array:h=[,,,,k=(j=[],new Map([["hello","world"],["mutual",m=new Set(["hello","world"])]]))],regexp:/[a-z0-9]+/i,date:new Date("2023-11-19T09:25:24.118Z"),map:k,set:m},h[3]=h,k.set("self",k),m.add(m).add(h),o.self=o,o))()
|
|
63
63
|
|
|
64
64
|
// Formatted for readability
|
|
65
|
-
((h, j, k, m) => (
|
|
66
|
-
(
|
|
67
|
-
number: [0.
|
|
65
|
+
((h, j, k, m, o) => (
|
|
66
|
+
(o = {
|
|
67
|
+
number: [0.3325212548332517, -0, 0 / 0, 1 / 0, -1 / 0],
|
|
68
68
|
string: ["hello world", "\x3Cscript>Hello World\x3C/script>"],
|
|
69
69
|
boolean: [!0, !1],
|
|
70
70
|
null: null,
|
|
@@ -75,21 +75,23 @@ Output (as a string):
|
|
|
75
75
|
,
|
|
76
76
|
,
|
|
77
77
|
,
|
|
78
|
-
(
|
|
79
|
-
[
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
(k =
|
|
79
|
+
((j = []),
|
|
80
|
+
new Map([
|
|
81
|
+
["hello", "world"],
|
|
82
|
+
["mutual", (m = new Set(["hello", "world"]))],
|
|
83
|
+
]))),
|
|
82
84
|
]),
|
|
83
85
|
regexp: /[a-z0-9]+/i,
|
|
84
|
-
date: new Date("2023-
|
|
85
|
-
map:
|
|
86
|
-
set:
|
|
86
|
+
date: new Date("2023-11-19T09:25:24.118Z"),
|
|
87
|
+
map: k,
|
|
88
|
+
set: m,
|
|
87
89
|
}),
|
|
88
90
|
(h[3] = h),
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
(
|
|
92
|
-
|
|
91
|
+
k.set("self", k),
|
|
92
|
+
m.add(m).add(h),
|
|
93
|
+
(o.self = o),
|
|
94
|
+
o
|
|
93
95
|
))();
|
|
94
96
|
```
|
|
95
97
|
|
|
@@ -1070,7 +1070,7 @@ var BaseParserContext = class {
|
|
|
1070
1070
|
o: void 0
|
|
1071
1071
|
};
|
|
1072
1072
|
}
|
|
1073
|
-
parseAsyncIteratorFactory() {
|
|
1073
|
+
parseAsyncIteratorFactory(streaming) {
|
|
1074
1074
|
const registeredID = this.refs.get(ASYNC_ITERATOR);
|
|
1075
1075
|
if (registeredID != null) {
|
|
1076
1076
|
this.markRef(registeredID);
|
|
@@ -1081,7 +1081,7 @@ var BaseParserContext = class {
|
|
|
1081
1081
|
return {
|
|
1082
1082
|
t: 44 /* AsyncIteratorFactory */,
|
|
1083
1083
|
i: id,
|
|
1084
|
-
s:
|
|
1084
|
+
s: streaming,
|
|
1085
1085
|
l: void 0,
|
|
1086
1086
|
c: void 0,
|
|
1087
1087
|
m: void 0,
|
|
@@ -1308,7 +1308,7 @@ var BaseAsyncParserContext = class extends BaseParserContext {
|
|
|
1308
1308
|
);
|
|
1309
1309
|
valueNodes.push(
|
|
1310
1310
|
createAsyncIteratorFactoryInstanceNode(
|
|
1311
|
-
this.parseAsyncIteratorFactory(),
|
|
1311
|
+
this.parseAsyncIteratorFactory(0),
|
|
1312
1312
|
await this.parse(
|
|
1313
1313
|
await asyncIteratorToSequence(properties)
|
|
1314
1314
|
)
|
|
@@ -2880,22 +2880,40 @@ var BaseSerializerContext = class {
|
|
|
2880
2880
|
serializeIteratorFactoryInstance(node) {
|
|
2881
2881
|
return "(" + this.serialize(node.a[0]) + ")(" + this.serialize(node.a[1]) + ")";
|
|
2882
2882
|
}
|
|
2883
|
+
getStreamingAsyncIteratorFactory(node) {
|
|
2884
|
+
return this.createFunction(
|
|
2885
|
+
["s"],
|
|
2886
|
+
this.createFunction(
|
|
2887
|
+
["b", "t"],
|
|
2888
|
+
"(b=s.tee(),s=b[0],b=b[1].getReader(),t={[" + this.serialize(node.f) + "]:" + this.createFunction([], "t") + ",next:" + this.createFunction(
|
|
2889
|
+
[],
|
|
2890
|
+
"b.read().then(" + this.createEffectfulFunction(
|
|
2891
|
+
["d"],
|
|
2892
|
+
"if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}"
|
|
2893
|
+
) + ")"
|
|
2894
|
+
) + "})"
|
|
2895
|
+
)
|
|
2896
|
+
);
|
|
2897
|
+
}
|
|
2898
|
+
getBlockingAsyncIteratorFactory(node) {
|
|
2899
|
+
return this.createFunction(
|
|
2900
|
+
["s"],
|
|
2901
|
+
this.createFunction(
|
|
2902
|
+
["i", "t"],
|
|
2903
|
+
"(i=0,t={[" + this.serialize(node.f) + "]:" + this.createFunction([], "t") + ",next:" + this.createFunction(
|
|
2904
|
+
[],
|
|
2905
|
+
"Promise.resolve().then(" + this.createEffectfulFunction(
|
|
2906
|
+
["c", "d"],
|
|
2907
|
+
"if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}"
|
|
2908
|
+
) + ")"
|
|
2909
|
+
) + "})"
|
|
2910
|
+
)
|
|
2911
|
+
);
|
|
2912
|
+
}
|
|
2883
2913
|
serializeAsyncIteratorFactory(node) {
|
|
2884
2914
|
return this.assignIndexedValue(
|
|
2885
2915
|
node.i,
|
|
2886
|
-
this.
|
|
2887
|
-
["s"],
|
|
2888
|
-
this.createFunction(
|
|
2889
|
-
["i", "t"],
|
|
2890
|
-
"(i=0,t={[" + this.serialize(node.f) + "]:" + this.createFunction([], "t") + ",next:" + this.createFunction(
|
|
2891
|
-
[],
|
|
2892
|
-
"Promise.resolve().then(" + this.createEffectfulFunction(
|
|
2893
|
-
["c", "d"],
|
|
2894
|
-
"if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}"
|
|
2895
|
-
) + ")"
|
|
2896
|
-
) + "})"
|
|
2897
|
-
)
|
|
2898
|
-
)
|
|
2916
|
+
node.s ? this.getStreamingAsyncIteratorFactory(node) : this.getBlockingAsyncIteratorFactory(node)
|
|
2899
2917
|
);
|
|
2900
2918
|
}
|
|
2901
2919
|
serializeAsyncIteratorFactoryInstance(node) {
|
|
@@ -3614,24 +3632,6 @@ var CrossSerializerContext = class extends BaseSerializerContext {
|
|
|
3614
3632
|
serializeReadableStreamClose(node) {
|
|
3615
3633
|
return GLOBAL_CONTEXT_API + "." + GLOBAL_CONTEXT_STREAM_CLOSE + "(" + this.getRefParam(node.i) + ")";
|
|
3616
3634
|
}
|
|
3617
|
-
serializeAsyncIteratorFactory(node) {
|
|
3618
|
-
return this.assignIndexedValue(
|
|
3619
|
-
node.i,
|
|
3620
|
-
this.createFunction(
|
|
3621
|
-
["s"],
|
|
3622
|
-
this.createFunction(
|
|
3623
|
-
["b", "t"],
|
|
3624
|
-
"(b=s.tee(),s=b[0],b=b[1].getReader(),t={[" + this.serialize(node.f) + "]:" + this.createFunction([], "t") + ",next:" + this.createFunction(
|
|
3625
|
-
[],
|
|
3626
|
-
"b.read().then(" + this.createEffectfulFunction(
|
|
3627
|
-
["d"],
|
|
3628
|
-
"if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}"
|
|
3629
|
-
) + ")"
|
|
3630
|
-
) + "})"
|
|
3631
|
-
)
|
|
3632
|
-
)
|
|
3633
|
-
);
|
|
3634
|
-
}
|
|
3635
3635
|
serializeTop(tree) {
|
|
3636
3636
|
const result = this.serialize(tree);
|
|
3637
3637
|
const id = tree.i;
|
|
@@ -3722,7 +3722,7 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3722
3722
|
);
|
|
3723
3723
|
valueNodes.push(
|
|
3724
3724
|
createAsyncIteratorFactoryInstanceNode(
|
|
3725
|
-
this.parseAsyncIteratorFactory(),
|
|
3725
|
+
this.parseAsyncIteratorFactory(1),
|
|
3726
3726
|
this.parse(
|
|
3727
3727
|
asyncIteratorToReadableStream(
|
|
3728
3728
|
properties,
|
|
@@ -3809,8 +3809,8 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3809
3809
|
b: void 0,
|
|
3810
3810
|
o: void 0
|
|
3811
3811
|
}, false);
|
|
3812
|
-
this.popPendingState();
|
|
3813
3812
|
}
|
|
3813
|
+
this.popPendingState();
|
|
3814
3814
|
}
|
|
3815
3815
|
}
|
|
3816
3816
|
);
|
|
@@ -3890,8 +3890,8 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3890
3890
|
b: void 0,
|
|
3891
3891
|
o: void 0
|
|
3892
3892
|
}, false);
|
|
3893
|
-
this.popPendingState();
|
|
3894
3893
|
}
|
|
3894
|
+
this.popPendingState();
|
|
3895
3895
|
},
|
|
3896
3896
|
(data) => {
|
|
3897
3897
|
if (this.alive) {
|
|
@@ -3911,9 +3911,9 @@ var BaseStreamParserContext = class extends BaseSyncParserContext {
|
|
|
3911
3911
|
b: void 0,
|
|
3912
3912
|
o: void 0
|
|
3913
3913
|
}, false);
|
|
3914
|
-
this.popPendingState();
|
|
3915
3914
|
}
|
|
3916
3915
|
}
|
|
3916
|
+
this.popPendingState();
|
|
3917
3917
|
}
|
|
3918
3918
|
);
|
|
3919
3919
|
this.pushPendingState();
|