main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 6 months ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var GetIntrinsic = require('get-intrinsic');
|
---|
4 | var IsCallable = require('es-abstract/2024/IsCallable');
|
---|
5 | var isObject = require('es-abstract/helpers/isObject');
|
---|
6 | var whichBuiltinType = require('which-builtin-type');
|
---|
7 | var $TypeError = require('es-errors/type');
|
---|
8 |
|
---|
9 | var gPO = require('get-proto');
|
---|
10 | var $Object = require('es-object-atoms');
|
---|
11 |
|
---|
12 | module.exports = function getPrototypeOf(O) {
|
---|
13 | if (!isObject(O)) {
|
---|
14 | throw new $TypeError('Reflect.getPrototypeOf called on non-object');
|
---|
15 | }
|
---|
16 |
|
---|
17 | if (gPO) {
|
---|
18 | return gPO(O);
|
---|
19 | }
|
---|
20 |
|
---|
21 | var type = whichBuiltinType(O);
|
---|
22 | if (type) {
|
---|
23 | var intrinsic = GetIntrinsic('%' + type + '.prototype%', true);
|
---|
24 | if (intrinsic) {
|
---|
25 | return intrinsic;
|
---|
26 | }
|
---|
27 | }
|
---|
28 | if (IsCallable(O.constructor)) {
|
---|
29 | return O.constructor.prototype;
|
---|
30 | }
|
---|
31 | if (O instanceof Object) {
|
---|
32 | return $Object.prototype;
|
---|
33 | }
|
---|
34 |
|
---|
35 | /*
|
---|
36 | * Correctly return null for Objects created with `Object.create(null)` (shammed or native) or `{ __proto__: null}`. Also returns null for
|
---|
37 | * cross-realm objects on browsers that lack `__proto__` support (like IE <11), but that's the best we can do.
|
---|
38 | */
|
---|
39 | return null;
|
---|
40 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.