renovate/lib/util/number.ts
2023-09-06 13:35:52 +00:00

12 lines
276 B
TypeScript

/**
* Coerces a value to a number with optional default value.
* @param val the value to coerce
* @param def default value
* @returns cocerced value
*/
export function coerceNumber(
val: number | null | undefined,
def?: number
): number {
return val ?? def ?? 0;
}