UNPKG

tn-numpad

Version:

Leading zeroes to a number

11 lines (8 loc) 385 B
import integer from './core/integer' import fractional from './core/fractional' export const numpad = function (num: number, padlen: number, padstr: string = '0', toFixed: number | false = false) { const minus = num < 0 ? '-' : '' const intePart = integer(num, padlen, padstr, toFixed) const fracPart = fractional(num, toFixed) return minus + intePart + fracPart }