MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / proxifyValue

Function proxifyValue

src/common/browser.js:19–36  ·  view source on GitHub ↗
(target, key, src, metaVal)

Source from the content-addressed store, hash-verified

17 || key === 'hasListeners';
18 /** API types or enums or literal constants */
19 const proxifyValue = (target, key, src, metaVal) => {
20 const srcVal = src[key];
21 if (srcVal === undefined) return;
22 let res;
23 if (isFunction(metaVal)) {
24 res = metaVal(src, srcVal);
25 } else if (isFunction(srcVal)) {
26 res = metaVal === 0 || isSyncMethodName(key) || !hasOwnProperty(src, key)
27 ? srcVal::bind(src)
28 : wrapAsync(src, srcVal); // eslint-disable-line no-use-before-define
29 } else if (isObject(srcVal) && metaVal !== 0) {
30 res = proxifyGroup(srcVal, metaVal); // eslint-disable-line no-use-before-define
31 } else {
32 res = srcVal;
33 }
34 target[key] = res;
35 return res;
36 };
37 const proxifyGroup = (src, meta) => new SafeProxy({ __proto__: null }, {
38 __proto__: null,
39 get: (group, key) => group[key] ?? proxifyValue(group, key, src, meta?.[key]),

Callers 1

proxifyGroupFunction · 0.85

Calls 5

isFunctionFunction · 0.85
isSyncMethodNameFunction · 0.85
wrapAsyncFunction · 0.85
isObjectFunction · 0.85
proxifyGroupFunction · 0.85

Tested by

no test coverage detected