leading-zeroes
Version:
Pad a number with leading zeroes
12 lines (11 loc) • 453 B
TypeScript
/**
* Adds zeroes to the left of a number until its final length is `targetLength`.
*
* If `targetLength` is 0, returns an empty string. If `targetLength` is smaller
* than `num`'s existing length, returns `num` unchanged.
*
* @param num The number to pad
* @param targetLength The final desired number of digits
*/
declare const padWithLeadingZeroes: (num: string | number, targetLength: number) => string;
export default padWithLeadingZeroes;