polyfill.js 672 B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. var Type = require('es-abstract/2023/Type');
  3. var $TypeError = require('es-errors/type');
  4. var implementation = require('./implementation');
  5. var hasProto = [].__proto__ === Array.prototype; // eslint-disable-line no-proto
  6. var getProto = function getPrototypeOf(value) {
  7. if (Type(value) !== 'Object') {
  8. throw new $TypeError('Reflect.getPrototypeOf called on non-object');
  9. }
  10. return value.__proto__; // eslint-disable-line no-proto
  11. };
  12. module.exports = function getPolyfill() {
  13. if (typeof Reflect === 'object' && Reflect && Reflect.getPrototypeOf) {
  14. return Reflect.getPrototypeOf;
  15. }
  16. if (hasProto) {
  17. return getProto;
  18. }
  19. return implementation;
  20. };