index.js 836 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*!
  2. * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
  3. *
  4. * Copyright (c) 2014-2017, Jon Schlinkert.
  5. * Released under the MIT License.
  6. */
  7. import isObject from 'isobject';
  8. function isObjectObject(o) {
  9. return isObject(o) === true
  10. && Object.prototype.toString.call(o) === '[object Object]';
  11. }
  12. export default function isPlainObject(o) {
  13. var ctor,prot;
  14. if (isObjectObject(o) === false) return false;
  15. // If has modified constructor
  16. ctor = o.constructor;
  17. if (typeof ctor !== 'function') return false;
  18. // If has modified prototype
  19. prot = ctor.prototype;
  20. if (isObjectObject(prot) === false) return false;
  21. // If constructor does not have an Object-specific method
  22. if (prot.hasOwnProperty('isPrototypeOf') === false) {
  23. return false;
  24. }
  25. // Most likely a plain Object
  26. return true;
  27. };