-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
es.reflect.get.js
25 lines (23 loc) · 1.07 KB
/
es.reflect.get.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'use strict';
var $ = require('../internals/export');
var call = require('../internals/function-call');
var isObject = require('../internals/is-object');
var anObject = require('../internals/an-object');
var isDataDescriptor = require('../internals/is-data-descriptor');
var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');
var getPrototypeOf = require('../internals/object-get-prototype-of');
// `Reflect.get` method
// https://tc39.es/ecma262/#sec-reflect.get
function get(target, propertyKey /* , receiver */) {
var receiver = arguments.length < 3 ? target : arguments[2];
var descriptor, prototype;
if (anObject(target) === receiver) return target[propertyKey];
descriptor = getOwnPropertyDescriptorModule.f(target, propertyKey);
if (descriptor) return isDataDescriptor(descriptor)
? descriptor.value
: descriptor.get === undefined ? undefined : call(descriptor.get, receiver);
if (isObject(prototype = getPrototypeOf(target))) return get(prototype, propertyKey, receiver);
}
$({ target: 'Reflect', stat: true }, {
get: get
});