Skip to content

Commit

Permalink
Fix inconsistent parentheses on serial data
Browse files Browse the repository at this point in the history
  • Loading branch information
lxsmnsyc committed Jul 30, 2024
1 parent 1746c7b commit efe0d0b
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 73 deletions.
2 changes: 1 addition & 1 deletion packages/seroval/src/core/context/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export default abstract class BaseSerializerContext
parameters.length === 1
? parameters[0]
: '(' + parameters.join(',') + ')';
return joined + '=>' + body;
return joined + '=>' + (body.startsWith('{') ? '(' + body + ')' : body);
}
return 'function(' + parameters.join(',') + '){return ' + body + '}';
}
Expand Down
8 changes: 6 additions & 2 deletions packages/seroval/src/core/cross/serializer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SerovalNodeType } from '../constants';
import type { BaseSerializerContextOptions } from '../context/serializer';
import BaseSerializerContext from '../context/serializer';
import { GLOBAL_CONTEXT_REFERENCES } from '../keys';
Expand Down Expand Up @@ -48,10 +49,13 @@ export default class CrossSerializerContext extends BaseSerializerContext {
// Parameters needed for scoping
const params = this.scopeId == null ? '' : GLOBAL_CONTEXT_REFERENCES;
// If there are patches, append it after the result
const body = patches ? result + ',' + patches + ref : result;
const body = patches ? '(' + result + ',' + patches + ref + ')' : result;
// If there are no params, there's no need to generate a function
if (params === '') {
return patches ? '(' + body + ')' : body;
if (tree.t === SerovalNodeType.Object && !patches) {
return '(' + body + ')';
}
return body;
}
// Get the arguments for the IIFE
const args =
Expand Down
3 changes: 2 additions & 1 deletion packages/seroval/src/core/tree/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ export default class VanillaSerializerContext extends BaseSerializerContext {
if (!result.startsWith(index + '=')) {
body = index + '=' + body;
}
body = '(' + body + ')';
}
return '(' + this.createFunction(this.vars, '(' + body + ')') + ')()';
return '(' + this.createFunction(this.vars, body) + ')()';
}
if (tree.t === SerovalNodeType.Object) {
return '(' + result + ')';
Expand Down
4 changes: 2 additions & 2 deletions packages/seroval/test/__snapshots__/array.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`arrays > crossSerialize > scoped > supports Arrays 1`] = `"($R=>$R[0]=[1,2,3])($R["example"])"`;

exports[`arrays > crossSerialize > scoped > supports self recursion 1`] = `"($R=>$R[0]=[,,],$R[0][1]=$R[0][0]=$R[0],$R[0])($R["example"])"`;
exports[`arrays > crossSerialize > scoped > supports self recursion 1`] = `"($R=>($R[0]=[,,],$R[0][1]=$R[0][0]=$R[0],$R[0]))($R["example"])"`;

exports[`arrays > crossSerialize > supports Arrays 1`] = `"$R[0]=[1,2,3]"`;

