|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
939 bytes
|
| Line | |
|---|
| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 4 | value: true
|
|---|
| 5 | });
|
|---|
| 6 | exports.arrayContentsAreEqualCheck = arrayContentsAreEqualCheck;
|
|---|
| 7 | exports.emptyArraysAreEqualCheck = emptyArraysAreEqualCheck;
|
|---|
| 8 | /**
|
|---|
| 9 | * Checks if two arrays are equal, treating empty arrays as equal regardless of reference.
|
|---|
| 10 | * If both arrays are non-empty, it checks for reference equality.
|
|---|
| 11 | * @param a
|
|---|
| 12 | * @param b
|
|---|
| 13 | */
|
|---|
| 14 | function emptyArraysAreEqualCheck(a, b) {
|
|---|
| 15 | if (Array.isArray(a) && Array.isArray(b) && a.length === 0 && b.length === 0) {
|
|---|
| 16 | // empty arrays are always equal, regardless of reference
|
|---|
| 17 | return true;
|
|---|
| 18 | }
|
|---|
| 19 | return a === b;
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | /**
|
|---|
| 23 | * Checks if two arrays have the same contents in the same order.
|
|---|
| 24 | * @param a
|
|---|
| 25 | * @param b
|
|---|
| 26 | */
|
|---|
| 27 | function arrayContentsAreEqualCheck(a, b) {
|
|---|
| 28 | if (a.length === b.length) {
|
|---|
| 29 | for (var i = 0; i < a.length; i++) {
|
|---|
| 30 | if (a[i] !== b[i]) {
|
|---|
| 31 | return false;
|
|---|
| 32 | }
|
|---|
| 33 | }
|
|---|
| 34 | return true;
|
|---|
| 35 | }
|
|---|
| 36 | return false;
|
|---|
| 37 | } |
|---|
Note:
See
TracBrowser
for help on using the repository browser.