From af52304e1f65e0a0305020fc2c693120136b2680 Mon Sep 17 00:00:00 2001 From: "Alexis H. Munsayac" Date: Sat, 13 Jul 2024 01:15:00 +0800 Subject: [PATCH 01/10] Add `OpaqueReference` --- packages/seroval/src/core/context/parser/async.ts | 9 ++++++++- packages/seroval/src/core/context/parser/sync.ts | 9 ++++++++- packages/seroval/src/core/opaque-reference.ts | 6 ++++++ packages/seroval/src/index.ts | 10 ++++++---- 4 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 packages/seroval/src/core/opaque-reference.ts diff --git a/packages/seroval/src/core/context/parser/async.ts b/packages/seroval/src/core/context/parser/async.ts index 2821def..132b3c6 100644 --- a/packages/seroval/src/core/context/parser/async.ts +++ b/packages/seroval/src/core/context/parser/async.ts @@ -30,6 +30,7 @@ import { TRUE_NODE, UNDEFINED_NODE, } from '../../literals'; +import { OpaqueReference } from '../../opaque-reference'; import { SpecialReference } from '../../special-reference'; import type { Stream } from '../../stream'; import { createStreamFromAsyncIterable, isStream } from '../../stream'; @@ -331,6 +332,7 @@ export default abstract class BaseAsyncParserContext extends BaseParserContext { ); } + // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: private async parseObject(id: number, current: object): Promise { if (Array.isArray(current)) { return this.parseArray(id, current); @@ -338,11 +340,16 @@ export default abstract class BaseAsyncParserContext extends BaseParserContext { if (isStream(current)) { return this.parseStream(id, current); } + const currentClass = current.constructor; + if (currentClass === OpaqueReference) { + return this.parse( + (current as OpaqueReference).replacement, + ); + } const parsed = await this.parsePlugin(id, current); if (parsed) { return parsed; } - const currentClass = current.constructor; switch (currentClass) { case Object: return this.parsePlainObject( diff --git a/packages/seroval/src/core/context/parser/sync.ts b/packages/seroval/src/core/context/parser/sync.ts index 1200dce..031321d 100644 --- a/packages/seroval/src/core/context/parser/sync.ts +++ b/packages/seroval/src/core/context/parser/sync.ts @@ -26,6 +26,7 @@ import { TRUE_NODE, UNDEFINED_NODE, } from '../../literals'; +import { OpaqueReference } from '../../opaque-reference'; import { SpecialReference } from '../../special-reference'; import type { Stream } from '../../stream'; import { createStream, isStream } from '../../stream'; @@ -240,6 +241,7 @@ export default abstract class BaseSyncParserContext extends BaseParserContext { return this.createPromiseConstructorNode(id); } + // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: protected parseObject(id: number, current: object): SerovalNode { if (Array.isArray(current)) { return this.parseArray(id, current); @@ -247,11 +249,16 @@ export default abstract class BaseSyncParserContext extends BaseParserContext { if (isStream(current)) { return this.parseStream(id, current); } + const currentClass = current.constructor; + if (currentClass === OpaqueReference) { + return this.parse( + (current as OpaqueReference).replacement, + ); + } const parsed = this.parsePlugin(id, current); if (parsed) { return parsed; } - const currentClass = current.constructor; switch (currentClass) { case Object: return this.parsePlainObject( diff --git a/packages/seroval/src/core/opaque-reference.ts b/packages/seroval/src/core/opaque-reference.ts new file mode 100644 index 0000000..675e77e --- /dev/null +++ b/packages/seroval/src/core/opaque-reference.ts @@ -0,0 +1,6 @@ +export class OpaqueReference { + constructor( + public value: V, + public replacement?: R, + ) {} +} diff --git a/packages/seroval/src/index.ts b/packages/seroval/src/index.ts index 7c8406b..eb8f7c7 100644 --- a/packages/seroval/src/index.ts +++ b/packages/seroval/src/index.ts @@ -1,16 +1,18 @@ export { Feature } from './core/compat'; export { createReference } from './core/reference'; -export * from './core/tree'; export * from './core/cross'; +export * from './core/tree'; export { getCrossReferenceHeader } from './core/keys'; -export { default as Serializer } from './core/Serializer'; export * from './core/plugin'; +export { default as Serializer } from './core/Serializer'; -export type { Stream } from './core/stream'; export { createStream } from './core/stream'; +export type { Stream } from './core/stream'; -export type { SerovalNode } from './core/types'; export * from './core/errors'; +export type { SerovalNode } from './core/types'; + +export { OpaqueReference } from './core/opaque-reference'; From 49d672870888895da3ffd91ae1b6dd047db0647d Mon Sep 17 00:00:00 2001 From: "Alexis H. Munsayac" Date: Sat, 13 Jul 2024 01:30:32 +0800 Subject: [PATCH 02/10] Add tests --- .../__snapshots__/async-iterable.test.ts.snap | 14 +- .../__snapshots__/frozen-object.test.ts.snap | 10 +- .../null-constructor.test.ts.snap | 10 +- .../test/__snapshots__/object.test.ts.snap | 10 +- .../opaque-reference.test.ts.snap | 53 ++++ .../__snapshots__/sealed-object.test.ts.snap | 10 +- .../seroval/test/opaque-reference.test.ts | 287 ++++++++++++++++++ 7 files changed, 367 insertions(+), 27 deletions(-) create mode 100644 packages/seroval/test/__snapshots__/opaque-reference.test.ts.snap create mode 100644 packages/seroval/test/opaque-reference.test.ts diff --git a/packages/seroval/test/__snapshots__/async-iterable.test.ts.snap b/packages/seroval/test/__snapshots__/async-iterable.test.ts.snap index ecdbb71..c47b346 100644 --- a/packages/seroval/test/__snapshots__/async-iterable.test.ts.snap +++ b/packages/seroval/test/__snapshots__/async-iterable.test.ts.snap @@ -1,16 +1,16 @@ // 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=b.length)?(p.push(t=j()),t):{done:!0,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 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=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 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=b.length)?(p.push(t=j()),t):{done:!0,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 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=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 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{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:!0,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{for(x=0,z=b.length;x(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 > 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{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{for(x=0,z=b.length;x(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{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:!0,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{for(x=0,z=b.length;x(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{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{for(x=0,z=b.length;x(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{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:!0,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{for(x=0,z=b.length;x(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"])"`; +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{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{for(x=0,z=b.length;x(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"])"`; exports[`AsyncIterable > crossSerializeStream > scoped > supports AsyncIterables 2`] = `"($R=>$R[4].next(1))($R["example"])"`; @@ -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{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:!0,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{for(x=0,z=b.length;x(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{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{for(x=0,z=b.length;x(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)"`; @@ -30,7 +30,7 @@ exports[`AsyncIterable > crossSerializeStream > supports AsyncIterables 4`] = `" exports[`AsyncIterable > crossSerializeStream > supports AsyncIterables 5`] = `"$R[4].return(void 0)"`; -exports[`AsyncIterable > serializeAsync > supports AsyncIterables 1`] = `"((h,j,k,m,o)=>({title:"Hello World",[h=Symbol.asyncIterator]:((j=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p),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{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={[h]:()=>t,next:(i,t,v)=>{if(d===-1){return((i=c++)>=b.length)?(p.push(t=j()),t):{done:!0,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=((b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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)}}))(),o.next(1),o.next(2),o.next(3),o.return(void 0),o))}))()"`; +exports[`AsyncIterable > serializeAsync > supports AsyncIterables 1`] = `"((h,j,k,m,o)=>({title:"Hello World",[h=Symbol.asyncIterator]:((j=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p),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{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={[h]:()=>t,next:(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=((b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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)}}))(),o.next(1),o.next(2),o.next(3),o.return(void 0),o))}))()"`; exports[`AsyncIterable > toCrossJSONAsync > supports AsyncIterables 1`] = `"{"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}"`; diff --git a/packages/seroval/test/__snapshots__/frozen-object.test.ts.snap b/packages/seroval/test/__snapshots__/frozen-object.test.ts.snap index 2bc8faa..d56cdd6 100644 --- a/packages/seroval/test/__snapshots__/frozen-object.test.ts.snap +++ b/packages/seroval/test/__snapshots__/frozen-object.test.ts.snap @@ -14,7 +14,7 @@ exports[`frozen object > crossSerialize > supports self-recursion 1`] = `"($R[0] exports[`frozen object > crossSerializeAsync > scoped > supports Objects 1`] = `"($R=>$R[0]=Promise.resolve($R[1]={example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"}),Object.freeze($R[1]),$R[0])($R["example"])"`; -exports[`frozen object > crossSerializeAsync > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]={[$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{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:!0,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{for(x=0,z=b.length;x(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]))},Object.freeze($R[0]),$R[0])($R["example"])"`; +exports[`frozen object > crossSerializeAsync > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]={[$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{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{for(x=0,z=b.length;x(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]))},Object.freeze($R[0]),$R[0])($R["example"])"`; exports[`frozen object > crossSerializeAsync > scoped > supports Symbol.iterator 1`] = `"($R=>$R[0]=Promise.resolve($R[1]={[$R[2]=Symbol.iterator]:($R[3]=s=>(i,c,d,t)=>(i=0,t={[$R[2]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};if(d=s.v[c=i++],c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[4]={v:$R[5]=[1,2,3,void 0],t:-1,d:3})}),Object.freeze($R[1]),$R[0])($R["example"])"`; @@ -22,7 +22,7 @@ exports[`frozen object > crossSerializeAsync > scoped > supports self-recursion exports[`frozen object > crossSerializeAsync > supports Objects 1`] = `"($R[0]=Promise.resolve($R[1]={example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"}),Object.freeze($R[1]),$R[0])"`; -exports[`frozen object > crossSerializeAsync > supports Symbol.asyncIterator 1`] = `"($R[0]={[$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{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:!0,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{for(x=0,z=b.length;x(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]))},Object.freeze($R[0]),$R[0])"`; +exports[`frozen object > crossSerializeAsync > supports Symbol.asyncIterator 1`] = `"($R[0]={[$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{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{for(x=0,z=b.length;x(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]))},Object.freeze($R[0]),$R[0])"`; exports[`frozen object > crossSerializeAsync > supports Symbol.iterator 1`] = `"($R[0]=Promise.resolve($R[1]={[$R[2]=Symbol.iterator]:($R[3]=s=>(i,c,d,t)=>(i=0,t={[$R[2]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};if(d=s.v[c=i++],c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[4]={v:$R[5]=[1,2,3,void 0],t:-1,d:3})}),Object.freeze($R[1]),$R[0])"`; @@ -32,7 +32,7 @@ exports[`frozen object > crossSerializeStream > scoped > supports Objects 1`] = exports[`frozen object > crossSerializeStream > scoped > supports Objects 2`] = `"($R=>($R[3]=(p,d)=>{p.s(d),p.status="success",p.value=d;delete p.s;delete p.f})($R[0],$R[2]={example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"}),Object.freeze($R[2]),$R[0])($R["example"])"`; -exports[`frozen object > crossSerializeStream > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]={[$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{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:!0,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{for(x=0,z=b.length;x(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)}}))())},Object.freeze($R[0]),$R[0])($R["example"])"`; +exports[`frozen object > crossSerializeStream > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]={[$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{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{for(x=0,z=b.length;x(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)}}))())},Object.freeze($R[0]),$R[0])($R["example"])"`; exports[`frozen object > crossSerializeStream > scoped > supports Symbol.asyncIterator 2`] = `"($R=>$R[4].next(1))($R["example"])"`; @@ -56,7 +56,7 @@ exports[`frozen object > crossSerializeStream > supports Objects 1`] = `"$R[0]=( exports[`frozen object > crossSerializeStream > supports Objects 2`] = `"(($R[3]=(p,d)=>{p.s(d),p.status="success",p.value=d;delete p.s;delete p.f})($R[0],$R[2]={example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"}),Object.freeze($R[2]),$R[0])"`; -exports[`frozen object > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"($R[0]={[$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{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:!0,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{for(x=0,z=b.length;x(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)}}))())},Object.freeze($R[0]),$R[0])"`; +exports[`frozen object > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"($R[0]={[$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{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{for(x=0,z=b.length;x(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)}}))())},Object.freeze($R[0]),$R[0])"`; exports[`frozen object > crossSerializeStream > supports Symbol.asyncIterator 2`] = `"$R[4].next(1)"`; @@ -84,7 +84,7 @@ exports[`frozen object > serialize > supports self-recursion 1`] = `"(h=>(h={},h exports[`frozen object > serializeAsync > supports Objects 1`] = `"((h,j)=>(j=Promise.resolve(h={example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"}),Object.freeze(h),j))()"`; -exports[`frozen object > serializeAsync > supports Symbol.asyncIterator 1`] = `"((h,j,k,m,o,q)=>(h={[j=Symbol.asyncIterator]:((k=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p),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{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={[j]:()=>t,next:(i,t,v)=>{if(d===-1){return((i=c++)>=b.length)?(p.push(t=k()),t):{done:!0,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}}})))((q=((b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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)}}))(),q.next(1),q.next(2),q.next(3),q.return(void 0),q))},Object.freeze(h),h))()"`; +exports[`frozen object > serializeAsync > supports Symbol.asyncIterator 1`] = `"((h,j,k,m,o,q)=>(h={[j=Symbol.asyncIterator]:((k=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p),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{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={[j]:()=>t,next:(i,t,v)=>{if(d===-1){return((i=c++)>=b.length)?(p.push(t=k()),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}}})))((q=((b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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)}}))(),q.next(1),q.next(2),q.next(3),q.return(void 0),q))},Object.freeze(h),h))()"`; exports[`frozen object > serializeAsync > supports Symbol.iterator 1`] = `"((h,j,k,m)=>(m=Promise.resolve(h={[j=Symbol.iterator]:(s=>(i,c,d,t)=>(i=0,t={[j]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};if(d=s.v[c=i++],c===s.t)throw d;return{done:c===s.d,value:d}}}))({v:[1,2,3,void 0],t:-1,d:3})}),Object.freeze(h),m))()"`; diff --git a/packages/seroval/test/__snapshots__/null-constructor.test.ts.snap b/packages/seroval/test/__snapshots__/null-constructor.test.ts.snap index ee11f4d..e7cdc9b 100644 --- a/packages/seroval/test/__snapshots__/null-constructor.test.ts.snap +++ b/packages/seroval/test/__snapshots__/null-constructor.test.ts.snap @@ -20,7 +20,7 @@ exports[`null-constructor > crossSerialize > supports self-recursion 1`] = `"($R exports[`null-constructor > crossSerializeAsync > scoped > supports Object.create(null) 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=Object.assign(Object.create(null),{example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"})))($R["example"])"`; -exports[`null-constructor > crossSerializeAsync > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]=Object.assign(Object.create(null),{[$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{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:!0,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{for(x=0,z=b.length;x(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[`null-constructor > crossSerializeAsync > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]=Object.assign(Object.create(null),{[$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{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{for(x=0,z=b.length;x(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[`null-constructor > crossSerializeAsync > scoped > supports Symbol.iterator 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=Object.assign(Object.create(null),{[$R[2]=Symbol.iterator]:($R[3]=s=>(i,c,d,t)=>(i=0,t={[$R[2]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};if(d=s.v[c=i++],c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[4]={v:$R[5]=[1,2,3,void 0],t:-1,d:3})})))($R["example"])"`; @@ -28,7 +28,7 @@ exports[`null-constructor > crossSerializeAsync > scoped > supports self-recursi exports[`null-constructor > crossSerializeAsync > supports Object.create(null) 1`] = `"$R[0]=Promise.resolve($R[1]=Object.assign(Object.create(null),{example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"}))"`; -exports[`null-constructor > crossSerializeAsync > supports Symbol.asyncIterator 1`] = `"$R[0]=Object.assign(Object.create(null),{[$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{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:!0,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{for(x=0,z=b.length;x(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[`null-constructor > crossSerializeAsync > supports Symbol.asyncIterator 1`] = `"$R[0]=Object.assign(Object.create(null),{[$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{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{for(x=0,z=b.length;x(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[`null-constructor > crossSerializeAsync > supports Symbol.iterator 1`] = `"$R[0]=Promise.resolve($R[1]=Object.assign(Object.create(null),{[$R[2]=Symbol.iterator]:($R[3]=s=>(i,c,d,t)=>(i=0,t={[$R[2]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};if(d=s.v[c=i++],c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[4]={v:$R[5]=[1,2,3,void 0],t:-1,d:3})}))"`; @@ -38,7 +38,7 @@ exports[`null-constructor > crossSerializeStream > scoped > supports Object.crea exports[`null-constructor > crossSerializeStream > scoped > supports Object.create(null) 2`] = `"($R=>($R[3]=(p,d)=>{p.s(d),p.status="success",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Object.assign(Object.create(null),{example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"})))($R["example"])"`; -exports[`null-constructor > crossSerializeStream > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]=Object.assign(Object.create(null),{[$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{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:!0,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{for(x=0,z=b.length;x(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"])"`; +exports[`null-constructor > crossSerializeStream > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]=Object.assign(Object.create(null),{[$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{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{for(x=0,z=b.length;x(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"])"`; exports[`null-constructor > crossSerializeStream > scoped > supports Symbol.asyncIterator 2`] = `"($R=>$R[4].next(1))($R["example"])"`; @@ -62,7 +62,7 @@ exports[`null-constructor > crossSerializeStream > supports Object.create(null) exports[`null-constructor > crossSerializeStream > supports Object.create(null) 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status="success",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Object.assign(Object.create(null),{example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"}))"`; -exports[`null-constructor > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"$R[0]=Object.assign(Object.create(null),{[$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{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:!0,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{for(x=0,z=b.length;x(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[`null-constructor > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"$R[0]=Object.assign(Object.create(null),{[$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{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{for(x=0,z=b.length;x(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[`null-constructor > crossSerializeStream > supports Symbol.asyncIterator 2`] = `"$R[4].next(1)"`; @@ -90,7 +90,7 @@ exports[`null-constructor > serialize > supports self-recursion 1`] = `"(h=>(h=O exports[`null-constructor > serializeAsync > supports Object.create(null) 1`] = `"Promise.resolve(Object.assign(Object.create(null),{example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"}))"`; -exports[`null-constructor > serializeAsync > supports Symbol.asyncIterator 1`] = `"((h,j,k,m,o)=>(Object.assign(Object.create(null),{[h=Symbol.asyncIterator]:((j=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p),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{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={[h]:()=>t,next:(i,t,v)=>{if(d===-1){return((i=c++)>=b.length)?(p.push(t=j()),t):{done:!0,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=((b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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)}}))(),o.next(1),o.next(2),o.next(3),o.return(void 0),o))})))()"`; +exports[`null-constructor > serializeAsync > supports Symbol.asyncIterator 1`] = `"((h,j,k,m,o)=>(Object.assign(Object.create(null),{[h=Symbol.asyncIterator]:((j=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p),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{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={[h]:()=>t,next:(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=((b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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)}}))(),o.next(1),o.next(2),o.next(3),o.return(void 0),o))})))()"`; exports[`null-constructor > serializeAsync > supports Symbol.iterator 1`] = `"((h,j)=>(Promise.resolve(Object.assign(Object.create(null),{[h=Symbol.iterator]:(s=>(i,c,d,t)=>(i=0,t={[h]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};if(d=s.v[c=i++],c===s.t)throw d;return{done:c===s.d,value:d}}}))({v:[1,2,3,void 0],t:-1,d:3})}))))()"`; diff --git a/packages/seroval/test/__snapshots__/object.test.ts.snap b/packages/seroval/test/__snapshots__/object.test.ts.snap index 820154d..c337992 100644 --- a/packages/seroval/test/__snapshots__/object.test.ts.snap +++ b/packages/seroval/test/__snapshots__/object.test.ts.snap @@ -20,7 +20,7 @@ exports[`objects > crossSerialize > supports self-recursion 1`] = `"($R[0]={},$R exports[`objects > crossSerializeAsync > scoped > supports Objects 1`] = `"($R=>$R[0]=Promise.resolve($R[1]={example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"}))($R["example"])"`; -exports[`objects > crossSerializeAsync > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]={[$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{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:!0,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{for(x=0,z=b.length;x(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[`objects > crossSerializeAsync > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]={[$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{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{for(x=0,z=b.length;x(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[`objects > crossSerializeAsync > scoped > supports Symbol.iterator 1`] = `"($R=>$R[0]=Promise.resolve($R[1]={[$R[2]=Symbol.iterator]:($R[3]=s=>(i,c,d,t)=>(i=0,t={[$R[2]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};if(d=s.v[c=i++],c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[4]={v:$R[5]=[1,2,3,void 0],t:-1,d:3})}))($R["example"])"`; @@ -28,7 +28,7 @@ exports[`objects > crossSerializeAsync > scoped > supports self-recursion 1`] = exports[`objects > crossSerializeAsync > supports Objects 1`] = `"$R[0]=Promise.resolve($R[1]={example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"})"`; -exports[`objects > crossSerializeAsync > supports Symbol.asyncIterator 1`] = `"$R[0]={[$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{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:!0,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{for(x=0,z=b.length;x(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[`objects > crossSerializeAsync > supports Symbol.asyncIterator 1`] = `"$R[0]={[$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{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{for(x=0,z=b.length;x(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[`objects > crossSerializeAsync > supports Symbol.iterator 1`] = `"$R[0]=Promise.resolve($R[1]={[$R[2]=Symbol.iterator]:($R[3]=s=>(i,c,d,t)=>(i=0,t={[$R[2]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};if(d=s.v[c=i++],c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[4]={v:$R[5]=[1,2,3,void 0],t:-1,d:3})})"`; @@ -38,7 +38,7 @@ exports[`objects > crossSerializeStream > scoped > supports Objects 1`] = `"($R= exports[`objects > crossSerializeStream > scoped > supports Objects 2`] = `"($R=>($R[3]=(p,d)=>{p.s(d),p.status="success",p.value=d;delete p.s;delete p.f})($R[0],$R[2]={example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"}))($R["example"])"`; -exports[`objects > crossSerializeStream > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]={[$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{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:!0,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{for(x=0,z=b.length;x(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"])"`; +exports[`objects > crossSerializeStream > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]={[$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{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{for(x=0,z=b.length;x(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"])"`; exports[`objects > crossSerializeStream > scoped > supports Symbol.asyncIterator 2`] = `"($R=>$R[4].next(1))($R["example"])"`; @@ -62,7 +62,7 @@ exports[`objects > crossSerializeStream > supports Objects 1`] = `"$R[0]=($R[1]= exports[`objects > crossSerializeStream > supports Objects 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status="success",p.value=d;delete p.s;delete p.f})($R[0],$R[2]={example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"})"`; -exports[`objects > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"$R[0]={[$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{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:!0,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{for(x=0,z=b.length;x(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[`objects > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"$R[0]={[$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{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{for(x=0,z=b.length;x(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[`objects > crossSerializeStream > supports Symbol.asyncIterator 2`] = `"$R[4].next(1)"`; @@ -90,7 +90,7 @@ exports[`objects > serialize > supports self-recursion 1`] = `"(h=>(h={},h.b=h.a exports[`objects > serializeAsync > supports Objects 1`] = `"Promise.resolve({example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"})"`; -exports[`objects > serializeAsync > supports Symbol.asyncIterator 1`] = `"((h,j,k,m,o)=>({[h=Symbol.asyncIterator]:((j=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p),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{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={[h]:()=>t,next:(i,t,v)=>{if(d===-1){return((i=c++)>=b.length)?(p.push(t=j()),t):{done:!0,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=((b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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)}}))(),o.next(1),o.next(2),o.next(3),o.return(void 0),o))}))()"`; +exports[`objects > serializeAsync > supports Symbol.asyncIterator 1`] = `"((h,j,k,m,o)=>({[h=Symbol.asyncIterator]:((j=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p),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{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={[h]:()=>t,next:(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=((b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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)}}))(),o.next(1),o.next(2),o.next(3),o.return(void 0),o))}))()"`; exports[`objects > serializeAsync > supports Symbol.iterator 1`] = `"((h,j)=>(Promise.resolve({[h=Symbol.iterator]:(s=>(i,c,d,t)=>(i=0,t={[h]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};if(d=s.v[c=i++],c===s.t)throw d;return{done:c===s.d,value:d}}}))({v:[1,2,3,void 0],t:-1,d:3})})))()"`; diff --git a/packages/seroval/test/__snapshots__/opaque-reference.test.ts.snap b/packages/seroval/test/__snapshots__/opaque-reference.test.ts.snap new file mode 100644 index 0000000..15acc02 --- /dev/null +++ b/packages/seroval/test/__snapshots__/opaque-reference.test.ts.snap @@ -0,0 +1,53 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`OpaqueReference > crossSerialize > scoped > supports OpaqueReference 1`] = `"($R=>$R[0]={transparent:"This is transparent",opaque:void 0})($R["example"])"`; + +exports[`OpaqueReference > crossSerialize > scoped > supports OpaqueReference with replacement 1`] = `"$R[0]={transparent:"This is transparent",opaque:"This is a dummy value."}"`; + +exports[`OpaqueReference > crossSerialize > supports OpaqueReference 1`] = `"$R[0]={transparent:"This is transparent",opaque:void 0}"`; + +exports[`OpaqueReference > crossSerialize > supports OpaqueReference with replacement 1`] = `"$R[0]={transparent:"This is transparent",opaque:"This is a dummy value."}"`; + +exports[`OpaqueReference > crossSerializeAsync > scoped > supports OpaqueReference 1`] = `"($R=>$R[0]={transparent:"This is transparent",opaque:void 0})($R["example"])"`; + +exports[`OpaqueReference > crossSerializeAsync > scoped > supports OpaqueReference with replacement 1`] = `"($R=>$R[0]={transparent:"This is transparent",opaque:"This is a dummy value."})($R["example"])"`; + +exports[`OpaqueReference > crossSerializeAsync > supports OpaqueReference 1`] = `"$R[0]={transparent:"This is transparent",opaque:void 0}"`; + +exports[`OpaqueReference > crossSerializeAsync > supports OpaqueReference with replacement 1`] = `"$R[0]={transparent:"This is transparent",opaque:"This is a dummy value."}"`; + +exports[`OpaqueReference > crossSerializeStream > scoped > supports OpaqueReference 1`] = `"($R=>$R[0]={transparent:"This is transparent",opaque:void 0})($R["example"])"`; + +exports[`OpaqueReference > crossSerializeStream > scoped > supports OpaqueReference with replacement 1`] = `"($R=>$R[0]={transparent:"This is transparent",opaque:"This is a dummy value."})($R["example"])"`; + +exports[`OpaqueReference > crossSerializeStream > supports OpaqueReference 1`] = `"$R[0]={transparent:"This is transparent",opaque:void 0}"`; + +exports[`OpaqueReference > crossSerializeStream > supports OpaqueReference with replacement 1`] = `"$R[0]={transparent:"This is transparent",opaque:"This is a dummy value."}"`; + +exports[`OpaqueReference > serialize > supports OpaqueReference 1`] = `"({transparent:"This is transparent",opaque:void 0})"`; + +exports[`OpaqueReference > serialize > supports OpaqueReference with replacement 1`] = `"({transparent:"This is transparent",opaque:"This is a dummy value."})"`; + +exports[`OpaqueReference > serializeAsync > supports OpaqueReference 1`] = `"({transparent:"This is transparent",opaque:void 0})"`; + +exports[`OpaqueReference > serializeAsync > supports OpaqueReference with replacement 1`] = `"({transparent:"This is transparent",opaque:"This is a dummy value."})"`; + +exports[`OpaqueReference > toCrossJSON > supports OpaqueReference 1`] = `"{"t":10,"i":0,"p":{"k":["transparent","opaque"],"v":[{"t":1,"s":"This is transparent"},{"t":2,"s":1}],"s":2},"o":0}"`; + +exports[`OpaqueReference > toCrossJSON > supports OpaqueReference with replacement 1`] = `"{"t":10,"i":0,"p":{"k":["transparent","opaque"],"v":[{"t":1,"s":"This is transparent"},{"t":1,"s":"This is a dummy value."}],"s":2},"o":0}"`; + +exports[`OpaqueReference > toCrossJSONAsync > supports OpaqueReference 1`] = `"{"t":10,"i":0,"p":{"k":["transparent","opaque"],"v":[{"t":1,"s":"This is transparent"},{"t":2,"s":1}],"s":2},"o":0}"`; + +exports[`OpaqueReference > toCrossJSONAsync > supports OpaqueReference with replacement 1`] = `"{"t":10,"i":0,"p":{"k":["transparent","opaque"],"v":[{"t":1,"s":"This is transparent"},{"t":1,"s":"This is a dummy value."}],"s":2},"o":0}"`; + +exports[`OpaqueReference > toCrossJSONStream > supports OpaqueReference 1`] = `"{"t":10,"i":0,"p":{"k":["transparent","opaque"],"v":[{"t":1,"s":"This is transparent"},{"t":2,"s":1}],"s":2},"o":0}"`; + +exports[`OpaqueReference > toCrossJSONStream > supports OpaqueReference with replacement 1`] = `"{"t":10,"i":0,"p":{"k":["transparent","opaque"],"v":[{"t":1,"s":"This is transparent"},{"t":1,"s":"This is a dummy value."}],"s":2},"o":0}"`; + +exports[`OpaqueReference > toJSON > supports OpaqueReference 1`] = `"{"t":{"t":10,"i":0,"p":{"k":["transparent","opaque"],"v":[{"t":1,"s":"This is transparent"},{"t":2,"s":1}],"s":2},"o":0},"f":31,"m":[]}"`; + +exports[`OpaqueReference > toJSON > supports OpaqueReference with replacement 1`] = `"{"t":{"t":10,"i":0,"p":{"k":["transparent","opaque"],"v":[{"t":1,"s":"This is transparent"},{"t":1,"s":"This is a dummy value."}],"s":2},"o":0},"f":31,"m":[]}"`; + +exports[`OpaqueReference > toJSONAsync > supports OpaqueReference 1`] = `"{"t":{"t":10,"i":0,"p":{"k":["transparent","opaque"],"v":[{"t":1,"s":"This is transparent"},{"t":2,"s":1}],"s":2},"o":0},"f":31,"m":[]}"`; + +exports[`OpaqueReference > toJSONAsync > supports OpaqueReference with replacement 1`] = `"{"t":{"t":10,"i":0,"p":{"k":["transparent","opaque"],"v":[{"t":1,"s":"This is transparent"},{"t":1,"s":"This is a dummy value."}],"s":2},"o":0},"f":31,"m":[]}"`; diff --git a/packages/seroval/test/__snapshots__/sealed-object.test.ts.snap b/packages/seroval/test/__snapshots__/sealed-object.test.ts.snap index 08f1076..9b24ea2 100644 --- a/packages/seroval/test/__snapshots__/sealed-object.test.ts.snap +++ b/packages/seroval/test/__snapshots__/sealed-object.test.ts.snap @@ -14,7 +14,7 @@ exports[`sealed object > crossSerialize > supports self-recursion 1`] = `"($R[0] exports[`sealed object > crossSerializeAsync > scoped > supports Objects 1`] = `"($R=>$R[0]=Promise.resolve($R[1]={example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"}),Object.seal($R[1]),$R[0])($R["example"])"`; -exports[`sealed object > crossSerializeAsync > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]={[$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{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:!0,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{for(x=0,z=b.length;x(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]))},Object.seal($R[0]),$R[0])($R["example"])"`; +exports[`sealed object > crossSerializeAsync > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]={[$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{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{for(x=0,z=b.length;x(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]))},Object.seal($R[0]),$R[0])($R["example"])"`; exports[`sealed object > crossSerializeAsync > scoped > supports Symbol.iterator 1`] = `"($R=>$R[0]=Promise.resolve($R[1]={[$R[2]=Symbol.iterator]:($R[3]=s=>(i,c,d,t)=>(i=0,t={[$R[2]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};if(d=s.v[c=i++],c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[4]={v:$R[5]=[1,2,3,void 0],t:-1,d:3})}),Object.seal($R[1]),$R[0])($R["example"])"`; @@ -22,7 +22,7 @@ exports[`sealed object > crossSerializeAsync > scoped > supports self-recursion exports[`sealed object > crossSerializeAsync > supports Objects 1`] = `"($R[0]=Promise.resolve($R[1]={example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"}),Object.seal($R[1]),$R[0])"`; -exports[`sealed object > crossSerializeAsync > supports Symbol.asyncIterator 1`] = `"($R[0]={[$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{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:!0,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{for(x=0,z=b.length;x(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]))},Object.seal($R[0]),$R[0])"`; +exports[`sealed object > crossSerializeAsync > supports Symbol.asyncIterator 1`] = `"($R[0]={[$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{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{for(x=0,z=b.length;x(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]))},Object.seal($R[0]),$R[0])"`; exports[`sealed object > crossSerializeAsync > supports Symbol.iterator 1`] = `"($R[0]=Promise.resolve($R[1]={[$R[2]=Symbol.iterator]:($R[3]=s=>(i,c,d,t)=>(i=0,t={[$R[2]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};if(d=s.v[c=i++],c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[4]={v:$R[5]=[1,2,3,void 0],t:-1,d:3})}),Object.seal($R[1]),$R[0])"`; @@ -32,7 +32,7 @@ exports[`sealed object > crossSerializeStream > scoped > supports Objects 1`] = exports[`sealed object > crossSerializeStream > scoped > supports Objects 2`] = `"($R=>($R[3]=(p,d)=>{p.s(d),p.status="success",p.value=d;delete p.s;delete p.f})($R[0],$R[2]={example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"}),Object.seal($R[2]),$R[0])($R["example"])"`; -exports[`sealed object > crossSerializeStream > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]={[$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{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:!0,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{for(x=0,z=b.length;x(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)}}))())},Object.seal($R[0]),$R[0])($R["example"])"`; +exports[`sealed object > crossSerializeStream > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]={[$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{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{for(x=0,z=b.length;x(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)}}))())},Object.seal($R[0]),$R[0])($R["example"])"`; exports[`sealed object > crossSerializeStream > scoped > supports Symbol.asyncIterator 2`] = `"($R=>$R[4].next(1))($R["example"])"`; @@ -56,7 +56,7 @@ exports[`sealed object > crossSerializeStream > supports Objects 1`] = `"$R[0]=( exports[`sealed object > crossSerializeStream > supports Objects 2`] = `"(($R[3]=(p,d)=>{p.s(d),p.status="success",p.value=d;delete p.s;delete p.f})($R[0],$R[2]={example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"}),Object.seal($R[2]),$R[0])"`; -exports[`sealed object > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"($R[0]={[$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{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:!0,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{for(x=0,z=b.length;x(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)}}))())},Object.seal($R[0]),$R[0])"`; +exports[`sealed object > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"($R[0]={[$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{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{for(x=0,z=b.length;x(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)}}))())},Object.seal($R[0]),$R[0])"`; exports[`sealed object > crossSerializeStream > supports Symbol.asyncIterator 2`] = `"$R[4].next(1)"`; @@ -84,7 +84,7 @@ exports[`sealed object > serialize > supports self-recursion 1`] = `"(h=>(h={},h exports[`sealed object > serializeAsync > supports Objects 1`] = `"((h,j)=>(j=Promise.resolve(h={example:"valid identifier","%example":"invalid identifier","0x1":"hexadecimal","0b1":"binary","0o1":"octal","1_000":"numeric separator",1.7976931348623157e+308:"exponentiation"}),Object.seal(h),j))()"`; -exports[`sealed object > serializeAsync > supports Symbol.asyncIterator 1`] = `"((h,j,k,m,o,q)=>(h={[j=Symbol.asyncIterator]:((k=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p),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{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={[j]:()=>t,next:(i,t,v)=>{if(d===-1){return((i=c++)>=b.length)?(p.push(t=k()),t):{done:!0,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}}})))((q=((b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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)}}))(),q.next(1),q.next(2),q.next(3),q.return(void 0),q))},Object.seal(h),h))()"`; +exports[`sealed object > serializeAsync > supports Symbol.asyncIterator 1`] = `"((h,j,k,m,o,q)=>(h={[j=Symbol.asyncIterator]:((k=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p),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{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={[j]:()=>t,next:(i,t,v)=>{if(d===-1){return((i=c++)>=b.length)?(p.push(t=k()),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}}})))((q=((b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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)}}))(),q.next(1),q.next(2),q.next(3),q.return(void 0),q))},Object.seal(h),h))()"`; exports[`sealed object > serializeAsync > supports Symbol.iterator 1`] = `"((h,j,k,m)=>(m=Promise.resolve(h={[j=Symbol.iterator]:(s=>(i,c,d,t)=>(i=0,t={[j]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};if(d=s.v[c=i++],c===s.t)throw d;return{done:c===s.d,value:d}}}))({v:[1,2,3,void 0],t:-1,d:3})}),Object.seal(h),m))()"`; diff --git a/packages/seroval/test/opaque-reference.test.ts b/packages/seroval/test/opaque-reference.test.ts new file mode 100644 index 0000000..1c142c4 --- /dev/null +++ b/packages/seroval/test/opaque-reference.test.ts @@ -0,0 +1,287 @@ +import { describe, expect, it } from 'vitest'; +import { + OpaqueReference, + crossSerialize, + crossSerializeAsync, + crossSerializeStream, + deserialize, + fromCrossJSON, + fromJSON, + serialize, + serializeAsync, + toCrossJSON, + toCrossJSONAsync, + toCrossJSONStream, + toJSON, +} from '../src'; + +const EXAMPLE = { + transparent: 'This is transparent', + opaque: new OpaqueReference('This is opaque'), +}; + +const REPLACEMENT = 'This is a dummy value.'; + +const EXAMPLE_WITH_REPLACEMENT = { + transparent: 'This is transparent', + opaque: new OpaqueReference('This is opaque', REPLACEMENT), +}; + +describe('OpaqueReference', () => { + describe('serialize', () => { + it('supports OpaqueReference', () => { + const result = serialize(EXAMPLE); + expect(result).toMatchSnapshot(); + const back = deserialize(result); + expect(back.constructor).toBe(Object); + expect(back.transparent).toBe(EXAMPLE.transparent); + expect(back.opaque).toBe(undefined); + }); + it('supports OpaqueReference with replacement', () => { + const result = serialize(EXAMPLE_WITH_REPLACEMENT); + expect(result).toMatchSnapshot(); + const back = deserialize(result); + expect(back.constructor).toBe(Object); + expect(back.transparent).toBe(EXAMPLE_WITH_REPLACEMENT.transparent); + expect(back.opaque).toBe(REPLACEMENT); + }); + }); + describe('serializeAsync', () => { + it('supports OpaqueReference', async () => { + const result = await serializeAsync(EXAMPLE); + expect(result).toMatchSnapshot(); + const back = deserialize(result); + expect(back.constructor).toBe(Object); + expect(back.transparent).toBe(EXAMPLE.transparent); + expect(back.opaque).toBe(undefined); + }); + it('supports OpaqueReference with replacement', async () => { + const result = await serializeAsync(EXAMPLE_WITH_REPLACEMENT); + expect(result).toMatchSnapshot(); + const back = deserialize(result); + expect(back.constructor).toBe(Object); + expect(back.transparent).toBe(EXAMPLE_WITH_REPLACEMENT.transparent); + expect(back.opaque).toBe(REPLACEMENT); + }); + }); + describe('toJSON', () => { + it('supports OpaqueReference', () => { + const result = toJSON(EXAMPLE); + expect(JSON.stringify(result)).toMatchSnapshot(); + const back = fromJSON(result); + expect(back.constructor).toBe(Object); + expect(back.transparent).toBe(EXAMPLE.transparent); + expect(back.opaque).toBe(undefined); + }); + it('supports OpaqueReference with replacement', () => { + const result = toJSON(EXAMPLE_WITH_REPLACEMENT); + expect(JSON.stringify(result)).toMatchSnapshot(); + const back = fromJSON(result); + expect(back.constructor).toBe(Object); + expect(back.transparent).toBe(EXAMPLE_WITH_REPLACEMENT.transparent); + expect(back.opaque).toBe(REPLACEMENT); + }); + }); + describe('toJSONAsync', () => { + it('supports OpaqueReference', () => { + const result = toJSON(EXAMPLE); + expect(JSON.stringify(result)).toMatchSnapshot(); + const back = fromJSON(result); + expect(back.constructor).toBe(Object); + expect(back.transparent).toBe(EXAMPLE.transparent); + expect(back.opaque).toBe(undefined); + }); + it('supports OpaqueReference with replacement', () => { + const result = toJSON(EXAMPLE_WITH_REPLACEMENT); + expect(JSON.stringify(result)).toMatchSnapshot(); + const back = fromJSON(result); + expect(back.constructor).toBe(Object); + expect(back.transparent).toBe(EXAMPLE_WITH_REPLACEMENT.transparent); + expect(back.opaque).toBe(REPLACEMENT); + }); + }); + describe('crossSerialize', () => { + it('supports OpaqueReference', () => { + const result = crossSerialize(EXAMPLE); + expect(result).toMatchSnapshot(); + }); + it('supports OpaqueReference with replacement', () => { + const result = crossSerialize(EXAMPLE_WITH_REPLACEMENT); + expect(result).toMatchSnapshot(); + }); + describe('scoped', () => { + it('supports OpaqueReference', () => { + const result = crossSerialize(EXAMPLE, { scopeId: 'example' }); + expect(result).toMatchSnapshot(); + }); + it('supports OpaqueReference with replacement', () => { + const result = crossSerialize(EXAMPLE_WITH_REPLACEMENT); + expect(result).toMatchSnapshot(); + }); + }); + }); + describe('crossSerializeAsync', () => { + it('supports OpaqueReference', async () => { + const result = await crossSerializeAsync(EXAMPLE); + expect(result).toMatchSnapshot(); + }); + it('supports OpaqueReference with replacement', async () => { + const result = await crossSerializeAsync(EXAMPLE_WITH_REPLACEMENT); + expect(result).toMatchSnapshot(); + }); + describe('scoped', () => { + it('supports OpaqueReference', async () => { + const result = await crossSerializeAsync(EXAMPLE, { + scopeId: 'example', + }); + expect(result).toMatchSnapshot(); + }); + it('supports OpaqueReference with replacement', async () => { + const result = await crossSerializeAsync(EXAMPLE_WITH_REPLACEMENT, { + scopeId: 'example', + }); + expect(result).toMatchSnapshot(); + }); + }); + }); + describe('crossSerializeStream', () => { + it('supports OpaqueReference', async () => + new Promise((resolve, reject) => { + crossSerializeStream(EXAMPLE, { + onSerialize(data) { + expect(data).toMatchSnapshot(); + }, + onDone() { + resolve(); + }, + onError(error) { + reject(error); + }, + }); + })); + it('supports OpaqueReference with replacement', async () => + new Promise((resolve, reject) => { + crossSerializeStream(EXAMPLE_WITH_REPLACEMENT, { + onSerialize(data) { + expect(data).toMatchSnapshot(); + }, + onDone() { + resolve(); + }, + onError(error) { + reject(error); + }, + }); + })); + describe('scoped', () => { + it('supports OpaqueReference', async () => + new Promise((resolve, reject) => { + crossSerializeStream(EXAMPLE, { + scopeId: 'example', + onSerialize(data) { + expect(data).toMatchSnapshot(); + }, + onDone() { + resolve(); + }, + onError(error) { + reject(error); + }, + }); + })); + it('supports OpaqueReference with replacement', async () => + new Promise((resolve, reject) => { + crossSerializeStream(EXAMPLE_WITH_REPLACEMENT, { + scopeId: 'example', + onSerialize(data) { + expect(data).toMatchSnapshot(); + }, + onDone() { + resolve(); + }, + onError(error) { + reject(error); + }, + }); + })); + }); + }); + describe('toCrossJSON', () => { + it('supports OpaqueReference', () => { + const result = toCrossJSON(EXAMPLE); + expect(JSON.stringify(result)).toMatchSnapshot(); + const back = fromCrossJSON(result, { + refs: new Map(), + }); + + expect(back.constructor).toBe(Object); + expect(back.transparent).toBe(EXAMPLE.transparent); + expect(back.opaque).toBe(undefined); + }); + it('supports OpaqueReference with replacement', () => { + const result = toCrossJSON(EXAMPLE_WITH_REPLACEMENT); + expect(JSON.stringify(result)).toMatchSnapshot(); + const back = fromCrossJSON(result, { + refs: new Map(), + }); + + expect(back.constructor).toBe(Object); + expect(back.transparent).toBe(EXAMPLE_WITH_REPLACEMENT.transparent); + expect(back.opaque).toBe(REPLACEMENT); + }); + }); + describe('toCrossJSONAsync', () => { + it('supports OpaqueReference', async () => { + const result = await toCrossJSONAsync(EXAMPLE); + expect(JSON.stringify(result)).toMatchSnapshot(); + const back = fromCrossJSON(result, { + refs: new Map(), + }); + + expect(back.constructor).toBe(Object); + expect(back.transparent).toBe(EXAMPLE.transparent); + expect(back.opaque).toBe(undefined); + }); + it('supports OpaqueReference with replacement', async () => { + const result = await toCrossJSONAsync(EXAMPLE_WITH_REPLACEMENT); + expect(JSON.stringify(result)).toMatchSnapshot(); + const back = fromCrossJSON(result, { + refs: new Map(), + }); + + expect(back.constructor).toBe(Object); + expect(back.transparent).toBe(EXAMPLE_WITH_REPLACEMENT.transparent); + expect(back.opaque).toBe(REPLACEMENT); + }); + }); + describe('toCrossJSONStream', () => { + it('supports OpaqueReference', async () => + new Promise((resolve, reject) => { + toCrossJSONStream(EXAMPLE, { + onParse(data) { + expect(JSON.stringify(data)).toMatchSnapshot(); + }, + onDone() { + resolve(); + }, + onError(error) { + reject(error); + }, + }); + })); + it('supports OpaqueReference with replacement', async () => + new Promise((resolve, reject) => { + toCrossJSONStream(EXAMPLE_WITH_REPLACEMENT, { + onParse(data) { + expect(JSON.stringify(data)).toMatchSnapshot(); + }, + onDone() { + resolve(); + }, + onError(error) { + reject(error); + }, + }); + })); + }); +}); From 4274db279df9930788ed206b3bfdd2295eabdf6d Mon Sep 17 00:00:00 2001 From: "Alexis H. Munsayac" Date: Sat, 13 Jul 2024 01:34:23 +0800 Subject: [PATCH 03/10] Update opaque-reference.ts --- packages/seroval/src/core/opaque-reference.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/seroval/src/core/opaque-reference.ts b/packages/seroval/src/core/opaque-reference.ts index 675e77e..aa21935 100644 --- a/packages/seroval/src/core/opaque-reference.ts +++ b/packages/seroval/src/core/opaque-reference.ts @@ -1,6 +1,6 @@ export class OpaqueReference { constructor( - public value: V, - public replacement?: R, + public readonly value: V, + public readonly replacement?: R, ) {} } From fd7d88d3b57c795d47b1833505445c05a29c9c8d Mon Sep 17 00:00:00 2001 From: "Alexis H. Munsayac" Date: Sat, 13 Jul 2024 01:38:04 +0800 Subject: [PATCH 04/10] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4aaea3b..9708a51 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,7 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2.2.2 + - uses: pnpm/action-setup@v2.4.1 with: version: 8 run_install: | From 15ca4b43047a939f2d16abd2d9349f4b0e4bfdcf Mon Sep 17 00:00:00 2001 From: "Alexis H. Munsayac" Date: Sat, 13 Jul 2024 01:41:09 +0800 Subject: [PATCH 05/10] Update main.yml --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9708a51..7866904 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,18 +6,18 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2.4.1 + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 with: version: 8 run_install: | - args: [--frozen-lockfile] - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: 20 - cache: 'pnpm' - + cache: "pnpm" + - name: Clean run: pnpm recursive run clean env: From c2d4a3f29697247ad3eefe1241b0284c3a04d14e Mon Sep 17 00:00:00 2001 From: "Alexis H. Munsayac" Date: Sat, 13 Jul 2024 01:42:09 +0800 Subject: [PATCH 06/10] Update main.yml --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7866904..cebb708 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,8 +10,7 @@ jobs: - uses: pnpm/action-setup@v4 with: version: 8 - run_install: | - - args: [--frozen-lockfile] + run_install: false - uses: actions/setup-node@v4 with: From 2a4974f587490b4cefddf597542bb4cd1d05014c Mon Sep 17 00:00:00 2001 From: "Alexis H. Munsayac" Date: Sat, 13 Jul 2024 01:45:55 +0800 Subject: [PATCH 07/10] Update main.yml --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cebb708..7866904 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,8 @@ jobs: - uses: pnpm/action-setup@v4 with: version: 8 - run_install: false + run_install: | + - args: [--frozen-lockfile] - uses: actions/setup-node@v4 with: From 0ea546889419575fd965448f652e3821bb248278 Mon Sep 17 00:00:00 2001 From: "Alexis H. Munsayac" Date: Sat, 13 Jul 2024 01:47:54 +0800 Subject: [PATCH 08/10] Update main.yml --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7866904..7651d83 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,8 +10,7 @@ jobs: - uses: pnpm/action-setup@v4 with: version: 8 - run_install: | - - args: [--frozen-lockfile] + run_install: true - uses: actions/setup-node@v4 with: From 79bcdf08fa3d2b43a72b4778fe0b03583403a929 Mon Sep 17 00:00:00 2001 From: "Alexis H. Munsayac" Date: Sat, 13 Jul 2024 01:49:16 +0800 Subject: [PATCH 09/10] Fix snapshots --- .../readable-stream.test.ts.snap | 20 +++++++++---------- .../web/__snapshots__/request.test.ts.snap | 4 ++-- .../web/__snapshots__/response.test.ts.snap | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/plugins/tests/web/__snapshots__/readable-stream.test.ts.snap b/packages/plugins/tests/web/__snapshots__/readable-stream.test.ts.snap index 5ce19f9..5248203 100644 --- a/packages/plugins/tests/web/__snapshots__/readable-stream.test.ts.snap +++ b/packages/plugins/tests/web/__snapshots__/readable-stream.test.ts.snap @@ -1,14 +1,14 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`ReadableStream > crossSerializeAsync > scoped > supports ReadableStream 1`] = `"($R=>$R[0]=($R[1]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))(($R[2]=($R[3]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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[2].next("foo"),$R[2].next("bar"),$R[2].next("baz"),$R[2].return(void 0),$R[2])))($R["example"])"`; +exports[`ReadableStream > crossSerializeAsync > scoped > supports ReadableStream 1`] = `"($R=>$R[0]=($R[1]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))(($R[2]=($R[3]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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[2].next("foo"),$R[2].next("bar"),$R[2].next("baz"),$R[2].return(void 0),$R[2])))($R["example"])"`; -exports[`ReadableStream > crossSerializeAsync > scoped > supports ReadableStream errors 1`] = `"($R=>$R[0]=($R[1]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))(($R[2]=($R[3]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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[2].throw($R[4]=Object.assign(new Error("Oops!"),{stack:""})),$R[2])))($R["example"])"`; +exports[`ReadableStream > crossSerializeAsync > scoped > supports ReadableStream errors 1`] = `"($R=>$R[0]=($R[1]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))(($R[2]=($R[3]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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[2].throw($R[4]=Object.assign(new Error("Oops!"),{stack:""})),$R[2])))($R["example"])"`; -exports[`ReadableStream > crossSerializeAsync > supports ReadableStream 1`] = `"$R[0]=($R[1]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))(($R[2]=($R[3]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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[2].next("foo"),$R[2].next("bar"),$R[2].next("baz"),$R[2].return(void 0),$R[2]))"`; +exports[`ReadableStream > crossSerializeAsync > supports ReadableStream 1`] = `"$R[0]=($R[1]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))(($R[2]=($R[3]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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[2].next("foo"),$R[2].next("bar"),$R[2].next("baz"),$R[2].return(void 0),$R[2]))"`; -exports[`ReadableStream > crossSerializeAsync > supports ReadableStream errors 1`] = `"$R[0]=($R[1]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))(($R[2]=($R[3]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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[2].throw($R[4]=Object.assign(new Error("Oops!"),{stack:""})),$R[2]))"`; +exports[`ReadableStream > crossSerializeAsync > supports ReadableStream errors 1`] = `"$R[0]=($R[1]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))(($R[2]=($R[3]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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[2].throw($R[4]=Object.assign(new Error("Oops!"),{stack:""})),$R[2]))"`; -exports[`ReadableStream > crossSerializeStream > scoped > supports ReadableStream 1`] = `"($R=>$R[0]=($R[1]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))($R[2]=($R[3]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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"])"`; +exports[`ReadableStream > crossSerializeStream > scoped > supports ReadableStream 1`] = `"($R=>$R[0]=($R[1]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))($R[2]=($R[3]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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"])"`; exports[`ReadableStream > crossSerializeStream > scoped > supports ReadableStream 2`] = `"($R=>$R[2].next("foo"))($R["example"])"`; @@ -18,11 +18,11 @@ exports[`ReadableStream > crossSerializeStream > scoped > supports ReadableStrea exports[`ReadableStream > crossSerializeStream > scoped > supports ReadableStream 5`] = `"($R=>$R[2].return(void 0))($R["example"])"`; -exports[`ReadableStream > crossSerializeStream > scoped > supports ReadableStream errors 1`] = `"($R=>$R[0]=($R[1]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))($R[2]=($R[3]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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"])"`; +exports[`ReadableStream > crossSerializeStream > scoped > supports ReadableStream errors 1`] = `"($R=>$R[0]=($R[1]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))($R[2]=($R[3]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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"])"`; exports[`ReadableStream > crossSerializeStream > scoped > supports ReadableStream errors 2`] = `"($R=>$R[2].throw($R[4]=Object.assign(new Error("Oops!"),{stack:""})))($R["example"])"`; -exports[`ReadableStream > crossSerializeStream > supports ReadableStream 1`] = `"$R[0]=($R[1]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))($R[2]=($R[3]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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[`ReadableStream > crossSerializeStream > supports ReadableStream 1`] = `"$R[0]=($R[1]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))($R[2]=($R[3]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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[`ReadableStream > crossSerializeStream > supports ReadableStream 2`] = `"$R[2].next("foo")"`; @@ -32,13 +32,13 @@ exports[`ReadableStream > crossSerializeStream > supports ReadableStream 4`] = ` exports[`ReadableStream > crossSerializeStream > supports ReadableStream 5`] = `"$R[2].return(void 0)"`; -exports[`ReadableStream > crossSerializeStream > supports ReadableStream errors 1`] = `"$R[0]=($R[1]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))($R[2]=($R[3]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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[`ReadableStream > crossSerializeStream > supports ReadableStream errors 1`] = `"$R[0]=($R[1]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))($R[2]=($R[3]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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[`ReadableStream > crossSerializeStream > supports ReadableStream errors 2`] = `"$R[2].throw($R[4]=Object.assign(new Error("Oops!"),{stack:""}))"`; -exports[`ReadableStream > serializeAsync > supports ReadableStream 1`] = `"((h,j)=>((d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))((j=((b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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)}}))(),j.next("foo"),j.next("bar"),j.next("baz"),j.return(void 0),j))))()"`; +exports[`ReadableStream > serializeAsync > supports ReadableStream 1`] = `"((h,j)=>((d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))((j=((b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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)}}))(),j.next("foo"),j.next("bar"),j.next("baz"),j.return(void 0),j))))()"`; -exports[`ReadableStream > serializeAsync > supports ReadableStream errors 1`] = `"((h,j)=>((d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))((j=((b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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)}}))(),j.throw(Object.assign(new Error("Oops!"),{stack:""})),j))))()"`; +exports[`ReadableStream > serializeAsync > supports ReadableStream errors 1`] = `"((h,j)=>((d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))((j=((b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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)}}))(),j.throw(Object.assign(new Error("Oops!"),{stack:""})),j))))()"`; exports[`ReadableStream > serializeAsync > supports ReadableStream errors 2`] = `[Error: Oops!]`; diff --git a/packages/plugins/tests/web/__snapshots__/request.test.ts.snap b/packages/plugins/tests/web/__snapshots__/request.test.ts.snap index ce21581..fbbeddd 100644 --- a/packages/plugins/tests/web/__snapshots__/request.test.ts.snap +++ b/packages/plugins/tests/web/__snapshots__/request.test.ts.snap @@ -4,13 +4,13 @@ exports[`Request > crossSerializeAsync > scoped > supports Request 1`] = `"($R=> exports[`Request > crossSerializeAsync > supports Request 1`] = `"$R[0]=new Request("http://localhost:3000/",$R[1]={body:$R[2]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100,33]).buffer,cache:"default",credentials:"same-origin",headers:$R[3]=new Headers($R[4]=[$R[5]=["content-type","text/plain;charset=UTF-8"]]),integrity:"",keepalive:!1,method:"POST",mode:"cors",redirect:"follow",referrer:"about:client",referrerPolicy:""})"`; -exports[`Request > crossSerializeStream > scoped > supports Request 1`] = `"($R=>$R[0]=new Request("http://localhost:3000/",$R[1]={body:$R[2]=($R[3]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))($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{for(x=0,z=b.length;x(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)}}))()),cache:"default",credentials:"same-origin",headers:$R[6]=new Headers($R[7]=[$R[8]=["content-type","text/plain;charset=UTF-8"]]),integrity:"",keepalive:!1,method:"POST",mode:"cors",redirect:"follow",referrer:"about:client",referrerPolicy:""}))($R["example"])"`; +exports[`Request > crossSerializeStream > scoped > supports Request 1`] = `"($R=>$R[0]=new Request("http://localhost:3000/",$R[1]={body:$R[2]=($R[3]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))($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{for(x=0,z=b.length;x(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)}}))()),cache:"default",credentials:"same-origin",headers:$R[6]=new Headers($R[7]=[$R[8]=["content-type","text/plain;charset=UTF-8"]]),integrity:"",keepalive:!1,method:"POST",mode:"cors",redirect:"follow",referrer:"about:client",referrerPolicy:""}))($R["example"])"`; exports[`Request > crossSerializeStream > scoped > supports Request 2`] = `"($R=>$R[4].next($R[9]=new Uint8Array($R[10]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100,33]).buffer,0,12)))($R["example"])"`; exports[`Request > crossSerializeStream > scoped > supports Request 3`] = `"($R=>$R[4].return(void 0))($R["example"])"`; -exports[`Request > crossSerializeStream > supports Request 1`] = `"$R[0]=new Request("http://localhost:3000/",$R[1]={body:$R[2]=($R[3]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))($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{for(x=0,z=b.length;x(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)}}))()),cache:"default",credentials:"same-origin",headers:$R[6]=new Headers($R[7]=[$R[8]=["content-type","text/plain;charset=UTF-8"]]),integrity:"",keepalive:!1,method:"POST",mode:"cors",redirect:"follow",referrer:"about:client",referrerPolicy:""})"`; +exports[`Request > crossSerializeStream > supports Request 1`] = `"$R[0]=new Request("http://localhost:3000/",$R[1]={body:$R[2]=($R[3]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))($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{for(x=0,z=b.length;x(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)}}))()),cache:"default",credentials:"same-origin",headers:$R[6]=new Headers($R[7]=[$R[8]=["content-type","text/plain;charset=UTF-8"]]),integrity:"",keepalive:!1,method:"POST",mode:"cors",redirect:"follow",referrer:"about:client",referrerPolicy:""})"`; exports[`Request > crossSerializeStream > supports Request 2`] = `"$R[4].next($R[9]=new Uint8Array($R[10]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100,33]).buffer,0,12))"`; diff --git a/packages/plugins/tests/web/__snapshots__/response.test.ts.snap b/packages/plugins/tests/web/__snapshots__/response.test.ts.snap index 90b94b7..81429d9 100644 --- a/packages/plugins/tests/web/__snapshots__/response.test.ts.snap +++ b/packages/plugins/tests/web/__snapshots__/response.test.ts.snap @@ -4,13 +4,13 @@ exports[`Response > crossSerializeAsync > scoped > supports Response 1`] = `"($R exports[`Response > crossSerializeAsync > supports Response 1`] = `"$R[0]=new Response($R[1]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100,33]).buffer,$R[2]={headers:$R[3]=new Headers($R[4]=[$R[5]=["content-type","text/plain;charset=UTF-8"]]),status:200,statusText:""})"`; -exports[`Response > crossSerializeStream > scoped > supports Response 1`] = `"($R=>$R[0]=new Response($R[1]=($R[2]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))($R[3]=($R[4]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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[5]={headers:$R[6]=new Headers($R[7]=[$R[8]=["content-type","text/plain;charset=UTF-8"]]),status:200,statusText:""}))($R["example"])"`; +exports[`Response > crossSerializeStream > scoped > supports Response 1`] = `"($R=>$R[0]=new Response($R[1]=($R[2]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))($R[3]=($R[4]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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[5]={headers:$R[6]=new Headers($R[7]=[$R[8]=["content-type","text/plain;charset=UTF-8"]]),status:200,statusText:""}))($R["example"])"`; exports[`Response > crossSerializeStream > scoped > supports Response 2`] = `"($R=>$R[3].next($R[9]=new Uint8Array($R[10]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100,33]).buffer,0,12)))($R["example"])"`; exports[`Response > crossSerializeStream > scoped > supports Response 3`] = `"($R=>$R[3].return(void 0))($R["example"])"`; -exports[`Response > crossSerializeStream > supports Response 1`] = `"$R[0]=new Response($R[1]=($R[2]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))($R[3]=($R[4]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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[5]={headers:$R[6]=new Headers($R[7]=[$R[8]=["content-type","text/plain;charset=UTF-8"]]),status:200,statusText:""})"`; +exports[`Response > crossSerializeStream > supports Response 1`] = `"$R[0]=new Response($R[1]=($R[2]=d=>new ReadableStream({start:c=>{d.on({next:v=>{c.enqueue(v)},throw:v=>{c.error(v)},return:()=>{c.close()}})}}))($R[3]=($R[4]=(b,a,s,l,p,f,e,n)=>(b=[],a=!0,s=!1,l=[],p=0,f=(v,m,x)=>{for(x=0;x{for(x=0,z=b.length;x(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[5]={headers:$R[6]=new Headers($R[7]=[$R[8]=["content-type","text/plain;charset=UTF-8"]]),status:200,statusText:""})"`; exports[`Response > crossSerializeStream > supports Response 2`] = `"$R[3].next($R[9]=new Uint8Array($R[10]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100,33]).buffer,0,12))"`; From e97b924e8fbded25fd9ee348bf9dac5cf2886e3f Mon Sep 17 00:00:00 2001 From: "Alexis H. Munsayac" Date: Sat, 13 Jul 2024 02:01:39 +0800 Subject: [PATCH 10/10] Update benchmarks --- ...rge-simple-collection to string.chart.html | 14 ++--- .../charts/simple-object to string.chart.html | 14 ++--- .../small-collection to string.chart.html | 14 ++--- .../csv/large-simple-collection to string.csv | 20 +++---- .../results/csv/simple-object to string.csv | 14 ++--- .../csv/small-collection to string.csv | 20 +++---- .../large-simple-collection to string.json | 60 +++++++++---------- .../results/json/simple-object to string.json | 42 ++++++------- .../json/small-collection to string.json | 60 +++++++++---------- 9 files changed, 129 insertions(+), 129 deletions(-) diff --git a/benchmark/results/charts/large-simple-collection to string.chart.html b/benchmark/results/charts/large-simple-collection to string.chart.html index 8dbf057..78975ab 100644 --- a/benchmark/results/charts/large-simple-collection to string.chart.html +++ b/benchmark/results/charts/large-simple-collection to string.chart.html @@ -28,7 +28,7 @@
- +