-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
polyfill.js
33 lines (25 loc) · 932 Bytes
/
polyfill.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
var Type = require('es-abstract/2024/Type');
var $TypeError = require('es-errors/type');
var callBind = require('call-bind');
var gOPD = require('gopd');
var implementation = require('./implementation');
var hasProto = [].__proto__ === Array.prototype; // eslint-disable-line no-proto
var dunderGetter = hasProto && gOPD && gOPD(Object.prototype, '__proto__');
var getDunder = dunderGetter && dunderGetter.get && callBind(dunderGetter.get);
var getProto = function getPrototypeOf(value) {
if (Type(value) !== 'Object') {
throw new $TypeError('Reflect.getPrototypeOf called on non-object');
}
// eslint-disable-next-line no-proto
return getDunder ? getDunder(value) : value.__proto__;
};
module.exports = function getPolyfill() {
if (typeof Reflect === 'object' && Reflect && Reflect.getPrototypeOf) {
return Reflect.getPrototypeOf;
}
if (hasProto) {
return getProto;
}
return implementation;
};