You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
821 B
27 lines
821 B
'use strict';
|
|
|
|
var reflectGetProto = require('./Reflect.getPrototypeOf');
|
|
var originalGetProto = require('./Object.getPrototypeOf');
|
|
|
|
var getDunderProto = require('dunder-proto/get');
|
|
|
|
/** @type {import('.')} */
|
|
module.exports = reflectGetProto
|
|
? function getProto(O) {
|
|
// @ts-expect-error TS can't narrow inside a closure, for some reason
|
|
return reflectGetProto(O);
|
|
}
|
|
: originalGetProto
|
|
? function getProto(O) {
|
|
if (!O || (typeof O !== 'object' && typeof O !== 'function')) {
|
|
throw new TypeError('getProto: not an object');
|
|
}
|
|
// @ts-expect-error TS can't narrow inside a closure, for some reason
|
|
return originalGetProto(O);
|
|
}
|
|
: getDunderProto
|
|
? function getProto(O) {
|
|
// @ts-expect-error TS can't narrow inside a closure, for some reason
|
|
return getDunderProto(O);
|
|
}
|
|
: null;
|