isPlainObject.js 473 B

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