is-object.js 811 B

123456789101112131415161718192021222324
  1. "use strict";
  2. // Returns true when the value is a regular Object and not a specialized Object
  3. //
  4. // This helps speeding up deepEqual cyclic checks
  5. // The premise is that only Objects are stored in the visited array.
  6. // So if this function returns false, we don't have to do the
  7. // expensive operation of searching for the value in the the array of already
  8. // visited objects
  9. function isObject(value) {
  10. return (
  11. typeof value === "object" &&
  12. value !== null &&
  13. // none of these are collection objects, so we can return false
  14. !(value instanceof Boolean) &&
  15. !(value instanceof Date) &&
  16. !(value instanceof Error) &&
  17. !(value instanceof Number) &&
  18. !(value instanceof RegExp) &&
  19. !(value instanceof String)
  20. );
  21. }
  22. module.exports = isObject;