debian-mirror-gitlab/core-js/modules/es.object.lookup-getter.js

24 lines
925 B
JavaScript
Raw Normal View History

2019-09-25 13:30:05 +05:30
'use strict';
var $ = require('../internals/export');
var DESCRIPTORS = require('../internals/descriptors');
var FORCED = require('../internals/forced-object-prototype-accessors-methods');
var toObject = require('../internals/to-object');
var toPrimitive = require('../internals/to-primitive');
var getPrototypeOf = require('../internals/object-get-prototype-of');
var getOwnPropertyDescriptor = require('../internals/object-get-own-property-descriptor').f;
// `Object.prototype.__lookupGetter__` method
// https://tc39.github.io/ecma262/#sec-object.prototype.__lookupGetter__
if (DESCRIPTORS) {
$({ target: 'Object', proto: true, forced: FORCED }, {
__lookupGetter__: function __lookupGetter__(P) {
var O = toObject(this);
var key = toPrimitive(P, true);
var desc;
do {
if (desc = getOwnPropertyDescriptor(O, key)) return desc.get;
} while (O = getPrototypeOf(O));
}
});
}