source: imaps-frontend/node_modules/es-abstract/2018/OrdinaryGetOwnProperty.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

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