Repository: chartjs/Chart.js
File: src/helpers/helpers.options.ts (TypeScript)

Code before:
  for (const prop of keys) {
    ret[prop] = numberOrZero(read(prop) as number);
  }
  return ret;
}

/**
 * Converts the given value into a TRBL object.
 * @param value - If a number, set the value to all TRBL component,
 *  else, if an object, use defined properties and sets undefined ones to 0.
 *  x / y are shorthands for same value for left/right and top/bottom.
 * @returns The padding values (top, right, bottom, left)
 * @since 3.0.0
 */
export function toTRBL(value: number | Partial<TRBL>): TRBL | ChartArea {
  return _readValueToProps(value, {top: 'y', right: 'x', bottom: 'y', left: 'x'});
}

/**
 * Converts the given value into a TRBL corners object (similar with css border-radius).
 * @param value - If a number, set the value to all TRBL corner components,
 *  else, if an object, use defined properties and sets undefined ones to 0.
 * @returns The TRBL corner values (topLeft, topRight, bottomLeft, bottomRight)
 * @since 3.0.0
 */
export function toTRBLCorners(value: number | Partial<TRBL>): TRBLCorners {
  return _readValueToProps(value, ['topLeft', 'topRight', 'bottomLeft', 'bottomRight']);
}

/**
 * Converts the given value into a padding object with pre-computed width/height.
 * @param value - If a number, set the value to all TRBL component,
 *  else, if an object, use defined properties and sets undefined ones to 0.
 *  x / y are shorthands for same value for left/right and top/bottom.
 * @returns The padding values (top, right, bottom, left, width, height)
 * @since 2.7.0
 */
export function toPadding(value?: number | Partial<TRBL>): ChartArea {
  const obj: ChartArea = {...toTRBL(value), width: 0, height: 0};

  obj.width = obj.left + obj.right;
  obj.height = obj.top + obj.bottom;

  return obj;
}

export interface CanvasFontSpec extends FontSpec {
  string: string;
}

/**

Review comment (suggestion):
value can contain 'topLeft', 'topRight', 'bottomLeft', 'bottomRight' props, but types does not represents it

Code after:
    : () => value;

  for (const prop of keys) {
    ret[prop] = numberOrZero(read(prop));
  }
  return ret;
}

/**
 * Converts the given value into a TRBL object.
 * @param value - If a number, set the value to all TRBL component,
 *  else, if an object, use defined properties and sets undefined ones to 0.
 *  x / y are shorthands for same value for left/right and top/bottom.
 * @returns The padding values (top, right, bottom, left)
 * @since 3.0.0
 */
export function toTRBL(value: number | TRBL | Point) {
  return _readValueToProps(value, {top: 'y', right: 'x', bottom: 'y', left: 'x'});
}

/**
 * Converts the given value into a TRBL corners object (similar with css border-radius).
 * @param value - If a number, set the value to all TRBL corner components,
 *  else, if an object, use defined properties and sets undefined ones to 0.
 * @returns The TRBL corner values (topLeft, topRight, bottomLeft, bottomRight)
 * @since 3.0.0
 */
export function toTRBLCorners(value: number | TRBLCorners) {
  return _readValueToProps(value, ['topLeft', 'topRight', 'bottomLeft', 'bottomRight']);
}

/**
 * Converts the given value into a padding object with pre-computed width/height.
 * @param value - If a number, set the value to all TRBL component,
 *  else, if an object, use defined properties and sets undefined ones to 0.
 *  x / y are shorthands for same value for left/right and top/bottom.
 * @returns The padding values (top, right, bottom, left, width, height)
 * @since 2.7.0
 */
export function toPadding(value?: number | TRBL): ChartArea {
  const obj = toTRBL(value) as ChartArea;

  obj.width = obj.left + obj.right;
  obj.height = obj.top + obj.bottom;

  return obj;
}

export interface CanvasFontSpec extends FontSpec {
  string: string;
}