( source: Record<string, unknown>, key: string, allowed: readonly T[], fallback: T, )
| 70 | } |
| 71 | |
| 72 | export 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 | |
| 85 | export function replaceStoreIfChanged<T extends Record<string, any>>( |
| 86 | store: Pick<ElectronStore<T>, 'store'>, |
no outgoing calls
no test coverage detected