MCPcopy Index your code
hub / github.com/ember-cli/ember-cli / get

Function get

lib/models/per-bundle-addon-cache/addon-proxy.js:80–137  ·  view source on GitHub ↗
(targetCacheEntry, property)

Source from the content-addressed store, hash-verified

78
79 return new Proxy(targetCacheEntry, {
80 get(targetCacheEntry, property) {
81 if (property === 'parent') {
82 return parent;
83 }
84
85 if (property === 'app') {
86 return _app;
87 }
88
89 // only return `_preprocessJs` here if it was previously set to a patched version
90 if (property === 'preprocessJs' && _preprocessJs) {
91 return _preprocessJs;
92 }
93
94 // keep proxies from even trying to set or initialize addons
95 if (property === 'initializeAddons') {
96 return undefined;
97 }
98
99 // See the {@link index.js} file for a discussion of why the proxy 'addons'
100 // property returns an empty array.
101 if (property === 'addons') {
102 return [];
103 }
104
105 // allow access to the property pointing to the real instance.
106 if (property === TARGET_INSTANCE) {
107 return targetCacheEntry[TARGET_INSTANCE];
108 }
109
110 // `included` will be called on the "real" addon, so there's no need for it to be
111 // called again; instead we return a no-op implementation here
112 if (property === 'included') {
113 return () => undefined;
114 }
115
116 if (targetCacheEntry[TARGET_INSTANCE]) {
117 if (property !== 'constructor' && typeof targetCacheEntry[TARGET_INSTANCE][property] === 'function') {
118 // If we fall through to the Reflect.get just below, the 'this' context of the function when
119 // invoked is the proxy, not the original instance (so its local state is incorrect).
120 // Wrap the original methods to maintain the correct 'this' context.
121 return function _originalAddonPropMethodWrapper() {
122 let originalReturnValue = targetCacheEntry[TARGET_INSTANCE][property](...arguments);
123
124 if (property === 'cacheKeyForTree') {
125 const treeType = arguments[0];
126 validateCacheKey(targetCacheEntry[TARGET_INSTANCE], treeType, originalReturnValue);
127 }
128
129 return originalReturnValue;
130 };
131 }
132
133 return Reflect.get(targetCacheEntry[TARGET_INSTANCE], property);
134 }
135
136 return Reflect.get(targetCacheEntry, property);
137 },

Callers 1

Calls 2

validateCacheKeyFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected