github
595 of 835 branches covered (71.26%)
Branch coverage included in aggregate %.
66 of 101 new or added lines in 7 files covered. (65.35%)
8541 existing lines in 129 files now uncovered.18683 of 36740 relevant lines covered (50.85%)
11.74 hits per line
| 1 |
// luma.gl
|
1✔ |
| 2 |
// SPDX-License-Identifier: MIT
|
1✔ |
| 3 |
// Copyright (c) vis.gl contributors
|
1✔ |
| 4 |
|
1✔ |
| 5 |
import {isNumberArray} from './is-array';
|
|
| 6 |
|
1✔ |
| 7 |
/** Test if two arrays are deep equal, with a length limit that defaults to 16 */
|
1✔ |
| 8 |
export function arrayEqual(a: unknown, b: unknown, limit: number = 16) { |
1✔ |
|
UNCOV
9
|
if (a !== b) {
|
× |
|
UNCOV
10
|
return false; |
× |
|
UNCOV
11
|
} |
× |
| 12 |
const arrayA = a;
|
× |
| 13 |
const arrayB = b;
|
× |
| 14 |
if (!isNumberArray(arrayA)) {
|
× |
| 15 |
return false; |
× |
| 16 |
} |
× |
|
UNCOV
17
|
if (isNumberArray(arrayB) && arrayA.length === arrayB.length) {
|
× |
| 18 |
for (let i = 0; i < arrayA.length; ++i) { |
× |
| 19 |
if (arrayB[i] !== arrayA[i]) {
|
× |
| 20 |
return false; |
× |
| 21 |
} |
× |
| 22 |
} |
× |
| 23 |
} |
× |
| 24 |
return true; |
× |
| 25 |
} |
× |
| 26 |
|
1✔ |
| 27 |
/** Copy a value */
|
1✔ |
| 28 |
export function arrayCopy<T>(a: T): T {
|
1✔ |
|
UNCOV
29
|
if (isNumberArray(a)) {
|
× |
|
UNCOV
30
|
return a.slice() as T;
|
× |
|
UNCOV
31
|
} |
× |
|
UNCOV
32
|
return a;
|
× |
|
UNCOV
33
|
} |
× |