refactor: cleanup statistic helpers code
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 8 May 2023 22:36:53 +0000 (00:36 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 8 May 2023 22:36:53 +0000 (00:36 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/utils/Utils.ts

index 4f89179f1dc5f45ba3b954ff38f1b0ceafe207c5..be372de697f43b384a6929a14884567fa23b72d0 100644 (file)
@@ -343,8 +343,11 @@ export class Utils {
     if (Array.isArray(dataSet) === true && dataSet.length === 1) {
       return dataSet[0];
     }
-    dataSet = dataSet.slice().sort((a, b) => a - b);
-    return (dataSet[(dataSet.length - 1) >> 1] + dataSet[dataSet.length >> 1]) / 2;
+    const sortedDataSet = dataSet.slice().sort((a, b) => a - b);
+    return (
+      (sortedDataSet[(sortedDataSet.length - 1) >> 1] + sortedDataSet[sortedDataSet.length >> 1]) /
+      2
+    );
   }
 
   // TODO: use order statistics tree https://en.wikipedia.org/wiki/Order_statistic_tree