MCPcopy
hub / github.com/chartjs/Chart.js / _readValueToProps

Function _readValueToProps

src/helpers/helpers.options.ts:51–65  ·  view source on GitHub ↗
(value: number | Record<string, number>, props: string[] | Record<string, string>)

Source from the content-addressed store, hash-verified

49export function _readValueToProps<K extends string>(value: number | Record<K, number>, props: K[]): Record<K, number>;
50export function _readValueToProps<K extends string, T extends string>(value: number | Record<K & T, number>, props: Record<T, K>): Record<T, number>;
51export 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.

Callers 3

toTRBLFunction · 0.85
toTRBLCornersFunction · 0.85
toRadiusCornersFunction · 0.85

Calls 3

isObjectFunction · 0.85
valueOrDefaultFunction · 0.85
numberOrZeroFunction · 0.85

Tested by

no test coverage detected