You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

is-plain-object.js 592B

1234567891011121314151617181920
  1. "use strict";
  2. var getPrototypeOf = Object.getPrototypeOf
  3. , prototype = Object.prototype
  4. , objToString = prototype.toString
  5. , id = Object().toString();
  6. module.exports = function (value) {
  7. var proto, valueConstructor;
  8. if (!value || typeof value !== "object" || objToString.call(value) !== id) {
  9. return false;
  10. }
  11. proto = getPrototypeOf(value);
  12. if (proto === null) {
  13. valueConstructor = value.constructor;
  14. if (typeof valueConstructor !== "function") return true;
  15. return valueConstructor.prototype !== value;
  16. }
  17. return proto === prototype || getPrototypeOf(proto) === null;
  18. };