UNPKG

713 BJavaScriptView Raw
1var has = require('../internals/has');
2var toObject = require('../internals/to-object');
3var sharedKey = require('../internals/shared-key');
4var CORRECT_PROTOTYPE_GETTER = require('../internals/correct-prototype-getter');
5
6var IE_PROTO = sharedKey('IE_PROTO');
7var ObjectPrototype = Object.prototype;
8
9// `Object.getPrototypeOf` method
10// https://tc39.github.io/ecma262/#sec-object.getprototypeof
11module.exports = CORRECT_PROTOTYPE_GETTER ? Object.getPrototypeOf : function (O) {
12 O = toObject(O);
13 if (has(O, IE_PROTO)) return O[IE_PROTO];
14 if (typeof O.constructor == 'function' && O instanceof O.constructor) {
15 return O.constructor.prototype;
16 } return O instanceof Object ? ObjectPrototype : null;
17};