UNPKG

1.14 kBJavaScriptView Raw
1'use strict';
2var DESCRIPTORS = require('../internals/descriptors');
3var call = require('../internals/function-call');
4var propertyIsEnumerableModule = require('../internals/object-property-is-enumerable');
5var createPropertyDescriptor = require('../internals/create-property-descriptor');
6var toIndexedObject = require('../internals/to-indexed-object');
7var toPropertyKey = require('../internals/to-property-key');
8var hasOwn = require('../internals/has-own-property');
9var IE8_DOM_DEFINE = require('../internals/ie8-dom-define');
10
11// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
12var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
13
14// `Object.getOwnPropertyDescriptor` method
15// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
16exports.f = DESCRIPTORS ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
17 O = toIndexedObject(O);
18 P = toPropertyKey(P);
19 if (IE8_DOM_DEFINE) try {
20 return $getOwnPropertyDescriptor(O, P);
21 } catch (error) { /* empty */ }
22 if (hasOwn(O, P)) return createPropertyDescriptor(!call(propertyIsEnumerableModule.f, O, P), O[P]);
23};