seroval 0.13.1 → 0.14.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.
@@ -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: void 0,
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.createFunction(
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,