Expand Down Expand Up @@ -42,7 +42,7 @@ exports[`arrays > serialize > supports self recursion 1`] = `"(h=>(h=[,,],h[1]=h

exports[`arrays > serializeAsync > supports Arrays 1`] = `"Promise.resolve([1,2,3])"`;

exports[`arrays > serializeAsync > supports self recursion 1`] = `"(h=>(h=[Promise.resolve().then(()=>h),Promise.resolve().then(()=>h)]))()"`;
exports[`arrays > serializeAsync > supports self recursion 1`] = `"(h=>h=[Promise.resolve().then(()=>h),Promise.resolve().then(()=>h)])()"`;

exports[`arrays > toCrossJSON > supports Arrays 1`] = `"{"t":9,"i":0,"l":3,"a":[{"t":0,"s":1},{"t":0,"s":2},{"t":0,"s":3}],"o":0}"`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`AsyncIterable > compat > should use function expressions instead of arrow functions. 1`] = `"(function(h,j,k,m,o){return ({title:"Hello World",[h=Symbol.asyncIterator]:((j=function(s,f,p){return ((p=new Promise(function(a,b){s=a,f=b})).s=s,p.f=f,p)},function(s){return function(b,c,p,d,e,t,f){return (b=[],c=0,p=[],d=-1,e=!1,f=function(i,l){for(i=0,l=p.length;i<l;i++)p[i].s({done:!0,value:void 0})},s.on({next:function(v,t){if(t=p.shift())t.s({done:!1,value:v});b.push(v)},throw:function(v,t){if(t=p.shift())t.f(v);f(),d=b.length,e=!0,b.push(v)},return:function(v,t){if(t=p.shift())t.s({done:!0,value:v});f(),d=b.length,b.push(v)}}),t={[h]:function(){return t},next:function(i,t,v){if(d===-1){return((i=c++)>=b.length)?(p.push(t=j()),t):{done:!1,value:b[i]}}if(c>d)return{done:!0,value:void 0};if(v=b[i=c++],i!==d)return{done:!1,value:v};if(e)throw v;return{done:!0,value:v}}})}}))((o=(function(b,a,s,l,p,f,e,n){return (b=[],a=!0,s=!1,l=[],p=0,f=function(v,m,x){for(x=0;x<p;x++)l[x]&&l[x][m](v)},n=function(o,x,z,c){for(x=0,z=b.length;x<z;x++)(c=b[x],(!a&&x===z-1)?o[s?"return":"throw"](c):o.next(c))},e=function(o,t){return (a&&(l[t=p++]=o),n(o),function(){a&&(l[t]=void 0)})},{__SEROVAL_STREAM__:!0,on:function(o){return e(o)},next:function(v){a&&(b.push(v),f(v,"next"))},throw:function(v){a&&(b.push(v),f(v,"throw"),a=s=!1,l.length=0)},return:function(v){a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)}})})(),o.next(1),o.next(2),o.next(3),o.return(void 0),o))})})()"`;
exports[`AsyncIterable > compat > should use function expressions instead of arrow functions. 1`] = `"(function(h,j,k,m,o){return {title:"Hello World",[h=Symbol.asyncIterator]:((j=function(s,f,p){return ((p=new Promise(function(a,b){s=a,f=b})).s=s,p.f=f,p)},function(s){return function(b,c,p,d,e,t,f){return (b=[],c=0,p=[],d=-1,e=!1,f=function(i,l){for(i=0,l=p.length;i<l;i++)p[i].s({done:!0,value:void 0})},s.on({next:function(v,t){if(t=p.shift())t.s({done:!1,value:v});b.push(v)},throw:function(v,t){if(t=p.shift())t.f(v);f(),d=b.length,e=!0,b.push(v)},return:function(v,t){if(t=p.shift())t.s({done:!0,value:v});f(),d=b.length,b.push(v)}}),t={[h]:function(){return t},next:function(i,t,v){if(d===-1){return((i=c++)>=b.length)?(p.push(t=j()),t):{done:!1,value:b[i]}}if(c>d)return{done:!0,value:void 0};if(v=b[i=c++],i!==d)return{done:!1,value:v};if(e)throw v;return{done:!0,value:v}}})}}))((o=(function(b,a,s,l,p,f,e,n){return (b=[],a=!0,s=!1,l=[],p=0,f=function(v,m,x){for(x=0;x<p;x++)l[x]&&l[x][m](v)},n=function(o,x,z,c){for(x=0,z=b.length;x<z;x++)(c=b[x],(!a&&x===z-1)?o[s?"return":"throw"](c):o.next(c))},e=function(o,t){return (a&&(l[t=p++]=o),n(o),function(){a&&(l[t]=void 0)})},{__SEROVAL_STREAM__:!0,on:function(o){return e(o)},next:function(v){a&&(b.push(v),f(v,"next"))},throw:function(v){a&&(b.push(v),f(v,"throw"),a=s=!1,l.length=0)},return:function(v){a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)}})})(),o.next(1),o.next(2),o.next(3),o.return(void 0),o))}})()"`;

exports[`AsyncIterable > compat#toJSONAsync > should use function expression instead of arrow functions. 1`] = `"{"t":{"t":10,"i":0,"p":{"k":["title",{"t":17,"i":1,"s":0}],"v":[{"t":1,"s":"Hello World"},{"t":30,"a":[{"t":29,"i":2,"a":[{"t":26,"i":3,"s":1},{"t":4,"i":1}]},{"t":31,"i":4,"a":[{"t":32,"i":4,"f":{"t":0,"s":1}},{"t":32,"i":4,"f":{"t":0,"s":2}},{"t":32,"i":4,"f":{"t":0,"s":3}},{"t":34,"i":4,"f":{"t":2,"s":1}}],"f":{"t":26,"i":5,"s":4}}]}],"s":2},"o":0},"f":29,"m":[1,4]}"`;

