Skip to content

Commit

Permalink
[New] ES2015+: add OrdinaryGetOwnProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Aug 26, 2019
1 parent ccb47e4 commit 0609672
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 3 deletions.
25 changes: 25 additions & 0 deletions es2015.js
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,31 @@ var ES6 = assign(assign({}, ES5), {
return this.ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current);
},

// http://www.ecma-international.org/ecma-262/6.0/#sec-ordinarygetownproperty
OrdinaryGetOwnProperty: function OrdinaryGetOwnProperty(O, P) {
if (this.Type(O) !== 'Object') {
throw new $TypeError('Assertion failed: O must be an Object');
}
if (!this.IsPropertyKey(P)) {
throw new $TypeError('Assertion failed: P must be a Property Key');
}
if (!has(O, P)) {
return void 0;
}
if (!$gOPD) {
// ES3 fallback
var arrayLength = this.IsArray(O) && P === 'length';
var regexLastIndex = this.IsRegExp(O) && P === 'lastIndex';
return {
'[[Configurable]]': !(arrayLength || regexLastIndex),
'[[Enumerable]]': $isEnumerable(O, P),
'[[Value]]': O[P],
'[[Writable]]': true
};
}
return this.ToPropertyDescriptor($gOPD(O, P));
},

// http://www.ecma-international.org/ecma-262/6.0/#sec-arraycreate
ArrayCreate: function ArrayCreate(length) {
if (!this.IsInteger(length) || length < 0) {
Expand Down
1 change: 1 addition & 0 deletions operations/2015.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module.exports = {
NormalCompletion: 'https://ecma-international.org/ecma-262/6.0/#sec-normalcompletion',
ObjectCreate: 'https://ecma-international.org/ecma-262/6.0/#sec-objectcreate',
OrdinaryDefineOwnProperty: 'http://www.ecma-international.org/ecma-262/6.0/#sec-ordinarydefineownproperty',
OrdinaryGetOwnProperty: 'http://www.ecma-international.org/ecma-262/6.0/#sec-ordinarygetownproperty',
OrdinaryHasInstance: 'https://ecma-international.org/ecma-262/6.0/#sec-ordinaryhasinstance',
RegExpBuiltinExec: 'https://ecma-international.org/ecma-262/6.0/#sec-regexpbuiltinexec',
RegExpExec: 'https://ecma-international.org/ecma-262/6.0/#sec-regexpexec',
Expand Down
2 changes: 1 addition & 1 deletion test/es2016.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0609672

Please sign in to comment.