Browse Source

fix: resolve cases when comparing arrays to non-array values

pull/18/head
Máté Szentgróti 11 months ago
parent
commit
91efdfc0b9
  1. 5
      src/utils.ts

5
src/utils.ts

@ -3,7 +3,8 @@ import { isEqualOptions } from "./model"; @@ -3,7 +3,8 @@ import { isEqualOptions } from "./model";
/**
* Returns true if two data are equal
* @param {any} a - The original data.
* @param {any} b- The data to compare.
* @param {any} b - The data to compare.
* @param {isEqualOptions} options - The options to compare the data.
* @returns boolean
*/
export function isEqual(
@ -12,7 +13,7 @@ export function isEqual( @@ -12,7 +13,7 @@ export function isEqual(
options: isEqualOptions = { ignoreArrayOrder: false }
): boolean {
if (typeof a !== typeof b) return false;
if (Array.isArray(a)) {
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length !== b.length) {
return false;
}

Loading…
Cancel
Save