exports[`AsyncIterable > compat#toJSONAsync > should use function expression instead of arrow functions. 2`] = `"(function(h,j,k,m,o){return ({title:"Hello World",[h=Symbol.asyncIterator]:((j=function(s,f,p){return ((p=new Promise(function(a,b){s=a,f=b})).s=s,p.f=f,p)},function(s){return function(b,c,p,d,e,t,f){return (b=[],c=0,p=[],d=-1,e=!1,f=function(i,l){for(i=0,l=p.length;i<l;i++)p[i].s({done:!0,value:void 0})},s.on({next:function(v,t){if(t=p.shift())t.s({done:!1,value:v});b.push(v)},throw:function(v,t){if(t=p.shift())t.f(v);f(),d=b.length,e=!0,b.push(v)},return:function(v,t){if(t=p.shift())t.s({done:!0,value:v});f(),d=b.length,b.push(v)}}),t={[h]:function(){return t},next:function(i,t,v){if(d===-1){return((i=c++)>=b.length)?(p.push(t=j()),t):{done:!1,value:b[i]}}if(c>d)return{done:!0,value:void 0};if(v=b[i=c++],i!==d)return{done:!1,value:v};if(e)throw v;return{done:!0,value:v}}})}}))((o=(function(b,a,s,l,p,f,e,n){return (b=[],a=!0,s=!1,l=[],p=0,f=function(v,m,x){for(x=0;x<p;x++)l[x]&&l[x][m](v)},n=function(o,x,z,c){for(x=0,z=b.length;x<z;x++)(c=b[x],(!a&&x===z-1)?o[s?"return":"throw"](c):o.next(c))},e=function(o,t){return (a&&(l[t=p++]=o),n(o),function(){a&&(l[t]=void 0)})},{__SEROVAL_STREAM__:!0,on:function(o){return e(o)},next:function(v){a&&(b.push(v),f(v,"next"))},throw:function(v){a&&(b.push(v),f(v,"throw"),a=s=!1,l.length=0)},return:function(v){a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)}})})(),o.next(1),o.next(2),o.next(3),o.return(void 0),o))})})()"`;
exports[`AsyncIterable > compat#toJSONAsync > should use function expression instead of arrow functions. 2`] = `"(function(h,j,k,m,o){return {title:"Hello World",[h=Symbol.asyncIterator]:((j=function(s,f,p){return ((p=new Promise(function(a,b){s=a,f=b})).s=s,p.f=f,p)},function(s){return function(b,c,p,d,e,t,f){return (b=[],c=0,p=[],d=-1,e=!1,f=function(i,l){for(i=0,l=p.length;i<l;i++)p[i].s({done:!0,value:void 0})},s.on({next:function(v,t){if(t=p.shift())t.s({done:!1,value:v});b.push(v)},throw:function(v,t){if(t=p.shift())t.f(v);f(),d=b.length,e=!0,b.push(v)},return:function(v,t){if(t=p.shift())t.s({done:!0,value:v});f(),d=b.length,b.push(v)}}),t={[h]:function(){return t},next:function(i,t,v){if(d===-1){return((i=c++)>=b.length)?(p.push(t=j()),t):{done:!1,value:b[i]}}if(c>d)return{done:!0,value:void 0};if(v=b[i=c++],i!==d)return{done:!1,value:v};if(e)throw v;return{done:!0,value:v}}})}}))((o=(function(b,a,s,l,p,f,e,n){return (b=[],a=!0,s=!1,l=[],p=0,f=function(v,m,x){for(x=0;x<p;x++)l[x]&&l[x][m](v)},n=function(o,x,z,c){for(x=0,z=b.length;x<z;x++)(c=b[x],(!a&&x===z-1)?o[s?"return":"throw"](c):o.next(c))},e=function(o,t){return (a&&(l[t=p++]=o),n(o),function(){a&&(l[t]=void 0)})},{__SEROVAL_STREAM__:!0,on:function(o){return e(o)},next:function(v){a&&(b.push(v),f(v,"next"))},throw:function(v){a&&(b.push(v),f(v,"throw"),a=s=!1,l.length=0)},return:function(v){a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)}})})(),o.next(1),o.next(2),o.next(3),o.return(void 0),o))}})()"`;

