Skip to content
Snippets Groups Projects
Commit ea66c333 authored by Mathias Chouet's avatar Mathias Chouet Committed by mathias.chouet
Browse files

Fix arraysAreEqual()

parent 0dbd6ec8
No related branches found
No related tags found
No related merge requests found
......@@ -163,15 +163,17 @@ export function generateValuesCombination(
}
export function arraysAreEqual(arrayA: any[], arrayB: any[], property?: string, sort = false): boolean {
let aA: any[] = JSON.parse(JSON.stringify(arrayA)); // array copy
let aB: any[] = JSON.parse(JSON.stringify(arrayB)); // array copy
if (sort) {
arrayA.sort((a, b) => a-b);
arrayB.sort((a, b) => a-b);
aA.sort((a, b) => a-b);
aB.sort((a, b) => a-b);
}
let equal = true;
if (arrayA.length === arrayB.length) {
for (let i=0; i < arrayA.length; i++) {
const eA = arrayA[i];
const eB = arrayB[i];
if (aA.length === aB.length) {
for (let i=0; i < aA.length; i++) {
const eA = aA[i];
const eB = aB[i];
if (property === undefined) {
equal = equal && (eA === eB);
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment