File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ describe('Simple chart session', async () => {
2323
2424 while (
2525 chart . infos . full_name !== 'BINANCE:BTCEUR'
26- || ! chart . periods . length
26+ || chart . periods . length < 10
2727 ) await utils . wait ( 100 ) ;
2828
2929 expect ( chart . infos . full_name ) . toBe ( 'BINANCE:BTCEUR' ) ;
@@ -39,7 +39,7 @@ describe('Simple chart session', async () => {
3939 console . log ( 'Setting timeframe to 15 minutes...' ) ;
4040 chart . setSeries ( '15' ) ;
4141
42- while ( ! chart . periods . length ) await utils . wait ( 100 ) ;
42+ while ( chart . periods . length < 10 ) await utils . wait ( 100 ) ;
4343 console . log ( 'Chart timeframe set' ) ;
4444
4545 expect (
Original file line number Diff line number Diff line change @@ -5,13 +5,11 @@ export const wait = (ms: number) => (
55export function calculateTimeGap ( periods : { time : number } [ ] ) {
66 let minTimeGap = Infinity ;
77
8- for ( let i = 1 ; i < 10 ; i += 1 ) {
9- const time1 = periods [ i - 1 ] ?. time ;
10- const time2 = periods [ i ] ?. time ;
11- if ( ! time1 || ! time2 ) continue ;
12-
13- const timeGap = time1 - time2 ;
14- if ( timeGap < minTimeGap ) minTimeGap = timeGap ;
8+ for ( let i = 1 ; i < periods . length ; i += 1 ) {
9+ minTimeGap = Math . min (
10+ minTimeGap ,
11+ periods [ i - 1 ] . time - periods [ i ] . time ,
12+ ) ;
1513 }
1614
1715 return minTimeGap ;
You can’t perform that action at this time.
0 commit comments