exports[`AsyncIterable > crossSerializeAsync > scoped > supports AsyncIterables 1`] = `"($R=>$R[0]={title:"Hello World",[$R[1]=Symbol.asyncIterator]:(($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p),$R[2]=s=>(b,c,p,d,e,t,f)=>(b=[],c=0,p=[],d=-1,e=!1,f=(i,l)=>{for(i=0,l=p.length;i<l;i++)p[i].s({done:!0,value:void 0})},s.on({next:(v,t)=>{if(t=p.shift())t.s({done:!1,value:v});b.push(v)},throw:(v,t)=>{if(t=p.shift())t.f(v);f(),d=b.length,e=!0,b.push(v)},return:(v,t)=>{if(t=p.shift())t.s({done:!0,value:v});f(),d=b.length,b.push(v)}}),t={[$R[1]]:()=>t,next:(i,t,v)=>{if(d===-1){return((i=c++)>=b.length)?(p.push(t=$R[3]()),t):{done:!1,value:b[i]}}if(c>d)return{done:!0,value:void 0};if(v=b[i=c++],i!==d)return{done:!1,value:v};if(e)throw v;return{done:!0,value:v}}})))(($R[4]=($R[5]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x<p;x++)l[x]&&l[x][m](v)},n=(o,x,z,c)=>{for(x=0,z=b.length;x<z;x++)(c=b[x],(!a&&x===z-1)?o[s?"return":"throw"](c):o.next(c))},e=(o,t)=>(a&&(l[t=p++]=o),n(o),()=>{a&&(l[t]=void 0)}),{__SEROVAL_STREAM__:!0,on:o=>e(o),next:v=>{a&&(b.push(v),f(v,"next"))},throw:v=>{a&&(b.push(v),f(v,"throw"),a=s=!1,l.length=0)},return:v=>{a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)}}))(),$R[4].next(1),$R[4].next(2),$R[4].next(3),$R[4].return(void 0),$R[4]))})($R["example"])"`;

