MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / applyDelta

Method applyDelta

packages/hydrooj/src/settings.ts:72–84  ·  view source on GitHub ↗
(source: any, key: string, value: any)

Source from the content-addressed store, hash-verified

70 }
71
72 applyDelta(source: any, key: string, value: any) {
73 const path = key.split('.');
74 if (path.some((i) => SettingService.blacklist.includes(i))) return false;
75 const t = path.pop();
76 const root = JSON.parse(JSON.stringify(source));
77 let cursor = root;
78 for (const p of path) {
79 cursor[p] ??= {};
80 cursor = cursor[p];
81 }
82 cursor[t] = value;
83 return root;
84 }
85
86 isPatchValid(key: string, value: any) {
87 const root = this.applyDelta(this.systemConfig, key, value);

Callers 3

isPatchValidMethod · 0.95
processNodeMethod · 0.95
setConfigMethod · 0.95

Calls 1

popMethod · 0.80

Tested by

no test coverage detected