Skip to content

Instantly share code, notes, and snippets.

@LFTroya
Created August 9, 2019 14:20
Show Gist options
  • Save LFTroya/a4cf8fd61f4de042239b5867780636de to your computer and use it in GitHub Desktop.
Save LFTroya/a4cf8fd61f4de042239b5867780636de to your computer and use it in GitHub Desktop.
let number = '1234568,65';
number = number.replace(/,/g, '.');
const parsedNumber = numeral(number);
console.log(number);
console.log('Format', parsedNumber.format('0,0.00'))
console.log('Value', parsedNumber.value())
const numeral = require("numeral");
numeral.register('locale', 'cop', {
delimiters: {
thousands: ',',
decimal: '.'
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
ordinal : function (number) {
return '';
},
currency: {
symbol: '$'
}
});
// switch between locales
numeral.locale('cop');
exports = {numeral}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment