fix: provide initial value to avoid reducing empty array

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Reduce_of_empty_array_with_no_initial_value
This commit is contained in:
Nick Krecklow 2021-06-07 11:51:47 -05:00
parent af2301495e
commit 0f297b72a8
No known key found for this signature in database
GPG Key ID: 5F149FDE156FFA94
4 changed files with 8 additions and 5 deletions

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

@ -1,3 +1,6 @@
**5.6.0** *(June 7 2021)*
- Fixed a regression caused by rendering error fixed in 5.5.9. See https://github.com/Cryptkeeper/Minetrack/issues/257
**5.5.9** *(May 31 2021)* **5.5.9** *(May 31 2021)*
- Added configuration option to enable/disable ping failure logging. - Added configuration option to enable/disable ping failure logging.
- Fixed a rendering error when the primary historical graph has too many data points. - Fixed a rendering error when the primary historical graph has too many data points.

2
package-lock.json generated

@ -1,6 +1,6 @@
{ {
"name": "minetrack", "name": "minetrack",
"version": "5.5.9", "version": "5.6.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {

@ -1,6 +1,6 @@
{ {
"name": "minetrack", "name": "minetrack",
"version": "5.5.9", "version": "5.6.0",
"description": "A Minecraft server tracker that lets you focus on the basics.", "description": "A Minecraft server tracker that lets you focus on the basics.",
"dependencies": { "dependencies": {
"finalhandler": "^1.1.2", "finalhandler": "^1.1.2",