MCPcopy
hub / github.com/imbrn/v8n / proxylessContext

Function proxylessContext

src/v8n.js:43–74  ·  view source on GitHub ↗
(context)

Source from the content-addressed store, hash-verified

41}
42
43function proxylessContext(context) {
44 const addRuleSet = (ruleSet, targetContext) => {
45 Object.keys(ruleSet).forEach(prop => {
46 targetContext[prop] = (...args) => {
47 const newContext = proxylessContext(targetContext._clone());
48 const contextWithRuleApplied = newContext._applyRule(
49 ruleSet[prop],
50 prop,
51 )(...args);
52 return contextWithRuleApplied;
53 };
54 });
55 return targetContext;
56 };
57
58 const contextWithAvailableRules = addRuleSet(availableRules, context);
59 const contextWithAllRules = addRuleSet(
60 customRules,
61 contextWithAvailableRules,
62 );
63
64 Object.keys(availableModifiers).forEach(prop => {
65 Object.defineProperty(contextWithAllRules, prop, {
66 get: () => {
67 const newContext = proxylessContext(contextWithAllRules._clone());
68 return newContext._applyModifier(availableModifiers[prop], prop);
69 },
70 });
71 });
72
73 return contextWithAllRules;
74}
75
76const availableModifiers = {
77 not: {

Callers 2

v8nFunction · 0.85
addRuleSetFunction · 0.85

Calls 3

addRuleSetFunction · 0.85
_cloneMethod · 0.80
_applyModifierMethod · 0.80

Tested by

no test coverage detected