File tree Expand file tree Collapse file tree 2 files changed +8
-20
lines changed
Expand file tree Collapse file tree 2 files changed +8
-20
lines changed Original file line number Diff line number Diff line change @@ -40,32 +40,20 @@ function range(lowEnd, highEnd) {
4040 return arr ;
4141}
4242
43- const max = function ( arr ) {
44- return Math . max . apply ( null , arr ) ;
45- } ;
46-
47- const min = function ( arr ) {
48- return Math . min . apply ( null , arr ) ;
49- } ;
50-
5143function nearestIndex ( arr , x ) {
5244 // Return index of nearest values in array
5345 // http://stackoverflow.com/questions/25854212/return-index-of-nearest-values-in-an-array
54- const l = [ ] ;
55- const h = [ ] ;
56-
57- arr . forEach ( function ( v ) {
46+ let low = 0 ;
47+ let high = arr . length - 1 ;
48+ arr . forEach ( ( v , idx ) => {
5849 if ( v < x ) {
59- l . push ( v ) ;
50+ low = Math . max ( idx , low ) ;
6051 } else if ( v > x ) {
61- h . push ( v ) ;
52+ high = Math . min ( idx , high ) ;
6253 }
6354 } ) ;
6455
65- return {
66- low : arr . indexOf ( max ( l ) ) ,
67- high : arr . indexOf ( min ( h ) ) ,
68- } ;
56+ return { low, high } ;
6957}
7058
7159function prefetch ( element ) {
Original file line number Diff line number Diff line change 11export default function uuidv4 ( ) {
22 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' . replace ( / [ x y ] / g, function ( c ) {
3- let r = ( Math . random ( ) * 16 ) | 0 ,
4- v = c == 'x' ? r : ( r & 0x3 ) | 0x8 ;
3+ const r = ( Math . random ( ) * 16 ) | 0 ; // eslint-disable-line no-bitwise
4+ const v = c === 'x' ? r : ( r & 0x3 ) | 0x8 ; // eslint-disable-line no-bitwise
55
66 return v . toString ( 16 ) ;
77 } ) ;
You can’t perform that action at this time.
0 commit comments