get.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. "use strict";
  2. exports.__esModule = true;
  3. var _getPrototypeOf = require("../core-js/object/get-prototype-of");
  4. var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
  5. var _getOwnPropertyDescriptor = require("../core-js/object/get-own-property-descriptor");
  6. var _getOwnPropertyDescriptor2 = _interopRequireDefault(_getOwnPropertyDescriptor);
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. exports.default = function get(object, property, receiver) {
  9. if (object === null) object = Function.prototype;
  10. var desc = (0, _getOwnPropertyDescriptor2.default)(object, property);
  11. if (desc === undefined) {
  12. var parent = (0, _getPrototypeOf2.default)(object);
  13. if (parent === null) {
  14. return undefined;
  15. } else {
  16. return get(parent, property, receiver);
  17. }
  18. } else if ("value" in desc) {
  19. return desc.value;
  20. } else {
  21. var getter = desc.get;
  22. if (getter === undefined) {
  23. return undefined;
  24. }
  25. return getter.call(receiver);
  26. }
  27. };