💬 (Money) Add withPadEnd parameter

This commit is contained in:
Julien Calixte
2019-10-12 13:56:43 +02:00
parent 59fd5578e0
commit 8e23b69038
3 changed files with 35 additions and 8 deletions

View File

@@ -18,13 +18,18 @@ export const money = (
export const moneypad = (
value: number,
currency: ICurrency | null | undefined
currency?: ICurrency | null,
withPadEnd: boolean = true
): string => {
const m = money(value, currency)
const s: string[] = m.split('\xa0')
const cur: string | undefined = s.pop()
return `${s.join('\xa0')}\xa0${(cur || '').padEnd(3, '\xa0')}`
const result = `${s.join('\xa0')}\xa0${cur || ''}`
if (withPadEnd) {
return result.padEnd(3, '\xa0')
}
return result
}
export const date = (value: string, country: string = 'fr-FR') => {