MCPcopy Index your code
hub / github.com/massCodeIO/massCode / readEnum

Function readEnum

src/main/store/sanitize.ts:72–83  ·  view source on GitHub ↗
(
  source: Record<string, unknown>,
  key: string,
  allowed: readonly T[],
  fallback: T,
)

Source from the content-addressed store, hash-verified

70}
71
72export function readEnum<T extends string>(
73 source: Record<string, unknown>,
74 key: string,
75 allowed: readonly T[],
76 fallback: T,
77): T {
78 const value = source[key]
79
80 return typeof value === 'string' && allowed.includes(value as T)
81 ? (value as T)
82 : fallback
83}
84
85export function replaceStoreIfChanged<T extends Record<string, any>>(
86 store: Pick<ElectronStore<T>, 'store'>,

Callers 4

sanitizeHttpSettingsFunction · 0.90
sanitizeContentSortFunction · 0.90
sanitizeAppStoreFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected