UNPKG
tn-numpad
Version:
latest (2.1.2)
2.1.2
2.1.1
2.1.0
2.0.1
2.0.0
1.0.1
1.0.0
Leading zeroes to a number
tn-numpad
/
src
/
core
/
fractional.ts
12 lines
(8 loc)
•
268 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
export
default
function
(
num
:
number
,
toFixed
:
number
|
false
) {
let
numstr
:
string
if
(toFixed !==
false
) numstr = num.
toFixed
(toFixed)
else
numstr = num.
toString
()
let
frac = numstr.
split
(
'.'
)[
1
] frac = frac ?
`.
${frac}
`
:
''
return
frac }