Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Use numberFormatter.
var numberFormatter = Globalize.numberFormatter({minimumFractionDigits: 0, maximumFractionDigits: 10});
console.log(numberFormatter(Math.PI));
// Use formatNumber.
console.log(Globalize.formatNumber(12345.6789));
// Use parseNumber.
console.log(Globalize.parseNumber("12345.6789"));
/**
* Currency
*/
// Use currencyFormatter.
var currencyFormatter = Globalize.currencyFormatter("EUR");
console.log(currencyFormatter(9.99));
// Use formatCurrency.
console.log(Globalize.formatCurrency(69900, "USD"));
/**
* Message
*/
// Use pluralGenerator.
var pluralGenerator = Globalize.pluralGenerator({type: "ordinal"});
console.log(pluralGenerator(2));
// Use plural.
console.log(Globalize.plural(12345.6789));
var Globalize = require( "globalize" );
var startTime = new Date();
// Standalone table.
var numberFormatter = Globalize.numberFormatter({ maximumFractionDigits: 2 });
document.getElementById( "number" ).textContent = numberFormatter( 12345.6789 );
var numberCompactFormatter = Globalize.numberFormatter({
compact: "short",
minimumSignificantDigits: 1,
maximumSignificantDigits: 3
});
document.getElementById( "number-compact" ).textContent = numberCompactFormatter( 12345.6789 );
var currencyFormatter = Globalize.currencyFormatter( "USD" );
document.getElementById( "currency" ).textContent = currencyFormatter( 69900 );
var dateFormatter = Globalize.dateFormatter({ datetime: "medium" });
document.getElementById( "date" ).textContent = dateFormatter( new Date() );
var dateWithTimeZoneFormatter = Globalize.dateFormatter({
datetime: "full",
timeZone: "America/Sao_Paulo"
});
document.getElementById( "date-time-zone" ).textContent = dateWithTimeZoneFormatter( new Date() );
var _dateToPartsFormatter = Globalize.dateToPartsFormatter({ datetime: "medium" });
var dateToPartsFormatter = function( value ) {
return _dateToPartsFormatter( value, {
datetime: "medium"
}).map(function( part ) {