diff --git a/docs/serialization.md b/docs/serialization.md index 93a2b085..541308a4 100644 --- a/docs/serialization.md +++ b/docs/serialization.md @@ -57,8 +57,6 @@ import { compileJSON } from 'seroval'; import { crossSerialize, crossSerializeAsync } from 'seroval'; ``` -Cross-reference serialization provides a different JS output, and so requires prepending a header script provided by `GLOBAL_CONTEXT_API_SCRIPT` and `getCrossReferenceHeader`. - ## Streaming serialization Async serialization allows `Promise` instances to be serialized by `await`-ing it, however, this results in a blocking process. With streaming serialization, `Promise` instances can be streamed later on, while the synchronous values can be emitted immediately. @@ -86,10 +84,7 @@ const stop = crossSerializeStream(data, { }); ``` -Like other cross-reference serialization: - -- you can define `refs` for mapping cross-referenced values. -- `crossSerializeStream` would require both `GLOBAL_CONTEXT_API_SCRIPT` and `getCrossReferenceHeader`. +Like other cross-reference serialization, you can define `refs` for mapping cross-referenced values. ### `Serializer` diff --git a/packages/seroval/src/core/cross/index.ts b/packages/seroval/src/core/cross/index.ts index 9f0e40e0..4d5ce203 100644 --- a/packages/seroval/src/core/cross/index.ts +++ b/packages/seroval/src/core/cross/index.ts @@ -1,3 +1,4 @@ +import { getCrossReferenceHeader } from '../keys'; import type { SerovalNode } from '../types'; import type { CrossAsyncParserContextOptions } from './async'; import AsyncCrossParserContext from './async'; @@ -10,6 +11,10 @@ import StreamCrossParserContext from './stream'; import type { CrossSyncParserContextOptions } from './sync'; import SyncCrossParserContext from './sync'; +function insertCrossReferenceHeader(scopeId: string | undefined, value: string): string { + return '(' + getCrossReferenceHeader(scopeId) + ',' + value + ')'; +} + export interface CrossSerializeOptions extends CrossSyncParserContextOptions, CrossContextOptions { } @@ -30,7 +35,7 @@ export function crossSerialize( scopeId: options.scopeId, markedRefs: ctx.marked, }); - return serial.serializeTop(tree); + return insertCrossReferenceHeader(options.scopeId, serial.serializeTop(tree)); } export interface CrossSerializeAsyncOptions @@ -53,7 +58,7 @@ export async function crossSerializeAsync( scopeId: options.scopeId, markedRefs: ctx.marked, }); - return serial.serializeTop(tree); + return insertCrossReferenceHeader(options.scopeId, serial.serializeTop(tree)); } export type ToCrossJSONOptions = CrossParserContextOptions; @@ -116,6 +121,10 @@ export function crossSerializeStream( return; } + if (initial) { + serialized = insertCrossReferenceHeader(options.scopeId, serialized); + } + options.onSerialize( serialized, initial, diff --git a/packages/seroval/src/core/is-serializable.new.ts b/packages/seroval/src/core/is-serializable.new.ts deleted file mode 100644 index b83816f8..00000000 --- a/packages/seroval/src/core/is-serializable.new.ts +++ /dev/null @@ -1,208 +0,0 @@ -import { ALL_ENABLED, BIGINT_FLAG, Feature } from './compat'; -import { INV_SYMBOL_REF, UNIVERSAL_SENTINEL } from './constants'; -import type { Plugin, PluginAccessOptions } from './plugin'; -import { hasReferenceID } from './reference'; -import { getErrorOptions } from './utils/error'; - -export type SerializationMode = 'sync' | 'async' | 'stream'; - -export interface IsSerializableOptions extends PluginAccessOptions { - mode: SerializationMode; - disabledFeatures?: number; -} - -class IsSerializableContext implements PluginAccessOptions { - plugins?: Plugin[] | undefined; - - mode: SerializationMode; - - features: number; - - constructor(options: IsSerializableOptions) { - this.mode = options.mode; - this.plugins = options.plugins; - this.features = ALL_ENABLED ^ (options.disabledFeatures || 0); - } - - checkArray(values: unknown[]): boolean { - if (!this.check(values[0])) { - return false; - } - for (let i = 1, len = values.length; i < len; i++) { - if (!this.check(values[i])) { - return false; - } - } - return true; - } - - checkPlainObject(value: object): boolean { - return this.checkArray(Object.values(value)); - } - - checkError(value: Error): boolean { - const options = getErrorOptions(value, this.features); - if (options) { - return this.checkPlainObject(options); - } - return true; - } - - checkPlugin(value: unknown): boolean { - const current = this.plugins; - if (current) { - for (let i = 0, len = current.length; i < len; i++) { - const plugin = current[i]; - if (plugin.test(value) && plugin.isSerializable && plugin.isSerializable(value)) { - return true; - } - } - } - return true; - } - - checkObject(value: object | null): boolean { - if (!value) { - return true; - } - if (Array.isArray(value)) { - return this.checkArray(value); - } - const currentClass = value.constructor; - switch (currentClass) { - case Date: - case RegExp: - case Number: - case Boolean: - case String: - case BigInt: - return true; - case Object: - case undefined: - return this.checkPlainObject(value); - case Error: - case EvalError: - case RangeError: - case ReferenceError: - case SyntaxError: - case TypeError: - case URIError: - return this.checkError(value as unknown as Error); - default: - break; - } - const currentFeatures = this.features; - // Promises - if ( - (currentFeatures & Feature.Promise) - && (currentClass === Promise || value instanceof Promise) - ) { - return this.mode === 'async' || this.mode === 'stream'; - } - // Typed Arrays - if (currentFeatures & Feature.TypedArray) { - switch (currentClass) { - case ArrayBuffer: - case Int8Array: - case Int16Array: - case Int32Array: - case Uint8Array: - case Uint16Array: - case Uint32Array: - case Uint8ClampedArray: - case Float32Array: - case Float64Array: - case DataView: - return true; - default: - break; - } - } - // BigInt Typed Arrays - if ((currentFeatures & BIGINT_FLAG) === BIGINT_FLAG) { - switch (currentClass) { - case BigInt64Array: - case BigUint64Array: - return true; - default: - break; - } - } - // ES Collection - if (currentFeatures & Feature.Map && currentClass === Map) { - return true; - } - if (currentFeatures & Feature.Set && currentClass === Set) { - return true; - } - // Web APIs - if (currentFeatures & Feature.WebAPI) { - switch (currentClass) { - case (typeof URL !== 'undefined' ? URL : UNIVERSAL_SENTINEL): - case (typeof URLSearchParams !== 'undefined' ? URLSearchParams : UNIVERSAL_SENTINEL): - case (typeof Headers !== 'undefined' ? Headers : UNIVERSAL_SENTINEL): - case (typeof FormData !== 'undefined' ? FormData : UNIVERSAL_SENTINEL): - case (typeof Event !== 'undefined' ? Event : UNIVERSAL_SENTINEL): - case (typeof CustomEvent !== 'undefined' ? CustomEvent : UNIVERSAL_SENTINEL): - case (typeof DOMException !== 'undefined' ? DOMException : UNIVERSAL_SENTINEL): - return true; - case (typeof Request !== 'undefined' ? Request : UNIVERSAL_SENTINEL): - case (typeof Response !== 'undefined' ? Response : UNIVERSAL_SENTINEL): - return this.mode === 'async' || this.mode === 'stream'; - case (typeof Blob !== 'undefined' ? Blob : UNIVERSAL_SENTINEL): - case (typeof File !== 'undefined' ? File : UNIVERSAL_SENTINEL): - return this.mode === 'async'; - case (typeof ReadableStream !== 'undefined' ? ReadableStream : UNIVERSAL_SENTINEL): - return this.mode === 'stream'; - default: - break; - } - } - const parsed = this.checkPlugin(value); - if (parsed) { - return parsed; - } - if ( - (currentFeatures & Feature.AggregateError) - && typeof AggregateError !== 'undefined' - && (currentClass === AggregateError || value instanceof AggregateError) - ) { - return true; - } - // Slow path. We only need to handle Errors and Iterators - // since they have very broad implementations. - if (value instanceof Error) { - return true; - } - // Generator functions don't have a global constructor - // despite existing - if (currentFeatures & Feature.Symbol && Symbol.iterator in value) { - return true; - } - return false; - } - - check(value: unknown): boolean { - switch (typeof value) { - case 'string': - case 'number': - case 'boolean': - case 'undefined': - return true; - case 'bigint': - return !!(this.features & Feature.BigInt); - case 'object': - return this.checkObject(value); - case 'symbol': - return !!(this.features & Feature.Symbol) && value in INV_SYMBOL_REF; - case 'function': - return hasReferenceID(value); - default: - return false; - } - } -} - -export function isSerializable(value: T, options: IsSerializableOptions): boolean { - return new IsSerializableContext(options).check(value); -} diff --git a/packages/seroval/src/core/keys.ts b/packages/seroval/src/core/keys.ts index ffe88b10..be400b3a 100644 --- a/packages/seroval/src/core/keys.ts +++ b/packages/seroval/src/core/keys.ts @@ -9,7 +9,7 @@ const GLOBAL_CONTEXT_R = `self.${GLOBAL_CONTEXT_REFERENCES}`; export function getCrossReferenceHeader(id?: string): string { if (id == null) { - return `${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||[];`; + return `${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||[]`; } - return `(${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||{})["${serializeString(id)}"]=[];`; + return `(${GLOBAL_CONTEXT_R}=${GLOBAL_CONTEXT_R}||{})["${serializeString(id)}"]=[]`; } diff --git a/packages/seroval/src/core/plugin.ts b/packages/seroval/src/core/plugin.ts index b302294c..286f1833 100644 --- a/packages/seroval/src/core/plugin.ts +++ b/packages/seroval/src/core/plugin.ts @@ -40,8 +40,6 @@ export interface Plugin { ctx: BaseDeserializerContext, data: PluginData, ): Value; - // isIterable?: (value: Value) => boolean; - // isSerializable?: (value: Value) => boolean; } export function createPlugin( diff --git a/packages/seroval/src/index.ts b/packages/seroval/src/index.ts index 5774d64a..2a5ddac0 100644 --- a/packages/seroval/src/index.ts +++ b/packages/seroval/src/index.ts @@ -14,8 +14,6 @@ export { createReference } from './core/reference'; export * from './core/tree'; export * from './core/cross'; -export { getCrossReferenceHeader } from './core/keys'; - export { default as Serializer } from './core/Serializer'; export * from './core/plugin'; diff --git a/packages/seroval/test/__snapshots__/array.test.ts.snap b/packages/seroval/test/__snapshots__/array.test.ts.snap index 6c76cd56..8548f8c4 100644 --- a/packages/seroval/test/__snapshots__/array.test.ts.snap +++ b/packages/seroval/test/__snapshots__/array.test.ts.snap @@ -1,36 +1,36 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`arrays > crossSerialize > scoped > supports Arrays 1`] = `"($R=>$R[0]=[1,2,3])($R[\\"example\\"])"`; +exports[`arrays > crossSerialize > scoped > supports Arrays 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=[1,2,3])($R[\\"example\\"]))"`; -exports[`arrays > crossSerialize > scoped > supports self recursion 1`] = `"($R=>$R[0]=[,,],$R[0][1]=$R[0][0]=$R[0],$R[0])($R[\\"example\\"])"`; +exports[`arrays > crossSerialize > scoped > supports self recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=[,,],$R[0][1]=$R[0][0]=$R[0],$R[0])($R[\\"example\\"]))"`; -exports[`arrays > crossSerialize > supports Arrays 1`] = `"$R[0]=[1,2,3]"`; +exports[`arrays > crossSerialize > supports Arrays 1`] = `"(self.$R=self.$R||[],$R[0]=[1,2,3])"`; -exports[`arrays > crossSerialize > supports self recursion 1`] = `"($R[0]=[,,],$R[0][1]=$R[0][0]=$R[0],$R[0])"`; +exports[`arrays > crossSerialize > supports self recursion 1`] = `"(self.$R=self.$R||[],($R[0]=[,,],$R[0][1]=$R[0][0]=$R[0],$R[0]))"`; -exports[`arrays > crossSerializeAsync > scoped > supports Arrays 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=[1,2,3]))($R[\\"example\\"])"`; +exports[`arrays > crossSerializeAsync > scoped > supports Arrays 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=[1,2,3]))($R[\\"example\\"]))"`; -exports[`arrays > crossSerializeAsync > scoped > supports self recursion 1`] = `"($R=>$R[0]=[$R[1]=Promise.resolve().then(()=>$R[0]),$R[2]=Promise.resolve().then(()=>$R[0])])($R[\\"example\\"])"`; +exports[`arrays > crossSerializeAsync > scoped > supports self recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=[$R[1]=Promise.resolve().then(()=>$R[0]),$R[2]=Promise.resolve().then(()=>$R[0])])($R[\\"example\\"]))"`; -exports[`arrays > crossSerializeAsync > supports Arrays 1`] = `"$R[0]=Promise.resolve($R[1]=[1,2,3])"`; +exports[`arrays > crossSerializeAsync > supports Arrays 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=[1,2,3]))"`; -exports[`arrays > crossSerializeAsync > supports self recursion 1`] = `"$R[0]=[$R[1]=Promise.resolve().then(()=>$R[0]),$R[2]=Promise.resolve().then(()=>$R[0])]"`; +exports[`arrays > crossSerializeAsync > supports self recursion 1`] = `"(self.$R=self.$R||[],$R[0]=[$R[1]=Promise.resolve().then(()=>$R[0]),$R[2]=Promise.resolve().then(()=>$R[0])])"`; -exports[`arrays > crossSerializeStream > scoped > supports Arrays 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`arrays > crossSerializeStream > scoped > supports Arrays 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`arrays > crossSerializeStream > scoped > supports Arrays 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]=[1,2,3]))($R[\\"example\\"])"`; -exports[`arrays > crossSerializeStream > scoped > supports self recursion 1`] = `"($R=>$R[0]=[$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),$R[3]=$R[2]()])($R[\\"example\\"])"`; +exports[`arrays > crossSerializeStream > scoped > supports self recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=[$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),$R[3]=$R[2]()])($R[\\"example\\"]))"`; exports[`arrays > crossSerializeStream > scoped > supports self recursion 2`] = `"($R=>($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[1],$R[0]))($R[\\"example\\"])"`; exports[`arrays > crossSerializeStream > scoped > supports self recursion 3`] = `"($R=>$R[4]($R[3],$R[0]))($R[\\"example\\"])"`; -exports[`arrays > crossSerializeStream > supports Arrays 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`arrays > crossSerializeStream > supports Arrays 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`arrays > crossSerializeStream > supports Arrays 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=[1,2,3])"`; -exports[`arrays > crossSerializeStream > supports self recursion 1`] = `"$R[0]=[$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),$R[3]=$R[2]()]"`; +exports[`arrays > crossSerializeStream > supports self recursion 1`] = `"(self.$R=self.$R||[],$R[0]=[$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),$R[3]=$R[2]()])"`; exports[`arrays > crossSerializeStream > supports self recursion 2`] = `"($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[1],$R[0])"`; diff --git a/packages/seroval/test/__snapshots__/async-iterable.test.ts.snap b/packages/seroval/test/__snapshots__/async-iterable.test.ts.snap index e8f198c1..59face6a 100644 --- a/packages/seroval/test/__snapshots__/async-iterable.test.ts.snap +++ b/packages/seroval/test/__snapshots__/async-iterable.test.ts.snap @@ -6,11 +6,11 @@ exports[`AsyncIterable > compat#toJSONAsync > should use function expression ins exports[`AsyncIterable > compat#toJSONAsync > should use function expression instead of arrow functions. 2`] = `"(function(h,j){return ({title:\\"Hello World\\",[h=Symbol.asyncIterator]:(function(s){return function(i,t){return (i=0,t={[h]:function(){return t},next:function(){return Promise.resolve().then(function(c,d){if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}})}})({v:[1,2,3,void 0],t:-1,d:3})})})()"`; -exports[`AsyncIterable > crossSerializeAsync > scoped > supports AsyncIterables 1`] = `"($R=>$R[0]={title:\\"Hello World\\",[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})})($R[\\"example\\"])"`; +exports[`AsyncIterable > crossSerializeAsync > scoped > supports AsyncIterables 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={title:\\"Hello World\\",[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})})($R[\\"example\\"]))"`; -exports[`AsyncIterable > crossSerializeAsync > supports AsyncIterables 1`] = `"$R[0]={title:\\"Hello World\\",[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})}"`; +exports[`AsyncIterable > crossSerializeAsync > supports AsyncIterables 1`] = `"(self.$R=self.$R||[],$R[0]={title:\\"Hello World\\",[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})})"`; -exports[`AsyncIterable > crossSerializeStream > scoped > supports AsyncIterables 1`] = `"($R=>$R[0]={title:\\"Hello World\\",[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())})($R[\\"example\\"])"`; +exports[`AsyncIterable > crossSerializeStream > scoped > supports AsyncIterables 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={title:\\"Hello World\\",[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())})($R[\\"example\\"]))"`; exports[`AsyncIterable > crossSerializeStream > scoped > supports AsyncIterables 2`] = `"($R=>($R[6]=(s,d)=>{s.c.enqueue(d)})($R[3],$R[5]=[0,1]))($R[\\"example\\"])"`; @@ -22,7 +22,7 @@ exports[`AsyncIterable > crossSerializeStream > scoped > supports AsyncIterables exports[`AsyncIterable > crossSerializeStream > scoped > supports AsyncIterables 6`] = `"($R=>($R[10]=s=>{s.c.close();delete s.c})($R[3]))($R[\\"example\\"])"`; -exports[`AsyncIterable > crossSerializeStream > supports AsyncIterables 1`] = `"$R[0]={title:\\"Hello World\\",[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())}"`; +exports[`AsyncIterable > crossSerializeStream > supports AsyncIterables 1`] = `"(self.$R=self.$R||[],$R[0]={title:\\"Hello World\\",[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())})"`; exports[`AsyncIterable > crossSerializeStream > supports AsyncIterables 2`] = `"($R[6]=(s,d)=>{s.c.enqueue(d)})($R[3],$R[5]=[0,1])"`; diff --git a/packages/seroval/test/__snapshots__/bigint.test.ts.snap b/packages/seroval/test/__snapshots__/bigint.test.ts.snap index b9c13d21..933ee55c 100644 --- a/packages/seroval/test/__snapshots__/bigint.test.ts.snap +++ b/packages/seroval/test/__snapshots__/bigint.test.ts.snap @@ -4,11 +4,11 @@ exports[`bigint > compat > should throw an error for unsupported target 1`] = `" exports[`bigint > compat#toJSON > should throw an error for unsupported target 1`] = `"Unsupported type \\"[object BigInt]\\""`; -exports[`bigint > crossSerialize > supports bigint 1`] = `"9007199254740991n"`; +exports[`bigint > crossSerialize > supports bigint 1`] = `"(self.$R=self.$R||[],9007199254740991n)"`; -exports[`bigint > crossSerializeAsync > supports bigint 1`] = `"$R[0]=Promise.resolve(9007199254740991n)"`; +exports[`bigint > crossSerializeAsync > supports bigint 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve(9007199254740991n))"`; -exports[`bigint > crossSerializeStream > supports bigint 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`bigint > crossSerializeStream > supports bigint 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`bigint > crossSerializeStream > supports bigint 2`] = `"($R[2]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],9007199254740991n)"`; diff --git a/packages/seroval/test/__snapshots__/boolean.test.ts.snap b/packages/seroval/test/__snapshots__/boolean.test.ts.snap index 42ded919..902839fb 100644 --- a/packages/seroval/test/__snapshots__/boolean.test.ts.snap +++ b/packages/seroval/test/__snapshots__/boolean.test.ts.snap @@ -1,18 +1,18 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`boolean > crossSerialize > supports boolean 1`] = `"!0"`; +exports[`boolean > crossSerialize > supports boolean 1`] = `"(self.$R=self.$R||[],!0)"`; -exports[`boolean > crossSerialize > supports boolean 2`] = `"!1"`; +exports[`boolean > crossSerialize > supports boolean 2`] = `"(self.$R=self.$R||[],!1)"`; -exports[`boolean > crossSerializeAsync > supports boolean 1`] = `"$R[0]=Promise.resolve(!0)"`; +exports[`boolean > crossSerializeAsync > supports boolean 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve(!0))"`; -exports[`boolean > crossSerializeAsync > supports boolean 2`] = `"$R[0]=Promise.resolve(!1)"`; +exports[`boolean > crossSerializeAsync > supports boolean 2`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve(!1))"`; -exports[`boolean > crossSerializeStream > supports false value 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`boolean > crossSerializeStream > supports false value 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`boolean > crossSerializeStream > supports false value 2`] = `"($R[2]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],!1)"`; -exports[`boolean > crossSerializeStream > supports true value 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`boolean > crossSerializeStream > supports true value 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`boolean > crossSerializeStream > supports true value 2`] = `"($R[2]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],!0)"`; diff --git a/packages/seroval/test/__snapshots__/boxed-bigint.test.ts.snap b/packages/seroval/test/__snapshots__/boxed-bigint.test.ts.snap index 671336b6..2bdc8340 100644 --- a/packages/seroval/test/__snapshots__/boxed-bigint.test.ts.snap +++ b/packages/seroval/test/__snapshots__/boxed-bigint.test.ts.snap @@ -4,19 +4,19 @@ exports[`boxed bigint > compat > should throw an error for unsupported target 1` exports[`boxed bigint > compat#toJSON > should throw an error for unsupported target 1`] = `"Unsupported type \\"[object BigInt]\\""`; -exports[`boxed bigint > crossSerialize > scoped > supports boxed bigint 1`] = `"($R=>$R[0]=Object(9007199254740991n))($R[\\"example\\"])"`; +exports[`boxed bigint > crossSerialize > scoped > supports boxed bigint 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object(9007199254740991n))($R[\\"example\\"]))"`; -exports[`boxed bigint > crossSerialize > supports boxed bigint 1`] = `"$R[0]=Object(9007199254740991n)"`; +exports[`boxed bigint > crossSerialize > supports boxed bigint 1`] = `"(self.$R=self.$R||[],$R[0]=Object(9007199254740991n))"`; -exports[`boxed bigint > crossSerializeAsync > scoped > supports boxed bigint 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=Object(9007199254740991n)))($R[\\"example\\"])"`; +exports[`boxed bigint > crossSerializeAsync > scoped > supports boxed bigint 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Object(9007199254740991n)))($R[\\"example\\"]))"`; -exports[`boxed bigint > crossSerializeAsync > supports boxed bigint 1`] = `"$R[0]=Promise.resolve($R[1]=Object(9007199254740991n))"`; +exports[`boxed bigint > crossSerializeAsync > supports boxed bigint 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Object(9007199254740991n)))"`; -exports[`boxed bigint > crossSerializeStream > scoped > supports boxed bigint 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`boxed bigint > crossSerializeStream > scoped > supports boxed bigint 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`boxed bigint > crossSerializeStream > scoped > supports boxed bigint 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(9007199254740991n)))($R[\\"example\\"])"`; -exports[`boxed bigint > crossSerializeStream > supports boxed bigint 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`boxed bigint > crossSerializeStream > supports boxed bigint 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`boxed bigint > crossSerializeStream > supports boxed bigint 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(9007199254740991n))"`; diff --git a/packages/seroval/test/__snapshots__/boxed-boolean.test.ts.snap b/packages/seroval/test/__snapshots__/boxed-boolean.test.ts.snap index 7e6e6f7d..b6ccc2ae 100644 --- a/packages/seroval/test/__snapshots__/boxed-boolean.test.ts.snap +++ b/packages/seroval/test/__snapshots__/boxed-boolean.test.ts.snap @@ -1,34 +1,34 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`boxed boolean > crossSerialize > scoped > supports boolean 1`] = `"($R=>$R[0]=Object(!0))($R[\\"example\\"])"`; +exports[`boxed boolean > crossSerialize > scoped > supports boolean 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object(!0))($R[\\"example\\"]))"`; -exports[`boxed boolean > crossSerialize > scoped > supports boolean 2`] = `"($R=>$R[0]=Object(!1))($R[\\"example\\"])"`; +exports[`boxed boolean > crossSerialize > scoped > supports boolean 2`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object(!1))($R[\\"example\\"]))"`; -exports[`boxed boolean > crossSerialize > supports boolean 1`] = `"$R[0]=Object(!0)"`; +exports[`boxed boolean > crossSerialize > supports boolean 1`] = `"(self.$R=self.$R||[],$R[0]=Object(!0))"`; -exports[`boxed boolean > crossSerialize > supports boolean 2`] = `"$R[0]=Object(!1)"`; +exports[`boxed boolean > crossSerialize > supports boolean 2`] = `"(self.$R=self.$R||[],$R[0]=Object(!1))"`; -exports[`boxed boolean > crossSerializeAsync > scoped > supports boolean 1`] = `"($R=>$R[0]=Object(!0))($R[\\"example\\"])"`; +exports[`boxed boolean > crossSerializeAsync > scoped > supports boolean 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object(!0))($R[\\"example\\"]))"`; -exports[`boxed boolean > crossSerializeAsync > scoped > supports boolean 2`] = `"($R=>$R[0]=Object(!1))($R[\\"example\\"])"`; +exports[`boxed boolean > crossSerializeAsync > scoped > supports boolean 2`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object(!1))($R[\\"example\\"]))"`; -exports[`boxed boolean > crossSerializeAsync > supports boolean 1`] = `"$R[0]=Object(!0)"`; +exports[`boxed boolean > crossSerializeAsync > supports boolean 1`] = `"(self.$R=self.$R||[],$R[0]=Object(!0))"`; -exports[`boxed boolean > crossSerializeAsync > supports boolean 2`] = `"$R[0]=Object(!1)"`; +exports[`boxed boolean > crossSerializeAsync > supports boolean 2`] = `"(self.$R=self.$R||[],$R[0]=Object(!1))"`; -exports[`boxed boolean > crossSerializeStream > scoped > supports boxed false 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`boxed boolean > crossSerializeStream > scoped > supports boxed false 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`boxed boolean > crossSerializeStream > scoped > supports boxed false 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(!1)))($R[\\"example\\"])"`; -exports[`boxed boolean > crossSerializeStream > scoped > supports boxed true 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`boxed boolean > crossSerializeStream > scoped > supports boxed true 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`boxed boolean > crossSerializeStream > scoped > supports boxed true 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(!0)))($R[\\"example\\"])"`; -exports[`boxed boolean > crossSerializeStream > supports boxed false 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`boxed boolean > crossSerializeStream > supports boxed false 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`boxed boolean > crossSerializeStream > supports boxed false 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(!1))"`; -exports[`boxed boolean > crossSerializeStream > supports boxed true 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`boxed boolean > crossSerializeStream > supports boxed true 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`boxed boolean > crossSerializeStream > supports boxed true 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(!0))"`; diff --git a/packages/seroval/test/__snapshots__/boxed-number.test.ts.snap b/packages/seroval/test/__snapshots__/boxed-number.test.ts.snap index 8e1bad49..4cd45e8b 100644 --- a/packages/seroval/test/__snapshots__/boxed-number.test.ts.snap +++ b/packages/seroval/test/__snapshots__/boxed-number.test.ts.snap @@ -1,82 +1,82 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`boxed number > crossSerialize > scoped > supports boxed numbers 1`] = `"($R=>$R[0]=Object(3735928559))($R[\\"example\\"])"`; +exports[`boxed number > crossSerialize > scoped > supports boxed numbers 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object(3735928559))($R[\\"example\\"]))"`; -exports[`boxed number > crossSerialize > scoped > supports boxed numbers 2`] = `"($R=>$R[0]=Object(0/0))($R[\\"example\\"])"`; +exports[`boxed number > crossSerialize > scoped > supports boxed numbers 2`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object(0/0))($R[\\"example\\"]))"`; -exports[`boxed number > crossSerialize > scoped > supports boxed numbers 3`] = `"($R=>$R[0]=Object(1/0))($R[\\"example\\"])"`; +exports[`boxed number > crossSerialize > scoped > supports boxed numbers 3`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object(1/0))($R[\\"example\\"]))"`; -exports[`boxed number > crossSerialize > scoped > supports boxed numbers 4`] = `"($R=>$R[0]=Object(-1/0))($R[\\"example\\"])"`; +exports[`boxed number > crossSerialize > scoped > supports boxed numbers 4`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object(-1/0))($R[\\"example\\"]))"`; -exports[`boxed number > crossSerialize > scoped > supports boxed numbers 5`] = `"($R=>$R[0]=Object(-0))($R[\\"example\\"])"`; +exports[`boxed number > crossSerialize > scoped > supports boxed numbers 5`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object(-0))($R[\\"example\\"]))"`; -exports[`boxed number > crossSerialize > supports boxed numbers 1`] = `"$R[0]=Object(3735928559)"`; +exports[`boxed number > crossSerialize > supports boxed numbers 1`] = `"(self.$R=self.$R||[],$R[0]=Object(3735928559))"`; -exports[`boxed number > crossSerialize > supports boxed numbers 2`] = `"$R[0]=Object(0/0)"`; +exports[`boxed number > crossSerialize > supports boxed numbers 2`] = `"(self.$R=self.$R||[],$R[0]=Object(0/0))"`; -exports[`boxed number > crossSerialize > supports boxed numbers 3`] = `"$R[0]=Object(1/0)"`; +exports[`boxed number > crossSerialize > supports boxed numbers 3`] = `"(self.$R=self.$R||[],$R[0]=Object(1/0))"`; -exports[`boxed number > crossSerialize > supports boxed numbers 4`] = `"$R[0]=Object(-1/0)"`; +exports[`boxed number > crossSerialize > supports boxed numbers 4`] = `"(self.$R=self.$R||[],$R[0]=Object(-1/0))"`; -exports[`boxed number > crossSerialize > supports boxed numbers 5`] = `"$R[0]=Object(-0)"`; +exports[`boxed number > crossSerialize > supports boxed numbers 5`] = `"(self.$R=self.$R||[],$R[0]=Object(-0))"`; -exports[`boxed number > crossSerializeAsync > scoped > supports boxed numbers 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=Object(3735928559)))($R[\\"example\\"])"`; +exports[`boxed number > crossSerializeAsync > scoped > supports boxed numbers 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Object(3735928559)))($R[\\"example\\"]))"`; -exports[`boxed number > crossSerializeAsync > scoped > supports boxed numbers 2`] = `"($R=>$R[0]=Promise.resolve($R[1]=Object(0/0)))($R[\\"example\\"])"`; +exports[`boxed number > crossSerializeAsync > scoped > supports boxed numbers 2`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Object(0/0)))($R[\\"example\\"]))"`; -exports[`boxed number > crossSerializeAsync > scoped > supports boxed numbers 3`] = `"($R=>$R[0]=Promise.resolve($R[1]=Object(1/0)))($R[\\"example\\"])"`; +exports[`boxed number > crossSerializeAsync > scoped > supports boxed numbers 3`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Object(1/0)))($R[\\"example\\"]))"`; -exports[`boxed number > crossSerializeAsync > scoped > supports boxed numbers 4`] = `"($R=>$R[0]=Promise.resolve($R[1]=Object(-1/0)))($R[\\"example\\"])"`; +exports[`boxed number > crossSerializeAsync > scoped > supports boxed numbers 4`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Object(-1/0)))($R[\\"example\\"]))"`; -exports[`boxed number > crossSerializeAsync > scoped > supports boxed numbers 5`] = `"($R=>$R[0]=Promise.resolve($R[1]=Object(-0)))($R[\\"example\\"])"`; +exports[`boxed number > crossSerializeAsync > scoped > supports boxed numbers 5`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Object(-0)))($R[\\"example\\"]))"`; -exports[`boxed number > crossSerializeAsync > supports boxed numbers 1`] = `"$R[0]=Promise.resolve($R[1]=Object(3735928559))"`; +exports[`boxed number > crossSerializeAsync > supports boxed numbers 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Object(3735928559)))"`; -exports[`boxed number > crossSerializeAsync > supports boxed numbers 2`] = `"$R[0]=Promise.resolve($R[1]=Object(0/0))"`; +exports[`boxed number > crossSerializeAsync > supports boxed numbers 2`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Object(0/0)))"`; -exports[`boxed number > crossSerializeAsync > supports boxed numbers 3`] = `"$R[0]=Promise.resolve($R[1]=Object(1/0))"`; +exports[`boxed number > crossSerializeAsync > supports boxed numbers 3`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Object(1/0)))"`; -exports[`boxed number > crossSerializeAsync > supports boxed numbers 4`] = `"$R[0]=Promise.resolve($R[1]=Object(-1/0))"`; +exports[`boxed number > crossSerializeAsync > supports boxed numbers 4`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Object(-1/0)))"`; -exports[`boxed number > crossSerializeAsync > supports boxed numbers 5`] = `"$R[0]=Promise.resolve($R[1]=Object(-0))"`; +exports[`boxed number > crossSerializeAsync > supports boxed numbers 5`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Object(-0)))"`; -exports[`boxed number > crossSerializeStream > scoped > supports boxed -0 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`boxed number > crossSerializeStream > scoped > supports boxed -0 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`boxed number > crossSerializeStream > scoped > supports boxed -0 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(-0)))($R[\\"example\\"])"`; -exports[`boxed number > crossSerializeStream > scoped > supports boxed -Infinity 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`boxed number > crossSerializeStream > scoped > supports boxed -Infinity 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`boxed number > crossSerializeStream > scoped > supports boxed -Infinity 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(-1/0)))($R[\\"example\\"])"`; -exports[`boxed number > crossSerializeStream > scoped > supports boxed Infinity 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`boxed number > crossSerializeStream > scoped > supports boxed Infinity 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`boxed number > crossSerializeStream > scoped > supports boxed Infinity 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(1/0)))($R[\\"example\\"])"`; -exports[`boxed number > crossSerializeStream > scoped > supports boxed NaN 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`boxed number > crossSerializeStream > scoped > supports boxed NaN 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`boxed number > crossSerializeStream > scoped > supports boxed NaN 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(0/0)))($R[\\"example\\"])"`; -exports[`boxed number > crossSerializeStream > scoped > supports boxed numbers 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`boxed number > crossSerializeStream > scoped > supports boxed numbers 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`boxed number > crossSerializeStream > scoped > supports boxed numbers 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(3735928559)))($R[\\"example\\"])"`; -exports[`boxed number > crossSerializeStream > supports boxed -0 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`boxed number > crossSerializeStream > supports boxed -0 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`boxed number > crossSerializeStream > supports boxed -0 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(-0))"`; -exports[`boxed number > crossSerializeStream > supports boxed -Infinity 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`boxed number > crossSerializeStream > supports boxed -Infinity 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`boxed number > crossSerializeStream > supports boxed -Infinity 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(-1/0))"`; -exports[`boxed number > crossSerializeStream > supports boxed Infinity 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`boxed number > crossSerializeStream > supports boxed Infinity 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`boxed number > crossSerializeStream > supports boxed Infinity 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(1/0))"`; -exports[`boxed number > crossSerializeStream > supports boxed NaN 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`boxed number > crossSerializeStream > supports boxed NaN 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`boxed number > crossSerializeStream > supports boxed NaN 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(0/0))"`; -exports[`boxed number > crossSerializeStream > supports boxed numbers 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`boxed number > crossSerializeStream > supports boxed numbers 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`boxed number > crossSerializeStream > supports boxed numbers 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(3735928559))"`; diff --git a/packages/seroval/test/__snapshots__/boxed-string.test.ts.snap b/packages/seroval/test/__snapshots__/boxed-string.test.ts.snap index f720e4b7..c4f85f48 100644 --- a/packages/seroval/test/__snapshots__/boxed-string.test.ts.snap +++ b/packages/seroval/test/__snapshots__/boxed-string.test.ts.snap @@ -1,34 +1,34 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`boxed string > crossSerialize > scoped > supports boxed strings 1`] = `"($R=>$R[0]=Object(\\"\\\\\\"hello\\\\\\"\\"))($R[\\"example\\"])"`; +exports[`boxed string > crossSerialize > scoped > supports boxed strings 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object(\\"\\\\\\"hello\\\\\\"\\"))($R[\\"example\\"]))"`; -exports[`boxed string > crossSerialize > scoped > supports boxed strings 2`] = `"($R=>$R[0]=Object(\\"\\\\x3Cscript>\\\\x3C/script>\\"))($R[\\"example\\"])"`; +exports[`boxed string > crossSerialize > scoped > supports boxed strings 2`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object(\\"\\\\x3Cscript>\\\\x3C/script>\\"))($R[\\"example\\"]))"`; -exports[`boxed string > crossSerialize > supports boxed strings 1`] = `"$R[0]=Object(\\"\\\\\\"hello\\\\\\"\\")"`; +exports[`boxed string > crossSerialize > supports boxed strings 1`] = `"(self.$R=self.$R||[],$R[0]=Object(\\"\\\\\\"hello\\\\\\"\\"))"`; -exports[`boxed string > crossSerialize > supports boxed strings 2`] = `"$R[0]=Object(\\"\\\\x3Cscript>\\\\x3C/script>\\")"`; +exports[`boxed string > crossSerialize > supports boxed strings 2`] = `"(self.$R=self.$R||[],$R[0]=Object(\\"\\\\x3Cscript>\\\\x3C/script>\\"))"`; -exports[`boxed string > crossSerializeAsync > scoped > supports boxed strings 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=Object(\\"\\\\\\"hello\\\\\\"\\")))($R[\\"example\\"])"`; +exports[`boxed string > crossSerializeAsync > scoped > supports boxed strings 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Object(\\"\\\\\\"hello\\\\\\"\\")))($R[\\"example\\"]))"`; -exports[`boxed string > crossSerializeAsync > scoped > supports boxed strings 2`] = `"($R=>$R[0]=Promise.resolve($R[1]=Object(\\"\\\\x3Cscript>\\\\x3C/script>\\")))($R[\\"example\\"])"`; +exports[`boxed string > crossSerializeAsync > scoped > supports boxed strings 2`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Object(\\"\\\\x3Cscript>\\\\x3C/script>\\")))($R[\\"example\\"]))"`; -exports[`boxed string > crossSerializeAsync > supports boxed strings 1`] = `"$R[0]=Promise.resolve($R[1]=Object(\\"\\\\\\"hello\\\\\\"\\"))"`; +exports[`boxed string > crossSerializeAsync > supports boxed strings 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Object(\\"\\\\\\"hello\\\\\\"\\")))"`; -exports[`boxed string > crossSerializeAsync > supports boxed strings 2`] = `"$R[0]=Promise.resolve($R[1]=Object(\\"\\\\x3Cscript>\\\\x3C/script>\\"))"`; +exports[`boxed string > crossSerializeAsync > supports boxed strings 2`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Object(\\"\\\\x3Cscript>\\\\x3C/script>\\")))"`; -exports[`boxed string > crossSerializeStream > scoped > supports boxed sanitized strings 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`boxed string > crossSerializeStream > scoped > supports boxed sanitized strings 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`boxed string > crossSerializeStream > scoped > supports boxed sanitized strings 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(\\"\\\\x3Cscript>\\\\x3C/script>\\")))($R[\\"example\\"])"`; -exports[`boxed string > crossSerializeStream > scoped > supports boxed strings 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`boxed string > crossSerializeStream > scoped > supports boxed strings 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`boxed string > crossSerializeStream > scoped > supports boxed strings 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(\\"\\\\\\"hello\\\\\\"\\")))($R[\\"example\\"])"`; -exports[`boxed string > crossSerializeStream > supports boxed sanitized strings 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`boxed string > crossSerializeStream > supports boxed sanitized strings 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`boxed string > crossSerializeStream > supports boxed sanitized strings 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(\\"\\\\x3Cscript>\\\\x3C/script>\\"))"`; -exports[`boxed string > crossSerializeStream > supports boxed strings 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`boxed string > crossSerializeStream > supports boxed strings 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`boxed string > crossSerializeStream > supports boxed strings 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(\\"\\\\\\"hello\\\\\\"\\"))"`; diff --git a/packages/seroval/test/__snapshots__/data-view.test.ts.snap b/packages/seroval/test/__snapshots__/data-view.test.ts.snap index 0f1416d0..5e0ce3e3 100644 --- a/packages/seroval/test/__snapshots__/data-view.test.ts.snap +++ b/packages/seroval/test/__snapshots__/data-view.test.ts.snap @@ -1,18 +1,18 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`DataView > crossSerialize > scoped > supports DataView 1`] = `"($R=>$R[0]=new DataView($R[1]=new Uint8Array([0,0,42,0,0,0,0,0,0,0,0,0,0,0,0,0]).buffer,0,16))($R[\\"example\\"])"`; +exports[`DataView > crossSerialize > scoped > supports DataView 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=new DataView($R[1]=new Uint8Array([0,0,42,0,0,0,0,0,0,0,0,0,0,0,0,0]).buffer,0,16))($R[\\"example\\"]))"`; -exports[`DataView > crossSerialize > supports DataView 1`] = `"$R[0]=new DataView($R[1]=new Uint8Array([0,0,42,0,0,0,0,0,0,0,0,0,0,0,0,0]).buffer,0,16)"`; +exports[`DataView > crossSerialize > supports DataView 1`] = `"(self.$R=self.$R||[],$R[0]=new DataView($R[1]=new Uint8Array([0,0,42,0,0,0,0,0,0,0,0,0,0,0,0,0]).buffer,0,16))"`; -exports[`DataView > crossSerializeAsync > scoped > supports DataView 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=new DataView($R[2]=new Uint8Array([0,0,42,0,0,0,0,0,0,0,0,0,0,0,0,0]).buffer,0,16)))($R[\\"example\\"])"`; +exports[`DataView > crossSerializeAsync > scoped > supports DataView 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=new DataView($R[2]=new Uint8Array([0,0,42,0,0,0,0,0,0,0,0,0,0,0,0,0]).buffer,0,16)))($R[\\"example\\"]))"`; -exports[`DataView > crossSerializeAsync > supports DataView 1`] = `"$R[0]=Promise.resolve($R[1]=new DataView($R[2]=new Uint8Array([0,0,42,0,0,0,0,0,0,0,0,0,0,0,0,0]).buffer,0,16))"`; +exports[`DataView > crossSerializeAsync > supports DataView 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=new DataView($R[2]=new Uint8Array([0,0,42,0,0,0,0,0,0,0,0,0,0,0,0,0]).buffer,0,16)))"`; -exports[`DataView > crossSerializeStream > scoped > supports DataView 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`DataView > crossSerializeStream > scoped > supports DataView 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`DataView > crossSerializeStream > scoped > supports DataView 2`] = `"($R=>($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=new DataView($R[3]=new Uint8Array([0,0,42,0,0,0,0,0,0,0,0,0,0,0,0,0]).buffer,0,16)))($R[\\"example\\"])"`; -exports[`DataView > crossSerializeStream > supports DataView 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`DataView > crossSerializeStream > supports DataView 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`DataView > crossSerializeStream > supports DataView 2`] = `"($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=new DataView($R[3]=new Uint8Array([0,0,42,0,0,0,0,0,0,0,0,0,0,0,0,0]).buffer,0,16))"`; diff --git a/packages/seroval/test/__snapshots__/date.test.ts.snap b/packages/seroval/test/__snapshots__/date.test.ts.snap index 610c37bd..a716e98e 100644 --- a/packages/seroval/test/__snapshots__/date.test.ts.snap +++ b/packages/seroval/test/__snapshots__/date.test.ts.snap @@ -1,18 +1,18 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Date > crossSerialize > scoped > supports Date 1`] = `"($R=>$R[0]=new Date(\\"2023-03-14T11:16:24.879Z\\"))($R[\\"example\\"])"`; +exports[`Date > crossSerialize > scoped > supports Date 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=new Date(\\"2023-03-14T11:16:24.879Z\\"))($R[\\"example\\"]))"`; -exports[`Date > crossSerialize > supports Date 1`] = `"$R[0]=new Date(\\"2023-03-14T11:16:24.879Z\\")"`; +exports[`Date > crossSerialize > supports Date 1`] = `"(self.$R=self.$R||[],$R[0]=new Date(\\"2023-03-14T11:16:24.879Z\\"))"`; -exports[`Date > crossSerializeAsync > scoped > supports Date 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=new Date(\\"2023-03-14T11:16:24.879Z\\")))($R[\\"example\\"])"`; +exports[`Date > crossSerializeAsync > scoped > supports Date 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=new Date(\\"2023-03-14T11:16:24.879Z\\")))($R[\\"example\\"]))"`; -exports[`Date > crossSerializeAsync > supports Date 1`] = `"$R[0]=Promise.resolve($R[1]=new Date(\\"2023-03-14T11:16:24.879Z\\"))"`; +exports[`Date > crossSerializeAsync > supports Date 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=new Date(\\"2023-03-14T11:16:24.879Z\\")))"`; -exports[`Date > crossSerializeStream > scoped > supports Date 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`Date > crossSerializeStream > scoped > supports Date 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`Date > crossSerializeStream > scoped > supports Date 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]=new Date(\\"2023-03-14T11:16:24.879Z\\")))($R[\\"example\\"])"`; -exports[`Date > crossSerializeStream > supports Date 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`Date > crossSerializeStream > supports Date 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`Date > crossSerializeStream > supports Date 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=new Date(\\"2023-03-14T11:16:24.879Z\\"))"`; diff --git a/packages/seroval/test/__snapshots__/error.test.ts.snap b/packages/seroval/test/__snapshots__/error.test.ts.snap index 83e483a3..eb1bf15d 100644 --- a/packages/seroval/test/__snapshots__/error.test.ts.snap +++ b/packages/seroval/test/__snapshots__/error.test.ts.snap @@ -1,54 +1,54 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Error > crossSerialize > scoped > supports Error.prototype.cause 1`] = `"($R=>$R[0]=Object.assign(new Error(\\"B\\"),{stack:\\"\\",cause:$R[1]=Object.assign(new Error(\\"A\\"),{stack:\\"\\"})}))($R[\\"example\\"])"`; +exports[`Error > crossSerialize > scoped > supports Error.prototype.cause 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object.assign(new Error(\\"B\\"),{stack:\\"\\",cause:$R[1]=Object.assign(new Error(\\"A\\"),{stack:\\"\\"})}))($R[\\"example\\"]))"`; -exports[`Error > crossSerialize > scoped > supports Error.prototype.name 1`] = `"($R=>$R[0]=Object.assign(new Error(\\"A\\"),{name:\\"ExampleError\\",stack:\\"\\"}))($R[\\"example\\"])"`; +exports[`Error > crossSerialize > scoped > supports Error.prototype.name 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object.assign(new Error(\\"A\\"),{name:\\"ExampleError\\",stack:\\"\\"}))($R[\\"example\\"]))"`; -exports[`Error > crossSerialize > scoped > supports other Error classes 1`] = `"($R=>$R[0]=Object.assign(new ReferenceError(\\"A\\"),{stack:\\"\\"}))($R[\\"example\\"])"`; +exports[`Error > crossSerialize > scoped > supports other Error classes 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object.assign(new ReferenceError(\\"A\\"),{stack:\\"\\"}))($R[\\"example\\"]))"`; -exports[`Error > crossSerialize > supports Error.prototype.cause 1`] = `"$R[0]=Object.assign(new Error(\\"B\\"),{stack:\\"\\",cause:$R[1]=Object.assign(new Error(\\"A\\"),{stack:\\"\\"})})"`; +exports[`Error > crossSerialize > supports Error.prototype.cause 1`] = `"(self.$R=self.$R||[],$R[0]=Object.assign(new Error(\\"B\\"),{stack:\\"\\",cause:$R[1]=Object.assign(new Error(\\"A\\"),{stack:\\"\\"})}))"`; -exports[`Error > crossSerialize > supports Error.prototype.name 1`] = `"$R[0]=Object.assign(new Error(\\"A\\"),{name:\\"ExampleError\\",stack:\\"\\"})"`; +exports[`Error > crossSerialize > supports Error.prototype.name 1`] = `"(self.$R=self.$R||[],$R[0]=Object.assign(new Error(\\"A\\"),{name:\\"ExampleError\\",stack:\\"\\"}))"`; -exports[`Error > crossSerialize > supports other Error classes 1`] = `"$R[0]=Object.assign(new ReferenceError(\\"A\\"),{stack:\\"\\"})"`; +exports[`Error > crossSerialize > supports other Error classes 1`] = `"(self.$R=self.$R||[],$R[0]=Object.assign(new ReferenceError(\\"A\\"),{stack:\\"\\"}))"`; -exports[`Error > crossSerializeAsync > scoped > supports Error.prototype.cause 1`] = `"($R=>$R[0]=Object.assign(new Error(\\"B\\"),{stack:\\"\\",cause:$R[1]=Promise.resolve($R[2]=Object.assign(new Error(\\"A\\"),{stack:\\"\\"}))}))($R[\\"example\\"])"`; +exports[`Error > crossSerializeAsync > scoped > supports Error.prototype.cause 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object.assign(new Error(\\"B\\"),{stack:\\"\\",cause:$R[1]=Promise.resolve($R[2]=Object.assign(new Error(\\"A\\"),{stack:\\"\\"}))}))($R[\\"example\\"]))"`; -exports[`Error > crossSerializeAsync > scoped > supports Error.prototype.name 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=Object.assign(new Error(\\"A\\"),{name:\\"ExampleError\\",stack:\\"\\"})))($R[\\"example\\"])"`; +exports[`Error > crossSerializeAsync > scoped > supports Error.prototype.name 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Object.assign(new Error(\\"A\\"),{name:\\"ExampleError\\",stack:\\"\\"})))($R[\\"example\\"]))"`; -exports[`Error > crossSerializeAsync > scoped > supports other Error classes 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=Object.assign(new ReferenceError(\\"A\\"),{stack:\\"\\"})))($R[\\"example\\"])"`; +exports[`Error > crossSerializeAsync > scoped > supports other Error classes 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Object.assign(new ReferenceError(\\"A\\"),{stack:\\"\\"})))($R[\\"example\\"]))"`; -exports[`Error > crossSerializeAsync > supports Error.prototype.cause 1`] = `"$R[0]=Object.assign(new Error(\\"B\\"),{stack:\\"\\",cause:$R[1]=Promise.resolve($R[2]=Object.assign(new Error(\\"A\\"),{stack:\\"\\"}))})"`; +exports[`Error > crossSerializeAsync > supports Error.prototype.cause 1`] = `"(self.$R=self.$R||[],$R[0]=Object.assign(new Error(\\"B\\"),{stack:\\"\\",cause:$R[1]=Promise.resolve($R[2]=Object.assign(new Error(\\"A\\"),{stack:\\"\\"}))}))"`; -exports[`Error > crossSerializeAsync > supports Error.prototype.name 1`] = `"$R[0]=Promise.resolve($R[1]=Object.assign(new Error(\\"A\\"),{name:\\"ExampleError\\",stack:\\"\\"}))"`; +exports[`Error > crossSerializeAsync > supports Error.prototype.name 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Object.assign(new Error(\\"A\\"),{name:\\"ExampleError\\",stack:\\"\\"})))"`; -exports[`Error > crossSerializeAsync > supports other Error classes 1`] = `"$R[0]=Promise.resolve($R[1]=Object.assign(new ReferenceError(\\"A\\"),{stack:\\"\\"}))"`; +exports[`Error > crossSerializeAsync > supports other Error classes 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Object.assign(new ReferenceError(\\"A\\"),{stack:\\"\\"})))"`; -exports[`Error > crossSerializeStream > scoped > supports Error.prototype.cause 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`Error > crossSerializeStream > scoped > supports Error.prototype.cause 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`Error > crossSerializeStream > scoped > supports Error.prototype.cause 2`] = `"($R=>($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Object.assign(new Error(\\"B\\"),{stack:\\"\\",cause:$R[3]=$R[1]()})))($R[\\"example\\"])"`; exports[`Error > crossSerializeStream > scoped > supports Error.prototype.cause 3`] = `"($R=>$R[4]($R[3],$R[5]=Object.assign(new Error(\\"A\\"),{stack:\\"\\"})))($R[\\"example\\"])"`; -exports[`Error > crossSerializeStream > scoped > supports Error.prototype.name 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`Error > crossSerializeStream > scoped > supports Error.prototype.name 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`Error > crossSerializeStream > scoped > supports Error.prototype.name 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(new Error(\\"A\\"),{name:\\"ExampleError\\",stack:\\"\\"})))($R[\\"example\\"])"`; -exports[`Error > crossSerializeStream > scoped > supports other Error classes 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`Error > crossSerializeStream > scoped > supports other Error classes 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`Error > crossSerializeStream > scoped > supports other Error classes 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(new ReferenceError(\\"A\\"),{stack:\\"\\"})))($R[\\"example\\"])"`; -exports[`Error > crossSerializeStream > supports Error.prototype.cause 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`Error > crossSerializeStream > supports Error.prototype.cause 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`Error > crossSerializeStream > supports Error.prototype.cause 2`] = `"($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Object.assign(new Error(\\"B\\"),{stack:\\"\\",cause:$R[3]=$R[1]()}))"`; exports[`Error > crossSerializeStream > supports Error.prototype.cause 3`] = `"$R[4]($R[3],$R[5]=Object.assign(new Error(\\"A\\"),{stack:\\"\\"}))"`; -exports[`Error > crossSerializeStream > supports Error.prototype.name 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`Error > crossSerializeStream > supports Error.prototype.name 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`Error > crossSerializeStream > supports Error.prototype.name 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(new Error(\\"A\\"),{name:\\"ExampleError\\",stack:\\"\\"}))"`; -exports[`Error > crossSerializeStream > supports other Error classes 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`Error > crossSerializeStream > supports other Error classes 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`Error > crossSerializeStream > supports other Error classes 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(new ReferenceError(\\"A\\"),{stack:\\"\\"}))"`; diff --git a/packages/seroval/test/__snapshots__/frozen-object.test.ts.snap b/packages/seroval/test/__snapshots__/frozen-object.test.ts.snap index 9839f54f..2c1b507e 100644 --- a/packages/seroval/test/__snapshots__/frozen-object.test.ts.snap +++ b/packages/seroval/test/__snapshots__/frozen-object.test.ts.snap @@ -1,38 +1,38 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`frozen object > crossSerialize > scoped > supports Objects 1`] = `"($R=>$R[0]={hello:\\"world\\"},Object.freeze($R[0]),$R[0])($R[\\"example\\"])"`; +exports[`frozen object > crossSerialize > scoped > supports Objects 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={hello:\\"world\\"},Object.freeze($R[0]),$R[0])($R[\\"example\\"]))"`; -exports[`frozen object > crossSerialize > scoped > supports Symbol.iterator 1`] = `"($R=>$R[0]={[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})},Object.freeze($R[0]),$R[0])($R[\\"example\\"])"`; +exports[`frozen object > crossSerialize > scoped > supports Symbol.iterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})},Object.freeze($R[0]),$R[0])($R[\\"example\\"]))"`; -exports[`frozen object > crossSerialize > scoped > supports self-recursion 1`] = `"($R=>$R[0]={},$R[0].b=$R[0].a=$R[0],Object.freeze($R[0]),$R[0])($R[\\"example\\"])"`; +exports[`frozen object > crossSerialize > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={},$R[0].b=$R[0].a=$R[0],Object.freeze($R[0]),$R[0])($R[\\"example\\"]))"`; -exports[`frozen object > crossSerialize > supports Objects 1`] = `"($R[0]={hello:\\"world\\"},Object.freeze($R[0]),$R[0])"`; +exports[`frozen object > crossSerialize > supports Objects 1`] = `"(self.$R=self.$R||[],($R[0]={hello:\\"world\\"},Object.freeze($R[0]),$R[0]))"`; -exports[`frozen object > crossSerialize > supports Symbol.iterator 1`] = `"($R[0]={[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})},Object.freeze($R[0]),$R[0])"`; +exports[`frozen object > crossSerialize > supports Symbol.iterator 1`] = `"(self.$R=self.$R||[],($R[0]={[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})},Object.freeze($R[0]),$R[0]))"`; -exports[`frozen object > crossSerialize > supports self-recursion 1`] = `"($R[0]={},$R[0].b=$R[0].a=$R[0],Object.freeze($R[0]),$R[0])"`; +exports[`frozen object > crossSerialize > supports self-recursion 1`] = `"(self.$R=self.$R||[],($R[0]={},$R[0].b=$R[0].a=$R[0],Object.freeze($R[0]),$R[0]))"`; -exports[`frozen object > crossSerializeAsync > scoped > supports Objects 1`] = `"($R=>$R[0]=Promise.resolve($R[1]={hello:\\"world\\"}),Object.freeze($R[1]),$R[0])($R[\\"example\\"])"`; +exports[`frozen object > crossSerializeAsync > scoped > supports Objects 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]={hello:\\"world\\"}),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[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})},Object.freeze($R[0]),$R[0])($R[\\"example\\"])"`; +exports[`frozen object > crossSerializeAsync > scoped > supports Symbol.asyncIterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})},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};c=i++,d=s.v[c];if(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\\"])"`; +exports[`frozen object > crossSerializeAsync > scoped > supports Symbol.iterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($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};c=i++,d=s.v[c];if(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\\"]))"`; -exports[`frozen object > crossSerializeAsync > scoped > supports self-recursion 1`] = `"($R=>$R[0]={a:$R[1]=Promise.resolve().then(()=>$R[0]),b:$R[2]=Promise.resolve().then(()=>$R[0])},Object.freeze($R[0]),$R[0])($R[\\"example\\"])"`; +exports[`frozen object > crossSerializeAsync > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={a:$R[1]=Promise.resolve().then(()=>$R[0]),b:$R[2]=Promise.resolve().then(()=>$R[0])},Object.freeze($R[0]),$R[0])($R[\\"example\\"]))"`; -exports[`frozen object > crossSerializeAsync > supports Objects 1`] = `"($R[0]=Promise.resolve($R[1]={hello:\\"world\\"}),Object.freeze($R[1]),$R[0])"`; +exports[`frozen object > crossSerializeAsync > supports Objects 1`] = `"(self.$R=self.$R||[],($R[0]=Promise.resolve($R[1]={hello:\\"world\\"}),Object.freeze($R[1]),$R[0]))"`; -exports[`frozen object > crossSerializeAsync > supports Symbol.asyncIterator 1`] = `"($R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})},Object.freeze($R[0]),$R[0])"`; +exports[`frozen object > crossSerializeAsync > supports Symbol.asyncIterator 1`] = `"(self.$R=self.$R||[],($R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})},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};c=i++,d=s.v[c];if(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])"`; +exports[`frozen object > crossSerializeAsync > supports Symbol.iterator 1`] = `"(self.$R=self.$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};c=i++,d=s.v[c];if(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]))"`; -exports[`frozen object > crossSerializeAsync > supports self-recursion 1`] = `"($R[0]={a:$R[1]=Promise.resolve().then(()=>$R[0]),b:$R[2]=Promise.resolve().then(()=>$R[0])},Object.freeze($R[0]),$R[0])"`; +exports[`frozen object > crossSerializeAsync > supports self-recursion 1`] = `"(self.$R=self.$R||[],($R[0]={a:$R[1]=Promise.resolve().then(()=>$R[0]),b:$R[2]=Promise.resolve().then(()=>$R[0])},Object.freeze($R[0]),$R[0]))"`; -exports[`frozen object > crossSerializeStream > scoped > supports Objects 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`frozen object > crossSerializeStream > scoped > supports Objects 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; 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]={hello:\\"world\\"}),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[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())},Object.freeze($R[0]),$R[0])($R[\\"example\\"])"`; +exports[`frozen object > crossSerializeStream > scoped > supports Symbol.asyncIterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())},Object.freeze($R[0]),$R[0])($R[\\"example\\"]))"`; exports[`frozen object > crossSerializeStream > scoped > supports Symbol.asyncIterator 2`] = `"($R=>($R[6]=(s,d)=>{s.c.enqueue(d)})($R[3],$R[5]=[0,1]))($R[\\"example\\"])"`; @@ -44,21 +44,21 @@ exports[`frozen object > crossSerializeStream > scoped > supports Symbol.asyncIt exports[`frozen object > crossSerializeStream > scoped > supports Symbol.asyncIterator 6`] = `"($R=>($R[10]=s=>{s.c.close();delete s.c})($R[3]))($R[\\"example\\"])"`; -exports[`frozen object > crossSerializeStream > scoped > supports Symbol.iterator 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`frozen object > crossSerializeStream > scoped > supports Symbol.iterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`frozen object > crossSerializeStream > scoped > supports Symbol.iterator 2`] = `"($R=>($R[7]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]={[$R[3]=Symbol.iterator]:($R[4]=s=>(i,c,d,t)=>(i=0,t={[$R[3]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[5]={v:$R[6]=[1,2,3,void 0],t:-1,d:3})}),Object.freeze($R[2]),$R[0])($R[\\"example\\"])"`; -exports[`frozen object > crossSerializeStream > scoped > supports self-recursion 1`] = `"($R=>$R[0]={a:$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),b:$R[3]=$R[2]()},Object.freeze($R[0]),$R[0])($R[\\"example\\"])"`; +exports[`frozen object > crossSerializeStream > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={a:$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),b:$R[3]=$R[2]()},Object.freeze($R[0]),$R[0])($R[\\"example\\"]))"`; exports[`frozen object > crossSerializeStream > scoped > supports self-recursion 2`] = `"($R=>($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[1],$R[0]))($R[\\"example\\"])"`; exports[`frozen object > crossSerializeStream > scoped > supports self-recursion 3`] = `"($R=>$R[4]($R[3],$R[0]))($R[\\"example\\"])"`; -exports[`frozen object > crossSerializeStream > supports Objects 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`frozen object > crossSerializeStream > supports Objects 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; 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]={hello:\\"world\\"}),Object.freeze($R[2]),$R[0])"`; -exports[`frozen object > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"($R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())},Object.freeze($R[0]),$R[0])"`; +exports[`frozen object > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"(self.$R=self.$R||[],($R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())},Object.freeze($R[0]),$R[0]))"`; exports[`frozen object > crossSerializeStream > supports Symbol.asyncIterator 2`] = `"($R[6]=(s,d)=>{s.c.enqueue(d)})($R[3],$R[5]=[0,1])"`; @@ -70,11 +70,11 @@ exports[`frozen object > crossSerializeStream > supports Symbol.asyncIterator 5` exports[`frozen object > crossSerializeStream > supports Symbol.asyncIterator 6`] = `"($R[10]=s=>{s.c.close();delete s.c})($R[3])"`; -exports[`frozen object > crossSerializeStream > supports Symbol.iterator 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`frozen object > crossSerializeStream > supports Symbol.iterator 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`frozen object > crossSerializeStream > supports Symbol.iterator 2`] = `"(($R[7]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]={[$R[3]=Symbol.iterator]:($R[4]=s=>(i,c,d,t)=>(i=0,t={[$R[3]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[5]={v:$R[6]=[1,2,3,void 0],t:-1,d:3})}),Object.freeze($R[2]),$R[0])"`; -exports[`frozen object > crossSerializeStream > supports self-recursion 1`] = `"($R[0]={a:$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),b:$R[3]=$R[2]()},Object.freeze($R[0]),$R[0])"`; +exports[`frozen object > crossSerializeStream > supports self-recursion 1`] = `"(self.$R=self.$R||[],($R[0]={a:$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),b:$R[3]=$R[2]()},Object.freeze($R[0]),$R[0]))"`; exports[`frozen object > crossSerializeStream > supports self-recursion 2`] = `"($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[1],$R[0])"`; diff --git a/packages/seroval/test/__snapshots__/iterable.test.ts.snap b/packages/seroval/test/__snapshots__/iterable.test.ts.snap index 8111fb14..9c429bf9 100644 --- a/packages/seroval/test/__snapshots__/iterable.test.ts.snap +++ b/packages/seroval/test/__snapshots__/iterable.test.ts.snap @@ -6,19 +6,19 @@ exports[`Iterable > compat#toJSON > should use function expression instead of ar exports[`Iterable > compat#toJSON > should use function expression instead of arrow functions. 2`] = `"(function(h,j){return ({title:\\"Hello World\\",[h=Symbol.iterator]:(function(s){return function(i,c,d,t){return (i=0,t={[h]:function(){return t},next:function(){if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}})}})({v:[1,2,3,void 0],t:-1,d:3})})})()"`; -exports[`Iterable > crossSerialize > scoped > supports Iterables 1`] = `"($R=>$R[0]={title:\\"Hello World\\",[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})})($R[\\"example\\"])"`; +exports[`Iterable > crossSerialize > scoped > supports Iterables 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={title:\\"Hello World\\",[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})})($R[\\"example\\"]))"`; -exports[`Iterable > crossSerialize > supports Iterables 1`] = `"$R[0]={title:\\"Hello World\\",[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})}"`; +exports[`Iterable > crossSerialize > supports Iterables 1`] = `"(self.$R=self.$R||[],$R[0]={title:\\"Hello World\\",[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})})"`; -exports[`Iterable > crossSerializeAsync > scoped > supports Iterables 1`] = `"($R=>$R[0]=Promise.resolve($R[1]={title:\\"Hello World\\",[$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};c=i++,d=s.v[c];if(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\\"])"`; +exports[`Iterable > crossSerializeAsync > scoped > supports Iterables 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]={title:\\"Hello World\\",[$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};c=i++,d=s.v[c];if(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\\"]))"`; -exports[`Iterable > crossSerializeAsync > supports Iterables 1`] = `"$R[0]=Promise.resolve($R[1]={title:\\"Hello World\\",[$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};c=i++,d=s.v[c];if(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})})"`; +exports[`Iterable > crossSerializeAsync > supports Iterables 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]={title:\\"Hello World\\",[$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};c=i++,d=s.v[c];if(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})}))"`; -exports[`Iterable > crossSerializeStream > scoped > supports Iterables 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`Iterable > crossSerializeStream > scoped > supports Iterables 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`Iterable > crossSerializeStream > scoped > supports Iterables 2`] = `"($R=>($R[7]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]={title:\\"Hello World\\",[$R[3]=Symbol.iterator]:($R[4]=s=>(i,c,d,t)=>(i=0,t={[$R[3]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[5]={v:$R[6]=[1,2,3,void 0],t:-1,d:3})}))($R[\\"example\\"])"`; -exports[`Iterable > crossSerializeStream > supports Iterables 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`Iterable > crossSerializeStream > supports Iterables 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`Iterable > crossSerializeStream > supports Iterables 2`] = `"($R[7]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]={title:\\"Hello World\\",[$R[3]=Symbol.iterator]:($R[4]=s=>(i,c,d,t)=>(i=0,t={[$R[3]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[5]={v:$R[6]=[1,2,3,void 0],t:-1,d:3})})"`; diff --git a/packages/seroval/test/__snapshots__/map.test.ts.snap b/packages/seroval/test/__snapshots__/map.test.ts.snap index 5fe8ce6a..1da828d1 100644 --- a/packages/seroval/test/__snapshots__/map.test.ts.snap +++ b/packages/seroval/test/__snapshots__/map.test.ts.snap @@ -8,33 +8,33 @@ exports[`Map > compat#toJSON > should fallback to Symbol.iterator 1`] = `"{\\"t\ exports[`Map > compat#toJSON > should throw an error for unsupported target 1`] = `"Unsupported type \\"[object Map]\\""`; -exports[`Map > crossSerialize > scoped > supports Map 1`] = `"($R=>$R[0]=($R[1]=[],new Map([[1,2],[3,4]])))($R[\\"example\\"])"`; +exports[`Map > crossSerialize > scoped > supports Map 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=[],new Map([[1,2],[3,4]])))($R[\\"example\\"]))"`; -exports[`Map > crossSerialize > scoped > supports self-recursion 1`] = `"($R=>$R[0]=($R[1]=[],new Map),$R[0].set($R[0],$R[0]),$R[0])($R[\\"example\\"])"`; +exports[`Map > crossSerialize > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=[],new Map),$R[0].set($R[0],$R[0]),$R[0])($R[\\"example\\"]))"`; -exports[`Map > crossSerialize > supports Map 1`] = `"$R[0]=($R[1]=[],new Map([[1,2],[3,4]]))"`; +exports[`Map > crossSerialize > supports Map 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=[],new Map([[1,2],[3,4]])))"`; -exports[`Map > crossSerialize > supports self-recursion 1`] = `"($R[0]=($R[1]=[],new Map),$R[0].set($R[0],$R[0]),$R[0])"`; +exports[`Map > crossSerialize > supports self-recursion 1`] = `"(self.$R=self.$R||[],($R[0]=($R[1]=[],new Map),$R[0].set($R[0],$R[0]),$R[0]))"`; -exports[`Map > crossSerializeAsync > scoped > supports Map 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=($R[2]=[],new Map([[1,2],[3,4]]))))($R[\\"example\\"])"`; +exports[`Map > crossSerializeAsync > scoped > supports Map 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=($R[2]=[],new Map([[1,2],[3,4]]))))($R[\\"example\\"]))"`; -exports[`Map > crossSerializeAsync > scoped > supports self-recursion 1`] = `"($R=>$R[0]=($R[3]=[],new Map([[$R[1]=Promise.resolve().then(()=>$R[0]),$R[2]=Promise.resolve().then(()=>$R[0])]])))($R[\\"example\\"])"`; +exports[`Map > crossSerializeAsync > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[3]=[],new Map([[$R[1]=Promise.resolve().then(()=>$R[0]),$R[2]=Promise.resolve().then(()=>$R[0])]])))($R[\\"example\\"]))"`; -exports[`Map > crossSerializeAsync > supports Map 1`] = `"$R[0]=Promise.resolve($R[1]=($R[2]=[],new Map([[1,2],[3,4]])))"`; +exports[`Map > crossSerializeAsync > supports Map 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=($R[2]=[],new Map([[1,2],[3,4]]))))"`; -exports[`Map > crossSerializeAsync > supports self-recursion 1`] = `"$R[0]=($R[3]=[],new Map([[$R[1]=Promise.resolve().then(()=>$R[0]),$R[2]=Promise.resolve().then(()=>$R[0])]]))"`; +exports[`Map > crossSerializeAsync > supports self-recursion 1`] = `"(self.$R=self.$R||[],$R[0]=($R[3]=[],new Map([[$R[1]=Promise.resolve().then(()=>$R[0]),$R[2]=Promise.resolve().then(()=>$R[0])]])))"`; -exports[`Map > crossSerializeStream > scoped > supports Map 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`Map > crossSerializeStream > scoped > supports Map 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`Map > crossSerializeStream > scoped > supports Map 2`] = `"($R=>($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=($R[3]=[],new Map([[1,2],[3,4]]))))($R[\\"example\\"])"`; -exports[`Map > crossSerializeStream > scoped > supports self-recursion 1`] = `"($R=>$R[0]=($R[4]=[],new Map([[$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),$R[3]=$R[2]()]])))($R[\\"example\\"])"`; +exports[`Map > crossSerializeStream > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[4]=[],new Map([[$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),$R[3]=$R[2]()]])))($R[\\"example\\"]))"`; exports[`Map > crossSerializeStream > scoped > supports self-recursion 2`] = `"($R=>($R[5]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[1],$R[0]))($R[\\"example\\"])"`; exports[`Map > crossSerializeStream > scoped > supports self-recursion 3`] = `"($R=>$R[5]($R[3],$R[0]))($R[\\"example\\"])"`; -exports[`Map > crossSerializeStream > supports Map 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`Map > crossSerializeStream > supports Map 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`Map > crossSerializeStream > supports Map 2`] = `"($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=($R[3]=[],new Map([[1,2],[3,4]])))"`; @@ -42,7 +42,7 @@ exports[`Map > crossSerializeStream > supports Map 3`] = `"{\\"t\\":28,\\"i\\":0 exports[`Map > crossSerializeStream > supports Map 4`] = `"{\\"t\\":29,\\"i\\":0,\\"a\\":[{\\"t\\":41,\\"i\\":4,\\"s\\":3},{\\"t\\":8,\\"i\\":2,\\"e\\":{\\"k\\":[{\\"t\\":0,\\"s\\":1},{\\"t\\":0,\\"s\\":3}],\\"v\\":[{\\"t\\":0,\\"s\\":2},{\\"t\\":0,\\"s\\":4}],\\"s\\":2},\\"f\\":{\\"t\\":41,\\"i\\":3,\\"s\\":0}}]}"`; -exports[`Map > crossSerializeStream > supports self-recursion 1`] = `"$R[0]=($R[4]=[],new Map([[$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),$R[3]=$R[2]()]]))"`; +exports[`Map > crossSerializeStream > supports self-recursion 1`] = `"(self.$R=self.$R||[],$R[0]=($R[4]=[],new Map([[$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),$R[3]=$R[2]()]])))"`; exports[`Map > crossSerializeStream > supports self-recursion 2`] = `"($R[5]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[1],$R[0])"`; diff --git a/packages/seroval/test/__snapshots__/mutual-cycle.test.ts.snap b/packages/seroval/test/__snapshots__/mutual-cycle.test.ts.snap index 319bfd44..b6bf2071 100644 --- a/packages/seroval/test/__snapshots__/mutual-cycle.test.ts.snap +++ b/packages/seroval/test/__snapshots__/mutual-cycle.test.ts.snap @@ -1,60 +1,60 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`mutual cyclic references > crossSerialize > scoped > supports Arrays and Arrays 1`] = `"($R=>$R[0]=[$R[1]=[$R[2]=[,]],$R[2]],$R[2][0]=$R[1],$R[0])($R[\\"example\\"])"`; +exports[`mutual cyclic references > crossSerialize > scoped > supports Arrays and Arrays 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=[$R[1]=[$R[2]=[,]],$R[2]],$R[2][0]=$R[1],$R[0])($R[\\"example\\"]))"`; -exports[`mutual cyclic references > crossSerialize > scoped > supports Arrays and Objects 1`] = `"($R=>$R[0]=[$R[1]=[$R[2]={}],$R[2]],$R[2][0]=$R[1],$R[0])($R[\\"example\\"])"`; +exports[`mutual cyclic references > crossSerialize > scoped > supports Arrays and Objects 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=[$R[1]=[$R[2]={}],$R[2]],$R[2][0]=$R[1],$R[0])($R[\\"example\\"]))"`; -exports[`mutual cyclic references > crossSerialize > scoped > supports Objects and Objects 1`] = `"($R=>$R[0]=[$R[1]={0:$R[2]={}},$R[2]],$R[2][0]=$R[1],$R[0])($R[\\"example\\"])"`; +exports[`mutual cyclic references > crossSerialize > scoped > supports Objects and Objects 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=[$R[1]={0:$R[2]={}},$R[2]],$R[2][0]=$R[1],$R[0])($R[\\"example\\"]))"`; -exports[`mutual cyclic references > crossSerialize > supports Arrays and Arrays 1`] = `"($R[0]=[$R[1]=[$R[2]=[,]],$R[2]],$R[2][0]=$R[1],$R[0])"`; +exports[`mutual cyclic references > crossSerialize > supports Arrays and Arrays 1`] = `"(self.$R=self.$R||[],($R[0]=[$R[1]=[$R[2]=[,]],$R[2]],$R[2][0]=$R[1],$R[0]))"`; -exports[`mutual cyclic references > crossSerialize > supports Arrays and Objects 1`] = `"($R[0]=[$R[1]=[$R[2]={}],$R[2]],$R[2][0]=$R[1],$R[0])"`; +exports[`mutual cyclic references > crossSerialize > supports Arrays and Objects 1`] = `"(self.$R=self.$R||[],($R[0]=[$R[1]=[$R[2]={}],$R[2]],$R[2][0]=$R[1],$R[0]))"`; -exports[`mutual cyclic references > crossSerialize > supports Objects and Objects 1`] = `"($R[0]=[$R[1]={0:$R[2]={}},$R[2]],$R[2][0]=$R[1],$R[0])"`; +exports[`mutual cyclic references > crossSerialize > supports Objects and Objects 1`] = `"(self.$R=self.$R||[],($R[0]=[$R[1]={0:$R[2]={}},$R[2]],$R[2][0]=$R[1],$R[0]))"`; -exports[`mutual cyclic references > crossSerializeAsync > scoped > supports Arrays and Arrays 1`] = `"($R=>$R[0]=[$R[1]=[$R[2]=Promise.resolve($R[3]=[$R[4]=Promise.resolve().then(()=>$R[1])])],$R[3]])($R[\\"example\\"])"`; +exports[`mutual cyclic references > crossSerializeAsync > scoped > supports Arrays and Arrays 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=[$R[1]=[$R[2]=Promise.resolve($R[3]=[$R[4]=Promise.resolve().then(()=>$R[1])])],$R[3]])($R[\\"example\\"]))"`; -exports[`mutual cyclic references > crossSerializeAsync > scoped > supports Arrays and Objects 1`] = `"($R=>$R[0]=[$R[1]=[$R[2]=Promise.resolve($R[3]={0:$R[4]=Promise.resolve().then(()=>$R[1])})],$R[3]])($R[\\"example\\"])"`; +exports[`mutual cyclic references > crossSerializeAsync > scoped > supports Arrays and Objects 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=[$R[1]=[$R[2]=Promise.resolve($R[3]={0:$R[4]=Promise.resolve().then(()=>$R[1])})],$R[3]])($R[\\"example\\"]))"`; -exports[`mutual cyclic references > crossSerializeAsync > scoped > supports Objects and Objects 1`] = `"($R=>$R[0]=[$R[1]={0:$R[2]=Promise.resolve($R[3]={0:$R[4]=Promise.resolve().then(()=>$R[1])})},$R[3]])($R[\\"example\\"])"`; +exports[`mutual cyclic references > crossSerializeAsync > scoped > supports Objects and Objects 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=[$R[1]={0:$R[2]=Promise.resolve($R[3]={0:$R[4]=Promise.resolve().then(()=>$R[1])})},$R[3]])($R[\\"example\\"]))"`; -exports[`mutual cyclic references > crossSerializeAsync > supports Arrays and Arrays 1`] = `"$R[0]=[$R[1]=[$R[2]=Promise.resolve($R[3]=[$R[4]=Promise.resolve().then(()=>$R[1])])],$R[3]]"`; +exports[`mutual cyclic references > crossSerializeAsync > supports Arrays and Arrays 1`] = `"(self.$R=self.$R||[],$R[0]=[$R[1]=[$R[2]=Promise.resolve($R[3]=[$R[4]=Promise.resolve().then(()=>$R[1])])],$R[3]])"`; -exports[`mutual cyclic references > crossSerializeAsync > supports Arrays and Objects 1`] = `"$R[0]=[$R[1]=[$R[2]=Promise.resolve($R[3]={0:$R[4]=Promise.resolve().then(()=>$R[1])})],$R[3]]"`; +exports[`mutual cyclic references > crossSerializeAsync > supports Arrays and Objects 1`] = `"(self.$R=self.$R||[],$R[0]=[$R[1]=[$R[2]=Promise.resolve($R[3]={0:$R[4]=Promise.resolve().then(()=>$R[1])})],$R[3]])"`; -exports[`mutual cyclic references > crossSerializeAsync > supports Objects and Objects 1`] = `"$R[0]=[$R[1]={0:$R[2]=Promise.resolve($R[3]={0:$R[4]=Promise.resolve().then(()=>$R[1])})},$R[3]]"`; +exports[`mutual cyclic references > crossSerializeAsync > supports Objects and Objects 1`] = `"(self.$R=self.$R||[],$R[0]=[$R[1]={0:$R[2]=Promise.resolve($R[3]={0:$R[4]=Promise.resolve().then(()=>$R[1])})},$R[3]])"`; -exports[`mutual cyclic references > crossSerializeStream > scoped > supports Arrays and Arrays 1`] = `"($R=>$R[0]=[$R[1]=[$R[2]=($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()],$R[4]=[$R[5]=$R[3]()]])($R[\\"example\\"])"`; +exports[`mutual cyclic references > crossSerializeStream > scoped > supports Arrays and Arrays 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=[$R[1]=[$R[2]=($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()],$R[4]=[$R[5]=$R[3]()]])($R[\\"example\\"]))"`; exports[`mutual cyclic references > crossSerializeStream > scoped > supports Arrays and Arrays 2`] = `"($R=>($R[6]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[2],$R[4]))($R[\\"example\\"])"`; exports[`mutual cyclic references > crossSerializeStream > scoped > supports Arrays and Arrays 3`] = `"($R=>$R[6]($R[5],$R[1]))($R[\\"example\\"])"`; -exports[`mutual cyclic references > crossSerializeStream > scoped > supports Arrays and Objects 1`] = `"($R=>$R[0]=[$R[1]=[$R[2]=($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()],$R[4]={0:$R[5]=$R[3]()}])($R[\\"example\\"])"`; +exports[`mutual cyclic references > crossSerializeStream > scoped > supports Arrays and Objects 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=[$R[1]=[$R[2]=($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()],$R[4]={0:$R[5]=$R[3]()}])($R[\\"example\\"]))"`; exports[`mutual cyclic references > crossSerializeStream > scoped > supports Arrays and Objects 2`] = `"($R=>($R[6]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[2],$R[4]))($R[\\"example\\"])"`; exports[`mutual cyclic references > crossSerializeStream > scoped > supports Arrays and Objects 3`] = `"($R=>$R[6]($R[5],$R[1]))($R[\\"example\\"])"`; -exports[`mutual cyclic references > crossSerializeStream > scoped > supports Objects and Objects 1`] = `"($R=>$R[0]=[$R[1]={0:$R[2]=($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()},$R[4]={0:$R[5]=$R[3]()}])($R[\\"example\\"])"`; +exports[`mutual cyclic references > crossSerializeStream > scoped > supports Objects and Objects 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=[$R[1]={0:$R[2]=($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()},$R[4]={0:$R[5]=$R[3]()}])($R[\\"example\\"]))"`; exports[`mutual cyclic references > crossSerializeStream > scoped > supports Objects and Objects 2`] = `"($R=>($R[6]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[2],$R[4]))($R[\\"example\\"])"`; exports[`mutual cyclic references > crossSerializeStream > scoped > supports Objects and Objects 3`] = `"($R=>$R[6]($R[5],$R[1]))($R[\\"example\\"])"`; -exports[`mutual cyclic references > crossSerializeStream > supports Arrays and Arrays 1`] = `"$R[0]=[$R[1]=[$R[2]=($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()],$R[4]=[$R[5]=$R[3]()]]"`; +exports[`mutual cyclic references > crossSerializeStream > supports Arrays and Arrays 1`] = `"(self.$R=self.$R||[],$R[0]=[$R[1]=[$R[2]=($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()],$R[4]=[$R[5]=$R[3]()]])"`; exports[`mutual cyclic references > crossSerializeStream > supports Arrays and Arrays 2`] = `"($R[6]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[2],$R[4])"`; exports[`mutual cyclic references > crossSerializeStream > supports Arrays and Arrays 3`] = `"$R[6]($R[5],$R[1])"`; -exports[`mutual cyclic references > crossSerializeStream > supports Arrays and Objects 1`] = `"$R[0]=[$R[1]=[$R[2]=($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()],$R[4]={0:$R[5]=$R[3]()}]"`; +exports[`mutual cyclic references > crossSerializeStream > supports Arrays and Objects 1`] = `"(self.$R=self.$R||[],$R[0]=[$R[1]=[$R[2]=($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()],$R[4]={0:$R[5]=$R[3]()}])"`; exports[`mutual cyclic references > crossSerializeStream > supports Arrays and Objects 2`] = `"($R[6]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[2],$R[4])"`; exports[`mutual cyclic references > crossSerializeStream > supports Arrays and Objects 3`] = `"$R[6]($R[5],$R[1])"`; -exports[`mutual cyclic references > crossSerializeStream > supports Objects and Objects 1`] = `"$R[0]=[$R[1]={0:$R[2]=($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()},$R[4]={0:$R[5]=$R[3]()}]"`; +exports[`mutual cyclic references > crossSerializeStream > supports Objects and Objects 1`] = `"(self.$R=self.$R||[],$R[0]=[$R[1]={0:$R[2]=($R[3]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()},$R[4]={0:$R[5]=$R[3]()}])"`; exports[`mutual cyclic references > crossSerializeStream > supports Objects and Objects 2`] = `"($R[6]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[2],$R[4])"`; diff --git a/packages/seroval/test/__snapshots__/null-constructor.test.ts.snap b/packages/seroval/test/__snapshots__/null-constructor.test.ts.snap index 5f31e9dc..32c47f4a 100644 --- a/packages/seroval/test/__snapshots__/null-constructor.test.ts.snap +++ b/packages/seroval/test/__snapshots__/null-constructor.test.ts.snap @@ -6,39 +6,39 @@ exports[`null-constructor > compat#toJSON > should use manual assignment instead exports[`null-constructor > compat#toJSON > should use manual assignment instead of Object.assign 2`] = `"(h=>((h=Object.create(null),h.hello=\\"world\\",h)))()"`; -exports[`null-constructor > crossSerialize > scoped > supports Object.create(null) 1`] = `"($R=>$R[0]=Object.assign(Object.create(null),{hello:\\"world\\"}))($R[\\"example\\"])"`; +exports[`null-constructor > crossSerialize > scoped > supports Object.create(null) 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object.assign(Object.create(null),{hello:\\"world\\"}))($R[\\"example\\"]))"`; -exports[`null-constructor > crossSerialize > scoped > supports Symbol.iterator 1`] = `"($R=>$R[0]=Object.assign(Object.create(null),{[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})}))($R[\\"example\\"])"`; +exports[`null-constructor > crossSerialize > scoped > supports Symbol.iterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object.assign(Object.create(null),{[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})}))($R[\\"example\\"]))"`; -exports[`null-constructor > crossSerialize > scoped > supports self-recursion 1`] = `"($R=>$R[0]=Object.create(null),$R[0].b=$R[0].a=$R[0],$R[0])($R[\\"example\\"])"`; +exports[`null-constructor > crossSerialize > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object.create(null),$R[0].b=$R[0].a=$R[0],$R[0])($R[\\"example\\"]))"`; -exports[`null-constructor > crossSerialize > supports Object.create(null) 1`] = `"($R[0]={hello:\\"world\\"},Object.freeze($R[0]),$R[0])"`; +exports[`null-constructor > crossSerialize > supports Object.create(null) 1`] = `"(self.$R=self.$R||[],($R[0]={hello:\\"world\\"},Object.freeze($R[0]),$R[0]))"`; -exports[`null-constructor > crossSerialize > supports Symbol.iterator 1`] = `"$R[0]=Object.assign(Object.create(null),{[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})})"`; +exports[`null-constructor > crossSerialize > supports Symbol.iterator 1`] = `"(self.$R=self.$R||[],$R[0]=Object.assign(Object.create(null),{[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})}))"`; -exports[`null-constructor > crossSerialize > supports self-recursion 1`] = `"($R[0]=Object.create(null),$R[0].b=$R[0].a=$R[0],$R[0])"`; +exports[`null-constructor > crossSerialize > supports self-recursion 1`] = `"(self.$R=self.$R||[],($R[0]=Object.create(null),$R[0].b=$R[0].a=$R[0],$R[0]))"`; -exports[`null-constructor > crossSerializeAsync > scoped > supports Object.create(null) 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=Object.assign(Object.create(null),{hello:\\"world\\"})))($R[\\"example\\"])"`; +exports[`null-constructor > crossSerializeAsync > scoped > supports Object.create(null) 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Object.assign(Object.create(null),{hello:\\"world\\"})))($R[\\"example\\"]))"`; -exports[`null-constructor > crossSerializeAsync > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]=Object.assign(Object.create(null),{[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})}))($R[\\"example\\"])"`; +exports[`null-constructor > crossSerializeAsync > scoped > supports Symbol.asyncIterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object.assign(Object.create(null),{[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})}))($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};c=i++,d=s.v[c];if(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\\"])"`; +exports[`null-constructor > crossSerializeAsync > scoped > supports Symbol.iterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($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};c=i++,d=s.v[c];if(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\\"]))"`; -exports[`null-constructor > crossSerializeAsync > scoped > supports self-recursion 1`] = `"($R=>$R[0]=Object.assign(Object.create(null),{a:$R[1]=Promise.resolve().then(()=>$R[0]),b:$R[2]=Promise.resolve().then(()=>$R[0])}))($R[\\"example\\"])"`; +exports[`null-constructor > crossSerializeAsync > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object.assign(Object.create(null),{a:$R[1]=Promise.resolve().then(()=>$R[0]),b:$R[2]=Promise.resolve().then(()=>$R[0])}))($R[\\"example\\"]))"`; -exports[`null-constructor > crossSerializeAsync > supports Object.create(null) 1`] = `"$R[0]=Promise.resolve($R[1]=Object.assign(Object.create(null),{hello:\\"world\\"}))"`; +exports[`null-constructor > crossSerializeAsync > supports Object.create(null) 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Object.assign(Object.create(null),{hello:\\"world\\"})))"`; -exports[`null-constructor > crossSerializeAsync > supports Symbol.asyncIterator 1`] = `"$R[0]=Object.assign(Object.create(null),{[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})})"`; +exports[`null-constructor > crossSerializeAsync > supports Symbol.asyncIterator 1`] = `"(self.$R=self.$R||[],$R[0]=Object.assign(Object.create(null),{[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})}))"`; -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};c=i++,d=s.v[c];if(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})}))"`; +exports[`null-constructor > crossSerializeAsync > supports Symbol.iterator 1`] = `"(self.$R=self.$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};c=i++,d=s.v[c];if(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})})))"`; -exports[`null-constructor > crossSerializeAsync > supports self-recursion 1`] = `"$R[0]=Object.assign(Object.create(null),{a:$R[1]=Promise.resolve().then(()=>$R[0]),b:$R[2]=Promise.resolve().then(()=>$R[0])})"`; +exports[`null-constructor > crossSerializeAsync > supports self-recursion 1`] = `"(self.$R=self.$R||[],$R[0]=Object.assign(Object.create(null),{a:$R[1]=Promise.resolve().then(()=>$R[0]),b:$R[2]=Promise.resolve().then(()=>$R[0])}))"`; -exports[`null-constructor > crossSerializeStream > scoped > supports Object.create(null) 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`null-constructor > crossSerializeStream > scoped > supports Object.create(null) 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; 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),{hello:\\"world\\"})))($R[\\"example\\"])"`; -exports[`null-constructor > crossSerializeStream > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]=Object.assign(Object.create(null),{[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())}))($R[\\"example\\"])"`; +exports[`null-constructor > crossSerializeStream > scoped > supports Symbol.asyncIterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object.assign(Object.create(null),{[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())}))($R[\\"example\\"]))"`; exports[`null-constructor > crossSerializeStream > scoped > supports Symbol.asyncIterator 2`] = `"($R=>($R[6]=(s,d)=>{s.c.enqueue(d)})($R[3],$R[5]=[0,1]))($R[\\"example\\"])"`; @@ -50,21 +50,21 @@ exports[`null-constructor > crossSerializeStream > scoped > supports Symbol.asyn exports[`null-constructor > crossSerializeStream > scoped > supports Symbol.asyncIterator 6`] = `"($R=>($R[10]=s=>{s.c.close();delete s.c})($R[3]))($R[\\"example\\"])"`; -exports[`null-constructor > crossSerializeStream > scoped > supports Symbol.iterator 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`null-constructor > crossSerializeStream > scoped > supports Symbol.iterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`null-constructor > crossSerializeStream > scoped > supports Symbol.iterator 2`] = `"($R=>($R[7]=(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),{[$R[3]=Symbol.iterator]:($R[4]=s=>(i,c,d,t)=>(i=0,t={[$R[3]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[5]={v:$R[6]=[1,2,3,void 0],t:-1,d:3})})))($R[\\"example\\"])"`; -exports[`null-constructor > crossSerializeStream > scoped > supports self-recursion 1`] = `"($R=>$R[0]=Object.assign(Object.create(null),{a:$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),b:$R[3]=$R[2]()}))($R[\\"example\\"])"`; +exports[`null-constructor > crossSerializeStream > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Object.assign(Object.create(null),{a:$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),b:$R[3]=$R[2]()}))($R[\\"example\\"]))"`; exports[`null-constructor > crossSerializeStream > scoped > supports self-recursion 2`] = `"($R=>($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[1],$R[0]))($R[\\"example\\"])"`; exports[`null-constructor > crossSerializeStream > scoped > supports self-recursion 3`] = `"($R=>$R[4]($R[3],$R[0]))($R[\\"example\\"])"`; -exports[`null-constructor > crossSerializeStream > supports Object.create(null) 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`null-constructor > crossSerializeStream > supports Object.create(null) 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; 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),{hello:\\"world\\"}))"`; -exports[`null-constructor > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"$R[0]=Object.assign(Object.create(null),{[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())})"`; +exports[`null-constructor > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"(self.$R=self.$R||[],$R[0]=Object.assign(Object.create(null),{[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())}))"`; exports[`null-constructor > crossSerializeStream > supports Symbol.asyncIterator 2`] = `"($R[6]=(s,d)=>{s.c.enqueue(d)})($R[3],$R[5]=[0,1])"`; @@ -76,11 +76,11 @@ exports[`null-constructor > crossSerializeStream > supports Symbol.asyncIterator exports[`null-constructor > crossSerializeStream > supports Symbol.asyncIterator 6`] = `"($R[10]=s=>{s.c.close();delete s.c})($R[3])"`; -exports[`null-constructor > crossSerializeStream > supports Symbol.iterator 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`null-constructor > crossSerializeStream > supports Symbol.iterator 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`null-constructor > crossSerializeStream > supports Symbol.iterator 2`] = `"($R[7]=(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),{[$R[3]=Symbol.iterator]:($R[4]=s=>(i,c,d,t)=>(i=0,t={[$R[3]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[5]={v:$R[6]=[1,2,3,void 0],t:-1,d:3})}))"`; -exports[`null-constructor > crossSerializeStream > supports self-recursion 1`] = `"$R[0]=Object.assign(Object.create(null),{a:$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),b:$R[3]=$R[2]()})"`; +exports[`null-constructor > crossSerializeStream > supports self-recursion 1`] = `"(self.$R=self.$R||[],$R[0]=Object.assign(Object.create(null),{a:$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),b:$R[3]=$R[2]()}))"`; exports[`null-constructor > crossSerializeStream > supports self-recursion 2`] = `"($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[1],$R[0])"`; diff --git a/packages/seroval/test/__snapshots__/number.test.ts.snap b/packages/seroval/test/__snapshots__/number.test.ts.snap index beb96c27..6a065ac8 100644 --- a/packages/seroval/test/__snapshots__/number.test.ts.snap +++ b/packages/seroval/test/__snapshots__/number.test.ts.snap @@ -1,42 +1,42 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`number > crossSerialize > supports numbers 1`] = `"3735928559"`; +exports[`number > crossSerialize > supports numbers 1`] = `"(self.$R=self.$R||[],3735928559)"`; -exports[`number > crossSerialize > supports numbers 2`] = `"0/0"`; +exports[`number > crossSerialize > supports numbers 2`] = `"(self.$R=self.$R||[],0/0)"`; -exports[`number > crossSerialize > supports numbers 3`] = `"1/0"`; +exports[`number > crossSerialize > supports numbers 3`] = `"(self.$R=self.$R||[],1/0)"`; -exports[`number > crossSerialize > supports numbers 4`] = `"-1/0"`; +exports[`number > crossSerialize > supports numbers 4`] = `"(self.$R=self.$R||[],-1/0)"`; -exports[`number > crossSerialize > supports numbers 5`] = `"-0"`; +exports[`number > crossSerialize > supports numbers 5`] = `"(self.$R=self.$R||[],-0)"`; -exports[`number > crossSerializeAsync > supports numbers 1`] = `"$R[0]=Promise.resolve(3735928559)"`; +exports[`number > crossSerializeAsync > supports numbers 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve(3735928559))"`; -exports[`number > crossSerializeAsync > supports numbers 2`] = `"$R[0]=Promise.resolve(0/0)"`; +exports[`number > crossSerializeAsync > supports numbers 2`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve(0/0))"`; -exports[`number > crossSerializeAsync > supports numbers 3`] = `"$R[0]=Promise.resolve(1/0)"`; +exports[`number > crossSerializeAsync > supports numbers 3`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve(1/0))"`; -exports[`number > crossSerializeAsync > supports numbers 4`] = `"$R[0]=Promise.resolve(-1/0)"`; +exports[`number > crossSerializeAsync > supports numbers 4`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve(-1/0))"`; -exports[`number > crossSerializeAsync > supports numbers 5`] = `"$R[0]=Promise.resolve(-0)"`; +exports[`number > crossSerializeAsync > supports numbers 5`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve(-0))"`; -exports[`number > crossSerializeStream > supports -0 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`number > crossSerializeStream > supports -0 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`number > crossSerializeStream > supports -0 2`] = `"($R[2]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],-0)"`; -exports[`number > crossSerializeStream > supports -Infinity 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`number > crossSerializeStream > supports -Infinity 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`number > crossSerializeStream > supports -Infinity 2`] = `"($R[2]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],-1/0)"`; -exports[`number > crossSerializeStream > supports Infinity 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`number > crossSerializeStream > supports Infinity 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`number > crossSerializeStream > supports Infinity 2`] = `"($R[2]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],1/0)"`; -exports[`number > crossSerializeStream > supports NaN 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`number > crossSerializeStream > supports NaN 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`number > crossSerializeStream > supports NaN 2`] = `"($R[2]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],0/0)"`; -exports[`number > crossSerializeStream > supports numbers 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`number > crossSerializeStream > supports numbers 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`number > crossSerializeStream > supports numbers 2`] = `"($R[2]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],3735928559)"`; diff --git a/packages/seroval/test/__snapshots__/object.test.ts.snap b/packages/seroval/test/__snapshots__/object.test.ts.snap index 5946479f..5630c510 100644 --- a/packages/seroval/test/__snapshots__/object.test.ts.snap +++ b/packages/seroval/test/__snapshots__/object.test.ts.snap @@ -6,39 +6,39 @@ exports[`objects > compat#toJSON > should use manual assignment instead of Objec exports[`objects > compat#toJSON > should use manual assignment instead of Object.assign 2`] = `"({hello:\\"world\\"})"`; -exports[`objects > crossSerialize > scoped > supports Objects 1`] = `"($R=>$R[0]={hello:\\"world\\"})($R[\\"example\\"])"`; +exports[`objects > crossSerialize > scoped > supports Objects 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={hello:\\"world\\"})($R[\\"example\\"]))"`; -exports[`objects > crossSerialize > scoped > supports Symbol.iterator 1`] = `"($R=>$R[0]={[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})})($R[\\"example\\"])"`; +exports[`objects > crossSerialize > scoped > supports Symbol.iterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})})($R[\\"example\\"]))"`; -exports[`objects > crossSerialize > scoped > supports self-recursion 1`] = `"($R=>$R[0]={},$R[0].b=$R[0].a=$R[0],$R[0])($R[\\"example\\"])"`; +exports[`objects > crossSerialize > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={},$R[0].b=$R[0].a=$R[0],$R[0])($R[\\"example\\"]))"`; -exports[`objects > crossSerialize > supports Objects 1`] = `"($R[0]={hello:\\"world\\"},Object.freeze($R[0]),$R[0])"`; +exports[`objects > crossSerialize > supports Objects 1`] = `"(self.$R=self.$R||[],($R[0]={hello:\\"world\\"},Object.freeze($R[0]),$R[0]))"`; -exports[`objects > crossSerialize > supports Symbol.iterator 1`] = `"$R[0]={[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})}"`; +exports[`objects > crossSerialize > supports Symbol.iterator 1`] = `"(self.$R=self.$R||[],$R[0]={[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})})"`; -exports[`objects > crossSerialize > supports self-recursion 1`] = `"($R[0]={},$R[0].b=$R[0].a=$R[0],$R[0])"`; +exports[`objects > crossSerialize > supports self-recursion 1`] = `"(self.$R=self.$R||[],($R[0]={},$R[0].b=$R[0].a=$R[0],$R[0]))"`; -exports[`objects > crossSerializeAsync > scoped > supports Objects 1`] = `"($R=>$R[0]=Promise.resolve($R[1]={hello:\\"world\\"}))($R[\\"example\\"])"`; +exports[`objects > crossSerializeAsync > scoped > supports Objects 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]={hello:\\"world\\"}))($R[\\"example\\"]))"`; -exports[`objects > crossSerializeAsync > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})})($R[\\"example\\"])"`; +exports[`objects > crossSerializeAsync > scoped > supports Symbol.asyncIterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})})($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};c=i++,d=s.v[c];if(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\\"])"`; +exports[`objects > crossSerializeAsync > scoped > supports Symbol.iterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($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};c=i++,d=s.v[c];if(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\\"]))"`; -exports[`objects > crossSerializeAsync > scoped > supports self-recursion 1`] = `"($R=>$R[0]={a:$R[1]=Promise.resolve().then(()=>$R[0]),b:$R[2]=Promise.resolve().then(()=>$R[0])})($R[\\"example\\"])"`; +exports[`objects > crossSerializeAsync > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={a:$R[1]=Promise.resolve().then(()=>$R[0]),b:$R[2]=Promise.resolve().then(()=>$R[0])})($R[\\"example\\"]))"`; -exports[`objects > crossSerializeAsync > supports Objects 1`] = `"$R[0]=Promise.resolve($R[1]={hello:\\"world\\"})"`; +exports[`objects > crossSerializeAsync > supports Objects 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]={hello:\\"world\\"}))"`; -exports[`objects > crossSerializeAsync > supports Symbol.asyncIterator 1`] = `"$R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})}"`; +exports[`objects > crossSerializeAsync > supports Symbol.asyncIterator 1`] = `"(self.$R=self.$R||[],$R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})})"`; -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};c=i++,d=s.v[c];if(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})})"`; +exports[`objects > crossSerializeAsync > supports Symbol.iterator 1`] = `"(self.$R=self.$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};c=i++,d=s.v[c];if(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})}))"`; -exports[`objects > crossSerializeAsync > supports self-recursion 1`] = `"$R[0]={a:$R[1]=Promise.resolve().then(()=>$R[0]),b:$R[2]=Promise.resolve().then(()=>$R[0])}"`; +exports[`objects > crossSerializeAsync > supports self-recursion 1`] = `"(self.$R=self.$R||[],$R[0]={a:$R[1]=Promise.resolve().then(()=>$R[0]),b:$R[2]=Promise.resolve().then(()=>$R[0])})"`; -exports[`objects > crossSerializeStream > scoped > supports Objects 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`objects > crossSerializeStream > scoped > supports Objects 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; 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]={hello:\\"world\\"}))($R[\\"example\\"])"`; -exports[`objects > crossSerializeStream > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())})($R[\\"example\\"])"`; +exports[`objects > crossSerializeStream > scoped > supports Symbol.asyncIterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())})($R[\\"example\\"]))"`; exports[`objects > crossSerializeStream > scoped > supports Symbol.asyncIterator 2`] = `"($R=>($R[6]=(s,d)=>{s.c.enqueue(d)})($R[3],$R[5]=[0,1]))($R[\\"example\\"])"`; @@ -50,21 +50,21 @@ exports[`objects > crossSerializeStream > scoped > supports Symbol.asyncIterator exports[`objects > crossSerializeStream > scoped > supports Symbol.asyncIterator 6`] = `"($R=>($R[10]=s=>{s.c.close();delete s.c})($R[3]))($R[\\"example\\"])"`; -exports[`objects > crossSerializeStream > scoped > supports Symbol.iterator 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`objects > crossSerializeStream > scoped > supports Symbol.iterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`objects > crossSerializeStream > scoped > supports Symbol.iterator 2`] = `"($R=>($R[7]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]={[$R[3]=Symbol.iterator]:($R[4]=s=>(i,c,d,t)=>(i=0,t={[$R[3]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[5]={v:$R[6]=[1,2,3,void 0],t:-1,d:3})}))($R[\\"example\\"])"`; -exports[`objects > crossSerializeStream > scoped > supports self-recursion 1`] = `"($R=>$R[0]={a:$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),b:$R[3]=$R[2]()})($R[\\"example\\"])"`; +exports[`objects > crossSerializeStream > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={a:$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),b:$R[3]=$R[2]()})($R[\\"example\\"]))"`; exports[`objects > crossSerializeStream > scoped > supports self-recursion 2`] = `"($R=>($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[1],$R[0]))($R[\\"example\\"])"`; exports[`objects > crossSerializeStream > scoped > supports self-recursion 3`] = `"($R=>$R[4]($R[3],$R[0]))($R[\\"example\\"])"`; -exports[`objects > crossSerializeStream > supports Objects 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`objects > crossSerializeStream > supports Objects 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; 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]={hello:\\"world\\"})"`; -exports[`objects > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"$R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())}"`; +exports[`objects > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"(self.$R=self.$R||[],$R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())})"`; exports[`objects > crossSerializeStream > supports Symbol.asyncIterator 2`] = `"($R[6]=(s,d)=>{s.c.enqueue(d)})($R[3],$R[5]=[0,1])"`; @@ -76,11 +76,11 @@ exports[`objects > crossSerializeStream > supports Symbol.asyncIterator 5`] = `" exports[`objects > crossSerializeStream > supports Symbol.asyncIterator 6`] = `"($R[10]=s=>{s.c.close();delete s.c})($R[3])"`; -exports[`objects > crossSerializeStream > supports Symbol.iterator 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`objects > crossSerializeStream > supports Symbol.iterator 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`objects > crossSerializeStream > supports Symbol.iterator 2`] = `"($R[7]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]={[$R[3]=Symbol.iterator]:($R[4]=s=>(i,c,d,t)=>(i=0,t={[$R[3]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[5]={v:$R[6]=[1,2,3,void 0],t:-1,d:3})})"`; -exports[`objects > crossSerializeStream > supports self-recursion 1`] = `"$R[0]={a:$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),b:$R[3]=$R[2]()}"`; +exports[`objects > crossSerializeStream > supports self-recursion 1`] = `"(self.$R=self.$R||[],$R[0]={a:$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),b:$R[3]=$R[2]()})"`; exports[`objects > crossSerializeStream > supports self-recursion 2`] = `"($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[1],$R[0])"`; diff --git a/packages/seroval/test/__snapshots__/plugin.test.ts.snap b/packages/seroval/test/__snapshots__/plugin.test.ts.snap index d49576c0..206e200c 100644 --- a/packages/seroval/test/__snapshots__/plugin.test.ts.snap +++ b/packages/seroval/test/__snapshots__/plugin.test.ts.snap @@ -1,16 +1,16 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Plugin > crossSerialize > scoped > supports Plugin 1`] = `"($R=>$R[0]=Buffer.from(\\"SGVsbG8sIFdvcmxkIQ==\\", \\"base64\\"))($R[\\"example\\"])"`; +exports[`Plugin > crossSerialize > scoped > supports Plugin 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Buffer.from(\\"SGVsbG8sIFdvcmxkIQ==\\", \\"base64\\"))($R[\\"example\\"]))"`; -exports[`Plugin > crossSerialize > supports Plugin 1`] = `"$R[0]=Buffer.from(\\"SGVsbG8sIFdvcmxkIQ==\\", \\"base64\\")"`; +exports[`Plugin > crossSerialize > supports Plugin 1`] = `"(self.$R=self.$R||[],$R[0]=Buffer.from(\\"SGVsbG8sIFdvcmxkIQ==\\", \\"base64\\"))"`; -exports[`Plugin > crossSerializeAsync > scoped > supports Plugin 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=Buffer.from(\\"SGVsbG8sIFdvcmxkIQ==\\", \\"base64\\")))($R[\\"example\\"])"`; +exports[`Plugin > crossSerializeAsync > scoped > supports Plugin 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Buffer.from(\\"SGVsbG8sIFdvcmxkIQ==\\", \\"base64\\")))($R[\\"example\\"]))"`; -exports[`Plugin > crossSerializeAsync > supports Plugin 1`] = `"$R[0]=Promise.resolve($R[1]=Buffer.from(\\"SGVsbG8sIFdvcmxkIQ==\\", \\"base64\\"))"`; +exports[`Plugin > crossSerializeAsync > supports Plugin 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Buffer.from(\\"SGVsbG8sIFdvcmxkIQ==\\", \\"base64\\")))"`; -exports[`Plugin > crossSerializeStream > scoped > supports Plugin 1`] = `"($R=>$R[0]=Buffer.from(\\"SGVsbG8sIFdvcmxkIQ==\\", \\"base64\\"))($R[\\"example\\"])"`; +exports[`Plugin > crossSerializeStream > scoped > supports Plugin 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Buffer.from(\\"SGVsbG8sIFdvcmxkIQ==\\", \\"base64\\"))($R[\\"example\\"]))"`; -exports[`Plugin > crossSerializeStream > supports Plugin 1`] = `"$R[0]=Buffer.from(\\"SGVsbG8sIFdvcmxkIQ==\\", \\"base64\\")"`; +exports[`Plugin > crossSerializeStream > supports Plugin 1`] = `"(self.$R=self.$R||[],$R[0]=Buffer.from(\\"SGVsbG8sIFdvcmxkIQ==\\", \\"base64\\"))"`; exports[`Plugin > serialize > supports Plugin 1`] = `"Buffer.from(\\"SGVsbG8sIFdvcmxkIQ==\\", \\"base64\\")"`; diff --git a/packages/seroval/test/__snapshots__/reference.test.ts.snap b/packages/seroval/test/__snapshots__/reference.test.ts.snap index 0d490ee7..2df20656 100644 --- a/packages/seroval/test/__snapshots__/reference.test.ts.snap +++ b/packages/seroval/test/__snapshots__/reference.test.ts.snap @@ -1,18 +1,18 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Reference > crossSerialize > crossSerialize > supports Reference 1`] = `"($R=>$R[0]=__SEROVAL_REFS__.get(\\"example\\"))($R[\\"example\\"])"`; +exports[`Reference > crossSerialize > crossSerialize > supports Reference 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=__SEROVAL_REFS__.get(\\"example\\"))($R[\\"example\\"]))"`; -exports[`Reference > crossSerialize > supports Reference 1`] = `"$R[0]=__SEROVAL_REFS__.get(\\"example\\")"`; +exports[`Reference > crossSerialize > supports Reference 1`] = `"(self.$R=self.$R||[],$R[0]=__SEROVAL_REFS__.get(\\"example\\"))"`; -exports[`Reference > crossSerializeAsync > scoped > supports Reference 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=__SEROVAL_REFS__.get(\\"example\\")))($R[\\"example\\"])"`; +exports[`Reference > crossSerializeAsync > scoped > supports Reference 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=__SEROVAL_REFS__.get(\\"example\\")))($R[\\"example\\"]))"`; -exports[`Reference > crossSerializeAsync > supports Reference 1`] = `"$R[0]=Promise.resolve($R[1]=__SEROVAL_REFS__.get(\\"example\\"))"`; +exports[`Reference > crossSerializeAsync > supports Reference 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=__SEROVAL_REFS__.get(\\"example\\")))"`; -exports[`Reference > crossSerializeStream > scoped > supports Reference 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`Reference > crossSerializeStream > scoped > supports Reference 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`Reference > crossSerializeStream > scoped > supports Reference 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]=__SEROVAL_REFS__.get(\\"example\\")))($R[\\"example\\"])"`; -exports[`Reference > crossSerializeStream > supports Reference 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`Reference > crossSerializeStream > supports Reference 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`Reference > crossSerializeStream > supports Reference 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=__SEROVAL_REFS__.get(\\"example\\"))"`; diff --git a/packages/seroval/test/__snapshots__/regexp.test.ts.snap b/packages/seroval/test/__snapshots__/regexp.test.ts.snap index 8597e4d4..b68db8a7 100644 --- a/packages/seroval/test/__snapshots__/regexp.test.ts.snap +++ b/packages/seroval/test/__snapshots__/regexp.test.ts.snap @@ -1,18 +1,18 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`RegExp > crossSerialize > scoped > supports RegExp 1`] = `"($R=>$R[0]=/[a-z0-9]+/i)($R[\\"example\\"])"`; +exports[`RegExp > crossSerialize > scoped > supports RegExp 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=/[a-z0-9]+/i)($R[\\"example\\"]))"`; -exports[`RegExp > crossSerialize > supports RegExp 1`] = `"$R[0]=/[a-z0-9]+/i"`; +exports[`RegExp > crossSerialize > supports RegExp 1`] = `"(self.$R=self.$R||[],$R[0]=/[a-z0-9]+/i)"`; -exports[`RegExp > crossSerializeAsync > scoped > supports RegExp 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=/[a-z0-9]+/i))($R[\\"example\\"])"`; +exports[`RegExp > crossSerializeAsync > scoped > supports RegExp 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=/[a-z0-9]+/i))($R[\\"example\\"]))"`; -exports[`RegExp > crossSerializeAsync > supports RegExp 1`] = `"$R[0]=Promise.resolve($R[1]=/[a-z0-9]+/i)"`; +exports[`RegExp > crossSerializeAsync > supports RegExp 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=/[a-z0-9]+/i))"`; -exports[`RegExp > crossSerializeStream > scoped > supports RegExp 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`RegExp > crossSerializeStream > scoped > supports RegExp 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`RegExp > crossSerializeStream > scoped > supports RegExp 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]=/[a-z0-9]+/i))($R[\\"example\\"])"`; -exports[`RegExp > crossSerializeStream > supports RegExp 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`RegExp > crossSerializeStream > supports RegExp 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`RegExp > crossSerializeStream > supports RegExp 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=/[a-z0-9]+/i)"`; diff --git a/packages/seroval/test/__snapshots__/sealed-object.test.ts.snap b/packages/seroval/test/__snapshots__/sealed-object.test.ts.snap index 11679d82..9fe94bd5 100644 --- a/packages/seroval/test/__snapshots__/sealed-object.test.ts.snap +++ b/packages/seroval/test/__snapshots__/sealed-object.test.ts.snap @@ -1,38 +1,38 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`sealed object > crossSerialize > scoped > supports Objects 1`] = `"($R=>$R[0]={hello:\\"world\\"},Object.seal($R[0]),$R[0])($R[\\"example\\"])"`; +exports[`sealed object > crossSerialize > scoped > supports Objects 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={hello:\\"world\\"},Object.seal($R[0]),$R[0])($R[\\"example\\"]))"`; -exports[`sealed object > crossSerialize > scoped > supports Symbol.iterator 1`] = `"($R=>$R[0]={[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})},Object.seal($R[0]),$R[0])($R[\\"example\\"])"`; +exports[`sealed object > crossSerialize > scoped > supports Symbol.iterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})},Object.seal($R[0]),$R[0])($R[\\"example\\"]))"`; -exports[`sealed object > crossSerialize > scoped > supports self-recursion 1`] = `"($R=>$R[0]={},$R[0].b=$R[0].a=$R[0],Object.seal($R[0]),$R[0])($R[\\"example\\"])"`; +exports[`sealed object > crossSerialize > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={},$R[0].b=$R[0].a=$R[0],Object.seal($R[0]),$R[0])($R[\\"example\\"]))"`; -exports[`sealed object > crossSerialize > supports Objects 1`] = `"($R[0]={hello:\\"world\\"},Object.seal($R[0]),$R[0])"`; +exports[`sealed object > crossSerialize > supports Objects 1`] = `"(self.$R=self.$R||[],($R[0]={hello:\\"world\\"},Object.seal($R[0]),$R[0]))"`; -exports[`sealed object > crossSerialize > supports Symbol.iterator 1`] = `"($R[0]={[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})},Object.seal($R[0]),$R[0])"`; +exports[`sealed object > crossSerialize > supports Symbol.iterator 1`] = `"(self.$R=self.$R||[],($R[0]={[$R[1]=Symbol.iterator]:($R[2]=s=>(i,c,d,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})},Object.seal($R[0]),$R[0]))"`; -exports[`sealed object > crossSerialize > supports self-recursion 1`] = `"($R[0]={},$R[0].b=$R[0].a=$R[0],Object.seal($R[0]),$R[0])"`; +exports[`sealed object > crossSerialize > supports self-recursion 1`] = `"(self.$R=self.$R||[],($R[0]={},$R[0].b=$R[0].a=$R[0],Object.seal($R[0]),$R[0]))"`; -exports[`sealed object > crossSerializeAsync > scoped > supports Objects 1`] = `"($R=>$R[0]=Promise.resolve($R[1]={hello:\\"world\\"}),Object.seal($R[1]),$R[0])($R[\\"example\\"])"`; +exports[`sealed object > crossSerializeAsync > scoped > supports Objects 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]={hello:\\"world\\"}),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[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})},Object.seal($R[0]),$R[0])($R[\\"example\\"])"`; +exports[`sealed object > crossSerializeAsync > scoped > supports Symbol.asyncIterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})},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};c=i++,d=s.v[c];if(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\\"])"`; +exports[`sealed object > crossSerializeAsync > scoped > supports Symbol.iterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($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};c=i++,d=s.v[c];if(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\\"]))"`; -exports[`sealed object > crossSerializeAsync > scoped > supports self-recursion 1`] = `"($R=>$R[0]={a:$R[1]=Promise.resolve().then(()=>$R[0]),b:$R[2]=Promise.resolve().then(()=>$R[0])},Object.seal($R[0]),$R[0])($R[\\"example\\"])"`; +exports[`sealed object > crossSerializeAsync > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={a:$R[1]=Promise.resolve().then(()=>$R[0]),b:$R[2]=Promise.resolve().then(()=>$R[0])},Object.seal($R[0]),$R[0])($R[\\"example\\"]))"`; -exports[`sealed object > crossSerializeAsync > supports Objects 1`] = `"($R[0]=Promise.resolve($R[1]={hello:\\"world\\"}),Object.seal($R[1]),$R[0])"`; +exports[`sealed object > crossSerializeAsync > supports Objects 1`] = `"(self.$R=self.$R||[],($R[0]=Promise.resolve($R[1]={hello:\\"world\\"}),Object.seal($R[1]),$R[0]))"`; -exports[`sealed object > crossSerializeAsync > supports Symbol.asyncIterator 1`] = `"($R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})},Object.seal($R[0]),$R[0])"`; +exports[`sealed object > crossSerializeAsync > supports Symbol.asyncIterator 1`] = `"(self.$R=self.$R||[],($R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(i,t)=>(i=0,t={[$R[1]]:()=>t,next:()=>Promise.resolve().then((c,d)=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}})}))($R[3]={v:$R[4]=[1,2,3,void 0],t:-1,d:3})},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};c=i++,d=s.v[c];if(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])"`; +exports[`sealed object > crossSerializeAsync > supports Symbol.iterator 1`] = `"(self.$R=self.$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};c=i++,d=s.v[c];if(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]))"`; -exports[`sealed object > crossSerializeAsync > supports self-recursion 1`] = `"($R[0]={a:$R[1]=Promise.resolve().then(()=>$R[0]),b:$R[2]=Promise.resolve().then(()=>$R[0])},Object.seal($R[0]),$R[0])"`; +exports[`sealed object > crossSerializeAsync > supports self-recursion 1`] = `"(self.$R=self.$R||[],($R[0]={a:$R[1]=Promise.resolve().then(()=>$R[0]),b:$R[2]=Promise.resolve().then(()=>$R[0])},Object.seal($R[0]),$R[0]))"`; -exports[`sealed object > crossSerializeStream > scoped > supports Objects 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`sealed object > crossSerializeStream > scoped > supports Objects 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; 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]={hello:\\"world\\"}),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[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())},Object.seal($R[0]),$R[0])($R[\\"example\\"])"`; +exports[`sealed object > crossSerializeStream > scoped > supports Symbol.asyncIterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())},Object.seal($R[0]),$R[0])($R[\\"example\\"]))"`; exports[`sealed object > crossSerializeStream > scoped > supports Symbol.asyncIterator 2`] = `"($R=>($R[6]=(s,d)=>{s.c.enqueue(d)})($R[3],$R[5]=[0,1]))($R[\\"example\\"])"`; @@ -44,21 +44,21 @@ exports[`sealed object > crossSerializeStream > scoped > supports Symbol.asyncIt exports[`sealed object > crossSerializeStream > scoped > supports Symbol.asyncIterator 6`] = `"($R=>($R[10]=s=>{s.c.close();delete s.c})($R[3]))($R[\\"example\\"])"`; -exports[`sealed object > crossSerializeStream > scoped > supports Symbol.iterator 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`sealed object > crossSerializeStream > scoped > supports Symbol.iterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`sealed object > crossSerializeStream > scoped > supports Symbol.iterator 2`] = `"($R=>($R[7]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]={[$R[3]=Symbol.iterator]:($R[4]=s=>(i,c,d,t)=>(i=0,t={[$R[3]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[5]={v:$R[6]=[1,2,3,void 0],t:-1,d:3})}),Object.seal($R[2]),$R[0])($R[\\"example\\"])"`; -exports[`sealed object > crossSerializeStream > scoped > supports self-recursion 1`] = `"($R=>$R[0]={a:$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),b:$R[3]=$R[2]()},Object.seal($R[0]),$R[0])($R[\\"example\\"])"`; +exports[`sealed object > crossSerializeStream > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]={a:$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),b:$R[3]=$R[2]()},Object.seal($R[0]),$R[0])($R[\\"example\\"]))"`; exports[`sealed object > crossSerializeStream > scoped > supports self-recursion 2`] = `"($R=>($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[1],$R[0]))($R[\\"example\\"])"`; exports[`sealed object > crossSerializeStream > scoped > supports self-recursion 3`] = `"($R=>$R[4]($R[3],$R[0]))($R[\\"example\\"])"`; -exports[`sealed object > crossSerializeStream > supports Objects 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`sealed object > crossSerializeStream > supports Objects 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; 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]={hello:\\"world\\"}),Object.seal($R[2]),$R[0])"`; -exports[`sealed object > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"($R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())},Object.seal($R[0]),$R[0])"`; +exports[`sealed object > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"(self.$R=self.$R||[],($R[0]={[$R[1]=Symbol.asyncIterator]:($R[2]=s=>(b,t)=>(b=s.tee(),s=b[0],b=b[1].getReader(),t={[$R[1]]:()=>t,next:()=>b.read().then(d=>{if(d.done)return{done:!0,value:void 0};d=d.value;if(d[0]===1)throw d[1];return{done:d[0]===2,value:d[1]}})}))($R[3]=($R[4]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())},Object.seal($R[0]),$R[0]))"`; exports[`sealed object > crossSerializeStream > supports Symbol.asyncIterator 2`] = `"($R[6]=(s,d)=>{s.c.enqueue(d)})($R[3],$R[5]=[0,1])"`; @@ -70,11 +70,11 @@ exports[`sealed object > crossSerializeStream > supports Symbol.asyncIterator 5` exports[`sealed object > crossSerializeStream > supports Symbol.asyncIterator 6`] = `"($R[10]=s=>{s.c.close();delete s.c})($R[3])"`; -exports[`sealed object > crossSerializeStream > supports Symbol.iterator 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`sealed object > crossSerializeStream > supports Symbol.iterator 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`sealed object > crossSerializeStream > supports Symbol.iterator 2`] = `"(($R[7]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]={[$R[3]=Symbol.iterator]:($R[4]=s=>(i,c,d,t)=>(i=0,t={[$R[3]]:()=>t,next:()=>{if(i>s.d)return{done:!0,value:void 0};c=i++,d=s.v[c];if(c===s.t)throw d;return{done:c===s.d,value:d}}}))($R[5]={v:$R[6]=[1,2,3,void 0],t:-1,d:3})}),Object.seal($R[2]),$R[0])"`; -exports[`sealed object > crossSerializeStream > supports self-recursion 1`] = `"($R[0]={a:$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),b:$R[3]=$R[2]()},Object.seal($R[0]),$R[0])"`; +exports[`sealed object > crossSerializeStream > supports self-recursion 1`] = `"(self.$R=self.$R||[],($R[0]={a:$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))(),b:$R[3]=$R[2]()},Object.seal($R[0]),$R[0]))"`; exports[`sealed object > crossSerializeStream > supports self-recursion 2`] = `"($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[1],$R[0])"`; diff --git a/packages/seroval/test/__snapshots__/set.test.ts.snap b/packages/seroval/test/__snapshots__/set.test.ts.snap index f25e72ec..13cc6472 100644 --- a/packages/seroval/test/__snapshots__/set.test.ts.snap +++ b/packages/seroval/test/__snapshots__/set.test.ts.snap @@ -8,35 +8,35 @@ exports[`Set > compat#toJSON > should fallback to Symbol.iterator 1`] = `"{\\"t\ exports[`Set > compat#toJSON > should throw an error for unsupported target 1`] = `"Unsupported type \\"[object Set]\\""`; -exports[`Set > crossSerialize > scoped > supports Set 1`] = `"($R=>$R[0]=new Set([1,2,3]))($R[\\"example\\"])"`; +exports[`Set > crossSerialize > scoped > supports Set 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=new Set([1,2,3]))($R[\\"example\\"]))"`; -exports[`Set > crossSerialize > scoped > supports self-recursion 1`] = `"($R=>$R[0]=new Set,$R[0].add($R[0]),$R[0])($R[\\"example\\"])"`; +exports[`Set > crossSerialize > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=new Set,$R[0].add($R[0]),$R[0])($R[\\"example\\"]))"`; -exports[`Set > crossSerialize > supports Set 1`] = `"$R[0]=new Set([1,2,3])"`; +exports[`Set > crossSerialize > supports Set 1`] = `"(self.$R=self.$R||[],$R[0]=new Set([1,2,3]))"`; -exports[`Set > crossSerialize > supports self-recursion 1`] = `"($R[0]=new Set,$R[0].add($R[0]),$R[0])"`; +exports[`Set > crossSerialize > supports self-recursion 1`] = `"(self.$R=self.$R||[],($R[0]=new Set,$R[0].add($R[0]),$R[0]))"`; -exports[`Set > crossSerializeAsync > scoped > supports Set 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=new Set([1,2,3])))($R[\\"example\\"])"`; +exports[`Set > crossSerializeAsync > scoped > supports Set 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=new Set([1,2,3])))($R[\\"example\\"]))"`; -exports[`Set > crossSerializeAsync > scoped > supports self-recursion 1`] = `"($R=>$R[0]=new Set([$R[1]=Promise.resolve().then(()=>$R[0])]))($R[\\"example\\"])"`; +exports[`Set > crossSerializeAsync > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=new Set([$R[1]=Promise.resolve().then(()=>$R[0])]))($R[\\"example\\"]))"`; -exports[`Set > crossSerializeAsync > supports Set 1`] = `"$R[0]=Promise.resolve($R[1]=new Set([1,2,3]))"`; +exports[`Set > crossSerializeAsync > supports Set 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=new Set([1,2,3])))"`; -exports[`Set > crossSerializeAsync > supports self-recursion 1`] = `"$R[0]=new Set([$R[1]=Promise.resolve().then(()=>$R[0])])"`; +exports[`Set > crossSerializeAsync > supports self-recursion 1`] = `"(self.$R=self.$R||[],$R[0]=new Set([$R[1]=Promise.resolve().then(()=>$R[0])]))"`; -exports[`Set > crossSerializeStream > scoped > supports Set 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`Set > crossSerializeStream > scoped > supports Set 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`Set > crossSerializeStream > scoped > supports Set 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]=new Set([1,2,3])))($R[\\"example\\"])"`; -exports[`Set > crossSerializeStream > scoped > supports self-recursion 1`] = `"($R=>$R[0]=new Set([$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()]))($R[\\"example\\"])"`; +exports[`Set > crossSerializeStream > scoped > supports self-recursion 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=new Set([$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()]))($R[\\"example\\"]))"`; exports[`Set > crossSerializeStream > scoped > supports self-recursion 2`] = `"($R=>($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[1],$R[0]))($R[\\"example\\"])"`; -exports[`Set > crossSerializeStream > supports Set 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`Set > crossSerializeStream > supports Set 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`Set > crossSerializeStream > supports Set 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=new Set([1,2,3]))"`; -exports[`Set > crossSerializeStream > supports self-recursion 1`] = `"$R[0]=new Set([$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()])"`; +exports[`Set > crossSerializeStream > supports self-recursion 1`] = `"(self.$R=self.$R||[],$R[0]=new Set([$R[1]=($R[2]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()]))"`; exports[`Set > crossSerializeStream > supports self-recursion 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[1],$R[0])"`; diff --git a/packages/seroval/test/__snapshots__/sparse-array.test.ts.snap b/packages/seroval/test/__snapshots__/sparse-array.test.ts.snap index fa68b4cf..d6af8171 100644 --- a/packages/seroval/test/__snapshots__/sparse-array.test.ts.snap +++ b/packages/seroval/test/__snapshots__/sparse-array.test.ts.snap @@ -1,18 +1,18 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`sparse arrays > crossSerialize > scoped > supports sparse arrays 1`] = `"($R=>$R[0]=[,,,,,,,,,,])($R[\\"example\\"])"`; +exports[`sparse arrays > crossSerialize > scoped > supports sparse arrays 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=[,,,,,,,,,,])($R[\\"example\\"]))"`; -exports[`sparse arrays > crossSerialize > supports sparse arrays 1`] = `"$R[0]=[,,,,,,,,,,]"`; +exports[`sparse arrays > crossSerialize > supports sparse arrays 1`] = `"(self.$R=self.$R||[],$R[0]=[,,,,,,,,,,])"`; -exports[`sparse arrays > crossSerializeAsync > scoped > supports sparse arrays 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=[,,,,,,,,,,]))($R[\\"example\\"])"`; +exports[`sparse arrays > crossSerializeAsync > scoped > supports sparse arrays 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=[,,,,,,,,,,]))($R[\\"example\\"]))"`; -exports[`sparse arrays > crossSerializeAsync > supports sparse arrays 1`] = `"$R[0]=Promise.resolve($R[1]=[,,,,,,,,,,])"`; +exports[`sparse arrays > crossSerializeAsync > supports sparse arrays 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=[,,,,,,,,,,]))"`; -exports[`sparse arrays > crossSerializeStream > scoped > supports sparse arrays 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`sparse arrays > crossSerializeStream > scoped > supports sparse arrays 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`sparse arrays > crossSerializeStream > scoped > supports sparse arrays 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]=[,,,,,,,,,,]))($R[\\"example\\"])"`; -exports[`sparse arrays > crossSerializeStream > supports sparse arrays 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`sparse arrays > crossSerializeStream > supports sparse arrays 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`sparse arrays > crossSerializeStream > supports sparse arrays 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=[,,,,,,,,,,])"`; diff --git a/packages/seroval/test/__snapshots__/string.test.ts.snap b/packages/seroval/test/__snapshots__/string.test.ts.snap index 36a3152a..546247d2 100644 --- a/packages/seroval/test/__snapshots__/string.test.ts.snap +++ b/packages/seroval/test/__snapshots__/string.test.ts.snap @@ -1,18 +1,18 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`string > crossSerialize > supports strings 1`] = `"\\"\\\\\\"hello\\\\\\"\\""`; +exports[`string > crossSerialize > supports strings 1`] = `"(self.$R=self.$R||[],\\"\\\\\\"hello\\\\\\"\\")"`; -exports[`string > crossSerialize > supports strings 2`] = `"\\"\\\\x3Cscript>\\\\x3C/script>\\""`; +exports[`string > crossSerialize > supports strings 2`] = `"(self.$R=self.$R||[],\\"\\\\x3Cscript>\\\\x3C/script>\\")"`; -exports[`string > crossSerializeAsync > supports strings 1`] = `"$R[0]=Promise.resolve(\\"\\\\\\"hello\\\\\\"\\")"`; +exports[`string > crossSerializeAsync > supports strings 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve(\\"\\\\\\"hello\\\\\\"\\"))"`; -exports[`string > crossSerializeAsync > supports strings 2`] = `"$R[0]=Promise.resolve(\\"\\\\x3Cscript>\\\\x3C/script>\\")"`; +exports[`string > crossSerializeAsync > supports strings 2`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve(\\"\\\\x3Cscript>\\\\x3C/script>\\"))"`; -exports[`string > crossSerializeStream > supports sanitized strings 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`string > crossSerializeStream > supports sanitized strings 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`string > crossSerializeStream > supports sanitized strings 2`] = `"($R[2]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],\\"\\\\x3Cscript>\\\\x3C/script>\\")"`; -exports[`string > crossSerializeStream > supports strings 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`string > crossSerializeStream > supports strings 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`string > crossSerializeStream > supports strings 2`] = `"($R[2]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],\\"\\\\\\"hello\\\\\\"\\")"`; diff --git a/packages/seroval/test/__snapshots__/typed-array.test.ts.snap b/packages/seroval/test/__snapshots__/typed-array.test.ts.snap index 333f97b3..5fb52608 100644 --- a/packages/seroval/test/__snapshots__/typed-array.test.ts.snap +++ b/packages/seroval/test/__snapshots__/typed-array.test.ts.snap @@ -1,18 +1,18 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`typed arrays > crossSerialize > scoped > supports typed arrays 1`] = `"($R=>$R[0]=new Uint32Array($R[1]=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]).buffer,0,4))($R[\\"example\\"])"`; +exports[`typed arrays > crossSerialize > scoped > supports typed arrays 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=new Uint32Array($R[1]=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]).buffer,0,4))($R[\\"example\\"]))"`; -exports[`typed arrays > crossSerialize > supports typed arrays 1`] = `"$R[0]=new Uint32Array($R[1]=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]).buffer,0,4)"`; +exports[`typed arrays > crossSerialize > supports typed arrays 1`] = `"(self.$R=self.$R||[],$R[0]=new Uint32Array($R[1]=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]).buffer,0,4))"`; -exports[`typed arrays > crossSerializeAsync > scoped > supports typed arrays 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=new Uint32Array($R[2]=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]).buffer,0,4)))($R[\\"example\\"])"`; +exports[`typed arrays > crossSerializeAsync > scoped > supports typed arrays 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=new Uint32Array($R[2]=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]).buffer,0,4)))($R[\\"example\\"]))"`; -exports[`typed arrays > crossSerializeAsync > supports typed arrays 1`] = `"$R[0]=Promise.resolve($R[1]=new Uint32Array($R[2]=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]).buffer,0,4))"`; +exports[`typed arrays > crossSerializeAsync > supports typed arrays 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=new Uint32Array($R[2]=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]).buffer,0,4)))"`; -exports[`typed arrays > crossSerializeStream > scoped > supports typed arrays 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`typed arrays > crossSerializeStream > scoped > supports typed arrays 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`typed arrays > crossSerializeStream > scoped > supports typed arrays 2`] = `"($R=>($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=new Uint32Array($R[3]=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]).buffer,0,4)))($R[\\"example\\"])"`; -exports[`typed arrays > crossSerializeStream > supports typed arrays 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`typed arrays > crossSerializeStream > supports typed arrays 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`typed arrays > crossSerializeStream > supports typed arrays 2`] = `"($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=new Uint32Array($R[3]=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]).buffer,0,4))"`; diff --git a/packages/seroval/test/__snapshots__/wk-symbols.test.ts.snap b/packages/seroval/test/__snapshots__/wk-symbols.test.ts.snap index a1562b02..26fe43c6 100644 --- a/packages/seroval/test/__snapshots__/wk-symbols.test.ts.snap +++ b/packages/seroval/test/__snapshots__/wk-symbols.test.ts.snap @@ -1,210 +1,210 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 1`] = `"($R=>$R[0]=Symbol.asyncIterator)($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Symbol.asyncIterator)($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 2`] = `"($R=>$R[0]=Symbol.hasInstance)($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 2`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Symbol.hasInstance)($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 3`] = `"($R=>$R[0]=Symbol.isConcatSpreadable)($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 3`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Symbol.isConcatSpreadable)($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 4`] = `"($R=>$R[0]=Symbol.iterator)($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 4`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Symbol.iterator)($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 5`] = `"($R=>$R[0]=Symbol.match)($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 5`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Symbol.match)($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 6`] = `"($R=>$R[0]=Symbol.matchAll)($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 6`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Symbol.matchAll)($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 7`] = `"($R=>$R[0]=Symbol.replace)($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 7`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Symbol.replace)($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 8`] = `"($R=>$R[0]=Symbol.search)($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 8`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Symbol.search)($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 9`] = `"($R=>$R[0]=Symbol.species)($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 9`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Symbol.species)($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 10`] = `"($R=>$R[0]=Symbol.split)($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 10`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Symbol.split)($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 11`] = `"($R=>$R[0]=Symbol.toPrimitive)($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 11`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Symbol.toPrimitive)($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 12`] = `"($R=>$R[0]=Symbol.toStringTag)($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 12`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Symbol.toStringTag)($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 13`] = `"($R=>$R[0]=Symbol.unscopables)($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerialize > scoped > supports well-known symbols 13`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Symbol.unscopables)($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerialize > supports well-known symbols 1`] = `"$R[0]=Symbol.asyncIterator"`; +exports[`well-known symbols > crossSerialize > supports well-known symbols 1`] = `"(self.$R=self.$R||[],$R[0]=Symbol.asyncIterator)"`; -exports[`well-known symbols > crossSerialize > supports well-known symbols 2`] = `"$R[0]=Symbol.hasInstance"`; +exports[`well-known symbols > crossSerialize > supports well-known symbols 2`] = `"(self.$R=self.$R||[],$R[0]=Symbol.hasInstance)"`; -exports[`well-known symbols > crossSerialize > supports well-known symbols 3`] = `"$R[0]=Symbol.isConcatSpreadable"`; +exports[`well-known symbols > crossSerialize > supports well-known symbols 3`] = `"(self.$R=self.$R||[],$R[0]=Symbol.isConcatSpreadable)"`; -exports[`well-known symbols > crossSerialize > supports well-known symbols 4`] = `"$R[0]=Symbol.iterator"`; +exports[`well-known symbols > crossSerialize > supports well-known symbols 4`] = `"(self.$R=self.$R||[],$R[0]=Symbol.iterator)"`; -exports[`well-known symbols > crossSerialize > supports well-known symbols 5`] = `"$R[0]=Symbol.match"`; +exports[`well-known symbols > crossSerialize > supports well-known symbols 5`] = `"(self.$R=self.$R||[],$R[0]=Symbol.match)"`; -exports[`well-known symbols > crossSerialize > supports well-known symbols 6`] = `"$R[0]=Symbol.matchAll"`; +exports[`well-known symbols > crossSerialize > supports well-known symbols 6`] = `"(self.$R=self.$R||[],$R[0]=Symbol.matchAll)"`; -exports[`well-known symbols > crossSerialize > supports well-known symbols 7`] = `"$R[0]=Symbol.replace"`; +exports[`well-known symbols > crossSerialize > supports well-known symbols 7`] = `"(self.$R=self.$R||[],$R[0]=Symbol.replace)"`; -exports[`well-known symbols > crossSerialize > supports well-known symbols 8`] = `"$R[0]=Symbol.search"`; +exports[`well-known symbols > crossSerialize > supports well-known symbols 8`] = `"(self.$R=self.$R||[],$R[0]=Symbol.search)"`; -exports[`well-known symbols > crossSerialize > supports well-known symbols 9`] = `"$R[0]=Symbol.species"`; +exports[`well-known symbols > crossSerialize > supports well-known symbols 9`] = `"(self.$R=self.$R||[],$R[0]=Symbol.species)"`; -exports[`well-known symbols > crossSerialize > supports well-known symbols 10`] = `"$R[0]=Symbol.split"`; +exports[`well-known symbols > crossSerialize > supports well-known symbols 10`] = `"(self.$R=self.$R||[],$R[0]=Symbol.split)"`; -exports[`well-known symbols > crossSerialize > supports well-known symbols 11`] = `"$R[0]=Symbol.toPrimitive"`; +exports[`well-known symbols > crossSerialize > supports well-known symbols 11`] = `"(self.$R=self.$R||[],$R[0]=Symbol.toPrimitive)"`; -exports[`well-known symbols > crossSerialize > supports well-known symbols 12`] = `"$R[0]=Symbol.toStringTag"`; +exports[`well-known symbols > crossSerialize > supports well-known symbols 12`] = `"(self.$R=self.$R||[],$R[0]=Symbol.toStringTag)"`; -exports[`well-known symbols > crossSerialize > supports well-known symbols 13`] = `"$R[0]=Symbol.unscopables"`; +exports[`well-known symbols > crossSerialize > supports well-known symbols 13`] = `"(self.$R=self.$R||[],$R[0]=Symbol.unscopables)"`; -exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=Symbol.asyncIterator))($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Symbol.asyncIterator))($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 2`] = `"($R=>$R[0]=Promise.resolve($R[1]=Symbol.hasInstance))($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 2`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Symbol.hasInstance))($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 3`] = `"($R=>$R[0]=Promise.resolve($R[1]=Symbol.isConcatSpreadable))($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 3`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Symbol.isConcatSpreadable))($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 4`] = `"($R=>$R[0]=Promise.resolve($R[1]=Symbol.iterator))($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 4`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Symbol.iterator))($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 5`] = `"($R=>$R[0]=Promise.resolve($R[1]=Symbol.match))($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 5`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Symbol.match))($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 6`] = `"($R=>$R[0]=Promise.resolve($R[1]=Symbol.matchAll))($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 6`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Symbol.matchAll))($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 7`] = `"($R=>$R[0]=Promise.resolve($R[1]=Symbol.replace))($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 7`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Symbol.replace))($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 8`] = `"($R=>$R[0]=Promise.resolve($R[1]=Symbol.search))($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 8`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Symbol.search))($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 9`] = `"($R=>$R[0]=Promise.resolve($R[1]=Symbol.species))($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 9`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Symbol.species))($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 10`] = `"($R=>$R[0]=Promise.resolve($R[1]=Symbol.split))($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 10`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Symbol.split))($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 11`] = `"($R=>$R[0]=Promise.resolve($R[1]=Symbol.toPrimitive))($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 11`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Symbol.toPrimitive))($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 12`] = `"($R=>$R[0]=Promise.resolve($R[1]=Symbol.toStringTag))($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 12`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Symbol.toStringTag))($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 13`] = `"($R=>$R[0]=Promise.resolve($R[1]=Symbol.unscopables))($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeAsync > scoped > supports well-known symbols 13`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=Symbol.unscopables))($R[\\"example\\"]))"`; -exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 1`] = `"$R[0]=Promise.resolve($R[1]=Symbol.asyncIterator)"`; +exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Symbol.asyncIterator))"`; -exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 2`] = `"$R[0]=Promise.resolve($R[1]=Symbol.hasInstance)"`; +exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 2`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Symbol.hasInstance))"`; -exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 3`] = `"$R[0]=Promise.resolve($R[1]=Symbol.isConcatSpreadable)"`; +exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 3`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Symbol.isConcatSpreadable))"`; -exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 4`] = `"$R[0]=Promise.resolve($R[1]=Symbol.iterator)"`; +exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 4`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Symbol.iterator))"`; -exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 5`] = `"$R[0]=Promise.resolve($R[1]=Symbol.match)"`; +exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 5`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Symbol.match))"`; -exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 6`] = `"$R[0]=Promise.resolve($R[1]=Symbol.matchAll)"`; +exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 6`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Symbol.matchAll))"`; -exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 7`] = `"$R[0]=Promise.resolve($R[1]=Symbol.replace)"`; +exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 7`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Symbol.replace))"`; -exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 8`] = `"$R[0]=Promise.resolve($R[1]=Symbol.search)"`; +exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 8`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Symbol.search))"`; -exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 9`] = `"$R[0]=Promise.resolve($R[1]=Symbol.species)"`; +exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 9`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Symbol.species))"`; -exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 10`] = `"$R[0]=Promise.resolve($R[1]=Symbol.split)"`; +exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 10`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Symbol.split))"`; -exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 11`] = `"$R[0]=Promise.resolve($R[1]=Symbol.toPrimitive)"`; +exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 11`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Symbol.toPrimitive))"`; -exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 12`] = `"$R[0]=Promise.resolve($R[1]=Symbol.toStringTag)"`; +exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 12`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Symbol.toStringTag))"`; -exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 13`] = `"$R[0]=Promise.resolve($R[1]=Symbol.unscopables)"`; +exports[`well-known symbols > crossSerializeAsync > supports well-known symbols 13`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=Symbol.unscopables))"`; -exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.asyncIterator 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.asyncIterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.asyncIterator 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]=Symbol.asyncIterator))($R[\\"example\\"])"`; -exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.hasInstance 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.hasInstance 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.hasInstance 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]=Symbol.hasInstance))($R[\\"example\\"])"`; -exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.isConcatSpreadable 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.isConcatSpreadable 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.isConcatSpreadable 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]=Symbol.isConcatSpreadable))($R[\\"example\\"])"`; -exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.iterator 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.iterator 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.iterator 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]=Symbol.iterator))($R[\\"example\\"])"`; -exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.match 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.match 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.match 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]=Symbol.match))($R[\\"example\\"])"`; -exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.matchAll 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.matchAll 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.matchAll 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]=Symbol.matchAll))($R[\\"example\\"])"`; -exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.replace 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.replace 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.replace 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]=Symbol.replace))($R[\\"example\\"])"`; -exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.search 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.search 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.search 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]=Symbol.search))($R[\\"example\\"])"`; -exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.species 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.species 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.species 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]=Symbol.species))($R[\\"example\\"])"`; -exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.split 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.split 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.split 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]=Symbol.split))($R[\\"example\\"])"`; -exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.toPrimitive 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.toPrimitive 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.toPrimitive 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]=Symbol.toPrimitive))($R[\\"example\\"])"`; -exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.toStringTag 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.toStringTag 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.toStringTag 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]=Symbol.toStringTag))($R[\\"example\\"])"`; -exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.unscopables 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.unscopables 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`well-known symbols > crossSerializeStream > scoped > supports Symbol.unscopables 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]=Symbol.unscopables))($R[\\"example\\"])"`; -exports[`well-known symbols > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`well-known symbols > crossSerializeStream > supports Symbol.asyncIterator 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`well-known symbols > crossSerializeStream > supports Symbol.asyncIterator 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Symbol.asyncIterator)"`; -exports[`well-known symbols > crossSerializeStream > supports Symbol.hasInstance 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`well-known symbols > crossSerializeStream > supports Symbol.hasInstance 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`well-known symbols > crossSerializeStream > supports Symbol.hasInstance 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Symbol.hasInstance)"`; -exports[`well-known symbols > crossSerializeStream > supports Symbol.isConcatSpreadable 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`well-known symbols > crossSerializeStream > supports Symbol.isConcatSpreadable 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`well-known symbols > crossSerializeStream > supports Symbol.isConcatSpreadable 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Symbol.isConcatSpreadable)"`; -exports[`well-known symbols > crossSerializeStream > supports Symbol.iterator 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`well-known symbols > crossSerializeStream > supports Symbol.iterator 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`well-known symbols > crossSerializeStream > supports Symbol.iterator 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Symbol.iterator)"`; -exports[`well-known symbols > crossSerializeStream > supports Symbol.match 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`well-known symbols > crossSerializeStream > supports Symbol.match 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`well-known symbols > crossSerializeStream > supports Symbol.match 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Symbol.match)"`; -exports[`well-known symbols > crossSerializeStream > supports Symbol.matchAll 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`well-known symbols > crossSerializeStream > supports Symbol.matchAll 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`well-known symbols > crossSerializeStream > supports Symbol.matchAll 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Symbol.matchAll)"`; -exports[`well-known symbols > crossSerializeStream > supports Symbol.replace 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`well-known symbols > crossSerializeStream > supports Symbol.replace 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`well-known symbols > crossSerializeStream > supports Symbol.replace 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Symbol.replace)"`; -exports[`well-known symbols > crossSerializeStream > supports Symbol.search 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`well-known symbols > crossSerializeStream > supports Symbol.search 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`well-known symbols > crossSerializeStream > supports Symbol.search 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Symbol.search)"`; -exports[`well-known symbols > crossSerializeStream > supports Symbol.species 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`well-known symbols > crossSerializeStream > supports Symbol.species 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`well-known symbols > crossSerializeStream > supports Symbol.species 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Symbol.species)"`; -exports[`well-known symbols > crossSerializeStream > supports Symbol.split 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`well-known symbols > crossSerializeStream > supports Symbol.split 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`well-known symbols > crossSerializeStream > supports Symbol.split 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Symbol.split)"`; -exports[`well-known symbols > crossSerializeStream > supports Symbol.toPrimitive 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`well-known symbols > crossSerializeStream > supports Symbol.toPrimitive 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`well-known symbols > crossSerializeStream > supports Symbol.toPrimitive 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Symbol.toPrimitive)"`; -exports[`well-known symbols > crossSerializeStream > supports Symbol.toStringTag 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`well-known symbols > crossSerializeStream > supports Symbol.toStringTag 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`well-known symbols > crossSerializeStream > supports Symbol.toStringTag 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Symbol.toStringTag)"`; -exports[`well-known symbols > crossSerializeStream > supports Symbol.unscopables 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`well-known symbols > crossSerializeStream > supports Symbol.unscopables 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`well-known symbols > crossSerializeStream > supports Symbol.unscopables 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=Symbol.unscopables)"`; diff --git a/packages/seroval/test/web-api/__snapshots__/blob.test.ts.snap b/packages/seroval/test/web-api/__snapshots__/blob.test.ts.snap index 3bdc07cc..41f24d92 100644 --- a/packages/seroval/test/web-api/__snapshots__/blob.test.ts.snap +++ b/packages/seroval/test/web-api/__snapshots__/blob.test.ts.snap @@ -1,8 +1,8 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Blob > crossSerializeAsync > scoped > supports Blob 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=new Blob([$R[2]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100]).buffer],{type:\\"text/plain\\"})))($R[\\"example\\"])"`; +exports[`Blob > crossSerializeAsync > scoped > supports Blob 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=new Blob([$R[2]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100]).buffer],{type:\\"text/plain\\"})))($R[\\"example\\"]))"`; -exports[`Blob > crossSerializeAsync > supports Blob 1`] = `"$R[0]=new Blob([$R[1]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100]).buffer],{type:\\"text/plain\\"})"`; +exports[`Blob > crossSerializeAsync > supports Blob 1`] = `"(self.$R=self.$R||[],$R[0]=new Blob([$R[1]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100]).buffer],{type:\\"text/plain\\"}))"`; exports[`Blob > serializeAsync > supports Blob 1`] = `"new Blob([new Uint8Array([72,101,108,108,111,32,87,111,114,108,100]).buffer],{type:\\"text/plain\\"})"`; diff --git a/packages/seroval/test/web-api/__snapshots__/custom-event.test.ts.snap b/packages/seroval/test/web-api/__snapshots__/custom-event.test.ts.snap index 5d649bcc..f2c2e1f3 100644 --- a/packages/seroval/test/web-api/__snapshots__/custom-event.test.ts.snap +++ b/packages/seroval/test/web-api/__snapshots__/custom-event.test.ts.snap @@ -1,18 +1,18 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`CustomEvent > crossSerialize > scoped > supports CustomEvent 1`] = `"($R=>$R[0]=new CustomEvent(\\"example\\",$R[1]={detail:$R[2]={},bubbles:!1,cancelable:!1,composed:!1}),$R[2].self=$R[2],$R[0])($R[\\"example\\"])"`; +exports[`CustomEvent > crossSerialize > scoped > supports CustomEvent 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=new CustomEvent(\\"example\\",$R[1]={detail:$R[2]={},bubbles:!1,cancelable:!1,composed:!1}),$R[2].self=$R[2],$R[0])($R[\\"example\\"]))"`; -exports[`CustomEvent > crossSerialize > supports CustomEvent 1`] = `"($R[0]=new CustomEvent(\\"example\\",$R[1]={detail:$R[2]={},bubbles:!1,cancelable:!1,composed:!1}),$R[2].self=$R[2],$R[0])"`; +exports[`CustomEvent > crossSerialize > supports CustomEvent 1`] = `"(self.$R=self.$R||[],($R[0]=new CustomEvent(\\"example\\",$R[1]={detail:$R[2]={},bubbles:!1,cancelable:!1,composed:!1}),$R[2].self=$R[2],$R[0]))"`; -exports[`CustomEvent > crossSerializeAsync > scoped > supports CustomEvent 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=new CustomEvent(\\"example\\",$R[2]={detail:$R[3]={},bubbles:!1,cancelable:!1,composed:!1})),$R[3].self=$R[3],$R[0])($R[\\"example\\"])"`; +exports[`CustomEvent > crossSerializeAsync > scoped > supports CustomEvent 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=new CustomEvent(\\"example\\",$R[2]={detail:$R[3]={},bubbles:!1,cancelable:!1,composed:!1})),$R[3].self=$R[3],$R[0])($R[\\"example\\"]))"`; -exports[`CustomEvent > crossSerializeAsync > supports CustomEvent 1`] = `"($R[0]=Promise.resolve($R[1]=new CustomEvent(\\"example\\",$R[2]={detail:$R[3]={},bubbles:!1,cancelable:!1,composed:!1})),$R[3].self=$R[3],$R[0])"`; +exports[`CustomEvent > crossSerializeAsync > supports CustomEvent 1`] = `"(self.$R=self.$R||[],($R[0]=Promise.resolve($R[1]=new CustomEvent(\\"example\\",$R[2]={detail:$R[3]={},bubbles:!1,cancelable:!1,composed:!1})),$R[3].self=$R[3],$R[0]))"`; -exports[`CustomEvent > crossSerializeStream > scoped > supports CustomEvent 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`CustomEvent > crossSerializeStream > scoped > supports CustomEvent 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`CustomEvent > crossSerializeStream > scoped > supports CustomEvent 2`] = `"($R=>($R[5]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=new CustomEvent(\\"example\\",$R[3]={detail:$R[4]={},bubbles:!1,cancelable:!1,composed:!1})),$R[4].self=$R[4],$R[0])($R[\\"example\\"])"`; -exports[`CustomEvent > crossSerializeStream > supports CustomEvent 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`CustomEvent > crossSerializeStream > supports CustomEvent 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`CustomEvent > crossSerializeStream > supports CustomEvent 2`] = `"(($R[5]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=new CustomEvent(\\"example\\",$R[3]={detail:$R[4]={},bubbles:!1,cancelable:!1,composed:!1})),$R[4].self=$R[4],$R[0])"`; diff --git a/packages/seroval/test/web-api/__snapshots__/dom-exception.test.ts.snap b/packages/seroval/test/web-api/__snapshots__/dom-exception.test.ts.snap index f408f178..78737547 100644 --- a/packages/seroval/test/web-api/__snapshots__/dom-exception.test.ts.snap +++ b/packages/seroval/test/web-api/__snapshots__/dom-exception.test.ts.snap @@ -1,18 +1,18 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`DOMException > crossSerialize > scoped > supports DOMException 1`] = `"($R=>$R[0]=new DOMException(\\"This is an example message.\\",\\"Example\\"))($R[\\"example\\"])"`; +exports[`DOMException > crossSerialize > scoped > supports DOMException 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=new DOMException(\\"This is an example message.\\",\\"Example\\"))($R[\\"example\\"]))"`; -exports[`DOMException > crossSerialize > supports DOMException 1`] = `"$R[0]=new DOMException(\\"This is an example message.\\",\\"Example\\")"`; +exports[`DOMException > crossSerialize > supports DOMException 1`] = `"(self.$R=self.$R||[],$R[0]=new DOMException(\\"This is an example message.\\",\\"Example\\"))"`; -exports[`DOMException > crossSerializeAsync > scoped > supports DOMException 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=new DOMException(\\"This is an example message.\\",\\"Example\\")))($R[\\"example\\"])"`; +exports[`DOMException > crossSerializeAsync > scoped > supports DOMException 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=new DOMException(\\"This is an example message.\\",\\"Example\\")))($R[\\"example\\"]))"`; -exports[`DOMException > crossSerializeAsync > supports DOMException 1`] = `"$R[0]=Promise.resolve($R[1]=new DOMException(\\"This is an example message.\\",\\"Example\\"))"`; +exports[`DOMException > crossSerializeAsync > supports DOMException 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=new DOMException(\\"This is an example message.\\",\\"Example\\")))"`; -exports[`DOMException > crossSerializeStream > scoped > supports DOMException 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`DOMException > crossSerializeStream > scoped > supports DOMException 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`DOMException > crossSerializeStream > scoped > supports DOMException 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]=new DOMException(\\"This is an example message.\\",\\"Example\\")))($R[\\"example\\"])"`; -exports[`DOMException > crossSerializeStream > supports DOMException 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`DOMException > crossSerializeStream > supports DOMException 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`DOMException > crossSerializeStream > supports DOMException 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=new DOMException(\\"This is an example message.\\",\\"Example\\"))"`; diff --git a/packages/seroval/test/web-api/__snapshots__/event.test.ts.snap b/packages/seroval/test/web-api/__snapshots__/event.test.ts.snap index fa4b4918..f34ec14b 100644 --- a/packages/seroval/test/web-api/__snapshots__/event.test.ts.snap +++ b/packages/seroval/test/web-api/__snapshots__/event.test.ts.snap @@ -1,18 +1,18 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Event > crossSerialize > scoped > supports Event 1`] = `"($R=>$R[0]=new Event(\\"example\\",$R[1]={bubbles:!1,cancelable:!1,composed:!1}))($R[\\"example\\"])"`; +exports[`Event > crossSerialize > scoped > supports Event 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=new Event(\\"example\\",$R[1]={bubbles:!1,cancelable:!1,composed:!1}))($R[\\"example\\"]))"`; -exports[`Event > crossSerialize > supports Event 1`] = `"$R[0]=new Event(\\"example\\",$R[1]={bubbles:!1,cancelable:!1,composed:!1})"`; +exports[`Event > crossSerialize > supports Event 1`] = `"(self.$R=self.$R||[],$R[0]=new Event(\\"example\\",$R[1]={bubbles:!1,cancelable:!1,composed:!1}))"`; -exports[`Event > crossSerializeAsync > scoped > supports Event 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=new Event(\\"example\\",$R[2]={bubbles:!1,cancelable:!1,composed:!1})))($R[\\"example\\"])"`; +exports[`Event > crossSerializeAsync > scoped > supports Event 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=new Event(\\"example\\",$R[2]={bubbles:!1,cancelable:!1,composed:!1})))($R[\\"example\\"]))"`; -exports[`Event > crossSerializeAsync > supports Event 1`] = `"$R[0]=Promise.resolve($R[1]=new Event(\\"example\\",$R[2]={bubbles:!1,cancelable:!1,composed:!1}))"`; +exports[`Event > crossSerializeAsync > supports Event 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=new Event(\\"example\\",$R[2]={bubbles:!1,cancelable:!1,composed:!1})))"`; -exports[`Event > crossSerializeStream > scoped > supports Event 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`Event > crossSerializeStream > scoped > supports Event 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`Event > crossSerializeStream > scoped > supports Event 2`] = `"($R=>($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=new Event(\\"example\\",$R[3]={bubbles:!1,cancelable:!1,composed:!1})))($R[\\"example\\"])"`; -exports[`Event > crossSerializeStream > supports Event 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`Event > crossSerializeStream > supports Event 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`Event > crossSerializeStream > supports Event 2`] = `"($R[4]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=new Event(\\"example\\",$R[3]={bubbles:!1,cancelable:!1,composed:!1}))"`; diff --git a/packages/seroval/test/web-api/__snapshots__/file.test.ts.snap b/packages/seroval/test/web-api/__snapshots__/file.test.ts.snap index cf4946a2..e4e7890b 100644 --- a/packages/seroval/test/web-api/__snapshots__/file.test.ts.snap +++ b/packages/seroval/test/web-api/__snapshots__/file.test.ts.snap @@ -1,8 +1,8 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`File > crossSerializeAsync > scoped > supports File 1`] = `"($R=>$R[0]=new File([$R[1]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100]).buffer],\\"hello.txt\\",{type:\\"text/plain\\",lastModified:1681027542680}))($R[\\"example\\"])"`; +exports[`File > crossSerializeAsync > scoped > supports File 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=new File([$R[1]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100]).buffer],\\"hello.txt\\",{type:\\"text/plain\\",lastModified:1681027542680}))($R[\\"example\\"]))"`; -exports[`File > crossSerializeAsync > supports File 1`] = `"$R[0]=new File([$R[1]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100]).buffer],\\"hello.txt\\",{type:\\"text/plain\\",lastModified:1681027542680})"`; +exports[`File > crossSerializeAsync > supports File 1`] = `"(self.$R=self.$R||[],$R[0]=new File([$R[1]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100]).buffer],\\"hello.txt\\",{type:\\"text/plain\\",lastModified:1681027542680}))"`; exports[`File > serializeAsync > supports File 1`] = `"new File([new Uint8Array([72,101,108,108,111,32,87,111,114,108,100]).buffer],\\"hello.txt\\",{type:\\"text/plain\\",lastModified:1681027542680})"`; diff --git a/packages/seroval/test/web-api/__snapshots__/form-data.test.ts.snap b/packages/seroval/test/web-api/__snapshots__/form-data.test.ts.snap index 973488b5..7768bf1d 100644 --- a/packages/seroval/test/web-api/__snapshots__/form-data.test.ts.snap +++ b/packages/seroval/test/web-api/__snapshots__/form-data.test.ts.snap @@ -1,18 +1,18 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`FormData > crossSerialize > scoped > supports FormData 1`] = `"($R=>($R[0]=new FormData(),$R[0].append(\\"hello\\",\\"world\\"),$R[0].append(\\"foo\\",\\"bar\\"),$R[0]))($R[\\"example\\"])"`; +exports[`FormData > crossSerialize > scoped > supports FormData 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>($R[0]=new FormData(),$R[0].append(\\"hello\\",\\"world\\"),$R[0].append(\\"foo\\",\\"bar\\"),$R[0]))($R[\\"example\\"]))"`; -exports[`FormData > crossSerialize > supports FormData 1`] = `"($R[0]=new FormData(),$R[0].append(\\"hello\\",\\"world\\"),$R[0].append(\\"foo\\",\\"bar\\"),$R[0])"`; +exports[`FormData > crossSerialize > supports FormData 1`] = `"(self.$R=self.$R||[],($R[0]=new FormData(),$R[0].append(\\"hello\\",\\"world\\"),$R[0].append(\\"foo\\",\\"bar\\"),$R[0]))"`; -exports[`FormData > crossSerializeAsync > scoped > supports FormData 1`] = `"($R=>($R[0]=new FormData(),$R[0].append(\\"hello-world\\",$R[1]=new File([$R[2]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100]).buffer],\\"hello.txt\\",{type:\\"text/plain\\",lastModified:1681027542680})),$R[0].append(\\"foo-bar\\",$R[3]=new File([$R[4]=new Uint8Array([70,111,111,32,66,97,114]).buffer],\\"foo-bar.txt\\",{type:\\"text/plain\\",lastModified:1681027542680})),$R[0]))($R[\\"example\\"])"`; +exports[`FormData > crossSerializeAsync > scoped > supports FormData 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>($R[0]=new FormData(),$R[0].append(\\"hello-world\\",$R[1]=new File([$R[2]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100]).buffer],\\"hello.txt\\",{type:\\"text/plain\\",lastModified:1681027542680})),$R[0].append(\\"foo-bar\\",$R[3]=new File([$R[4]=new Uint8Array([70,111,111,32,66,97,114]).buffer],\\"foo-bar.txt\\",{type:\\"text/plain\\",lastModified:1681027542680})),$R[0]))($R[\\"example\\"]))"`; -exports[`FormData > crossSerializeAsync > supports FormData 1`] = `"($R[0]=new FormData(),$R[0].append(\\"hello-world\\",$R[1]=new File([$R[2]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100]).buffer],\\"hello.txt\\",{type:\\"text/plain\\",lastModified:1681027542680})),$R[0].append(\\"foo-bar\\",$R[3]=new File([$R[4]=new Uint8Array([70,111,111,32,66,97,114]).buffer],\\"foo-bar.txt\\",{type:\\"text/plain\\",lastModified:1681027542680})),$R[0])"`; +exports[`FormData > crossSerializeAsync > supports FormData 1`] = `"(self.$R=self.$R||[],($R[0]=new FormData(),$R[0].append(\\"hello-world\\",$R[1]=new File([$R[2]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100]).buffer],\\"hello.txt\\",{type:\\"text/plain\\",lastModified:1681027542680})),$R[0].append(\\"foo-bar\\",$R[3]=new File([$R[4]=new Uint8Array([70,111,111,32,66,97,114]).buffer],\\"foo-bar.txt\\",{type:\\"text/plain\\",lastModified:1681027542680})),$R[0]))"`; -exports[`FormData > crossSerializeStream > scoped > supports FormData 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`FormData > crossSerializeStream > scoped > supports FormData 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`FormData > crossSerializeStream > scoped > supports FormData 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]=new FormData(),$R[2].append(\\"hello\\",\\"world\\"),$R[2].append(\\"foo\\",\\"bar\\"),$R[2])))($R[\\"example\\"])"`; -exports[`FormData > crossSerializeStream > supports FormData 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`FormData > crossSerializeStream > supports FormData 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`FormData > crossSerializeStream > supports FormData 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],($R[2]=new FormData(),$R[2].append(\\"hello\\",\\"world\\"),$R[2].append(\\"foo\\",\\"bar\\"),$R[2]))"`; diff --git a/packages/seroval/test/web-api/__snapshots__/headers.test.ts.snap b/packages/seroval/test/web-api/__snapshots__/headers.test.ts.snap index cb394f17..8d620f3d 100644 --- a/packages/seroval/test/web-api/__snapshots__/headers.test.ts.snap +++ b/packages/seroval/test/web-api/__snapshots__/headers.test.ts.snap @@ -1,18 +1,18 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Headers > crossSerialize > scoped > supports Headers 1`] = `"($R=>$R[0]=new Headers({\\"content-encoding\\":\\"gzip\\",\\"content-type\\":\\"text/plain\\"}))($R[\\"example\\"])"`; +exports[`Headers > crossSerialize > scoped > supports Headers 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=new Headers({\\"content-encoding\\":\\"gzip\\",\\"content-type\\":\\"text/plain\\"}))($R[\\"example\\"]))"`; -exports[`Headers > crossSerialize > supports Headers 1`] = `"$R[0]=new Headers({\\"content-encoding\\":\\"gzip\\",\\"content-type\\":\\"text/plain\\"})"`; +exports[`Headers > crossSerialize > supports Headers 1`] = `"(self.$R=self.$R||[],$R[0]=new Headers({\\"content-encoding\\":\\"gzip\\",\\"content-type\\":\\"text/plain\\"}))"`; -exports[`Headers > crossSerializeAsync > scoped > supports Headers 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=new Headers({\\"content-encoding\\":\\"gzip\\",\\"content-type\\":\\"text/plain\\"})))($R[\\"example\\"])"`; +exports[`Headers > crossSerializeAsync > scoped > supports Headers 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=new Headers({\\"content-encoding\\":\\"gzip\\",\\"content-type\\":\\"text/plain\\"})))($R[\\"example\\"]))"`; -exports[`Headers > crossSerializeAsync > supports Headers 1`] = `"$R[0]=Promise.resolve($R[1]=new Headers({\\"content-encoding\\":\\"gzip\\",\\"content-type\\":\\"text/plain\\"}))"`; +exports[`Headers > crossSerializeAsync > supports Headers 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=new Headers({\\"content-encoding\\":\\"gzip\\",\\"content-type\\":\\"text/plain\\"})))"`; -exports[`Headers > crossSerializeStream > scoped > supports Headers 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`Headers > crossSerializeStream > scoped > supports Headers 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`Headers > crossSerializeStream > scoped > supports Headers 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]=new Headers({\\"content-encoding\\":\\"gzip\\",\\"content-type\\":\\"text/plain\\"})))($R[\\"example\\"])"`; -exports[`Headers > crossSerializeStream > supports Headers 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`Headers > crossSerializeStream > supports Headers 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`Headers > crossSerializeStream > supports Headers 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=new Headers({\\"content-encoding\\":\\"gzip\\",\\"content-type\\":\\"text/plain\\"}))"`; diff --git a/packages/seroval/test/web-api/__snapshots__/readable-stream.test.ts.snap b/packages/seroval/test/web-api/__snapshots__/readable-stream.test.ts.snap index 607fe67d..5192bc22 100644 --- a/packages/seroval/test/web-api/__snapshots__/readable-stream.test.ts.snap +++ b/packages/seroval/test/web-api/__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]=s=>new ReadableStream({start:c=>Promise.resolve().then((i,v)=>{for(i=0;i crossSerializeAsync > scoped > supports ReadableStream 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=s=>new ReadableStream({start:c=>Promise.resolve().then((i,v)=>{for(i=0;i crossSerializeAsync > scoped > supports ReadableStream errors 1`] = `"($R=>$R[0]=($R[1]=s=>new ReadableStream({start:c=>Promise.resolve().then((i,v)=>{for(i=0;i crossSerializeAsync > scoped > supports ReadableStream errors 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=s=>new ReadableStream({start:c=>Promise.resolve().then((i,v)=>{for(i=0;i crossSerializeAsync > supports ReadableStream 1`] = `"$R[0]=($R[1]=s=>new ReadableStream({start:c=>Promise.resolve().then((i,v)=>{for(i=0;i crossSerializeAsync > supports ReadableStream 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=s=>new ReadableStream({start:c=>Promise.resolve().then((i,v)=>{for(i=0;i crossSerializeAsync > supports ReadableStream errors 1`] = `"$R[0]=($R[1]=s=>new ReadableStream({start:c=>Promise.resolve().then((i,v)=>{for(i=0;i crossSerializeAsync > supports ReadableStream errors 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=s=>new ReadableStream({start:c=>Promise.resolve().then((i,v)=>{for(i=0;i crossSerializeStream > scoped > supports ReadableStream 1`] = `"($R=>$R[0]=($R[1]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())($R[\\"example\\"])"`; +exports[`ReadableStream > crossSerializeStream > scoped > supports ReadableStream 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())($R[\\"example\\"]))"`; exports[`ReadableStream > crossSerializeStream > scoped > supports ReadableStream 2`] = `"($R=>($R[2]=(s,d)=>{s.c.enqueue(d)})($R[0],\\"foo\\"))($R[\\"example\\"])"`; @@ -18,11 +18,11 @@ exports[`ReadableStream > crossSerializeStream > scoped > supports ReadableStrea exports[`ReadableStream > crossSerializeStream > scoped > supports ReadableStream 5`] = `"($R=>($R[3]=s=>{s.c.close();delete s.c})($R[0]))($R[\\"example\\"])"`; -exports[`ReadableStream > crossSerializeStream > scoped > supports ReadableStream errors 1`] = `"($R=>$R[0]=($R[1]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())($R[\\"example\\"])"`; +exports[`ReadableStream > crossSerializeStream > scoped > supports ReadableStream errors 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())($R[\\"example\\"]))"`; exports[`ReadableStream > crossSerializeStream > scoped > supports ReadableStream errors 2`] = `"($R=>($R[3]=(s,d)=>{s.c.error(d);delete s.c})($R[0],$R[2]=Object.assign(new Error(\\"Oops!\\"),{stack:\\"\\"})))($R[\\"example\\"])"`; -exports[`ReadableStream > crossSerializeStream > supports ReadableStream 1`] = `"$R[0]=($R[1]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))()"`; +exports[`ReadableStream > crossSerializeStream > supports ReadableStream 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())"`; exports[`ReadableStream > crossSerializeStream > supports ReadableStream 2`] = `"($R[2]=(s,d)=>{s.c.enqueue(d)})($R[0],\\"foo\\")"`; @@ -32,7 +32,7 @@ exports[`ReadableStream > crossSerializeStream > supports ReadableStream 4`] = ` exports[`ReadableStream > crossSerializeStream > supports ReadableStream 5`] = `"($R[3]=s=>{s.c.close();delete s.c})($R[0])"`; -exports[`ReadableStream > crossSerializeStream > supports ReadableStream errors 1`] = `"$R[0]=($R[1]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))()"`; +exports[`ReadableStream > crossSerializeStream > supports ReadableStream errors 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))())"`; exports[`ReadableStream > crossSerializeStream > supports ReadableStream errors 2`] = `"($R[3]=(s,d)=>{s.c.error(d);delete s.c})($R[0],$R[2]=Object.assign(new Error(\\"Oops!\\"),{stack:\\"\\"}))"`; diff --git a/packages/seroval/test/web-api/__snapshots__/request.test.ts.snap b/packages/seroval/test/web-api/__snapshots__/request.test.ts.snap index b99b01b3..28f0be3c 100644 --- a/packages/seroval/test/web-api/__snapshots__/request.test.ts.snap +++ b/packages/seroval/test/web-api/__snapshots__/request.test.ts.snap @@ -1,16 +1,16 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Request > crossSerializeAsync > scoped > supports Blob 1`] = `"($R=>$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({\\"content-type\\":\\"text/plain;charset=UTF-8\\"}),integrity:\\"\\",keepalive:!1,method:\\"POST\\",mode:\\"cors\\",redirect:\\"follow\\",referrer:\\"about:client\\",referrerPolicy:\\"\\"}))($R[\\"example\\"])"`; +exports[`Request > crossSerializeAsync > scoped > supports Blob 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$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({\\"content-type\\":\\"text/plain;charset=UTF-8\\"}),integrity:\\"\\",keepalive:!1,method:\\"POST\\",mode:\\"cors\\",redirect:\\"follow\\",referrer:\\"about:client\\",referrerPolicy:\\"\\"}))($R[\\"example\\"]))"`; -exports[`Request > crossSerializeAsync > supports Blob 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({\\"content-type\\":\\"text/plain;charset=UTF-8\\"}),integrity:\\"\\",keepalive:!1,method:\\"POST\\",mode:\\"cors\\",redirect:\\"follow\\",referrer:\\"about:client\\",referrerPolicy:\\"\\"})"`; +exports[`Request > crossSerializeAsync > supports Blob 1`] = `"(self.$R=self.$R||[],$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({\\"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]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))(),cache:\\"default\\",credentials:\\"same-origin\\",headers:$R[4]=new Headers({\\"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`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=new Request(\\"http://localhost:3000/\\",$R[1]={body:$R[2]=($R[3]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))(),cache:\\"default\\",credentials:\\"same-origin\\",headers:$R[4]=new Headers({\\"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[7]=(s,d)=>{s.c.enqueue(d)})($R[2],$R[5]=new Uint8Array($R[6]=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[8]=s=>{s.c.close();delete s.c})($R[2]))($R[\\"example\\"])"`; -exports[`Request > crossSerializeStream > supports Request 1`] = `"$R[0]=new Request(\\"http://localhost:3000/\\",$R[1]={body:$R[2]=($R[3]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))(),cache:\\"default\\",credentials:\\"same-origin\\",headers:$R[4]=new Headers({\\"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`] = `"(self.$R=self.$R||[],$R[0]=new Request(\\"http://localhost:3000/\\",$R[1]={body:$R[2]=($R[3]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))(),cache:\\"default\\",credentials:\\"same-origin\\",headers:$R[4]=new Headers({\\"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[7]=(s,d)=>{s.c.enqueue(d)})($R[2],$R[5]=new Uint8Array($R[6]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100,33]).buffer,0,12))"`; diff --git a/packages/seroval/test/web-api/__snapshots__/response.test.ts.snap b/packages/seroval/test/web-api/__snapshots__/response.test.ts.snap index 9e350bb8..bb6527b0 100644 --- a/packages/seroval/test/web-api/__snapshots__/response.test.ts.snap +++ b/packages/seroval/test/web-api/__snapshots__/response.test.ts.snap @@ -1,16 +1,16 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`Response > crossSerializeAsync > scoped > supports Blob 1`] = `"($R=>$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({\\"content-type\\":\\"text/plain;charset=UTF-8\\"}),status:200,statusText:\\"\\"}))($R[\\"example\\"])"`; +exports[`Response > crossSerializeAsync > scoped > supports Blob 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$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({\\"content-type\\":\\"text/plain;charset=UTF-8\\"}),status:200,statusText:\\"\\"}))($R[\\"example\\"]))"`; -exports[`Response > crossSerializeAsync > supports Blob 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({\\"content-type\\":\\"text/plain;charset=UTF-8\\"}),status:200,statusText:\\"\\"})"`; +exports[`Response > crossSerializeAsync > supports Blob 1`] = `"(self.$R=self.$R||[],$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({\\"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]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))(),$R[3]={headers:$R[4]=new Headers({\\"content-type\\":\\"text/plain;charset=UTF-8\\"}),status:200,statusText:\\"\\"}))($R[\\"example\\"])"`; +exports[`Response > crossSerializeStream > scoped > supports Response 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=new Response($R[1]=($R[2]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))(),$R[3]={headers:$R[4]=new Headers({\\"content-type\\":\\"text/plain;charset=UTF-8\\"}),status:200,statusText:\\"\\"}))($R[\\"example\\"]))"`; exports[`Response > crossSerializeStream > scoped > supports Response 2`] = `"($R=>($R[7]=(s,d)=>{s.c.enqueue(d)})($R[1],$R[5]=new Uint8Array($R[6]=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[8]=s=>{s.c.close();delete s.c})($R[1]))($R[\\"example\\"])"`; -exports[`Response > crossSerializeStream > supports Response 1`] = `"$R[0]=new Response($R[1]=($R[2]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))(),$R[3]={headers:$R[4]=new Headers({\\"content-type\\":\\"text/plain;charset=UTF-8\\"}),status:200,statusText:\\"\\"})"`; +exports[`Response > crossSerializeStream > supports Response 1`] = `"(self.$R=self.$R||[],$R[0]=new Response($R[1]=($R[2]=(s,c)=>((s=new ReadableStream({start:x=>{c=x}})).c=c,s))(),$R[3]={headers:$R[4]=new Headers({\\"content-type\\":\\"text/plain;charset=UTF-8\\"}),status:200,statusText:\\"\\"}))"`; exports[`Response > crossSerializeStream > supports Response 2`] = `"($R[7]=(s,d)=>{s.c.enqueue(d)})($R[1],$R[5]=new Uint8Array($R[6]=new Uint8Array([72,101,108,108,111,32,87,111,114,108,100,33]).buffer,0,12))"`; diff --git a/packages/seroval/test/web-api/__snapshots__/url-search-params.test.ts.snap b/packages/seroval/test/web-api/__snapshots__/url-search-params.test.ts.snap index f6ced126..c7a17080 100644 --- a/packages/seroval/test/web-api/__snapshots__/url-search-params.test.ts.snap +++ b/packages/seroval/test/web-api/__snapshots__/url-search-params.test.ts.snap @@ -1,18 +1,18 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`URLSearchParams > crossSerialize > scoped > supports URLSearchParams 1`] = `"($R=>$R[0]=new URLSearchParams(\\"hello=world&foo=bar\\"))($R[\\"example\\"])"`; +exports[`URLSearchParams > crossSerialize > scoped > supports URLSearchParams 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=new URLSearchParams(\\"hello=world&foo=bar\\"))($R[\\"example\\"]))"`; -exports[`URLSearchParams > crossSerialize > supports URLSearchParams 1`] = `"$R[0]=new URLSearchParams(\\"hello=world&foo=bar\\")"`; +exports[`URLSearchParams > crossSerialize > supports URLSearchParams 1`] = `"(self.$R=self.$R||[],$R[0]=new URLSearchParams(\\"hello=world&foo=bar\\"))"`; -exports[`URLSearchParams > crossSerializeAsync > scoped > supports URLSearchParams 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=new URLSearchParams(\\"hello=world&foo=bar\\")))($R[\\"example\\"])"`; +exports[`URLSearchParams > crossSerializeAsync > scoped > supports URLSearchParams 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=new URLSearchParams(\\"hello=world&foo=bar\\")))($R[\\"example\\"]))"`; -exports[`URLSearchParams > crossSerializeAsync > supports URLSearchParams 1`] = `"$R[0]=Promise.resolve($R[1]=new URLSearchParams(\\"hello=world&foo=bar\\"))"`; +exports[`URLSearchParams > crossSerializeAsync > supports URLSearchParams 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=new URLSearchParams(\\"hello=world&foo=bar\\")))"`; -exports[`URLSearchParams > crossSerializeStream > scoped > supports URLSearchParams 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`URLSearchParams > crossSerializeStream > scoped > supports URLSearchParams 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`URLSearchParams > crossSerializeStream > scoped > supports URLSearchParams 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]=new URLSearchParams(\\"hello=world&foo=bar\\")))($R[\\"example\\"])"`; -exports[`URLSearchParams > crossSerializeStream > supports URLSearchParams 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`URLSearchParams > crossSerializeStream > supports URLSearchParams 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`URLSearchParams > crossSerializeStream > supports URLSearchParams 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=new URLSearchParams(\\"hello=world&foo=bar\\"))"`; diff --git a/packages/seroval/test/web-api/__snapshots__/url.test.ts.snap b/packages/seroval/test/web-api/__snapshots__/url.test.ts.snap index b189a1e4..256547d2 100644 --- a/packages/seroval/test/web-api/__snapshots__/url.test.ts.snap +++ b/packages/seroval/test/web-api/__snapshots__/url.test.ts.snap @@ -1,18 +1,18 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`URL > crossSerialize > scoped > supports URL 1`] = `"($R=>$R[0]=new URL(\\"https://github.com/lxsmnsyc/seroval?hello=world\\"))($R[\\"example\\"])"`; +exports[`URL > crossSerialize > scoped > supports URL 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=new URL(\\"https://github.com/lxsmnsyc/seroval?hello=world\\"))($R[\\"example\\"]))"`; -exports[`URL > crossSerialize > supports URL 1`] = `"$R[0]=new URL(\\"https://github.com/lxsmnsyc/seroval?hello=world\\")"`; +exports[`URL > crossSerialize > supports URL 1`] = `"(self.$R=self.$R||[],$R[0]=new URL(\\"https://github.com/lxsmnsyc/seroval?hello=world\\"))"`; -exports[`URL > crossSerializeAsync > scoped > supports URL 1`] = `"($R=>$R[0]=Promise.resolve($R[1]=new URL(\\"https://github.com/lxsmnsyc/seroval?hello=world\\")))($R[\\"example\\"])"`; +exports[`URL > crossSerializeAsync > scoped > supports URL 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=Promise.resolve($R[1]=new URL(\\"https://github.com/lxsmnsyc/seroval?hello=world\\")))($R[\\"example\\"]))"`; -exports[`URL > crossSerializeAsync > supports URL 1`] = `"$R[0]=Promise.resolve($R[1]=new URL(\\"https://github.com/lxsmnsyc/seroval?hello=world\\"))"`; +exports[`URL > crossSerializeAsync > supports URL 1`] = `"(self.$R=self.$R||[],$R[0]=Promise.resolve($R[1]=new URL(\\"https://github.com/lxsmnsyc/seroval?hello=world\\")))"`; -exports[`URL > crossSerializeStream > scoped > supports URL 1`] = `"($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"])"`; +exports[`URL > crossSerializeStream > scoped > supports URL 1`] = `"((self.$R=self.$R||{})[\\"example\\"]=[],($R=>$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())($R[\\"example\\"]))"`; exports[`URL > crossSerializeStream > scoped > supports URL 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]=new URL(\\"https://github.com/lxsmnsyc/seroval?hello=world\\")))($R[\\"example\\"])"`; -exports[`URL > crossSerializeStream > supports URL 1`] = `"$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))()"`; +exports[`URL > crossSerializeStream > supports URL 1`] = `"(self.$R=self.$R||[],$R[0]=($R[1]=(s,f,p)=>((p=new Promise((a,b)=>{s=a,f=b})).s=s,p.f=f,p))())"`; exports[`URL > crossSerializeStream > supports URL 2`] = `"($R[3]=(p,d)=>{p.s(d),p.status=\\"success\\",p.value=d;delete p.s;delete p.f})($R[0],$R[2]=new URL(\\"https://github.com/lxsmnsyc/seroval?hello=world\\"))"`;