MCPcopy
hub / github.com/Koenkk/zigbee2mqtt / set

Function set

lib/util/settings.ts:461–479  ·  view source on GitHub ↗
(path: string[], value: string | number | boolean | KeyValue)

Source from the content-addressed store, hash-verified

459}
460
461export function set(path: string[], value: string | number | boolean | KeyValue): void {
462 // biome-ignore lint/suspicious/noExplicitAny: auto-parsing
463 let settings: any = getPersistedSettings();
464
465 for (let i = 0; i < path.length; i++) {
466 const key = path[i];
467 if (i === path.length - 1) {
468 settings[key] = value;
469 } else {
470 if (!settings[key]) {
471 settings[key] = {};
472 }
473
474 settings = settings[key];
475 }
476 }
477
478 write();
479}
480
481export function apply(settings: Record<string, unknown>, throwOnError = true): boolean {
482 getPersistedSettings(); // Ensure _settings is initialized.

Callers

nothing calls this directly

Calls 2

getPersistedSettingsFunction · 0.85
writeFunction · 0.70

Tested by

no test coverage detected