@@ -38,13 +38,13 @@ import type { Plugin } from './plugin';
3838
3939export interface DeserializerContextOptions {
4040 read ( ) : Promise < Uint8Array | undefined > ;
41- refs : Map < number , unknown > ;
41+ refs : Map < number , { value : unknown } > ;
4242 plugins ?: Plugin < any , any > [ ] ;
4343}
4444
4545export interface DeserializerContext {
4646 read ( ) : Promise < Uint8Array | undefined > ;
47- refs : Map < number , unknown > ;
47+ refs : Map < number , { value : unknown } > ;
4848 plugins ?: Plugin < any , any > [ ] ;
4949 root : PromiseConstructorResolver ;
5050 done : boolean ;
@@ -103,7 +103,7 @@ async function ensureChunk(ctx: DeserializerContext, requiredLength: number) {
103103}
104104
105105function upsert ( ctx : DeserializerContext , id : number , value : unknown ) : unknown {
106- ctx . refs . set ( id , value ) ;
106+ ctx . refs . set ( id , { value } ) ;
107107 return value ;
108108}
109109
@@ -148,7 +148,7 @@ async function deserializeId(
148148async function deserializeRef ( ctx : DeserializerContext ) {
149149 const ref = await deserializeInteger ( ctx ) ;
150150 if ( ctx . refs . has ( ref ) ) {
151- return { value : ctx . refs . get ( ref ) } ;
151+ return ctx . refs . get ( ref ) ! ;
152152 }
153153 throw new SerovalMalformedBinaryError ( ) ;
154154}
@@ -161,7 +161,7 @@ async function deserializeConstant(ctx: DeserializerContext) {
161161
162162async function deserializeNumber ( ctx : DeserializerContext ) {
163163 const id = await deserializeId ( ctx , SerovalNodeType . Number ) ;
164- upsert ( ctx , id , deserializeNumberValue ( ctx ) ) ;
164+ upsert ( ctx , id , await deserializeNumberValue ( ctx ) ) ;
165165}
166166
167167async function deserializeString ( ctx : DeserializerContext ) {
@@ -273,7 +273,7 @@ async function deserializeObjectFlag(ctx: DeserializerContext) {
273273
274274async function deserializeArray ( ctx : DeserializerContext ) {
275275 const id = await deserializeId ( ctx , SerovalNodeType . Array ) ;
276- const length = await deserializeNumberValue ( ctx ) ;
276+ const length = await deserializeInteger ( ctx ) ;
277277 upsert ( ctx , id , new Array ( length ) ) ;
278278}
279279
0 commit comments