isPlainObject.js 537 B

123456789101112131415161718192021
  1. "use strict";
  2. exports.__esModule = true;
  3. exports["default"] = isPlainObject;
  4. /**
  5. * @param {any} obj The object to inspect.
  6. * @returns {boolean} True if the argument appears to be a plain object.
  7. */
  8. function isPlainObject(obj) {
  9. if (typeof obj !== 'object' || obj === null) return false;
  10. var proto = Object.getPrototypeOf(obj);
  11. if (proto === null) return true;
  12. var baseProto = proto;
  13. while (Object.getPrototypeOf(baseProto) !== null) {
  14. baseProto = Object.getPrototypeOf(baseProto);
  15. }
  16. return proto === baseProto;
  17. }