@@ -161,7 +161,7 @@ const calcUnion = (a: Range, b: Range): Range | null => {
161161 if ( a [ 1 ] + 1 < b [ 0 ] || a [ 0 ] - 1 > b [ 1 ] ) {
162162 return null ; // cannot make union
163163 }
164- return [ Math . min ( a [ 0 ] , b [ 0 ] ) , Math . max ( a [ 1 ] , b [ 1 ] ) ] ;
164+ return [ a [ 0 ] < b [ 0 ] ? a [ 0 ] : b [ 0 ] , a [ 1 ] > b [ 1 ] ? a [ 1 ] : b [ 1 ] ] ;
165165} ;
166166
167167/**
@@ -306,8 +306,8 @@ export const intersect = (a: MIR, b: MIR): MIR => {
306306 const r2 = b [ j ] ;
307307 if ( r1 [ 0 ] <= r2 [ 1 ] && r1 [ 1 ] >= r2 [ 0 ] ) {
308308 jstart = j ;
309- const min = Math . max ( r1 [ 0 ] , r2 [ 0 ] ) ;
310- const max = Math . min ( r1 [ 1 ] , r2 [ 1 ] ) ;
309+ const min = r1 [ 0 ] < r2 [ 0 ] ? r2 [ 0 ] : r1 [ 0 ] ;
310+ const max = r1 [ 1 ] < r2 [ 1 ] ? r1 [ 1 ] : r2 [ 1 ] ;
311311 result . push ( [ min , max ] ) ;
312312 } else if ( r1 [ 1 ] < r2 [ 0 ] ) {
313313 break ;
@@ -328,11 +328,11 @@ export const intersect = (a: MIR, b: MIR): MIR => {
328328 * has([[2, 10]], [[0, 100]]); // false
329329 */
330330export const has = ( a : MIR , b : MIR ) : boolean => {
331- const s = 0 ;
331+ const start = 0 ;
332332 const len = a . length ;
333333 for ( let r of b ) {
334334 let i : number ;
335- for ( i = s ; i < len ; i ++ ) {
335+ for ( i = start ; i < len ; i ++ ) {
336336 const my = a [ i ] ;
337337 if ( r [ 0 ] >= my [ 0 ] && r [ 1 ] <= my [ 1 ] && r [ 1 ] >= my [ 0 ] && r [ 1 ] <= my [ 1 ] )
338338 break ;
@@ -436,7 +436,7 @@ export const max = (data: MIR): number | undefined => {
436436 * at([[2, 4], [8, 10]], -1); // 10
437437 */
438438export const at = ( data : MIR , index : number ) : number | undefined => {
439- if ( index === Infinity || index === - Infinity )
439+ if ( ! Number . isInteger ( index ) )
440440 throw new RangeError ( 'at() was invoked with an invalid index' ) ;
441441 if (
442442 data . length > 0 &&
0 commit comments