@@ -150,10 +150,11 @@ CustomFormatters.addFormatter({
150150type CharArrayConstructor = Uint8ArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor ;
151151
152152function formatRawString < T extends CharArrayConstructor > (
153- wasm : WasmInterface , value : Value , charType : T , decode : ( chars : InstanceType < T > ) => string ) : string | {
154- [ key : string ] : Value | null ,
155- }
156- {
153+ wasm : WasmInterface ,
154+ value : Value ,
155+ charType : T ,
156+ decode : ( chars : InstanceType < T > ) => string ,
157+ ) : string | Record < string , Value | null > {
157158 const address = value . asUint32 ( ) ;
158159 if ( address < Constants . SAFE_HEAP_START ) {
159160 return formatPointerOrReference ( wasm , value ) ;
@@ -184,24 +185,15 @@ function formatRawString<T extends CharArrayConstructor>(
184185 return formatPointerOrReference ( wasm , value ) ;
185186}
186187
187- export function formatCString ( wasm : WasmInterface , value : Value ) : string | {
188- [ key : string ] : Value | null ,
189- }
190- {
188+ export function formatCString ( wasm : WasmInterface , value : Value ) : string | Record < string , Value | null > {
191189 return formatRawString ( wasm , value , Uint8Array , str => new TextDecoder ( ) . decode ( str ) ) ;
192190}
193191
194- export function formatU16CString ( wasm : WasmInterface , value : Value ) : string | {
195- [ key : string ] : Value | null ,
196- }
197- {
192+ export function formatU16CString ( wasm : WasmInterface , value : Value ) : string | Record < string , Value | null > {
198193 return formatRawString ( wasm , value , Uint16Array , str => new TextDecoder ( 'utf-16le' ) . decode ( str ) ) ;
199194}
200195
201- export function formatCWString ( wasm : WasmInterface , value : Value ) : string | {
202- [ key : string ] : Value | null ,
203- }
204- {
196+ export function formatCWString ( wasm : WasmInterface , value : Value ) : string | Record < string , Value | null > {
205197 // emscripten's wchar is 4 byte
206198 return formatRawString ( wasm , value , Uint32Array , str => Array . from ( str ) . map ( v => String . fromCodePoint ( v ) ) . join ( '' ) ) ;
207199}
@@ -247,7 +239,7 @@ function reMatch(...exprs: RegExp[]): (type: TypeInfo) => boolean {
247239
248240CustomFormatters . addFormatter ( { types : reMatch ( / ^ s t d : : v e c t o r < .+ > $ / ) , format : formatVector } ) ;
249241
250- export function formatPointerOrReference ( wasm : WasmInterface , value : Value ) : { [ key : string ] : Value | null } {
242+ export function formatPointerOrReference ( wasm : WasmInterface , value : Value ) : Record < string , Value | null > {
251243 const address = value . asUint32 ( ) ;
252244 if ( address === 0 ) {
253245 return { '0x0' : null } ;
@@ -256,7 +248,7 @@ export function formatPointerOrReference(wasm: WasmInterface, value: Value): {[k
256248}
257249CustomFormatters . addFormatter ( { types : type => type . isPointer , format : formatPointerOrReference } ) ;
258250
259- export function formatDynamicArray ( wasm : WasmInterface , value : Value ) : { [ key : string ] : Value | null } {
251+ export function formatDynamicArray ( wasm : WasmInterface , value : Value ) : Record < string , Value | null > {
260252 return { [ `0x${ value . location . toString ( 16 ) } ` ] : value . $ ( 0 ) } ;
261253}
262254CustomFormatters . addFormatter ( { types : reMatch ( / ^ .+ \[ \] $ / ) , format : formatDynamicArray } ) ;
0 commit comments