-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
polyfill.js
36 lines (29 loc) · 889 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
34
35
36
'use strict';
var Type = require('es-abstract/2024/Type');
var $TypeError = require('es-errors/type');
var implementation = require('./implementation');
var hasProto;
try {
hasProto = [].__proto__ === Array.prototype; // eslint-disable-line no-proto
} catch (e) {
if (!e || typeof e !== 'object' || !('code' in e) || e.code !== 'ERR_PROTO_ACCESS') {
throw e;
}
}
var getDunder = require('dunder-proto/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;
};