exports[`AsyncIterable > crossSerializeAsync > supports AsyncIterables 1`] = `"$R[0]={title:"Hello World",[$R[1]=Symbol.asyncIterator]:(($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p),$R[2]=s=>(b,c,p,d,e,t,f)=>(b=[],c=0,p=[],d=-1,e=!1,f=(i,l)=>{for(i=0,l=p.length;i<l;i++)p[i].s({done:!0,value:void 0})},s.on({next:(v,t)=>{if(t=p.shift())t.s({done:!1,value:v});b.push(v)},throw:(v,t)=>{if(t=p.shift())t.f(v);f(),d=b.length,e=!0,b.push(v)},return:(v,t)=>{if(t=p.shift())t.s({done:!0,value:v});f(),d=b.length,b.push(v)}}),t={[$R[1]]:()=>t,next:(i,t,v)=>{if(d===-1){return((i=c++)>=b.length)?(p.push(t=$R[3]()),t):{done:!1,value:b[i]}}if(c>d)return{done:!0,value:void 0};if(v=b[i=c++],i!==d)return{done:!1,value:v};if(e)throw v;return{done:!0,value:v}}})))(($R[4]=($R[5]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x<p;x++)l[x]&&l[x][m](v)},n=(o,x,z,c)=>{for(x=0,z=b.length;x<z;x++)(c=b[x],(!a&&x===z-1)?o[s?"return":"throw"](c):o.next(c))},e=(o,t)=>(a&&(l[t=p++]=o),n(o),()=>{a&&(l[t]=void 0)}),{__SEROVAL_STREAM__:!0,on:o=>e(o),next:v=>{a&&(b.push(v),f(v,"next"))},throw:v=>{a&&(b.push(v),f(v,"throw"),a=s=!1,l.length=0)},return:v=>{a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)}}))(),$R[4].next(1),$R[4].next(2),$R[4].next(3),$R[4].return(void 0),$R[4]))}"`;
exports[`AsyncIterable > crossSerializeAsync > supports AsyncIterables 1`] = `"($R[0]={title:"Hello World",[$R[1]=Symbol.asyncIterator]:(($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p),$R[2]=s=>(b,c,p,d,e,t,f)=>(b=[],c=0,p=[],d=-1,e=!1,f=(i,l)=>{for(i=0,l=p.length;i<l;i++)p[i].s({done:!0,value:void 0})},s.on({next:(v,t)=>{if(t=p.shift())t.s({done:!1,value:v});b.push(v)},throw:(v,t)=>{if(t=p.shift())t.f(v);f(),d=b.length,e=!0,b.push(v)},return:(v,t)=>{if(t=p.shift())t.s({done:!0,value:v});f(),d=b.length,b.push(v)}}),t={[$R[1]]:()=>t,next:(i,t,v)=>{if(d===-1){return((i=c++)>=b.length)?(p.push(t=$R[3]()),t):{done:!1,value:b[i]}}if(c>d)return{done:!0,value:void 0};if(v=b[i=c++],i!==d)return{done:!1,value:v};if(e)throw v;return{done:!0,value:v}}})))(($R[4]=($R[5]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x<p;x++)l[x]&&l[x][m](v)},n=(o,x,z,c)=>{for(x=0,z=b.length;x<z;x++)(c=b[x],(!a&&x===z-1)?o[s?"return":"throw"](c):o.next(c))},e=(o,t)=>(a&&(l[t=p++]=o),n(o),()=>{a&&(l[t]=void 0)}),{__SEROVAL_STREAM__:!0,on:o=>e(o),next:v=>{a&&(b.push(v),f(v,"next"))},throw:v=>{a&&(b.push(v),f(v,"throw"),a=s=!1,l.length=0)},return:v=>{a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)}}))(),$R[4].next(1),$R[4].next(2),$R[4].next(3),$R[4].return(void 0),$R[4]))})"`;

exports[`AsyncIterable > crossSerializeStream > scoped > supports AsyncIterables 1`] = `"($R=>$R[0]={title:"Hello World",[$R[1]=Symbol.asyncIterator]:(($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p),$R[2]=s=>(b,c,p,d,e,t,f)=>(b=[],c=0,p=[],d=-1,e=!1,f=(i,l)=>{for(i=0,l=p.length;i<l;i++)p[i].s({done:!0,value:void 0})},s.on({next:(v,t)=>{if(t=p.shift())t.s({done:!1,value:v});b.push(v)},throw:(v,t)=>{if(t=p.shift())t.f(v);f(),d=b.length,e=!0,b.push(v)},return:(v,t)=>{if(t=p.shift())t.s({done:!0,value:v});f(),d=b.length,b.push(v)}}),t={[$R[1]]:()=>t,next:(i,t,v)=>{if(d===-1){return((i=c++)>=b.length)?(p.push(t=$R[3]()),t):{done:!1,value:b[i]}}if(c>d)return{done:!0,value:void 0};if(v=b[i=c++],i!==d)return{done:!1,value:v};if(e)throw v;return{done:!0,value:v}}})))($R[4]=($R[5]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x<p;x++)l[x]&&l[x][m](v)},n=(o,x,z,c)=>{for(x=0,z=b.length;x<z;x++)(c=b[x],(!a&&x===z-1)?o[s?"return":"throw"](c):o.next(c))},e=(o,t)=>(a&&(l[t=p++]=o),n(o),()=>{a&&(l[t]=void 0)}),{__SEROVAL_STREAM__:!0,on:o=>e(o),next:v=>{a&&(b.push(v),f(v,"next"))},throw:v=>{a&&(b.push(v),f(v,"throw"),a=s=!1,l.length=0)},return:v=>{a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)}}))())})($R["example"])"`;

