MCPcopy Create free account
hub / github.com/ether/etherpad / walk

Function walk

src/node/utils/AdminSettingsRedact.ts:32–48  ·  view source on GitHub ↗
(value: unknown, path: string[])

Source from the content-addressed store, hash-verified

30};
31
32const walk = (value: unknown, path: string[]): unknown => {
33 if (pathMatches(path)) return SENTINEL;
34 if (value === null || value === undefined) return value;
35 if (typeof value === 'function') return undefined;
36 if (Array.isArray(value)) {
37 return value.map((v, i) => walk(v, [...path, String(i)]));
38 }
39 if (typeof value === 'object') {
40 const out: Record<string, unknown> = {};
41 for (const [k, v] of Object.entries(value as Record<string, unknown>)) {
42 const child = walk(v, [...path, k]);
43 if (child !== undefined) out[k] = child;
44 }
45 return out;
46 }
47 return value;
48};
49
50export const redactSettings = (settings: unknown): unknown => walk(settings, []);

Callers 1

redactSettingsFunction · 0.70

Calls 2

pathMatchesFunction · 0.85
mapMethod · 0.80

Tested by

no test coverage detected