Skip to content

Commit

Permalink
fix(timeRange): shiftArray should not mutate its argument (plouc#2420)
Browse files Browse the repository at this point in the history
  • Loading branch information
wirhabenzeit authored Nov 14, 2023
1 parent 1620db2 commit e4a343f
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions packages/calendar/src/compute/timeRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,8 @@ const getTimeInterval = (firstWeekday: Weekday) => {
function shiftArray<T>(arr: T[], x: number): T[] {
if (!arr.length || !x) return arr

for (let i = 0; i < x; i++) {
const shifted = arr.shift() as T
arr.push(shifted)
}

return arr
x = x % arr.length
return arr.slice(x, arr.length).concat(arr.slice(0, x))
}

function computeGrid({
Expand Down

0 comments on commit e4a343f

Please sign in to comment.