15 lines
280 B
TypeScript
15 lines
280 B
TypeScript
const pad = (
|
|
value: unknown,
|
|
{
|
|
fillString = '0',
|
|
maxLength = 2,
|
|
which = 'Start',
|
|
}: {
|
|
fillString?: string;
|
|
maxLength?: number;
|
|
which?: 'Start' | 'End';
|
|
} = {},
|
|
): string => String(value)[`pad${which}`](maxLength, fillString);
|
|
|
|
export default pad;
|