main
Last change
on this file since d565449 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
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var $gOPD = require('gopd');
|
---|
4 | var $TypeError = require('es-errors/type');
|
---|
5 |
|
---|
6 | var callBound = require('call-bind/callBound');
|
---|
7 |
|
---|
8 | var $isEnumerable = callBound('Object.prototype.propertyIsEnumerable');
|
---|
9 |
|
---|
10 | var hasOwn = require('hasown');
|
---|
11 |
|
---|
12 | var IsArray = require('./IsArray');
|
---|
13 | var IsPropertyKey = require('./IsPropertyKey');
|
---|
14 | var IsRegExp = require('./IsRegExp');
|
---|
15 | var ToPropertyDescriptor = require('./ToPropertyDescriptor');
|
---|
16 | var Type = require('./Type');
|
---|
17 |
|
---|
18 | // https://262.ecma-international.org/6.0/#sec-ordinarygetownproperty
|
---|
19 |
|
---|
20 | module.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.