Skip to content
Snippets Groups Projects
Commit e17f6bf0 authored by Mathias Chouet's avatar Mathias Chouet
Browse files

Fix arraysAreEqual()

parent eed2ab04
No related branches found
No related tags found
No related merge requests found
...@@ -163,15 +163,17 @@ export function generateValuesCombination( ...@@ -163,15 +163,17 @@ export function generateValuesCombination(
} }
export function arraysAreEqual(arrayA: any[], arrayB: any[], property?: string, sort = false): boolean { 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) { if (sort) {
arrayA.sort((a, b) => a-b); aA.sort((a, b) => a-b);
arrayB.sort((a, b) => a-b); aB.sort((a, b) => a-b);
} }
let equal = true; let equal = true;
if (arrayA.length === arrayB.length) { if (aA.length === aB.length) {
for (let i=0; i < arrayA.length; i++) { for (let i=0; i < aA.length; i++) {
const eA = arrayA[i]; const eA = aA[i];
const eB = arrayB[i]; const eB = aB[i];
if (property === undefined) { if (property === undefined) {
equal = equal && (eA === eB); equal = equal && (eA === eB);
} else { } 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