is-plain-object.mjs 758 B

12345678910111213141516171819202122232425262728293031323334
  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. function isObject(o) {
  8. return Object.prototype.toString.call(o) === '[object Object]';
  9. }
  10. function isPlainObject(o) {
  11. var ctor,prot;
  12. if (isObject(o) === false) return false;
  13. // If has modified constructor
  14. ctor = o.constructor;
  15. if (ctor === undefined) return true;
  16. // If has modified prototype
  17. prot = ctor.prototype;
  18. if (isObject(prot) === false) return false;
  19. // If constructor does not have an Object-specific method
  20. if (prot.hasOwnProperty('isPrototypeOf') === false) {
  21. return false;
  22. }
  23. // Most likely a plain Object
  24. return true;
  25. }
  26. export { isPlainObject };