mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-11 09:54:10 +01:00
15 lines
453 B
TypeScript
15 lines
453 B
TypeScript
import { DeviceModelInternal } from '@trezor/connect';
|
|
|
|
export const pickByDeviceModel = <Type>(
|
|
deviceModelInternal: DeviceModelInternal | undefined,
|
|
options: { default: Type } & Partial<Record<DeviceModelInternal, Type>>,
|
|
): Type => {
|
|
if (!deviceModelInternal) {
|
|
return options.default;
|
|
}
|
|
|
|
const valueForDevice = options[deviceModelInternal];
|
|
|
|
return valueForDevice === undefined ? options.default : valueForDevice;
|
|
};
|