Monorepo with centralized build props, npm workspaces, LlamaSharp AI, SQLite/SQLCipher storage, Svelte frontend, and unified smoke tests. Co-Authored-By: Oz <oz-agent@warp.dev>
21 lines
476 B
TypeScript
21 lines
476 B
TypeScript
type UnknownObject = Record<string, unknown>;
|
|
|
|
function asObject(value: unknown): UnknownObject | undefined {
|
|
return value && typeof value === "object"
|
|
? (value as UnknownObject)
|
|
: undefined;
|
|
}
|
|
|
|
export function pickCase<T>(
|
|
source: unknown,
|
|
camelKey: string,
|
|
pascalKey: string,
|
|
fallback: T,
|
|
): T {
|
|
const obj = asObject(source);
|
|
if (!obj) return fallback;
|
|
|
|
const value = obj[camelKey] ?? obj[pascalKey];
|
|
return (value as T | undefined) ?? fallback;
|
|
}
|