get.js 835 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. var callBind = require('call-bind-apply-helpers');
  3. var gOPD = require('gopd');
  4. // eslint-disable-next-line no-extra-parens, no-proto
  5. var hasProtoAccessor = /** @type {{ __proto__?: typeof Array.prototype }} */ ([]).__proto__ === Array.prototype;
  6. // eslint-disable-next-line no-extra-parens
  7. var desc = hasProtoAccessor && gOPD && gOPD(Object.prototype, /** @type {keyof typeof Object.prototype} */ ('__proto__'));
  8. var $Object = Object;
  9. var $getPrototypeOf = $Object.getPrototypeOf;
  10. /** @type {import('./get')} */
  11. module.exports = desc && typeof desc.get === 'function'
  12. ? callBind([desc.get])
  13. : typeof $getPrototypeOf === 'function'
  14. ? /** @type {import('./get')} */ function getDunder(value) {
  15. // eslint-disable-next-line eqeqeq
  16. return $getPrototypeOf(value == null ? value : $Object(value));
  17. }
  18. : false;