diff --git a/src/NetscriptWorker.js b/src/NetscriptWorker.js index 2a5c37228..3c9ad6a77 100644 --- a/src/NetscriptWorker.js +++ b/src/NetscriptWorker.js @@ -16,7 +16,7 @@ import {Settings} from "./Settings"; import {parse} from "../utils/acorn"; import {dialogBoxCreate} from "../utils/DialogBox"; -import {compareArrays} from "../utils/HelperFunctions"; +import {compareArrays} from "../utils/helpers/compareArrays"; import {arrayToString} from "../utils/helpers/arrayToString"; import {roundToTwo} from "../utils/helpers/roundToTwo"; import {isString} from "../utils/StringHelperFunctions"; diff --git a/src/Script.js b/src/Script.js index 66cff5df8..55a6abba7 100644 --- a/src/Script.js +++ b/src/Script.js @@ -36,7 +36,7 @@ import {parse, Node} from "../utils/acorn"; import {dialogBoxCreate} from "../utils/DialogBox"; import {Reviver, Generic_toJSON, Generic_fromJSON} from "../utils/JSONReviver"; -import {compareArrays} from "../utils/HelperFunctions"; +import {compareArrays} from "../utils/helpers/compareArrays"; import {createElement} from "../utils/uiHelpers/createElement"; import {formatNumber} from "../utils/StringHelperFunctions"; import {roundToTwo} from "../utils/helpers/roundToTwo"; diff --git a/utils/HelperFunctions.js b/utils/HelperFunctions.js index 0ef532441..c56cbb9d9 100644 --- a/utils/HelperFunctions.js +++ b/utils/HelperFunctions.js @@ -90,23 +90,9 @@ function clearSelector(selector) { } } -//Returns true if all elements are equal, and false otherwise -//Assumes both arguments are arrays and that there are no nested arrays -function compareArrays(a1, a2) { - if (a1.length != a2.length) { - return false; - } - - for (var i = 0; i < a1.length; ++i) { - if (a1[i] != a2[i]) {return false;} - } - return true; -} - export {sizeOfObject, clearObject, clearEventListeners, - compareArrays, clearEventListenersEl, removeElement, createAccordionElement, diff --git a/utils/helpers/compareArrays.ts b/utils/helpers/compareArrays.ts new file mode 100644 index 000000000..95d0f29b2 --- /dev/null +++ b/utils/helpers/compareArrays.ts @@ -0,0 +1,19 @@ + +/** + * Does a shallow compare of two arrays to determine if they are equal. + * @param a1 The first array + * @param a2 The second array + */ +export function compareArrays(a1: T[], a2: T[]) { + if (a1.length !== a2.length) { + return false; + } + + for (let i: number = 0; i < a1.length; ++i) { + if (a1[i] !== a2[i]) { + return false; + } + } + + return true; +}