Numeral.js: A javascript library for formatting and manipulating numbers

Numeral.js is a library aimed at number formatting, it works on Node.js and Browser Javascript. It is easy to use for formatting a number by using a .format(format) function. Numbers can be formatted to look like currency, percentages, times, or even plain old numbers with decimal places, thousands, and abbreviations. For internationalising application, Numeral.js also support language support formatting.

numeral.language('nl', {
	delimiters: {
		thousands: '.',
		decimal  : ','
	},
	abbreviations: {
		thousand : 'k',
		million  : 'mln',
		billion  : 'mrd',
		trillion : 'bln'
	},
	ordinal : function (number) {
		var remainder = number % 100;
		return (number !== 0 && remainder <= 1 || remainder === 8 || remainder >= 20) ? 'ste' : 'de';
	},
	currency: {
		symbol: '€ '
	}
});
 
numeral.language('nl');
 
var string = numeral(1000).format('0,0.00');

Leave a Reply