mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 14:37:13 +01:00
fix range selection issue
This commit is contained in:
18
helpers/array.js
Normal file
18
helpers/array.js
Normal file
@@ -0,0 +1,18 @@
|
||||
export function getNextSmaller(array, pivot) {
|
||||
if (!array || !Array.isArray(array) || !array.length) {
|
||||
return null
|
||||
}
|
||||
|
||||
return array
|
||||
.sort()
|
||||
.reverse()
|
||||
.find((item) => item < pivot)
|
||||
}
|
||||
|
||||
export function getNextBigger(array, pivot) {
|
||||
if (!array || !Array.isArray(array) || !array.length) {
|
||||
return null
|
||||
}
|
||||
|
||||
return array.sort().find((day) => day > pivot)
|
||||
}
|
||||
Reference in New Issue
Block a user