es6.reflect.get.js 790 B

123456789101112131415161718192021
  1. // 26.1.6 Reflect.get(target, propertyKey [, receiver])
  2. var gOPD = require('./_object-gopd');
  3. var getPrototypeOf = require('./_object-gpo');
  4. var has = require('./_has');
  5. var $export = require('./_export');
  6. var isObject = require('./_is-object');
  7. var anObject = require('./_an-object');
  8. function get(target, propertyKey /* , receiver */) {
  9. var receiver = arguments.length < 3 ? target : arguments[2];
  10. var desc, proto;
  11. if (anObject(target) === receiver) return target[propertyKey];
  12. if (desc = gOPD.f(target, propertyKey)) return has(desc, 'value')
  13. ? desc.value
  14. : desc.get !== undefined
  15. ? desc.get.call(receiver)
  16. : undefined;
  17. if (isObject(proto = getPrototypeOf(target))) return get(proto, propertyKey, receiver);
  18. }
  19. $export($export.S, 'Reflect', { get: get });