es.object.define-getter.js 744 B

1234567891011121314151617
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var DESCRIPTORS = require('../internals/descriptors');
  4. var FORCED = require('../internals/object-prototype-accessors-forced');
  5. var toObject = require('../internals/to-object');
  6. var aFunction = require('../internals/a-function');
  7. var definePropertyModule = require('../internals/object-define-property');
  8. // `Object.prototype.__defineGetter__` method
  9. // https://tc39.github.io/ecma262/#sec-object.prototype.__defineGetter__
  10. if (DESCRIPTORS) {
  11. $({ target: 'Object', proto: true, forced: FORCED }, {
  12. __defineGetter__: function __defineGetter__(P, getter) {
  13. definePropertyModule.f(toObject(this), P, { get: aFunction(getter), enumerable: true, configurable: true });
  14. }
  15. });
  16. }