-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6958 from TerriaJS/minmax-exceed-stack
Fix maximum call stack size exceeded on Math.min/max when creating Charts
- Loading branch information
Showing
4 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export function getMax(nums: number[]) { | ||
let len = nums.length; | ||
if (len === 0) return undefined; | ||
|
||
let max = -Infinity; | ||
|
||
while (len--) { | ||
max = nums[len] > max ? nums[len] : max; | ||
} | ||
return max; | ||
} | ||
|
||
export function getMin(nums: number[]) { | ||
let len = nums.length; | ||
if (len === 0) return undefined; | ||
|
||
let min = Infinity; | ||
|
||
while (len--) { | ||
min = nums[len] < min ? nums[len] : min; | ||
} | ||
return min; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters