isPlainObject.js 522 B

123456789101112131415
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const getType = (value) => (Object.prototype.toString.call(value).slice(8, -1).toLowerCase());
  4. function isPlainObject(value) {
  5. if (getType(value) !== "object") {
  6. return false;
  7. }
  8. const pp = Object.getPrototypeOf(value);
  9. if (pp === null || pp === undefined) {
  10. return true;
  11. }
  12. const Ctor = pp.constructor && pp.constructor.toString();
  13. return Ctor === Object.toString();
  14. }
  15. exports.default = isPlainObject;