@@ -382,7 +382,7 @@ export async function compress(input, options) {
382382 if ( opts . justc && opts . jsonstring ) {
383383 const JUSTCobj = await toJUSTC ( obj ) ;
384384 const JSONstr = JSON . stringify ( await parseJUSTC ( JUSTCobj ) ) ;
385- if ( JSONstr == JSON . stringify ( str ) ) JUSTCstr = JUSTCobj ;
385+ if ( JSONstr == JSON . stringify ( obj ) ) JUSTCstr = JUSTCobj ;
386386 }
387387
388388 if ( typeof JUSTCstr != 'undefined' && JUSTCstr . length < str . length && str == JSON . stringify ( obj ) ) {
@@ -899,22 +899,24 @@ export async function decompressFromUint8Array(uint8array, ...params) {
899899
900900export async function compressLarge ( input , ...params ) {
901901 const LENGTH = 1024 ;
902+ if ( input . length < LENGTH || typeof input != 'string' ) return await compress ( input , ...params ) ;
903+
902904 const result = [ charCode ( cryptCharCode ( 11 , false , false , false , undefined , undefined , false , 3 ) ) ] ;
903905
904906 for ( let i = 0 ; i < input . length ; i += LENGTH ) {
905907 const chunk = input . slice ( i , i + LENGTH ) ;
906- const compressed = await compress ( chunk , ...params ) ;
908+ const compressed = noDebugMode ( await compress ( chunk , ...params ) ) ;
907909 result . push ( String . fromCharCode ( compressed . length ) , compressed ) ;
908910 }
909911
910912 return result . join ( '' ) ;
911913}
912914export async function compressLargeToBase64 ( ...input ) {
913- const compressed = noDebugMode ( await compress ( ...input ) ) ;
915+ const compressed = await compressLarge ( ...input ) ;
914916 return B64Padding ( encode ( compressed ) ) ;
915917}
916918export async function compressLargeToBase64URL ( ...input ) {
917- const compressed = noDebugMode ( await compress ( ...input ) ) ;
919+ const compressed = await compressLarge ( ...input ) ;
918920 return encode ( compressed , 64 , B64URL ) ;
919921}
920922export async function compressLargeToUint8Array ( ...input ) {
0 commit comments