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

Function hookSettingsForUI

src/common/ui/util.js:25–45  ·  view source on GitHub ↗
(items, settings, watch, delay)

Source from the content-addressed store, hash-verified

23 * @return {any[]}
24 */
25export function hookSettingsForUI(items, settings, watch, delay) {
26 const revokers = [];
27 for (const key in items) {
28 const obj = items[key];
29 const normalize = isFunction(obj) ? obj
30 : obj[NORMALIZE] || normalizeEnum.bind(obj);
31 const updater = (val, old) => {
32 val = normalize(val, key);
33 old = normalize(old, key);
34 if (val !== old) options.set(key, val);
35 };
36 revokers.push(
37 hookSetting(key, val => {
38 settings[key] = normalize(val, key);
39 }),
40 watch(() => settings[key],
41 delay ? debounce(updater, delay) : updater),
42 );
43 }
44 return revokers;
45}

Callers

nothing calls this directly

Calls 5

debounceFunction · 0.90
isFunctionFunction · 0.85
hookSettingFunction · 0.85
watchFunction · 0.85
normalizeFunction · 0.50

Tested by

no test coverage detected