@@ -645,14 +645,14 @@ export async function getModelFile(path_or_repo_id, filename, fatal = true, opti
645645 * @throws Will throw an error if the file is not found and `fatal` is true.
646646 */
647647export async function getModelJSON ( modelPath , fileName , fatal = true , options = { } ) {
648- let buffer = await getModelFile ( modelPath , fileName , fatal , options , false ) ;
648+ const buffer = await getModelFile ( modelPath , fileName , fatal , options , false ) ;
649649 if ( buffer === null ) {
650650 // Return empty object
651651 return { }
652652 }
653653
654- let decoder = new TextDecoder ( 'utf-8' ) ;
655- let jsonData = decoder . decode ( /** @type {Uint8Array } */ ( buffer ) ) ;
654+ const decoder = new TextDecoder ( 'utf-8' ) ;
655+ const jsonData = decoder . decode ( /** @type {Uint8Array } */ ( buffer ) ) ;
656656
657657 return JSON . parse ( jsonData ) ;
658658}
@@ -678,30 +678,26 @@ async function readResponse(response, progress_callback) {
678678 const { done, value } = await reader . read ( ) ;
679679 if ( done ) return ;
680680
681- let newLoaded = loaded + value . length ;
681+ const newLoaded = loaded + value . length ;
682682 if ( newLoaded > total ) {
683683 total = newLoaded ;
684684
685685 // Adding the new data will overflow buffer.
686686 // In this case, we extend the buffer
687- let newBuffer = new Uint8Array ( total ) ;
687+ const newBuffer = new Uint8Array ( total ) ;
688688
689689 // copy contents
690690 newBuffer . set ( buffer ) ;
691691
692692 buffer = newBuffer ;
693693 }
694- buffer . set ( value , loaded )
694+ buffer . set ( value , loaded ) ;
695695 loaded = newLoaded ;
696696
697697 const progress = ( loaded / total ) * 100 ;
698698
699699 // Call your function here
700- progress_callback ( {
701- progress : progress ,
702- loaded : loaded ,
703- total : total ,
704- } )
700+ progress_callback ( { progress, loaded, total } ) ;
705701
706702 return read ( ) ;
707703 }
0 commit comments