Last change
on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 |
|
---|
3 | exports.__esModule = true;
|
---|
4 | exports.default = createMetaResolver;
|
---|
5 |
|
---|
6 | var _utils = require("./utils");
|
---|
7 |
|
---|
8 | const PossibleGlobalObjects = new Set(["global", "globalThis", "self", "window"]);
|
---|
9 |
|
---|
10 | function createMetaResolver(polyfills) {
|
---|
11 | const {
|
---|
12 | static: staticP,
|
---|
13 | instance: instanceP,
|
---|
14 | global: globalP
|
---|
15 | } = polyfills;
|
---|
16 | return meta => {
|
---|
17 | if (meta.kind === "global" && globalP && (0, _utils.has)(globalP, meta.name)) {
|
---|
18 | return {
|
---|
19 | kind: "global",
|
---|
20 | desc: globalP[meta.name],
|
---|
21 | name: meta.name
|
---|
22 | };
|
---|
23 | }
|
---|
24 |
|
---|
25 | if (meta.kind === "property" || meta.kind === "in") {
|
---|
26 | const {
|
---|
27 | placement,
|
---|
28 | object,
|
---|
29 | key
|
---|
30 | } = meta;
|
---|
31 |
|
---|
32 | if (object && placement === "static") {
|
---|
33 | if (globalP && PossibleGlobalObjects.has(object) && (0, _utils.has)(globalP, key)) {
|
---|
34 | return {
|
---|
35 | kind: "global",
|
---|
36 | desc: globalP[key],
|
---|
37 | name: key
|
---|
38 | };
|
---|
39 | }
|
---|
40 |
|
---|
41 | if (staticP && (0, _utils.has)(staticP, object) && (0, _utils.has)(staticP[object], key)) {
|
---|
42 | return {
|
---|
43 | kind: "static",
|
---|
44 | desc: staticP[object][key],
|
---|
45 | name: `${object}$${key}`
|
---|
46 | };
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 | if (instanceP && (0, _utils.has)(instanceP, key)) {
|
---|
51 | return {
|
---|
52 | kind: "instance",
|
---|
53 | desc: instanceP[key],
|
---|
54 | name: `${key}`
|
---|
55 | };
|
---|
56 | }
|
---|
57 | }
|
---|
58 | };
|
---|
59 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.