PronounsPage/utils/getWithKey.ts
2025-07-27 23:43:57 +02:00

9 lines
295 B
TypeScript

import type { WithKey } from '~/utils/withKey.ts';
export default <T>(record: Record<string, T> | undefined, key: string | undefined): WithKey<T> | undefined => {
if (key === undefined || record?.[key] === undefined) {
return undefined;
}
return { ...record[key], key };
};