Expand All @@ -20,7 +20,7 @@ exports[`AsyncIterable > crossSerializeStream > scoped > supports AsyncIterables

exports[`AsyncIterable > crossSerializeStream > scoped > supports AsyncIterables 5`] = `"($R=>$R[4].return(void 0))($R["example"])"`;

exports[`AsyncIterable > crossSerializeStream > supports AsyncIterables 1`] = `"$R[0]={title:"Hello World",[$R[1]=Symbol.asyncIterator]:(($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p),$R[2]=s=>(b,c,p,d,e,t,f)=>(b=[],c=0,p=[],d=-1,e=!1,f=(i,l)=>{for(i=0,l=p.length;i<l;i++)p[i].s({done:!0,value:void 0})},s.on({next:(v,t)=>{if(t=p.shift())t.s({done:!1,value:v});b.push(v)},throw:(v,t)=>{if(t=p.shift())t.f(v);f(),d=b.length,e=!0,b.push(v)},return:(v,t)=>{if(t=p.shift())t.s({done:!0,value:v});f(),d=b.length,b.push(v)}}),t={[$R[1]]:()=>t,next:(i,t,v)=>{if(d===-1){return((i=c++)>=b.length)?(p.push(t=$R[3]()),t):{done:!1,value:b[i]}}if(c>d)return{done:!0,value:void 0};if(v=b[i=c++],i!==d)return{done:!1,value:v};if(e)throw v;return{done:!0,value:v}}})))($R[4]=($R[5]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x<p;x++)l[x]&&l[x][m](v)},n=(o,x,z,c)=>{for(x=0,z=b.length;x<z;x++)(c=b[x],(!a&&x===z-1)?o[s?"return":"throw"](c):o.next(c))},e=(o,t)=>(a&&(l[t=p++]=o),n(o),()=>{a&&(l[t]=void 0)}),{__SEROVAL_STREAM__:!0,on:o=>e(o),next:v=>{a&&(b.push(v),f(v,"next"))},throw:v=>{a&&(b.push(v),f(v,"throw"),a=s=!1,l.length=0)},return:v=>{a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)}}))())}"`;
exports[`AsyncIterable > crossSerializeStream > supports AsyncIterables 1`] = `"($R[0]={title:"Hello World",[$R[1]=Symbol.asyncIterator]:(($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p),$R[2]=s=>(b,c,p,d,e,t,f)=>(b=[],c=0,p=[],d=-1,e=!1,f=(i,l)=>{for(i=0,l=p.length;i<l;i++)p[i].s({done:!0,value:void 0})},s.on({next:(v,t)=>{if(t=p.shift())t.s({done:!1,value:v});b.push(v)},throw:(v,t)=>{if(t=p.shift())t.f(v);f(),d=b.length,e=!0,b.push(v)},return:(v,t)=>{if(t=p.shift())t.s({done:!0,value:v});f(),d=b.length,b.push(v)}}),t={[$R[1]]:()=>t,next:(i,t,v)=>{if(d===-1){return((i=c++)>=b.length)?(p.push(t=$R[3]()),t):{done:!1,value:b[i]}}if(c>d)return{done:!0,value:void 0};if(v=b[i=c++],i!==d)return{done:!1,value:v};if(e)throw v;return{done:!0,value:v}}})))($R[4]=($R[5]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x<p;x++)l[x]&&l[x][m](v)},n=(o,x,z,c)=>{for(x=0,z=b.length;x<z;x++)(c=b[x],(!a&&x===z-1)?o[s?"return":"throw"](c):o.next(c))},e=(o,t)=>(a&&(l[t=p++]=o),n(o),()=>{a&&(l[t]=void 0)}),{__SEROVAL_STREAM__:!0,on:o=>e(o),next:v=>{a&&(b.push(v),f(v,"next"))},throw:v=>{a&&(b.push(v),f(v,"throw"),a=s=!1,l.length=0)},return:v=>{a&&(b.push(v),f(v,"return"),a=!1,s=!0,l.length=0)}}))())})"`;

exports[`AsyncIterable > crossSerializeStream > supports AsyncIterables 2`] = `"$R[4].next(1)"`;

Expand Down
Loading

0 comments on commit efe0d0b

Please sign in to comment.