Format
Utility function to format text, mobile number, amount, masking and etc.
Capitalize
Code EditorCopyimport { formatCapitalizeWords } from '@erudilabs/alma'
formatCapitalizeWords(value: string)
Code EditorCopyformatCapitalizeWords("erudifi bukas danacita")
The result should be in below
Erudifi Bukas Danacita
Percentage
Code EditorCopyimport { formatPercentage } from '@erudilabs/alma'
formatPercentage(value: string | number, { toFixed: number })
Code EditorCopyformatPercentage("0.75")
The result should be in below
75%
Code EditorCopyformatPercentage("0.75", { toFixed: 2 })
The result should be in below
75.00%
Asterisk
Code EditorCopyimport { maskingAsterisk } from '@erudilabs/alma'
maskingAsterisk(value: string)
Code EditorCopymaskingAsterisk("+6282312341234")
The result should be in below
+62********234
Mobile Number
Code EditorCopyimport { formatMobileNumber } from '@erudilabs/alma'
formatMobileNumber(value: string, { options: countryCode: PH | ID })
Code EditorCopyformatMobileNumber("+6200000000000", { countryCode: 'ID' })
The result should be in below
+62 00 000 000 000
Code EditorCopyformatMobileNumber("+630000000000", { countryCode: 'PH' })
The result should be in below
+63 000 000 0000
Format Options
Code EditorCopyimport { formatOptions } from '@erudilabs/alma'
const resultApi = [{ id: 1, name: 'Danacita', country: 'indonesia' }, { id: 2, name: 'Bukas', country: 'philipines' }]
Code EditorCopyformatOptions(resultApi, { label:'name', value:'country' })
The result should be in below
[{ label: 'Danacita', value: 'indonesia' }, { label: 'Bukas', value: 'philipines' }]
You can sort by alphabetical
Code EditorCopyformatOptions(resultApi, { label:'name', value:'country', sort: true })
The result should be in below
[{ label: 'Bukas', value: 'philipines' }, { label: 'Danacita', value: 'indonesia' }]