source: frontend/node_modules/es-abstract/2016/OrdinaryGetOwnProperty.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.2 KB
Line 
1'use strict';
2
3var $gOPD = require('gopd');
4var $TypeError = require('es-errors/type');
5var isObject = require('es-object-atoms/isObject');
6var hasOwn = require('hasown');
7var callBound = require('call-bound');
8
9var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable');
10
11var IsArray = require('./IsArray');
12var isPropertyKey = require('../helpers/isPropertyKey');
13var IsRegExp = require('./IsRegExp');
14var ToPropertyDescriptor = require('./ToPropertyDescriptor');
15
16// https://262.ecma-international.org/6.0/#sec-ordinarygetownproperty
17
18module.exports = function OrdinaryGetOwnProperty(O, P) {
19 if (!isObject(O)) {
20 throw new $TypeError('Assertion failed: O must be an Object');
21 }
22 if (!isPropertyKey(P)) {
23 throw new $TypeError('Assertion failed: P must be a Property Key');
24 }
25 if (!hasOwn(O, P)) {
26 return void 0;
27 }
28 if (!$gOPD) {
29 // ES3 / IE 8 fallback
30 var arrayLength = IsArray(O) && P === 'length';
31 var regexLastIndex = IsRegExp(O) && P === 'lastIndex';
32 return {
33 '[[Configurable]]': !(arrayLength || regexLastIndex),
34 '[[Enumerable]]': $isEnumerable(O, P),
35 '[[Value]]': O[P],
36 '[[Writable]]': true
37 };
38 }
39 return ToPropertyDescriptor($gOPD(O, P));
40};
Note: See TracBrowser for help on using the repository browser.