@@ -9,6 +9,23 @@ function stringChunks(str, num) {
99 return output
1010}
1111
12+ const encodings = [
13+ '00: JSSCBASE' ,
14+ '01: JSSCRU' ,
15+ '02: JSSCENRU' ,
16+ '03: JSSCENKK' ,
17+ '04: JSSCHI' ,
18+ '05: JSSCENHI' ,
19+ '06: JSSCBN' ,
20+ '07: JSSCENBN' ,
21+ '08: JSSCHIBN' ,
22+ '09: JSSCJA' ,
23+ '10: JSSCTelu' ,
24+ '11: JSSCMR' ,
25+ '12: JSSCB' ,
26+ '13: JSSCE' ,
27+ '14: JSSCAR' ,
28+ ] ;
1229const modes = [
1330 '00: No compression' ,
1431 '01: 2-3 characters in 1' ,
@@ -83,7 +100,7 @@ async function test(text, name) {
83100 '\n\n\nOriginal:' , text , '\n\nCompressed:' , a , '\n\nDecompressed:' , b ,
84101 '\n\n\nSuccess?' , result , '(Decompressed successfully?' , success [ 0 ] , '; Compressed size ≤ Original size?' , success [ 1 ] , '; .min.js test:' , success [ 2 ] && success [ 3 ] , ')\nOriginal size:' , toString . length * 16 , 'bits\nCompressed size:' , a . length * 16 , 'bits\nSaved:' , toString . length * 16 - a . length * 16 , 'bits\nRatio:' , ( toString . length * 16 ) / ( a . length * 16 ) ,
85102 ': 1\n\n\n16-bit Data/Header character:' , data , '\nCharCode:' , data . charCodeAt ( 0 ) , '\nBits:' , bits , '\nBlocks:' , ...blocks , '\nCode 1:' , code [ 0 ] , '\nCode 2:' , code [ 1 ] , c . slice ( 10 , 11 ) == '1' ? '\nBeginID:' : '\nCode 3:' , code [ 2 ] , '\nSequences?' , c . slice ( 4 , 5 ) == '1' , ( code [ 1 ] > 0 && code [ 0 ] == 0 ) || code [ 0 ] == 6 ? '\nReturn as number?' : '\nInput RLE?' , c . slice ( 8 , 9 ) == '1' , '\nOutput RLE?' , c . slice ( 9 , 10 ) == '1' , '\nCode 3 is BeginID?' , c . slice ( 10 , 11 ) == '1' ,
86- '\n\nMode:' , modes [ code [ 0 ] ] , '\n\n\n\n\n'
103+ '\n\nMode:' , modes [ code [ 0 ] ] , code [ 0 ] == 5 ? '\nCharacter Encoding:' : code [ 0 ] == 31 ? '\nCompressed:' : '' , code [ 0 ] == 5 ? encodings [ code [ 1 ] ] : code [ 0 ] == 31 ? code [ 1 ] + 1 : '' , code [ 0 ] == 31 ? 'times' : '' , '\n\n\n\n\n'
87104 ) ;
88105
89106 return result ;
@@ -94,11 +111,12 @@ async function runTest(text = 'Lorem ipsum dolor sit amet, consectetur adipiscin
94111}
95112
96113const tests = async function ( ) {
97- await runTest ( ) . catch ( ( ) => { } ) ;
98- await runTest ( 'foo' . repeat ( 1000 ) , 'foo x1000' ) . catch ( ( ) => { } ) ;
99- await runTest ( 'ыалалыылаар' , 'ыалалыылаар' ) . catch ( ( ) => { } ) ;
100- await runTest ( String ( Math . round ( Math . random ( ) * 256000000 ) ) , 'random numbers' ) . catch ( ( ) => { } ) ;
101- await runTest ( 'asdasdsasdsadsdadsadssssssssssssssssssssыꙮ' . repeat ( 15 ) , 'absolutely random stuff' ) . catch ( ( ) => { } ) ;
114+ await runTest ( ) ;
115+ await runTest ( 'foo' . repeat ( 1000 ) , 'foo x1000' ) ;
116+ await runTest ( 'ыалалыылаар' , 'ыалалыылаар' ) ;
117+ await runTest ( String ( Math . round ( Math . random ( ) * 256000000 ) ) , 'random numbers' ) ;
118+ await runTest ( 'asdasdsasdsadsdadsadssssssssssssssssssssыꙮ' . repeat ( 15 ) , 'absolutely random stuff' ) ;
119+ await runTest ( 'aaaaaaaaaaaaaaa1ыыыыыыыыыыыыыꙮ' . repeat ( 30 ) , 'should use recursive compression mode' ) ;
102120}
103121
104- tests ( ) . catch ( ( ) => { } )
122+ tests ( ) . then ( ( ) => { } ) ;
0 commit comments