(value: number | Record<string, number>, props: string[] | Record<string, string>)
| 49 | export function _readValueToProps<K extends string>(value: number | Record<K, number>, props: K[]): Record<K, number>; |
| 50 | export function _readValueToProps<K extends string, T extends string>(value: number | Record<K & T, number>, props: Record<T, K>): Record<T, number>; |
| 51 | export function _readValueToProps(value: number | Record<string, number>, props: string[] | Record<string, string>) { |
| 52 | const ret = {}; |
| 53 | const objProps = isObject(props); |
| 54 | const keys = objProps ? Object.keys(props) : props; |
| 55 | const read = isObject(value) |
| 56 | ? objProps |
| 57 | ? prop => valueOrDefault(value[prop], value[props[prop]]) |
| 58 | : prop => value[prop] |
| 59 | : () => value; |
| 60 | |
| 61 | for (const prop of keys) { |
| 62 | ret[prop] = numberOrZero(read(prop)); |
| 63 | } |
| 64 | return ret; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Converts the given value into a TRBL object. |
no test coverage detected