react-native-reanimated
Version:
More powerful alternative to Animated library for React Native.
21 lines (16 loc) • 645 B
text/typescript
;
import type { FontVariant } from 'react-native';
import { FONT_WEIGHT_MAPPINGS } from '../../../constants';
import type { ValueProcessor } from '../types';
export const processFontWeight: ValueProcessor<number | string> = (value) => {
if (typeof value === 'number' || !isNaN(+value)) {
return String(value);
}
if (value in FONT_WEIGHT_MAPPINGS) {
return FONT_WEIGHT_MAPPINGS[value as keyof typeof FONT_WEIGHT_MAPPINGS];
}
};
export const processFontVariant: ValueProcessor<
ReadonlyArray<FontVariant> | string
// @ts-expect-error Implementation will be fixed in the next PR
> = (value) => value.join(', ');