All files utils.js

100% Statements 21/21
100% Branches 16/16
100% Functions 9/9
100% Lines 18/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39    86x       80x       13x 12x 20x 40x           19x 19x 19x 18x 25x 41x           79x 67x 13x   54x 19x   35x  
 
export function isObject(obj) {
  return obj === Object(obj);
}
 
export function isArray(arr) {
  return Array.isArray(arr);
}
 
export function isArrayEqual(a, b) {
  if (a.length !== b.length) return false;
  return a.filter(aValue => {
    return b.filter(bValue => {
      return isEqual(aValue, bValue);
    }).length === 1;
  }).length === a.length;
}
 
export function isObjectEqual(a, b) {
  const aKeys = Object.keys(a);
  const bKeys = Object.keys(b);
  if (aKeys.length !== bKeys.length) return false;
  return aKeys.filter(aKey => {
    return bKeys.filter(bKey => {
      return aKey === bKey && isEqual(a[aKey], b[bKey]);
    }).length === 1;
  }).length === aKeys.length;
}
 
export function isEqual(a, b) {
  if (typeof a !== typeof b) return false;
  if (isArray(a) && isArray(b)) {
    return isArrayEqual(a, b);
  }
  if (isObject(a) && isObject(b)) {
    return isObjectEqual(a, b);
  }
  return a === b;
}