@@ -9,29 +9,28 @@ test('cancellable', () => {
99 const cancelT = 50
1010 const start = Date . now ( )
1111 const log = ( ...argsArr ) => {
12- const diff = Math . floor ( Date . now ( ) - start ) ;
13- result . push ( { " time" : diff , " returned" : fn ( ...argsArr ) } )
12+ const diff = Math . floor ( Date . now ( ) - start )
13+ result . push ( { time : diff , returned : fn ( ...argsArr ) } )
1414 }
15- const cancel = cancellable ( log , [ 2 ] , 20 ) ;
15+ const cancel = cancellable ( log , [ 2 ] , 20 )
1616 const maxT = Math . max ( t , 50 )
1717 setTimeout ( cancel , cancelT )
1818 setTimeout ( ( ) => {
19- expect ( result ) . toEqual ( [ { " time" : 20 , " returned" : 10 } ] )
19+ expect ( result ) . toEqual ( [ { time : 20 , returned : 10 } ] )
2020 } , 65 )
2121} )
2222
23-
2423test ( 'cancellable2' , ( ) => {
2524 const result = [ ]
26- const fn = ( x ) => x ** 2
25+ const fn = ( x ) => x ** 2
2726 const t = 100
2827 const cancelT = 50
2928 const start = Date . now ( )
3029 const log = ( ...argsArr ) => {
31- const diff = Math . floor ( Date . now ( ) - start ) ;
32- result . push ( { " time" : diff , " returned" : fn ( ...argsArr ) } )
30+ const diff = Math . floor ( Date . now ( ) - start )
31+ result . push ( { time : diff , returned : fn ( ...argsArr ) } )
3332 }
34- const cancel = cancellable ( log , [ 2 ] , 20 ) ;
33+ const cancel = cancellable ( log , [ 2 ] , 20 )
3534 const maxT = Math . max ( t , 50 )
3635 setTimeout ( cancel , cancelT )
3736 setTimeout ( ( ) => {
@@ -46,13 +45,13 @@ test('cancellable3', () => {
4645 const cancelT = 100
4746 const start = Date . now ( )
4847 const log = ( ...argsArr ) => {
49- const diff = Math . floor ( Date . now ( ) - start ) ;
50- result . push ( { " time" : diff , " returned" : fn ( ...argsArr ) } )
48+ const diff = Math . floor ( Date . now ( ) - start )
49+ result . push ( { time : diff , returned : fn ( ...argsArr ) } )
5150 }
52- const cancel = cancellable ( log , [ 2 , 4 ] , 20 ) ;
51+ const cancel = cancellable ( log , [ 2 , 4 ] , 20 )
5352 const maxT = Math . max ( t , 50 )
5453 setTimeout ( cancel , cancelT )
5554 setTimeout ( ( ) => {
56- expect ( result ) . toEqual ( [ { " time" : 30 , " returned" : 8 } ] )
55+ expect ( result ) . toEqual ( [ { time : 30 , returned : 8 } ] )
5756 } , 65 )
5857} )
0 commit comments