is_object.js 600 B

12345678910111213141516171819
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. function isObjectLike(value) {
  4. return typeof value === 'object' && value !== null;
  5. }
  6. function isObject(input) {
  7. if (!isObjectLike(input) || Object.prototype.toString.call(input) !== '[object Object]') {
  8. return false;
  9. }
  10. if (Object.getPrototypeOf(input) === null) {
  11. return true;
  12. }
  13. let proto = input;
  14. while (Object.getPrototypeOf(proto) !== null) {
  15. proto = Object.getPrototypeOf(proto);
  16. }
  17. return Object.getPrototypeOf(input) === proto;
  18. }
  19. exports.default = isObject;