@@ -90,7 +90,7 @@ export class TimelineChart {
9090 scale . options . ticks . min = 0 ;
9191 scale . options . ticks . max = 60 ;
9292 const config = this . chart . config ;
93- if ( config && config . options ) {
93+ if ( config ? .options ) {
9494 config . options . plugins . zoom . zoom . rangeMax . x = 60 ;
9595 }
9696 labels . length = 0 ;
@@ -112,7 +112,7 @@ export class TimelineChart {
112112 if ( this . hidden ) {
113113 return ;
114114 }
115- if ( datasets && datasets . length ) {
115+ if ( datasets ? .length ) {
116116 const scale = this . chart . scales [ X_AXIS_SECONDS ] ;
117117 const { top } = this . chart . chartArea ;
118118 const height = top + datasets . reduce ( ( val , dataset ) => val + dataset . barThickness , 0 ) + scale . height + 5 ;
@@ -195,7 +195,7 @@ export class TimelineChart {
195195 const { targetduration, totalduration, url } = details ;
196196 const { datasets } = this . chart . data ;
197197 // eslint-disable-next-line no-restricted-properties
198- const levelDataSet = datasets . find ( dataset => dataset . url && dataset . url . toString ( ) === url ) ;
198+ const levelDataSet = arrayFind ( datasets , dataset => dataset . url && dataset . url . toString ( ) === url ) ;
199199 if ( ! levelDataSet ) {
200200 return ;
201201 }
@@ -238,7 +238,7 @@ export class TimelineChart {
238238 set maxZoom ( x : number ) {
239239 const { chart } = this ;
240240 const { config } = chart ;
241- if ( config && config . options ) {
241+ if ( config ? .options ) {
242242 const currentZoom = config . options . plugins . zoom . zoom . rangeMax . x ;
243243 const newZoom = Math . max ( x , currentZoom ) ;
244244 if ( currentZoom === 60 && newZoom !== currentZoom ) {
@@ -252,13 +252,12 @@ export class TimelineChart {
252252 updateFragment ( data : any ) {
253253 const { datasets } = this . chart . data ;
254254 const frag : Fragment = data . frag ;
255- // eslint-disable-next-line no-restricted-properties
256- const levelDataSet = datasets . find ( dataset => dataset . url === frag . baseurl ) ;
255+ const levelDataSet = arrayFind ( datasets , dataset => dataset . url === frag . baseurl ) ;
257256 if ( ! levelDataSet ) {
258257 return ;
259258 }
260259 // eslint-disable-next-line no-restricted-properties
261- const fragData = levelDataSet . data . find ( fragData => fragData . relurl === frag . relurl ) ;
260+ const fragData = arrayFind ( levelDataSet . data , fragData => fragData . relurl === frag . relurl ) ;
262261 if ( fragData && fragData !== frag ) {
263262 Object . assign ( fragData , frag ) ;
264263 }
@@ -631,3 +630,20 @@ function getChartOptions () {
631630 }
632631 } ;
633632}
633+
634+ function arrayFind ( array , predicate ) {
635+ const len = array . length >>> 0 ;
636+ if ( typeof predicate !== 'function' ) {
637+ throw TypeError ( 'predicate must be a function' ) ;
638+ }
639+ const thisArg = arguments [ 2 ] ;
640+ let k = 0 ;
641+ while ( k < len ) {
642+ const kValue = array [ k ] ;
643+ if ( predicate . call ( thisArg , kValue , k , array ) ) {
644+ return kValue ;
645+ }
646+ k ++ ;
647+ }
648+ return undefined ;
649+ }
0 commit comments