index.es.js 1.0 KB

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