Skip to content

Commit

Permalink
fix: TS in microbundle breaks on [...(new Set)], swapping to Array.from
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Dec 5, 2020
1 parent 7dbf037 commit 2402b5a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ export function roundAndCheckForNaN(unrounded) {
export function processSnapPoints(unsafeSnaps: number | number[], maxHeight) {
const safeSnaps = [].concat(unsafeSnaps).map(roundAndCheckForNaN)

const snapPoints = [
...safeSnaps.reduce((acc, snapPoint) => {
acc.add(clamp(snapPoint, 0, maxHeight))
return acc
}, new Set<number>()),
]
const snapPointsDedupedSet = safeSnaps.reduce((acc, snapPoint) => {
acc.add(clamp(snapPoint, 0, maxHeight))
return acc
}, new Set<number>())

const snapPoints = Array.from(snapPointsDedupedSet)

const minSnap = Math.min(...snapPoints)
if (Number.isNaN(minSnap)) {
throw new TypeError('minSnap is NaN')
Expand Down

0 comments on commit 2402b5a

Please sign in to comment.