How to use the reakit-utils/isObject.isObject function in reakit-utils

To help you get started, we’ve selected a few reakit-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reakit / reakit / packages / reakit / src / Form / __utils / filterAllEmpty.ts View on Github external
if (Array.isArray(object)) {
    return object.filter(value => {
      if (isObject(value)) {
        return filterAllEmpty(value);
      }
      return true;
    }) as T;
  }

  const result = {} as T;
  const keys = Object.keys(object);

  for (const key of keys) {
    const k = key as keyof T;
    const value = object[k];
    result[k] = isObject(value) ? filterAllEmpty(value) : object[k];
  }

  return result;
}
github reakit / reakit / packages / reakit / src / Form / __utils / filterAllEmpty.ts View on Github external
return object.filter(value => {
      if (isObject(value)) {
        return filterAllEmpty(value);
      }
      return true;
    }) as T;
  }
github reakit / reakit / packages / reakit-system / src / __utils / deepEqual.ts View on Github external
): boolean {
  if (objA === objB) return true;
  if (!objA || !objB) return false;

  const aKeys = Object.keys(objA);
  const bKeys = Object.keys(objB);
  const { length } = aKeys;

  if (bKeys.length !== length) return false;

  for (const key of aKeys) {
    if (objA[key] !== objB[key]) {
      if (
        !depth ||
        !isObject(objA[key]) ||
        !isObject(objB[key]) ||
        !deepEqual(objA[key], objB[key], depth - 1)
      ) {
        return false;
      }
    }
  }

  return true;
}
github reakit / reakit / packages / reakit / src / Form / utils / setAllIn.ts View on Github external
result[key] = val.map(v => {
        if (isObject(v)) {
          return unstable_setAllIn(v, value);
        }
        return value;
      });
    } else if (isObject(val)) {
github reakit / reakit / packages / reakit / src / Form / utils / setAllIn.ts View on Github external
export function unstable_setAllIn(object: T, value: V) {
  const typedObject = object as Record;
  const result = {} as Record;
  const keys = Object.keys(object);

  for (const key of keys) {
    const val = typedObject[key];

    if (Array.isArray(val)) {
      result[key] = val.map(v => {
        if (isObject(v)) {
          return unstable_setAllIn(v, value);
        }
        return value;
      });
    } else if (isObject(val)) {
      result[key] = unstable_setAllIn(val, value);
    } else {
      result[key] = value;
    }
  }

  return result as DeepMap;
}