Small tweaks to the arithmetic ops
parent
c1fb6d9776
commit
98f59ace3a
|
@ -122,11 +122,6 @@ const Categories = [
|
||||||
"AND",
|
"AND",
|
||||||
"ADD",
|
"ADD",
|
||||||
"SUB",
|
"SUB",
|
||||||
"Bit shift left",
|
|
||||||
"Bit shift right",
|
|
||||||
"Rotate left",
|
|
||||||
"Rotate right",
|
|
||||||
"ROT13",
|
|
||||||
"Sum",
|
"Sum",
|
||||||
"Subtract",
|
"Subtract",
|
||||||
"Multiply",
|
"Multiply",
|
||||||
|
@ -134,6 +129,11 @@ const Categories = [
|
||||||
"Mean",
|
"Mean",
|
||||||
"Median",
|
"Median",
|
||||||
"Standard Deviation",
|
"Standard Deviation",
|
||||||
|
"Bit shift left",
|
||||||
|
"Bit shift right",
|
||||||
|
"Rotate left",
|
||||||
|
"Rotate right",
|
||||||
|
"ROT13",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -520,6 +520,97 @@ const OperationConfig = {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"Sum": {
|
||||||
|
module: "Default",
|
||||||
|
description: "Adds together a list of numbers. If an item in the string is not a number it is excluded from the list.<br><br>e.g. <code>0x0a 8 .5</code> becomes <code>18.5</code>",
|
||||||
|
inputType: "string",
|
||||||
|
outputType: "number",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
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.<br><br>e.g. <code>0x0a 8 .5</code> becomes <code>1.5</code>",
|
||||||
|
inputType: "string",
|
||||||
|
outputType: "number",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
name: "Delimiter",
|
||||||
|
type: "option",
|
||||||
|
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.<br><br>e.g. <code>0x0a 8 .5</code> becomes <code>40</code>",
|
||||||
|
inputType: "string",
|
||||||
|
outputType: "number",
|
||||||
|
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.<br><br>e.g. <code>0x0a 8 .5</code> becomes <code>2.5</code>",
|
||||||
|
inputType: "string",
|
||||||
|
outputType: "number",
|
||||||
|
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.<br><br>e.g. <code>0x0a 8 .5 .5</code> becomes <code>4.75</code>",
|
||||||
|
inputType: "string",
|
||||||
|
outputType: "number",
|
||||||
|
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.<br><br>e.g. <code>0x0a 8 1 .5</code> becomes <code>4.5</code>",
|
||||||
|
inputType: "string",
|
||||||
|
outputType: "number",
|
||||||
|
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.<br><br>e.g. <code>0x0a 8 .5</code> becomes <code>4.089281382128433</code>",
|
||||||
|
inputType: "string",
|
||||||
|
outputType: "number",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
name: "Delimiter",
|
||||||
|
type: "option",
|
||||||
|
value: Arithmetic.DELIM_OPTIONS
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"From Hex": {
|
"From Hex": {
|
||||||
module: "Default",
|
module: "Default",
|
||||||
description: "Converts a hexadecimal byte string back into its raw value.<br><br>e.g. <code>ce 93 ce b5 ce b9 ce ac 20 cf 83 ce bf cf 85 0a</code> becomes the UTF-8 encoded string <code>Γειά σου</code>",
|
description: "Converts a hexadecimal byte string back into its raw value.<br><br>e.g. <code>ce 93 ce b5 ce b9 ce ac 20 cf 83 ce bf cf 85 0a</code> becomes the UTF-8 encoded string <code>Γειά σου</code>",
|
||||||
|
@ -677,97 +768,6 @@ const OperationConfig = {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Sum": {
|
|
||||||
module: "Default",
|
|
||||||
description: "Sums a list of numbers. If an item in the string is not a number it is excluded from the list.<br><br>e.g. <code>0x0a 8 .5</code> becomes <code>18.5</code>",
|
|
||||||
inputType: "string",
|
|
||||||
outputType: "string",
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
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.<br><br>e.g. <code>0x0a 8 .5</code> becomes <code>1.5</code>",
|
|
||||||
inputType: "string",
|
|
||||||
outputType: "string",
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
name: "Delimiter",
|
|
||||||
type: "option",
|
|
||||||
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.<br><br>e.g. <code>0x0a 8 .5</code> becomes <code>40</code>",
|
|
||||||
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.<br><br>e.g. <code>0x0a 8 .5</code> becomes <code>2.5</code>",
|
|
||||||
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.<br><br>e.g. <code>0x0a 8 .5 .5</code> becomes <code>4.75</code>",
|
|
||||||
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.<br><br>e.g. <code>0x0a 8 1 .5</code> becomes <code>4.5</code>",
|
|
||||||
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.<br><br>e.g. <code>0x0a 8 .5</code> becomes <code>4.089281382128433</code>",
|
|
||||||
inputType: "string",
|
|
||||||
outputType: "string",
|
|
||||||
args: [
|
|
||||||
{
|
|
||||||
name: "Delimiter",
|
|
||||||
type: "option",
|
|
||||||
value: Arithmetic.DELIM_OPTIONS
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"From Hexdump": {
|
"From Hexdump": {
|
||||||
module: "Default",
|
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.",
|
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.",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import Utils from "../Utils.js";
|
import Utils from "../Utils.js";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Math operations on numbers.
|
* Math operations on numbers.
|
||||||
*
|
*
|
||||||
|
@ -15,7 +16,7 @@ const Arithmetic = {
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
DELIM_OPTIONS: ["Space", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF"],
|
DELIM_OPTIONS: ["Line feed", "Space", "Comma", "Semi-colon", "Colon", "CRLF"],
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,11 +24,11 @@ const Arithmetic = {
|
||||||
*
|
*
|
||||||
* @param {string} input
|
* @param {string} input
|
||||||
* @param {Object[]} args
|
* @param {Object[]} args
|
||||||
* @returns {string}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
runSum: function(input, args) {
|
runSum: function(input, args) {
|
||||||
const val = Arithmetic._sum(Arithmetic._createNumArray(input, args[0]));
|
const val = Arithmetic._sum(Arithmetic._createNumArray(input, args[0]));
|
||||||
return typeof(val) === "number" ? val.toString() : "";
|
return typeof(val) === "number" ? val : NaN;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,11 +37,11 @@ const Arithmetic = {
|
||||||
*
|
*
|
||||||
* @param {string} input
|
* @param {string} input
|
||||||
* @param {Object[]} args
|
* @param {Object[]} args
|
||||||
* @returns {string}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
runSub: function(input, args) {
|
runSub: function(input, args) {
|
||||||
let val = Arithmetic._sub(Arithmetic._createNumArray(input, args[0]));
|
let val = Arithmetic._sub(Arithmetic._createNumArray(input, args[0]));
|
||||||
return typeof(val) === "number" ? val.toString() : "";
|
return typeof(val) === "number" ? val : NaN;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,11 +50,11 @@ const Arithmetic = {
|
||||||
*
|
*
|
||||||
* @param {string} input
|
* @param {string} input
|
||||||
* @param {Object[]} args
|
* @param {Object[]} args
|
||||||
* @returns {string}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
runMulti: function(input, args) {
|
runMulti: function(input, args) {
|
||||||
let val = Arithmetic._multi(Arithmetic._createNumArray(input, args[0]));
|
let val = Arithmetic._multi(Arithmetic._createNumArray(input, args[0]));
|
||||||
return typeof(val) === "number" ? val.toString() : "";
|
return typeof(val) === "number" ? val : NaN;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,11 +63,11 @@ const Arithmetic = {
|
||||||
*
|
*
|
||||||
* @param {string} input
|
* @param {string} input
|
||||||
* @param {Object[]} args
|
* @param {Object[]} args
|
||||||
* @returns {string}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
runDiv: function(input, args) {
|
runDiv: function(input, args) {
|
||||||
let val = Arithmetic._div(Arithmetic._createNumArray(input, args[0]));
|
let val = Arithmetic._div(Arithmetic._createNumArray(input, args[0]));
|
||||||
return typeof(val) === "number" ? val.toString() : "";
|
return typeof(val) === "number" ? val : NaN;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,11 +76,11 @@ const Arithmetic = {
|
||||||
*
|
*
|
||||||
* @param {string} input
|
* @param {string} input
|
||||||
* @param {Object[]} args
|
* @param {Object[]} args
|
||||||
* @returns {string}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
runMean: function(input, args) {
|
runMean: function(input, args) {
|
||||||
let val = Arithmetic._mean(Arithmetic._createNumArray(input, args[0]));
|
let val = Arithmetic._mean(Arithmetic._createNumArray(input, args[0]));
|
||||||
return typeof(val) === "number" ? val.toString() : "";
|
return typeof(val) === "number" ? val : NaN;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,11 +89,11 @@ const Arithmetic = {
|
||||||
*
|
*
|
||||||
* @param {string} input
|
* @param {string} input
|
||||||
* @param {Object[]} args
|
* @param {Object[]} args
|
||||||
* @returns {string}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
runMedian: function(input, args) {
|
runMedian: function(input, args) {
|
||||||
let val = Arithmetic._median(Arithmetic._createNumArray(input, args[0]));
|
let val = Arithmetic._median(Arithmetic._createNumArray(input, args[0]));
|
||||||
return typeof(val) === "number" ? val.toString() : "";
|
return typeof(val) === "number" ? val : NaN;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,17 +102,18 @@ const Arithmetic = {
|
||||||
*
|
*
|
||||||
* @param {string} input
|
* @param {string} input
|
||||||
* @param {Object[]} args
|
* @param {Object[]} args
|
||||||
* @returns {string}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
runStdDev: function(input, args) {
|
runStdDev: function(input, args) {
|
||||||
let val = Arithmetic._stdDev(Arithmetic._createNumArray(input, args[0]));
|
let val = Arithmetic._stdDev(Arithmetic._createNumArray(input, args[0]));
|
||||||
return typeof(val) === "number" ? val.toString() : "";
|
return typeof(val) === "number" ? val : NaN;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a string array to a number array.
|
* Converts a string array to a number array.
|
||||||
*
|
*
|
||||||
|
* @private
|
||||||
* @param {string[]} input
|
* @param {string[]} input
|
||||||
* @param {string} delim
|
* @param {string} delim
|
||||||
* @returns {number[]}
|
* @returns {number[]}
|
||||||
|
@ -121,6 +123,7 @@ const Arithmetic = {
|
||||||
let splitNumbers = input.split(delim),
|
let splitNumbers = input.split(delim),
|
||||||
numbers = [],
|
numbers = [],
|
||||||
num;
|
num;
|
||||||
|
|
||||||
for (let i = 0; i < splitNumbers.length; i++) {
|
for (let i = 0; i < splitNumbers.length; i++) {
|
||||||
if (splitNumbers[i].indexOf(".") >= 0) {
|
if (splitNumbers[i].indexOf(".") >= 0) {
|
||||||
num = parseFloat(splitNumbers[i].trim());
|
num = parseFloat(splitNumbers[i].trim());
|
||||||
|
@ -148,6 +151,7 @@ const Arithmetic = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subtracts an array of numbers and returns the value.
|
* Subtracts an array of numbers and returns the value.
|
||||||
*
|
*
|
||||||
|
@ -161,6 +165,7 @@ const Arithmetic = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiplies an array of numbers and returns the value.
|
* Multiplies an array of numbers and returns the value.
|
||||||
*
|
*
|
||||||
|
@ -174,6 +179,7 @@ const Arithmetic = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Divides an array of numbers and returns the value.
|
* Divides an array of numbers and returns the value.
|
||||||
*
|
*
|
||||||
|
@ -187,6 +193,7 @@ const Arithmetic = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes mean of a number array and returns the value.
|
* Computes mean of a number array and returns the value.
|
||||||
*
|
*
|
||||||
|
@ -200,6 +207,7 @@ const Arithmetic = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes median of a number array and returns the value.
|
* Computes median of a number array and returns the value.
|
||||||
*
|
*
|
||||||
|
@ -221,6 +229,7 @@ const Arithmetic = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes standard deviation of a number array and returns the value.
|
* Computes standard deviation of a number array and returns the value.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue