From ae8d1f21786a5fe2216bb6ebf9d22ff0dd57ce98 Mon Sep 17 00:00:00 2001 From: bwhitn Date: Sun, 17 Dec 2017 15:19:10 -0500 Subject: [PATCH 01/13] start of math operations --- src/core/config/OperationConfig.js | 19 +++++ src/core/operations/Arithmetic.js | 130 +++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 src/core/operations/Arithmetic.js diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js index 9caa4f91..81444880 100755 --- a/src/core/config/OperationConfig.js +++ b/src/core/config/OperationConfig.js @@ -1,3 +1,4 @@ +import Arithmetic from "../operations/Arithmetic.js"; import Base from "../operations/Base.js"; import Base58 from "../operations/Base58.js"; import Base64 from "../operations/Base64.js"; @@ -656,6 +657,24 @@ const OperationConfig = { } ] }, + "Arithmetic": { + module: "Default", + description: "Conducts mathamatical operations on a list of numbers", + inputType: "string" + outputType: "string" + args: [ + { + name: "Delimiter", + type: "option", + value: Arithmetic.DELIM_OPTIONS + }, + { + name: "Operation" + type: "option", + value: Arithmetic.OPERATIONS + } + ] + }, "From Hexdump": { module: "Default", description: "Attempts to convert a hexdump back into raw data. This operation supports many different hexdump variations, but probably not all. Make sure you verify that the data it gives you is correct before continuing analysis.", diff --git a/src/core/operations/Arithmetic.js b/src/core/operations/Arithmetic.js new file mode 100644 index 00000000..8a840a29 --- /dev/null +++ b/src/core/operations/Arithmetic.js @@ -0,0 +1,130 @@ +import Utils from "../Utils.js"; + +/** + * Math operations on numbers. + * + * @author bwhitn [brian.m.whitney@outlook.com] + * @copyright Crown Copyright 2016 + * @license Apache-2.0 + * + * @namespace + */ +const Arithmetic = { + + /** + * @constant + * @default + */ + DELIM_OPTIONS: ["Space", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF"], + + /** + * @constant + * @default + */ + OPERATIONS: ["Sum", "Sub", "Multiply", "Divide", "Mean", "Median", "Mode"], + + /** + * A mapping of operation names to their function. + * @constant + */ + opMap: { + "Sub": _sub, + "Sum": _sum, + "Multiply": _multiply, + "Divide": _divide, + "Mean": _mean, + "Median": _median, + "Mode": _mode, + }, + + /** + * + * + * @param {string} input + * @param {Object[]} args + * @returns {string} + */ + runOp: function(input, args) { + const delim = Utils.charRep[args[0] || "Space"]; + let splitNumbers = input.split(delim), + numbers = [], + num, + retVal; + for (i = 0; i < splitNumbers.length; i++) { + if splitNumbers[i].indexOf(".") { + num = parseFloat(splitNumbers[i].trim()); + } else { + num = parseInt(splitNumbers[i].trim()); + } + if (num !== "NaN") { + numbers.append(num); + } + } + num = Arithmetic.opMap[args[1] || "Sum"](numbers); + if (num !== null) { + return "The values " + args[1] + "equal: " + num; + } + throw "Error with Arithmetic Operation: " + args[1]; + }, + + + _sum: function(data) { + let total = 0; + for (i = 0; i < data.length; i++) { + total += data[i]; + } + return total; + }, + + _sub: function(data) { + let total = 0; + if (data.length > 1) { + total = data[0]; + for (i = 1; i < data.length; i++) { + total -= data[i]; + } + } else { + total = null; + } + return total; + }, + + _multiply: function(data) { + let total = 0; + if (data.length > 1) { + total = data[0]; + for (i = 1; i < data.length; i++) { + total *= data[i]; + } + } else { + total = null; + } + return total; + }, + + _divide: function(data) { + let total = 0; + if (data.length > 1) { + total = data[0]; + for (i = 1; i < data.length; i++) { + total /= data[i] + } + } else { + total = null; + } + return total; + }, + + _mean: function(data) { + let total = 0; + if (data.length > 1) { + total = Arithmetic._sum(data) / data.length; + } else { + total = null; + } + return total; + }, + +}; + +export default Arithmetic; From 772f9a806e8136ac235a7614136a647151afa1b8 Mon Sep 17 00:00:00 2001 From: bwhitn Date: Sun, 17 Dec 2017 15:20:58 -0500 Subject: [PATCH 02/13] Added additional arithmetic source --- src/core/config/Categories.js | 1 + src/core/config/OperationConfig.js | 6 +-- src/core/config/modules/Default.js | 2 + src/core/operations/Arithmetic.js | 80 +++++++++++++++++++++--------- 4 files changed, 62 insertions(+), 27 deletions(-) diff --git a/src/core/config/Categories.js b/src/core/config/Categories.js index f04b5fd9..7faa75f2 100755 --- a/src/core/config/Categories.js +++ b/src/core/config/Categories.js @@ -159,6 +159,7 @@ const Categories = [ { name: "Utils", ops: [ + "Arithmetic", "Diff", "Remove whitespace", "Remove null bytes", diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js index 81444880..65d1d065 100755 --- a/src/core/config/OperationConfig.js +++ b/src/core/config/OperationConfig.js @@ -660,8 +660,8 @@ const OperationConfig = { "Arithmetic": { module: "Default", description: "Conducts mathamatical operations on a list of numbers", - inputType: "string" - outputType: "string" + inputType: "string", + outputType: "string", args: [ { name: "Delimiter", @@ -669,7 +669,7 @@ const OperationConfig = { value: Arithmetic.DELIM_OPTIONS }, { - name: "Operation" + name: "Operation", type: "option", value: Arithmetic.OPERATIONS } diff --git a/src/core/config/modules/Default.js b/src/core/config/modules/Default.js index 682db223..5f049ac7 100644 --- a/src/core/config/modules/Default.js +++ b/src/core/config/modules/Default.js @@ -1,4 +1,5 @@ import FlowControl from "../../FlowControl.js"; +import Arithmetic from "../../operations/Arithmetic.js"; import Base from "../../operations/Base.js"; import Base58 from "../../operations/Base58.js"; import Base64 from "../../operations/Base64.js"; @@ -155,6 +156,7 @@ OpModules.Default = { "Conditional Jump": FlowControl.runCondJump, "Return": FlowControl.runReturn, "Comment": FlowControl.runComment, + "Arithmetic": Arithmetic.runOp, /* diff --git a/src/core/operations/Arithmetic.js b/src/core/operations/Arithmetic.js index 8a840a29..ef6643e4 100644 --- a/src/core/operations/Arithmetic.js +++ b/src/core/operations/Arithmetic.js @@ -23,20 +23,6 @@ const Arithmetic = { */ OPERATIONS: ["Sum", "Sub", "Multiply", "Divide", "Mean", "Median", "Mode"], - /** - * A mapping of operation names to their function. - * @constant - */ - opMap: { - "Sub": _sub, - "Sum": _sum, - "Multiply": _multiply, - "Divide": _divide, - "Mean": _mean, - "Median": _median, - "Mode": _mode, - }, - /** * * @@ -48,13 +34,12 @@ const Arithmetic = { const delim = Utils.charRep[args[0] || "Space"]; let splitNumbers = input.split(delim), numbers = [], - num, - retVal; - for (i = 0; i < splitNumbers.length; i++) { - if splitNumbers[i].indexOf(".") { + num; + for (let i = 0; i < splitNumbers.length; i++) { + if (splitNumbers[i].indexOf(".") >= 0) { num = parseFloat(splitNumbers[i].trim()); } else { - num = parseInt(splitNumbers[i].trim()); + num = parseInt(splitNumbers[i].trim(), 10); } if (num !== "NaN") { numbers.append(num); @@ -68,19 +53,33 @@ const Arithmetic = { }, + /** + * Adds an array of numbers and returns the value. + * + * @private + * @param {number[]} data + * @returns {number} + */ _sum: function(data) { let total = 0; - for (i = 0; i < data.length; i++) { + for (let i = 0; i < data.length; i++) { total += data[i]; } return total; }, + /** + * Subtracts an array of numbers and returns the value. + * + * @private + * @param {number[]} data + * @returns {number} + */ _sub: function(data) { let total = 0; if (data.length > 1) { total = data[0]; - for (i = 1; i < data.length; i++) { + for (let i = 1; i < data.length; i++) { total -= data[i]; } } else { @@ -89,11 +88,18 @@ const Arithmetic = { return total; }, + /** + * Multiplies an array of numbers and returns the value. + * + * @private + * @param {number[]} data + * @returns {number} + */ _multiply: function(data) { let total = 0; if (data.length > 1) { total = data[0]; - for (i = 1; i < data.length; i++) { + for (let i = 1; i < data.length; i++) { total *= data[i]; } } else { @@ -102,12 +108,19 @@ const Arithmetic = { return total; }, + /** + * Divides an array of numbers and returns the value. + * + * @private + * @param {number[]} data + * @returns {number} + */ _divide: function(data) { let total = 0; if (data.length > 1) { total = data[0]; - for (i = 1; i < data.length; i++) { - total /= data[i] + for (let i = 1; i < data.length; i++) { + total /= data[i]; } } else { total = null; @@ -115,6 +128,13 @@ const Arithmetic = { return total; }, + /** + * Finds the mean of a number array and returns the value. + * + * @private + * @param {number[]} data + * @returns {number} + */ _mean: function(data) { let total = 0; if (data.length > 1) { @@ -125,6 +145,18 @@ const Arithmetic = { return total; }, + /** + * A mapping of operation names to their function. + * @constant + */ + opMap: { + "Sub": Arithmetic._sum, + "Sum": Arithmetic._sub, + "Multiply": Arithmetic._multiply, + "Divide": Arithmetic._divide, + "Mean": Arithmetic._mean, + }, + }; export default Arithmetic; From 6ad3728314dcfb7caae95cab81b2a4d0a1536b0f Mon Sep 17 00:00:00 2001 From: bwhitn Date: Sun, 17 Dec 2017 15:29:31 -0500 Subject: [PATCH 03/13] changed op array --- src/core/operations/Arithmetic.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/operations/Arithmetic.js b/src/core/operations/Arithmetic.js index ef6643e4..1278ac3b 100644 --- a/src/core/operations/Arithmetic.js +++ b/src/core/operations/Arithmetic.js @@ -150,11 +150,11 @@ const Arithmetic = { * @constant */ opMap: { - "Sub": Arithmetic._sum, - "Sum": Arithmetic._sub, - "Multiply": Arithmetic._multiply, - "Divide": Arithmetic._divide, - "Mean": Arithmetic._mean, + "Sum": function(numArray) { return Arithmetic._sum(numArray); }, + "Sub": function(numArray) { return Arithmetic._sub(numArray); }, + "Multiply": function(numArray) { return Arithmetic._multiply(numArray); }, + "Divide": function(numArray) { return Arithmetic._divide(numArray); }, + "Mean": function(numArray) { return Arithmetic._mean(numArray); }, }, }; From 298e8e849199bd8c4d22b5625abac9a3c1d8184a Mon Sep 17 00:00:00 2001 From: bwhitn Date: Sun, 17 Dec 2017 21:57:09 -0500 Subject: [PATCH 04/13] Inital commit for pull --- src/core/operations/Arithmetic.js | 140 ++++++++++++++++++++---------- 1 file changed, 94 insertions(+), 46 deletions(-) diff --git a/src/core/operations/Arithmetic.js b/src/core/operations/Arithmetic.js index 1278ac3b..ffcb6c86 100644 --- a/src/core/operations/Arithmetic.js +++ b/src/core/operations/Arithmetic.js @@ -21,7 +21,15 @@ const Arithmetic = { * @constant * @default */ - OPERATIONS: ["Sum", "Sub", "Multiply", "Divide", "Mean", "Median", "Mode"], + OPERATIONS: [ + "Sum", + "Sub", + "Multiply", + "Divide", + "Mean", + "Median", + "Standard Deviation" + ], /** * @@ -39,17 +47,17 @@ const Arithmetic = { if (splitNumbers[i].indexOf(".") >= 0) { num = parseFloat(splitNumbers[i].trim()); } else { - num = parseInt(splitNumbers[i].trim(), 10); + num = parseInt(splitNumbers[i].trim(), 0); } - if (num !== "NaN") { - numbers.append(num); + if (!isNaN(num)) { + numbers.push(num); } } num = Arithmetic.opMap[args[1] || "Sum"](numbers); - if (num !== null) { - return "The values " + args[1] + "equal: " + num; + if (num === null) { + return ""; } - throw "Error with Arithmetic Operation: " + args[1]; + return num; }, @@ -61,11 +69,11 @@ const Arithmetic = { * @returns {number} */ _sum: function(data) { - let total = 0; - for (let i = 0; i < data.length; i++) { - total += data[i]; + if (data.length > 0) { + return data.reduce((acc, curr) => acc + curr); + } else { + return null; } - return total; }, /** @@ -76,16 +84,11 @@ const Arithmetic = { * @returns {number} */ _sub: function(data) { - let total = 0; - if (data.length > 1) { - total = data[0]; - for (let i = 1; i < data.length; i++) { - total -= data[i]; - } + if (data.length > 0) { + return data.reduce((acc, curr) => acc - curr); } else { - total = null; + return null; } - return total; }, /** @@ -96,16 +99,11 @@ const Arithmetic = { * @returns {number} */ _multiply: function(data) { - let total = 0; - if (data.length > 1) { - total = data[0]; - for (let i = 1; i < data.length; i++) { - total *= data[i]; - } + if (data.length > 0) { + return data.reduce((acc, curr) => acc * curr); } else { - total = null; + return null; } - return total; }, /** @@ -116,16 +114,11 @@ const Arithmetic = { * @returns {number} */ _divide: function(data) { - let total = 0; - if (data.length > 1) { - total = data[0]; - for (let i = 1; i < data.length; i++) { - total /= data[i]; - } + if (data.length > 0) { + return data.reduce((acc, curr) => acc / curr); } else { - total = null; + return null; } - return total; }, /** @@ -136,27 +129,82 @@ const Arithmetic = { * @returns {number} */ _mean: function(data) { - let total = 0; - if (data.length > 1) { - total = Arithmetic._sum(data) / data.length; + if (data.length > 0) { + return Arithmetic._sum(data) / data.length; } else { - total = null; + return null; + } + }, + + /** + * Finds the median of a number array and returns the value. + * + * @private + * @param {number[]} data + * @returns {number} + */ + _median: function (data) { + if ((data.length % 2) === 0) { + let first, second; + data.sort(function(a, b){ + return a - b; + }); + first = data[Math.floor(data.length / 2)]; + second = data[Math.floor(data.length / 2) - 1]; + return Arithmetic._mean([first, second]); + } else { + return data[Math.floor(data.length / 2)]; + } + }, + + /** + * Finds the standard deviation of a number array and returns the value. + * + * @private + * @param {number[]} data + * @returns {number} + */ + _stdDev: function (data) { + if (data.length > 0) { + let avg = Arithmetic._mean(data); + let devSum = 0; + for (let i = 0; i < data.length; i++) { + devSum += (data[i] - avg) ** 2; + } + return Math.sqrt(devSum / data.length); + } else { + return null; } - return total; }, /** * A mapping of operation names to their function. + * * @constant */ opMap: { - "Sum": function(numArray) { return Arithmetic._sum(numArray); }, - "Sub": function(numArray) { return Arithmetic._sub(numArray); }, - "Multiply": function(numArray) { return Arithmetic._multiply(numArray); }, - "Divide": function(numArray) { return Arithmetic._divide(numArray); }, - "Mean": function(numArray) { return Arithmetic._mean(numArray); }, + "Sum": function(numArray) { + return Arithmetic._sum(numArray); + }, + "Sub": function(numArray) { + return Arithmetic._sub(numArray); + }, + "Multiply": function(numArray) { + return Arithmetic._multiply(numArray); + }, + "Divide": function(numArray) { + return Arithmetic._divide(numArray); + }, + "Mean": function(numArray) { + return Arithmetic._mean(numArray); + }, + "Median": function(numArray) { + return Arithmetic._median(numArray); + }, + "Standard Deviation": function (numArray) { + return Arithmetic._stdDev(numArray); + }, }, - }; export default Arithmetic; From 2b47631f4d9c1174ca841005f4cc04c12df7225c Mon Sep 17 00:00:00 2001 From: bwhitn Date: Sun, 17 Dec 2017 22:15:13 -0500 Subject: [PATCH 05/13] minor fix --- src/core/operations/Arithmetic.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/operations/Arithmetic.js b/src/core/operations/Arithmetic.js index ffcb6c86..1151c28f 100644 --- a/src/core/operations/Arithmetic.js +++ b/src/core/operations/Arithmetic.js @@ -57,7 +57,7 @@ const Arithmetic = { if (num === null) { return ""; } - return num; + return num.toString(); }, From b9b4147c2fdfab8ed2bf12d9720c765be9cdcc8e Mon Sep 17 00:00:00 2001 From: bwhitn Date: Sun, 17 Dec 2017 15:19:10 -0500 Subject: [PATCH 06/13] start of math operations --- src/core/config/OperationConfig.js | 19 +++++ src/core/operations/Arithmetic.js | 130 +++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 src/core/operations/Arithmetic.js diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js index 43072558..ff609ba2 100755 --- a/src/core/config/OperationConfig.js +++ b/src/core/config/OperationConfig.js @@ -1,3 +1,4 @@ +import Arithmetic from "../operations/Arithmetic.js"; import Base from "../operations/Base.js"; import Base58 from "../operations/Base58.js"; import Base64 from "../operations/Base64.js"; @@ -657,6 +658,24 @@ const OperationConfig = { } ] }, + "Arithmetic": { + module: "Default", + description: "Conducts mathamatical operations on a list of numbers", + inputType: "string" + outputType: "string" + args: [ + { + name: "Delimiter", + type: "option", + value: Arithmetic.DELIM_OPTIONS + }, + { + name: "Operation" + type: "option", + value: Arithmetic.OPERATIONS + } + ] + }, "From Hexdump": { module: "Default", description: "Attempts to convert a hexdump back into raw data. This operation supports many different hexdump variations, but probably not all. Make sure you verify that the data it gives you is correct before continuing analysis.", diff --git a/src/core/operations/Arithmetic.js b/src/core/operations/Arithmetic.js new file mode 100644 index 00000000..8a840a29 --- /dev/null +++ b/src/core/operations/Arithmetic.js @@ -0,0 +1,130 @@ +import Utils from "../Utils.js"; + +/** + * Math operations on numbers. + * + * @author bwhitn [brian.m.whitney@outlook.com] + * @copyright Crown Copyright 2016 + * @license Apache-2.0 + * + * @namespace + */ +const Arithmetic = { + + /** + * @constant + * @default + */ + DELIM_OPTIONS: ["Space", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF"], + + /** + * @constant + * @default + */ + OPERATIONS: ["Sum", "Sub", "Multiply", "Divide", "Mean", "Median", "Mode"], + + /** + * A mapping of operation names to their function. + * @constant + */ + opMap: { + "Sub": _sub, + "Sum": _sum, + "Multiply": _multiply, + "Divide": _divide, + "Mean": _mean, + "Median": _median, + "Mode": _mode, + }, + + /** + * + * + * @param {string} input + * @param {Object[]} args + * @returns {string} + */ + runOp: function(input, args) { + const delim = Utils.charRep[args[0] || "Space"]; + let splitNumbers = input.split(delim), + numbers = [], + num, + retVal; + for (i = 0; i < splitNumbers.length; i++) { + if splitNumbers[i].indexOf(".") { + num = parseFloat(splitNumbers[i].trim()); + } else { + num = parseInt(splitNumbers[i].trim()); + } + if (num !== "NaN") { + numbers.append(num); + } + } + num = Arithmetic.opMap[args[1] || "Sum"](numbers); + if (num !== null) { + return "The values " + args[1] + "equal: " + num; + } + throw "Error with Arithmetic Operation: " + args[1]; + }, + + + _sum: function(data) { + let total = 0; + for (i = 0; i < data.length; i++) { + total += data[i]; + } + return total; + }, + + _sub: function(data) { + let total = 0; + if (data.length > 1) { + total = data[0]; + for (i = 1; i < data.length; i++) { + total -= data[i]; + } + } else { + total = null; + } + return total; + }, + + _multiply: function(data) { + let total = 0; + if (data.length > 1) { + total = data[0]; + for (i = 1; i < data.length; i++) { + total *= data[i]; + } + } else { + total = null; + } + return total; + }, + + _divide: function(data) { + let total = 0; + if (data.length > 1) { + total = data[0]; + for (i = 1; i < data.length; i++) { + total /= data[i] + } + } else { + total = null; + } + return total; + }, + + _mean: function(data) { + let total = 0; + if (data.length > 1) { + total = Arithmetic._sum(data) / data.length; + } else { + total = null; + } + return total; + }, + +}; + +export default Arithmetic; From 5368040e83279a7032e4f3d470e62b0db17e11d6 Mon Sep 17 00:00:00 2001 From: bwhitn Date: Sun, 17 Dec 2017 15:20:58 -0500 Subject: [PATCH 07/13] Added additional arithmetic source --- src/core/config/Categories.js | 1 + src/core/config/OperationConfig.js | 6 +-- src/core/config/modules/Default.js | 5 ++ src/core/operations/Arithmetic.js | 80 +++++++++++++++++++++--------- 4 files changed, 65 insertions(+), 27 deletions(-) diff --git a/src/core/config/Categories.js b/src/core/config/Categories.js index 3bc672b7..2109ff15 100755 --- a/src/core/config/Categories.js +++ b/src/core/config/Categories.js @@ -159,6 +159,7 @@ const Categories = [ { name: "Utils", ops: [ + "Arithmetic", "Diff", "Remove whitespace", "Remove null bytes", diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js index ff609ba2..9f41f2f8 100755 --- a/src/core/config/OperationConfig.js +++ b/src/core/config/OperationConfig.js @@ -661,8 +661,8 @@ const OperationConfig = { "Arithmetic": { module: "Default", description: "Conducts mathamatical operations on a list of numbers", - inputType: "string" - outputType: "string" + inputType: "string", + outputType: "string", args: [ { name: "Delimiter", @@ -670,7 +670,7 @@ const OperationConfig = { value: Arithmetic.DELIM_OPTIONS }, { - name: "Operation" + name: "Operation", type: "option", value: Arithmetic.OPERATIONS } diff --git a/src/core/config/modules/Default.js b/src/core/config/modules/Default.js index dec015a5..5068254e 100644 --- a/src/core/config/modules/Default.js +++ b/src/core/config/modules/Default.js @@ -1,4 +1,5 @@ import FlowControl from "../../FlowControl.js"; +import Arithmetic from "../../operations/Arithmetic.js"; import Base from "../../operations/Base.js"; import Base58 from "../../operations/Base58.js"; import Base64 from "../../operations/Base64.js"; @@ -155,7 +156,11 @@ OpModules.Default = { "Conditional Jump": FlowControl.runCondJump, "Return": FlowControl.runReturn, "Comment": FlowControl.runComment, +<<<<<<< HEAD "PHP Deserialize": PHP.runDeserialize, +======= + "Arithmetic": Arithmetic.runOp, +>>>>>>> Added additional arithmetic source /* diff --git a/src/core/operations/Arithmetic.js b/src/core/operations/Arithmetic.js index 8a840a29..ef6643e4 100644 --- a/src/core/operations/Arithmetic.js +++ b/src/core/operations/Arithmetic.js @@ -23,20 +23,6 @@ const Arithmetic = { */ OPERATIONS: ["Sum", "Sub", "Multiply", "Divide", "Mean", "Median", "Mode"], - /** - * A mapping of operation names to their function. - * @constant - */ - opMap: { - "Sub": _sub, - "Sum": _sum, - "Multiply": _multiply, - "Divide": _divide, - "Mean": _mean, - "Median": _median, - "Mode": _mode, - }, - /** * * @@ -48,13 +34,12 @@ const Arithmetic = { const delim = Utils.charRep[args[0] || "Space"]; let splitNumbers = input.split(delim), numbers = [], - num, - retVal; - for (i = 0; i < splitNumbers.length; i++) { - if splitNumbers[i].indexOf(".") { + num; + for (let i = 0; i < splitNumbers.length; i++) { + if (splitNumbers[i].indexOf(".") >= 0) { num = parseFloat(splitNumbers[i].trim()); } else { - num = parseInt(splitNumbers[i].trim()); + num = parseInt(splitNumbers[i].trim(), 10); } if (num !== "NaN") { numbers.append(num); @@ -68,19 +53,33 @@ const Arithmetic = { }, + /** + * Adds an array of numbers and returns the value. + * + * @private + * @param {number[]} data + * @returns {number} + */ _sum: function(data) { let total = 0; - for (i = 0; i < data.length; i++) { + for (let i = 0; i < data.length; i++) { total += data[i]; } return total; }, + /** + * Subtracts an array of numbers and returns the value. + * + * @private + * @param {number[]} data + * @returns {number} + */ _sub: function(data) { let total = 0; if (data.length > 1) { total = data[0]; - for (i = 1; i < data.length; i++) { + for (let i = 1; i < data.length; i++) { total -= data[i]; } } else { @@ -89,11 +88,18 @@ const Arithmetic = { return total; }, + /** + * Multiplies an array of numbers and returns the value. + * + * @private + * @param {number[]} data + * @returns {number} + */ _multiply: function(data) { let total = 0; if (data.length > 1) { total = data[0]; - for (i = 1; i < data.length; i++) { + for (let i = 1; i < data.length; i++) { total *= data[i]; } } else { @@ -102,12 +108,19 @@ const Arithmetic = { return total; }, + /** + * Divides an array of numbers and returns the value. + * + * @private + * @param {number[]} data + * @returns {number} + */ _divide: function(data) { let total = 0; if (data.length > 1) { total = data[0]; - for (i = 1; i < data.length; i++) { - total /= data[i] + for (let i = 1; i < data.length; i++) { + total /= data[i]; } } else { total = null; @@ -115,6 +128,13 @@ const Arithmetic = { return total; }, + /** + * Finds the mean of a number array and returns the value. + * + * @private + * @param {number[]} data + * @returns {number} + */ _mean: function(data) { let total = 0; if (data.length > 1) { @@ -125,6 +145,18 @@ const Arithmetic = { return total; }, + /** + * A mapping of operation names to their function. + * @constant + */ + opMap: { + "Sub": Arithmetic._sum, + "Sum": Arithmetic._sub, + "Multiply": Arithmetic._multiply, + "Divide": Arithmetic._divide, + "Mean": Arithmetic._mean, + }, + }; export default Arithmetic; From ef0d3b73b0db55f343f800bb17eca350866e8a51 Mon Sep 17 00:00:00 2001 From: bwhitn Date: Sun, 17 Dec 2017 15:29:31 -0500 Subject: [PATCH 08/13] changed op array --- src/core/operations/Arithmetic.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/operations/Arithmetic.js b/src/core/operations/Arithmetic.js index ef6643e4..1278ac3b 100644 --- a/src/core/operations/Arithmetic.js +++ b/src/core/operations/Arithmetic.js @@ -150,11 +150,11 @@ const Arithmetic = { * @constant */ opMap: { - "Sub": Arithmetic._sum, - "Sum": Arithmetic._sub, - "Multiply": Arithmetic._multiply, - "Divide": Arithmetic._divide, - "Mean": Arithmetic._mean, + "Sum": function(numArray) { return Arithmetic._sum(numArray); }, + "Sub": function(numArray) { return Arithmetic._sub(numArray); }, + "Multiply": function(numArray) { return Arithmetic._multiply(numArray); }, + "Divide": function(numArray) { return Arithmetic._divide(numArray); }, + "Mean": function(numArray) { return Arithmetic._mean(numArray); }, }, }; From f9ddee7d806b5fcc091ad6e86a9e04581297d2b4 Mon Sep 17 00:00:00 2001 From: bwhitn Date: Sun, 17 Dec 2017 21:57:09 -0500 Subject: [PATCH 09/13] Inital commit for pull --- src/core/operations/Arithmetic.js | 140 ++++++++++++++++++++---------- 1 file changed, 94 insertions(+), 46 deletions(-) diff --git a/src/core/operations/Arithmetic.js b/src/core/operations/Arithmetic.js index 1278ac3b..ffcb6c86 100644 --- a/src/core/operations/Arithmetic.js +++ b/src/core/operations/Arithmetic.js @@ -21,7 +21,15 @@ const Arithmetic = { * @constant * @default */ - OPERATIONS: ["Sum", "Sub", "Multiply", "Divide", "Mean", "Median", "Mode"], + OPERATIONS: [ + "Sum", + "Sub", + "Multiply", + "Divide", + "Mean", + "Median", + "Standard Deviation" + ], /** * @@ -39,17 +47,17 @@ const Arithmetic = { if (splitNumbers[i].indexOf(".") >= 0) { num = parseFloat(splitNumbers[i].trim()); } else { - num = parseInt(splitNumbers[i].trim(), 10); + num = parseInt(splitNumbers[i].trim(), 0); } - if (num !== "NaN") { - numbers.append(num); + if (!isNaN(num)) { + numbers.push(num); } } num = Arithmetic.opMap[args[1] || "Sum"](numbers); - if (num !== null) { - return "The values " + args[1] + "equal: " + num; + if (num === null) { + return ""; } - throw "Error with Arithmetic Operation: " + args[1]; + return num; }, @@ -61,11 +69,11 @@ const Arithmetic = { * @returns {number} */ _sum: function(data) { - let total = 0; - for (let i = 0; i < data.length; i++) { - total += data[i]; + if (data.length > 0) { + return data.reduce((acc, curr) => acc + curr); + } else { + return null; } - return total; }, /** @@ -76,16 +84,11 @@ const Arithmetic = { * @returns {number} */ _sub: function(data) { - let total = 0; - if (data.length > 1) { - total = data[0]; - for (let i = 1; i < data.length; i++) { - total -= data[i]; - } + if (data.length > 0) { + return data.reduce((acc, curr) => acc - curr); } else { - total = null; + return null; } - return total; }, /** @@ -96,16 +99,11 @@ const Arithmetic = { * @returns {number} */ _multiply: function(data) { - let total = 0; - if (data.length > 1) { - total = data[0]; - for (let i = 1; i < data.length; i++) { - total *= data[i]; - } + if (data.length > 0) { + return data.reduce((acc, curr) => acc * curr); } else { - total = null; + return null; } - return total; }, /** @@ -116,16 +114,11 @@ const Arithmetic = { * @returns {number} */ _divide: function(data) { - let total = 0; - if (data.length > 1) { - total = data[0]; - for (let i = 1; i < data.length; i++) { - total /= data[i]; - } + if (data.length > 0) { + return data.reduce((acc, curr) => acc / curr); } else { - total = null; + return null; } - return total; }, /** @@ -136,27 +129,82 @@ const Arithmetic = { * @returns {number} */ _mean: function(data) { - let total = 0; - if (data.length > 1) { - total = Arithmetic._sum(data) / data.length; + if (data.length > 0) { + return Arithmetic._sum(data) / data.length; } else { - total = null; + return null; + } + }, + + /** + * Finds the median of a number array and returns the value. + * + * @private + * @param {number[]} data + * @returns {number} + */ + _median: function (data) { + if ((data.length % 2) === 0) { + let first, second; + data.sort(function(a, b){ + return a - b; + }); + first = data[Math.floor(data.length / 2)]; + second = data[Math.floor(data.length / 2) - 1]; + return Arithmetic._mean([first, second]); + } else { + return data[Math.floor(data.length / 2)]; + } + }, + + /** + * Finds the standard deviation of a number array and returns the value. + * + * @private + * @param {number[]} data + * @returns {number} + */ + _stdDev: function (data) { + if (data.length > 0) { + let avg = Arithmetic._mean(data); + let devSum = 0; + for (let i = 0; i < data.length; i++) { + devSum += (data[i] - avg) ** 2; + } + return Math.sqrt(devSum / data.length); + } else { + return null; } - return total; }, /** * A mapping of operation names to their function. + * * @constant */ opMap: { - "Sum": function(numArray) { return Arithmetic._sum(numArray); }, - "Sub": function(numArray) { return Arithmetic._sub(numArray); }, - "Multiply": function(numArray) { return Arithmetic._multiply(numArray); }, - "Divide": function(numArray) { return Arithmetic._divide(numArray); }, - "Mean": function(numArray) { return Arithmetic._mean(numArray); }, + "Sum": function(numArray) { + return Arithmetic._sum(numArray); + }, + "Sub": function(numArray) { + return Arithmetic._sub(numArray); + }, + "Multiply": function(numArray) { + return Arithmetic._multiply(numArray); + }, + "Divide": function(numArray) { + return Arithmetic._divide(numArray); + }, + "Mean": function(numArray) { + return Arithmetic._mean(numArray); + }, + "Median": function(numArray) { + return Arithmetic._median(numArray); + }, + "Standard Deviation": function (numArray) { + return Arithmetic._stdDev(numArray); + }, }, - }; export default Arithmetic; From a9e60d345072b4065861faf6e5b8f4a4badca64f Mon Sep 17 00:00:00 2001 From: bwhitn Date: Sun, 17 Dec 2017 22:15:13 -0500 Subject: [PATCH 10/13] minor fix --- src/core/operations/Arithmetic.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/operations/Arithmetic.js b/src/core/operations/Arithmetic.js index ffcb6c86..1151c28f 100644 --- a/src/core/operations/Arithmetic.js +++ b/src/core/operations/Arithmetic.js @@ -57,7 +57,7 @@ const Arithmetic = { if (num === null) { return ""; } - return num; + return num.toString(); }, From 81082ea001e4db9948c2e4089c695a389b72d416 Mon Sep 17 00:00:00 2001 From: bwhitn Date: Sun, 17 Dec 2017 23:45:15 -0500 Subject: [PATCH 11/13] I really need to learn git --- src/core/config/modules/Default.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/core/config/modules/Default.js b/src/core/config/modules/Default.js index 83545221..6f672ce2 100644 --- a/src/core/config/modules/Default.js +++ b/src/core/config/modules/Default.js @@ -156,15 +156,8 @@ OpModules.Default = { "Conditional Jump": FlowControl.runCondJump, "Return": FlowControl.runReturn, "Comment": FlowControl.runComment, -<<<<<<< HEAD -<<<<<<< HEAD "PHP Deserialize": PHP.runDeserialize, -======= "Arithmetic": Arithmetic.runOp, ->>>>>>> Added additional arithmetic source -======= - "Arithmetic": Arithmetic.runOp, ->>>>>>> 2b47631f4d9c1174ca841005f4cc04c12df7225c /* From 0fea84ed7a63492f6cea6de19b8a5452ac17db18 Mon Sep 17 00:00:00 2001 From: bwhitn Date: Thu, 21 Dec 2017 00:19:47 -0500 Subject: [PATCH 12/13] WIP --- src/core/config/Categories.js | 9 ++- src/core/operations/Arithmetic.js | 100 +++++++++++++++--------------- 2 files changed, 57 insertions(+), 52 deletions(-) diff --git a/src/core/config/Categories.js b/src/core/config/Categories.js index 2109ff15..0ab32eb1 100755 --- a/src/core/config/Categories.js +++ b/src/core/config/Categories.js @@ -113,7 +113,7 @@ const Categories = [ ] }, { - name: "Logical operations", + name: "Arithmetic / Logic", ops: [ "XOR", "XOR Brute Force", @@ -127,6 +127,13 @@ const Categories = [ "Rotate left", "Rotate right", "ROT13", + "Sum", + "Sub", + "Multiply", + "Divide", + "Mean", + "Median", + "Standard Deviation", ] }, { diff --git a/src/core/operations/Arithmetic.js b/src/core/operations/Arithmetic.js index 1151c28f..6472a7fc 100644 --- a/src/core/operations/Arithmetic.js +++ b/src/core/operations/Arithmetic.js @@ -31,15 +31,58 @@ const Arithmetic = { "Standard Deviation" ], + /** * * * @param {string} input * @param {Object[]} args - * @returns {string} + * @returns {number} */ - runOp: function(input, args) { - const delim = Utils.charRep[args[0] || "Space"]; + computeSum: function(input, args) { + const val = Arithmetic._sum(Arithmetic._createNumArray(input, args[0])); + return typeof(val) === 'number' ? val.toString() : ""; + }, + + + computeSub: function(input, args) { + let val = Arithmetic._sub(Arithmetic._createNumArray(input, args[0])); + return typeof(val) === 'number' ? val.toString() : ""; + }, + + + computeMulti: function(input, args) { + let val = Arithmetic._multi(Arithmetic._createNumArray(input, args[0])); + return typeof(val) === 'number' ? val.toString() : ""; + }, + + + computeDiv: function(input, args) { + let val = Arithmetic._div(Arithmetic._createNumArray(input, args[0])); + return typeof(val) === 'number' ? val.toString() : ""; + }, + + + computeMean: function(input, args) { + let val = Arithmetic._mean(Arithmetic._createNumArray(input, args[0])); + return typeof(val) === 'number' ? val.toString() : ""; + }, + + + computeMedian: function(input, args) { + let val = Arithmetic._median(Arithmetic._createNumArray(input, args[0])); + return typeof(val) === 'number' ? val.toString() : ""; + }, + + + computeStdDev: function(input, args) { + let val = Arithmetic._stdDev(Arithmetic._createNumArray(input, args[0])); + return typeof(val) === 'number' ? val.toString() : ""; + }, + + + _createNumArray: function(input, delim) { + const delim = Utils.charRep[delim || "Space"]; let splitNumbers = input.split(delim), numbers = [], num; @@ -53,11 +96,7 @@ const Arithmetic = { numbers.push(num); } } - num = Arithmetic.opMap[args[1] || "Sum"](numbers); - if (num === null) { - return ""; - } - return num.toString(); + return numbers; }, @@ -71,8 +110,6 @@ const Arithmetic = { _sum: function(data) { if (data.length > 0) { return data.reduce((acc, curr) => acc + curr); - } else { - return null; } }, @@ -86,8 +123,6 @@ const Arithmetic = { _sub: function(data) { if (data.length > 0) { return data.reduce((acc, curr) => acc - curr); - } else { - return null; } }, @@ -98,11 +133,9 @@ const Arithmetic = { * @param {number[]} data * @returns {number} */ - _multiply: function(data) { + _multi: function(data) { if (data.length > 0) { return data.reduce((acc, curr) => acc * curr); - } else { - return null; } }, @@ -113,11 +146,9 @@ const Arithmetic = { * @param {number[]} data * @returns {number} */ - _divide: function(data) { + _div: function(data) { if (data.length > 0) { return data.reduce((acc, curr) => acc / curr); - } else { - return null; } }, @@ -131,8 +162,6 @@ const Arithmetic = { _mean: function(data) { if (data.length > 0) { return Arithmetic._sum(data) / data.length; - } else { - return null; } }, @@ -172,39 +201,8 @@ const Arithmetic = { devSum += (data[i] - avg) ** 2; } return Math.sqrt(devSum / data.length); - } else { - return null; } }, - - /** - * A mapping of operation names to their function. - * - * @constant - */ - opMap: { - "Sum": function(numArray) { - return Arithmetic._sum(numArray); - }, - "Sub": function(numArray) { - return Arithmetic._sub(numArray); - }, - "Multiply": function(numArray) { - return Arithmetic._multiply(numArray); - }, - "Divide": function(numArray) { - return Arithmetic._divide(numArray); - }, - "Mean": function(numArray) { - return Arithmetic._mean(numArray); - }, - "Median": function(numArray) { - return Arithmetic._median(numArray); - }, - "Standard Deviation": function (numArray) { - return Arithmetic._stdDev(numArray); - }, - }, }; export default Arithmetic; From fc7d2c2f5229c5c5b7c1eee7fbf7dc29a0a160fd Mon Sep 17 00:00:00 2001 From: bwhitn Date: Thu, 21 Dec 2017 05:58:31 -0800 Subject: [PATCH 13/13] separated all functions and updated comments/descriptions --- src/core/config/Categories.js | 3 +- src/core/config/OperationConfig.js | 83 +++++++++++++++++++++-- src/core/config/modules/Default.js | 8 ++- src/core/operations/Arithmetic.js | 103 +++++++++++++++++++---------- 4 files changed, 155 insertions(+), 42 deletions(-) diff --git a/src/core/config/Categories.js b/src/core/config/Categories.js index 0ab32eb1..8fc8ac02 100755 --- a/src/core/config/Categories.js +++ b/src/core/config/Categories.js @@ -128,7 +128,7 @@ const Categories = [ "Rotate right", "ROT13", "Sum", - "Sub", + "Subtract", "Multiply", "Divide", "Mean", @@ -166,7 +166,6 @@ const Categories = [ { name: "Utils", ops: [ - "Arithmetic", "Diff", "Remove whitespace", "Remove null bytes", diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js index 9f41f2f8..93c82adf 100755 --- a/src/core/config/OperationConfig.js +++ b/src/core/config/OperationConfig.js @@ -658,9 +658,9 @@ const OperationConfig = { } ] }, - "Arithmetic": { + "Sum": { module: "Default", - description: "Conducts mathamatical operations on a list of numbers", + description: "Sums a list of numbers. If an item in the string is not a number it is excluded from the list.

e.g. 0x0a 8 .5 becomes 18.5", inputType: "string", outputType: "string", args: [ @@ -668,11 +668,84 @@ const OperationConfig = { name: "Delimiter", type: "option", value: Arithmetic.DELIM_OPTIONS - }, + } + ] + }, + "Subtract": { + module: "Default", + description: "Subtracts a list of numbers. If an item in the string is not a number it is excluded from the list.

e.g. 0x0a 8 .5 becomes 1.5", + inputType: "string", + outputType: "string", + args: [ { - name: "Operation", + name: "Delimiter", type: "option", - value: Arithmetic.OPERATIONS + value: Arithmetic.DELIM_OPTIONS + } + ] + }, + "Multiply": { + module: "Default", + description: "Multiplies a list of numbers. If an item in the string is not a number it is excluded from the list.

e.g. 0x0a 8 .5 becomes 40", + inputType: "string", + outputType: "string", + args: [ + { + name: "Delimiter", + type: "option", + value: Arithmetic.DELIM_OPTIONS + } + ] + }, + "Divide": { + module: "Default", + description: "Divides a list of numbers. If an item in the string is not a number it is excluded from the list.

e.g. 0x0a 8 .5 becomes 2.5", + inputType: "string", + outputType: "string", + args: [ + { + name: "Delimiter", + type: "option", + value: Arithmetic.DELIM_OPTIONS + } + ] + }, + "Mean": { + module: "Default", + description: "Computes the mean (average) of a number list. If an item in the string is not a number it is excluded from the list.

e.g. 0x0a 8 .5 .5 becomes 4.75", + inputType: "string", + outputType: "string", + args: [ + { + name: "Delimiter", + type: "option", + value: Arithmetic.DELIM_OPTIONS + } + ] + }, + "Median": { + module: "Default", + description: "Computes the median of a number list. If an item in the string is not a number it is excluded from the list.

e.g. 0x0a 8 1 .5 becomes 4.5", + inputType: "string", + outputType: "string", + args: [ + { + name: "Delimiter", + type: "option", + value: Arithmetic.DELIM_OPTIONS + } + ] + }, + "Standard Deviation": { + module: "Default", + description: "Computes the standard deviation of a number list. If an item in the string is not a number it is excluded from the list.

e.g. 0x0a 8 .5 becomes 4.089281382128433", + inputType: "string", + outputType: "string", + args: [ + { + name: "Delimiter", + type: "option", + value: Arithmetic.DELIM_OPTIONS } ] }, diff --git a/src/core/config/modules/Default.js b/src/core/config/modules/Default.js index 6f672ce2..9a373e12 100644 --- a/src/core/config/modules/Default.js +++ b/src/core/config/modules/Default.js @@ -157,7 +157,13 @@ OpModules.Default = { "Return": FlowControl.runReturn, "Comment": FlowControl.runComment, "PHP Deserialize": PHP.runDeserialize, - "Arithmetic": Arithmetic.runOp, + "Sum": Arithmetic.runSum, + "Subtract": Arithmetic.runSub, + "Multiply": Arithmetic.runMulti, + "Divide": Arithmetic.runDiv, + "Mean": Arithmetic.runMean, + "Median": Arithmetic.runMedian, + "Standard Deviation": Arithmetic.runStdDev, /* diff --git a/src/core/operations/Arithmetic.js b/src/core/operations/Arithmetic.js index 6472a7fc..9b07f8ad 100644 --- a/src/core/operations/Arithmetic.js +++ b/src/core/operations/Arithmetic.js @@ -17,72 +17,107 @@ const Arithmetic = { */ DELIM_OPTIONS: ["Space", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF"], - /** - * @constant - * @default - */ - OPERATIONS: [ - "Sum", - "Sub", - "Multiply", - "Divide", - "Mean", - "Median", - "Standard Deviation" - ], - /** - * + * Splits a string based on a delimiter and calculates the sum of numbers. * * @param {string} input * @param {Object[]} args - * @returns {number} + * @returns {string} */ - computeSum: function(input, args) { + runSum: function(input, args) { const val = Arithmetic._sum(Arithmetic._createNumArray(input, args[0])); - return typeof(val) === 'number' ? val.toString() : ""; + return typeof(val) === "number" ? val.toString() : ""; }, - computeSub: function(input, args) { + /** + * Splits a string based on a delimiter and subtracts all the numbers. + * + * @param {string} input + * @param {Object[]} args + * @returns {string} + */ + runSub: function(input, args) { let val = Arithmetic._sub(Arithmetic._createNumArray(input, args[0])); - return typeof(val) === 'number' ? val.toString() : ""; + return typeof(val) === "number" ? val.toString() : ""; }, - computeMulti: function(input, args) { + /** + * Splits a string based on a delimiter and multiplies the numbers. + * + * @param {string} input + * @param {Object[]} args + * @returns {string} + */ + runMulti: function(input, args) { let val = Arithmetic._multi(Arithmetic._createNumArray(input, args[0])); - return typeof(val) === 'number' ? val.toString() : ""; + return typeof(val) === "number" ? val.toString() : ""; }, - computeDiv: function(input, args) { + /** + * Splits a string based on a delimiter and divides the numbers. + * + * @param {string} input + * @param {Object[]} args + * @returns {string} + */ + runDiv: function(input, args) { let val = Arithmetic._div(Arithmetic._createNumArray(input, args[0])); - return typeof(val) === 'number' ? val.toString() : ""; + return typeof(val) === "number" ? val.toString() : ""; }, - computeMean: function(input, args) { + /** + * Splits a string based on a delimiter and computes the mean (average). + * + * @param {string} input + * @param {Object[]} args + * @returns {string} + */ + runMean: function(input, args) { let val = Arithmetic._mean(Arithmetic._createNumArray(input, args[0])); - return typeof(val) === 'number' ? val.toString() : ""; + return typeof(val) === "number" ? val.toString() : ""; }, - computeMedian: function(input, args) { + /** + * Splits a string based on a delimiter and finds the median. + * + * @param {string} input + * @param {Object[]} args + * @returns {string} + */ + runMedian: function(input, args) { let val = Arithmetic._median(Arithmetic._createNumArray(input, args[0])); - return typeof(val) === 'number' ? val.toString() : ""; + return typeof(val) === "number" ? val.toString() : ""; }, - computeStdDev: function(input, args) { + /** + * splits a string based on a delimiter and computes the standard deviation. + * + * @param {string} input + * @param {Object[]} args + * @returns {string} + */ + runStdDev: function(input, args) { let val = Arithmetic._stdDev(Arithmetic._createNumArray(input, args[0])); - return typeof(val) === 'number' ? val.toString() : ""; + return typeof(val) === "number" ? val.toString() : ""; }, + /** + * Converts a string array to a number array. + * + * @param {string[]} input + * @param {string} delim + * @returns {number[]} + */ _createNumArray: function(input, delim) { - const delim = Utils.charRep[delim || "Space"]; + delim = Utils.charRep[delim || "Space"]; let splitNumbers = input.split(delim), numbers = [], num; @@ -153,7 +188,7 @@ const Arithmetic = { }, /** - * Finds the mean of a number array and returns the value. + * Computes mean of a number array and returns the value. * * @private * @param {number[]} data @@ -166,7 +201,7 @@ const Arithmetic = { }, /** - * Finds the median of a number array and returns the value. + * Computes median of a number array and returns the value. * * @private * @param {number[]} data @@ -187,7 +222,7 @@ const Arithmetic = { }, /** - * Finds the standard deviation of a number array and returns the value. + * Computes standard deviation of a number array and returns the value. * * @private * @param {number[]} data