react-native-theme-flow
Version:
react native style sheet with theme
15 lines (12 loc) • 319 B
text/typescript
import type { ValueOrFactory } from '../types';
export const isFactory = <T, C>(
v: ValueOrFactory<T, C>
): v is (input: C) => T => {
return typeof v === 'function';
};
export const getFactoryValue = <T, C>(
value: ValueOrFactory<T, C>,
input: C
): T => {
return isFactory(value) ? value(input) : value;
};