Skip to content

Commit

Permalink
fix: prevent min/reduce calls always returning a 0 value
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryptkeeper committed Jun 7, 2021
1 parent 0f297b7 commit d491b78
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions assets/js/scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class RelativeScale {
// https://stackoverflow.com/questions/63705432/maximum-call-stack-size-exceeded-when-using-the-dots-operator/63706516#63706516
const max = nonNullData.reduce((a, b) => {
return Math.max(a, b)
}, 0)
}, Number.NEGATIVE_INFINITY)

return RelativeScale.scale(
[0, RelativeScale.isFiniteOrZero(max)],
Expand Down Expand Up @@ -70,10 +70,10 @@ export class RelativeScale {
// https://stackoverflow.com/questions/63705432/maximum-call-stack-size-exceeded-when-using-the-dots-operator/63706516#63706516
const min = nonNullData.reduce((a, b) => {
return Math.min(a, b)
}, 0)
}, Number.POSITIVE_INFINITY)
const max = nonNullData.reduce((a, b) => {
return Math.max(a, b)
}, 0)
}, Number.NEGATIVE_INFINITY)

return {
min: RelativeScale.isFiniteOrZero(min),
Expand Down

0 comments on commit d491b78

Please sign in to comment.