Skip to content

Commit

Permalink
fix: guard against NaN in minSnap and maxSnap handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Dec 5, 2020
1 parent 315578a commit 7dbf037
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,18 @@ export function processSnapPoints(unsafeSnaps: number | number[], maxHeight) {
return acc
}, new Set<number>()),
]
const minSnap = Math.min(...snapPoints)
if (Number.isNaN(minSnap)) {
throw new TypeError('minSnap is NaN')
}
const maxSnap = Math.max(...snapPoints)
if (Number.isNaN(maxSnap)) {
throw new TypeError('maxSnap is NaN')
}

return {
snapPoints,
minSnap: Math.min(...snapPoints),
maxSnap: Math.max(...snapPoints),
minSnap,
maxSnap,
}
}

0 comments on commit 7dbf037

Please sign in to comment.