UNPKG

936 BJavaScriptView Raw
1'use strict';
2var hasOwn = require('../internals/has-own-property');
3var isCallable = require('../internals/is-callable');
4var toObject = require('../internals/to-object');
5var sharedKey = require('../internals/shared-key');
6var CORRECT_PROTOTYPE_GETTER = require('../internals/correct-prototype-getter');
7
8var IE_PROTO = sharedKey('IE_PROTO');
9var $Object = Object;
10var ObjectPrototype = $Object.prototype;
11
12// `Object.getPrototypeOf` method
13// https://tc39.es/ecma262/#sec-object.getprototypeof
14// eslint-disable-next-line es/no-object-getprototypeof -- safe
15module.exports = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
16 var object = toObject(O);
17 if (hasOwn(object, IE_PROTO)) return object[IE_PROTO];
18 var constructor = object.constructor;
19 if (isCallable(constructor) && object instanceof constructor) {
20 return constructor.prototype;
21 } return object instanceof $Object ? ObjectPrototype : null;
22};