@dra2020/district-analytics 5.5.1 → 5.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +7 -5
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -90787,16 +90787,18 @@ function maxArray(arr) {
|
|
|
90787
90787
|
}
|
|
90788
90788
|
exports.maxArray = maxArray;
|
|
90789
90789
|
// Modified from https://jsfiddle.net/Lucky500/3sy5au0c/
|
|
90790
|
+
// NOTE - Copy the array, because arr.sort() sorts in place!
|
|
90790
90791
|
function medianArray(arr) {
|
|
90791
90792
|
if (arr.length === 0)
|
|
90792
90793
|
return 0;
|
|
90793
|
-
|
|
90794
|
+
let copyArr = deepCopy(arr);
|
|
90795
|
+
copyArr.sort(function (a, b) {
|
|
90794
90796
|
return a - b;
|
|
90795
90797
|
});
|
|
90796
|
-
var half = Math.floor(
|
|
90797
|
-
if (
|
|
90798
|
-
return
|
|
90799
|
-
return (
|
|
90798
|
+
var half = Math.floor(copyArr.length / 2);
|
|
90799
|
+
if (copyArr.length % 2)
|
|
90800
|
+
return copyArr[half];
|
|
90801
|
+
return (copyArr[half - 1] + copyArr[half]) / 2.0;
|
|
90800
90802
|
}
|
|
90801
90803
|
exports.medianArray = medianArray;
|
|
90802
90804
|
function initArray(n, value) {
|