source: imaps-frontend/node_modules/es-abstract/2021/OrdinaryGetOwnProperty.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

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