Socket
Socket
Sign inDemoInstall

globalize

Package Overview
Dependencies
Maintainers
3
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

globalize - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0-alpha.0

doc/blog-post/2017-07-xx-1.3.0-announcement.md

6

dist/globalize-runtime.js
/**
* Globalize Runtime v1.3.0
* Globalize Runtime v1.4.0-alpha.0
*

@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize

*
* Date: 2017-07-03T21:37Z
* Date: 2017-10-05T18:50Z
*/
/*!
* Globalize Runtime v1.3.0 2017-07-03T21:37Z Released under the MIT license
* Globalize Runtime v1.4.0-alpha.0 2017-10-05T18:50Z Released under the MIT license
* http://git.io/TrdQbw

@@ -16,0 +16,0 @@ */

/**
* Globalize Runtime v1.3.0
* Globalize Runtime v1.4.0-alpha.0
*

@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize

*
* Date: 2017-07-03T21:37Z
* Date: 2017-10-05T18:50Z
*/
/*!
* Globalize Runtime v1.3.0 2017-07-03T21:37Z Released under the MIT license
* Globalize Runtime v1.4.0-alpha.0 2017-10-05T18:50Z Released under the MIT license
* http://git.io/TrdQbw

@@ -16,0 +16,0 @@ */

/**
* Globalize Runtime v1.3.0
* Globalize Runtime v1.4.0-alpha.0
*

@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize

*
* Date: 2017-07-03T21:37Z
* Date: 2017-10-05T18:50Z
*/
/*!
* Globalize Runtime v1.3.0 2017-07-03T21:37Z Released under the MIT license
* Globalize Runtime v1.4.0-alpha.0 2017-10-05T18:50Z Released under the MIT license
* http://git.io/TrdQbw

@@ -16,0 +16,0 @@ */

/**
* Globalize Runtime v1.3.0
* Globalize Runtime v1.4.0-alpha.0
*

@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize

*
* Date: 2017-07-03T21:37Z
* Date: 2017-10-05T18:50Z
*/
/*!
* Globalize Runtime v1.3.0 2017-07-03T21:37Z Released under the MIT license
* Globalize Runtime v1.4.0-alpha.0 2017-10-05T18:50Z Released under the MIT license
* http://git.io/TrdQbw

@@ -16,0 +16,0 @@ */

/**
* Globalize Runtime v1.3.0
* Globalize Runtime v1.4.0-alpha.0
*

@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize

*
* Date: 2017-07-03T21:37Z
* Date: 2017-10-05T18:50Z
*/
/*!
* Globalize Runtime v1.3.0 2017-07-03T21:37Z Released under the MIT license
* Globalize Runtime v1.4.0-alpha.0 2017-10-05T18:50Z Released under the MIT license
* http://git.io/TrdQbw

@@ -72,2 +72,23 @@ */

/**
* EBNF representation:
*
* compact_pattern_re = prefix?
* number_pattern_re
* suffix?
*
* number_pattern_re = 0+
*
* Regexp groups:
*
* 0: compact_pattern_re
* 1: prefix
* 2: number_pattern_re (the number pattern to use in compact mode)
* 3: suffix
*/
var numberCompactPatternRe = ( /^([^0]*)(0+)([^0]*)$/ );
/**
* goupingSeparator( number, primaryGroupingSize, secondaryGroupingSize )

@@ -261,2 +282,52 @@ *

/**
* EBNF representation:
*
* number_pattern_re = prefix?
* padding?
* (integer_fraction_pattern | significant_pattern)
* scientific_notation?
* suffix?
*
* prefix = non_number_stuff
*
* padding = "*" regexp(.)
*
* integer_fraction_pattern = integer_pattern
* fraction_pattern?
*
* integer_pattern = regexp([#,]*[0,]*0+)
*
* fraction_pattern = "." regexp(0*[0-9]*#*)
*
* significant_pattern = regexp([#,]*@+#*)
*
* scientific_notation = regexp(E\+?0+)
*
* suffix = non_number_stuff
*
* non_number_stuff = regexp(('[^']+'|''|[^*#@0,.E])*)
*
*
* Regexp groups:
*
* 0: number_pattern_re
* 1: prefix
* 2: -
* 3: -
* 4: padding
* 5: (integer_fraction_pattern | significant_pattern)
* 6: integer_fraction_pattern
* 7: integer_pattern
* 8: fraction_pattern
* 9: significant_pattern
* 10: scientific_notation
* 11: suffix
* 12: -
*/
var numberPatternRe = ( /^(('([^']|'')*'|[^*#@0,.E])*)(\*.)?((([#,]*[0,]*0+)(\.0*[0-9]*#*)?)|([#,]*@+#*))(E\+?0+)?(('[^']+'|''|[^*#@0,.E])*)$/ );
/**
* removeLiteralQuotes( string )

@@ -293,7 +364,7 @@ *

*/
var numberFormat = function( number, properties ) {
var infinitySymbol, maximumFractionDigits, maximumSignificantDigits, minimumFractionDigits,
minimumIntegerDigits, minimumSignificantDigits, nanSymbol, nuDigitsMap, padding, prefix,
primaryGroupingSize, pattern, ret, round, roundIncrement, secondaryGroupingSize, suffix,
symbolMap;
var numberFormat = function( number, properties, pluralGenerator ) {
var compactMap, infinitySymbol, maximumFractionDigits, maximumSignificantDigits,
minimumFractionDigits, minimumIntegerDigits, minimumSignificantDigits, nanSymbol, nuDigitsMap,
padding, prefix, primaryGroupingSize, pattern, ret, round, roundIncrement,
secondaryGroupingSize, suffix, symbolMap;

@@ -314,2 +385,3 @@ padding = properties[ 1 ];

nuDigitsMap = properties[ 19 ];
compactMap = properties[ 20 ];

@@ -336,4 +408,2 @@ // NaN

ret = prefix;
// Percent

@@ -348,2 +418,23 @@ if ( pattern.indexOf( "%" ) !== -1 ) {

var compactPattern, compactDigits, compactProperties, divisor, numberExponent, pluralForm;
// Compact mode: initial number digit processing
if ( compactMap ) {
numberExponent = Math.floor( number ).toString().length - 1;
numberExponent = Math.min( numberExponent, compactMap.maxExponent );
// Use default plural form to perform initial decimal shift
if ( numberExponent >= 3 ) {
compactPattern = compactMap[ numberExponent ] && compactMap[ numberExponent ].other;
}
if ( compactPattern === "0" ) {
compactPattern = null;
} else if ( compactPattern ) {
compactDigits = compactPattern.split( "0" ).length - 1;
divisor = numberExponent - ( compactDigits - 1 );
number = number / Math.pow( 10, divisor );
}
}
// Significant digit format

@@ -360,2 +451,16 @@ if ( !isNaN( minimumSignificantDigits * maximumSignificantDigits ) ) {

// Compact mode: apply formatting
if ( compactMap && compactPattern ) {
// Get plural form after possible roundings
pluralForm = pluralGenerator ? pluralGenerator( +number ) : "other";
compactPattern = compactMap[ numberExponent ][ pluralForm ] || compactPattern;
compactProperties = compactPattern.match( numberCompactPatternRe );
// update prefix/suffix with compact prefix/suffix
prefix += compactProperties[ 1 ];
suffix = compactProperties[ 3 ] + suffix;
}
// Remove the possible number minus sign

@@ -370,2 +475,4 @@ number = number.replace( /^-/, "" );

ret = prefix;
ret += number;

@@ -407,3 +514,3 @@

var numberFormatterFn = function( properties ) {
var numberFormatterFn = function( properties, pluralGenerator ) {
return function numberFormatter( value ) {

@@ -413,3 +520,3 @@ validateParameterPresence( value, "value" );

return numberFormat( value, properties );
return numberFormat( value, properties, pluralGenerator );
};

@@ -416,0 +523,0 @@ };

/**
* Globalize Runtime v1.3.0
* Globalize Runtime v1.4.0-alpha.0
*

@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize

*
* Date: 2017-07-03T21:37Z
* Date: 2017-10-05T18:50Z
*/
/*!
* Globalize Runtime v1.3.0 2017-07-03T21:37Z Released under the MIT license
* Globalize Runtime v1.4.0-alpha.0 2017-10-05T18:50Z Released under the MIT license
* http://git.io/TrdQbw

@@ -16,0 +16,0 @@ */

/**
* Globalize Runtime v1.3.0
* Globalize Runtime v1.4.0-alpha.0
*

@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize

*
* Date: 2017-07-03T21:37Z
* Date: 2017-10-05T18:50Z
*/
/*!
* Globalize Runtime v1.3.0 2017-07-03T21:37Z Released under the MIT license
* Globalize Runtime v1.4.0-alpha.0 2017-10-05T18:50Z Released under the MIT license
* http://git.io/TrdQbw

@@ -16,0 +16,0 @@ */

/**
* Globalize Runtime v1.3.0
* Globalize Runtime v1.4.0-alpha.0
*

@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize

*
* Date: 2017-07-03T21:37Z
* Date: 2017-10-05T18:50Z
*/
/*!
* Globalize Runtime v1.3.0 2017-07-03T21:37Z Released under the MIT license
* Globalize Runtime v1.4.0-alpha.0 2017-10-05T18:50Z Released under the MIT license
* http://git.io/TrdQbw

@@ -16,0 +16,0 @@ */

/**
* Globalize v1.3.0
* Globalize v1.4.0-alpha.0
*

@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize

*
* Date: 2017-07-03T21:37Z
* Date: 2017-10-05T18:50Z
*/
/*!
* Globalize v1.3.0 2017-07-03T21:37Z Released under the MIT license
* Globalize v1.4.0-alpha.0 2017-10-05T18:50Z Released under the MIT license
* http://git.io/TrdQbw

@@ -16,0 +16,0 @@ */

/*!
* Globalize v1.3.0
* Globalize v1.4.0-alpha.0
*

@@ -10,3 +10,3 @@ * http://github.com/jquery/globalize

*
* Date: 2017-07-03T21:37Z
* Date: 2017-10-05T18:50Z
*/

@@ -13,0 +13,0 @@ (function( root, factory ) {

/**
* Globalize v1.3.0
* Globalize v1.4.0-alpha.0
*

@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize

*
* Date: 2017-07-03T21:37Z
* Date: 2017-10-05T18:50Z
*/
/*!
* Globalize v1.3.0 2017-07-03T21:37Z Released under the MIT license
* Globalize v1.4.0-alpha.0 2017-10-05T18:50Z Released under the MIT license
* http://git.io/TrdQbw

@@ -16,0 +16,0 @@ */

/**
* Globalize v1.3.0
* Globalize v1.4.0-alpha.0
*

@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize

*
* Date: 2017-07-03T21:37Z
* Date: 2017-10-05T18:50Z
*/
/*!
* Globalize v1.3.0 2017-07-03T21:37Z Released under the MIT license
* Globalize v1.4.0-alpha.0 2017-10-05T18:50Z Released under the MIT license
* http://git.io/TrdQbw

@@ -86,2 +86,23 @@ */

/**
* EBNF representation:
*
* compact_pattern_re = prefix?
* number_pattern_re
* suffix?
*
* number_pattern_re = 0+
*
* Regexp groups:
*
* 0: compact_pattern_re
* 1: prefix
* 2: number_pattern_re (the number pattern to use in compact mode)
* 3: suffix
*/
var numberCompactPatternRe = ( /^([^0]*)(0+)([^0]*)$/ );
/**
* goupingSeparator( number, primaryGroupingSize, secondaryGroupingSize )

@@ -275,2 +296,52 @@ *

/**
* EBNF representation:
*
* number_pattern_re = prefix?
* padding?
* (integer_fraction_pattern | significant_pattern)
* scientific_notation?
* suffix?
*
* prefix = non_number_stuff
*
* padding = "*" regexp(.)
*
* integer_fraction_pattern = integer_pattern
* fraction_pattern?
*
* integer_pattern = regexp([#,]*[0,]*0+)
*
* fraction_pattern = "." regexp(0*[0-9]*#*)
*
* significant_pattern = regexp([#,]*@+#*)
*
* scientific_notation = regexp(E\+?0+)
*
* suffix = non_number_stuff
*
* non_number_stuff = regexp(('[^']+'|''|[^*#@0,.E])*)
*
*
* Regexp groups:
*
* 0: number_pattern_re
* 1: prefix
* 2: -
* 3: -
* 4: padding
* 5: (integer_fraction_pattern | significant_pattern)
* 6: integer_fraction_pattern
* 7: integer_pattern
* 8: fraction_pattern
* 9: significant_pattern
* 10: scientific_notation
* 11: suffix
* 12: -
*/
var numberPatternRe = ( /^(('([^']|'')*'|[^*#@0,.E])*)(\*.)?((([#,]*[0,]*0+)(\.0*[0-9]*#*)?)|([#,]*@+#*))(E\+?0+)?(('[^']+'|''|[^*#@0,.E])*)$/ );
/**
* removeLiteralQuotes( string )

@@ -307,7 +378,7 @@ *

*/
var numberFormat = function( number, properties ) {
var infinitySymbol, maximumFractionDigits, maximumSignificantDigits, minimumFractionDigits,
minimumIntegerDigits, minimumSignificantDigits, nanSymbol, nuDigitsMap, padding, prefix,
primaryGroupingSize, pattern, ret, round, roundIncrement, secondaryGroupingSize, suffix,
symbolMap;
var numberFormat = function( number, properties, pluralGenerator ) {
var compactMap, infinitySymbol, maximumFractionDigits, maximumSignificantDigits,
minimumFractionDigits, minimumIntegerDigits, minimumSignificantDigits, nanSymbol, nuDigitsMap,
padding, prefix, primaryGroupingSize, pattern, ret, round, roundIncrement,
secondaryGroupingSize, suffix, symbolMap;

@@ -328,2 +399,3 @@ padding = properties[ 1 ];

nuDigitsMap = properties[ 19 ];
compactMap = properties[ 20 ];

@@ -350,4 +422,2 @@ // NaN

ret = prefix;
// Percent

@@ -362,2 +432,23 @@ if ( pattern.indexOf( "%" ) !== -1 ) {

var compactPattern, compactDigits, compactProperties, divisor, numberExponent, pluralForm;
// Compact mode: initial number digit processing
if ( compactMap ) {
numberExponent = Math.floor( number ).toString().length - 1;
numberExponent = Math.min( numberExponent, compactMap.maxExponent );
// Use default plural form to perform initial decimal shift
if ( numberExponent >= 3 ) {
compactPattern = compactMap[ numberExponent ] && compactMap[ numberExponent ].other;
}
if ( compactPattern === "0" ) {
compactPattern = null;
} else if ( compactPattern ) {
compactDigits = compactPattern.split( "0" ).length - 1;
divisor = numberExponent - ( compactDigits - 1 );
number = number / Math.pow( 10, divisor );
}
}
// Significant digit format

@@ -374,2 +465,16 @@ if ( !isNaN( minimumSignificantDigits * maximumSignificantDigits ) ) {

// Compact mode: apply formatting
if ( compactMap && compactPattern ) {
// Get plural form after possible roundings
pluralForm = pluralGenerator ? pluralGenerator( +number ) : "other";
compactPattern = compactMap[ numberExponent ][ pluralForm ] || compactPattern;
compactProperties = compactPattern.match( numberCompactPatternRe );
// update prefix/suffix with compact prefix/suffix
prefix += compactProperties[ 1 ];
suffix = compactProperties[ 3 ] + suffix;
}
// Remove the possible number minus sign

@@ -384,2 +489,4 @@ number = number.replace( /^-/, "" );

ret = prefix;
ret += number;

@@ -421,3 +528,3 @@

var numberFormatterFn = function( properties ) {
var numberFormatterFn = function( properties, pluralGenerator ) {
return function numberFormatter( value ) {

@@ -427,3 +534,3 @@ validateParameterPresence( value, "value" );

return numberFormat( value, properties );
return numberFormat( value, properties, pluralGenerator );
};

@@ -468,2 +575,37 @@ };

/**
* Compact( name, cldr )
*
* @compactType [String] Compact mode, `short` or `long`.
*
* @cldr [Cldr instance].
*
* Return the localized compact map for the given compact mode.
*/
var numberCompact = function( compactType, cldr ) {
var maxExponent = 0;
var object = cldr.main([
"numbers/decimalFormats-numberSystem-" + numberNumberingSystem( cldr ),
compactType,
"decimalFormat"
]);
object = Object.keys( object ).reduce(function( newObject, compactKey ) {
var numberExponent = compactKey.split( "0" ).length - 1;
var pluralForm = compactKey.split( "-" )[ 2 ];
newObject[ numberExponent ] = newObject[ numberExponent ] || {};
newObject[ numberExponent ][ pluralForm ] = object[ compactKey ];
maxExponent = Math.max( numberExponent, maxExponent );
return newObject;
}, {});
object.maxExponent = maxExponent;
return object;
};
/**
* nuMap( cldr )

@@ -496,52 +638,2 @@ *

/**
* EBNF representation:
*
* number_pattern_re = prefix?
* padding?
* (integer_fraction_pattern | significant_pattern)
* scientific_notation?
* suffix?
*
* prefix = non_number_stuff
*
* padding = "*" regexp(.)
*
* integer_fraction_pattern = integer_pattern
* fraction_pattern?
*
* integer_pattern = regexp([#,]*[0,]*0+)
*
* fraction_pattern = "." regexp(0*[0-9]*#*)
*
* significant_pattern = regexp([#,]*@+#*)
*
* scientific_notation = regexp(E\+?0+)
*
* suffix = non_number_stuff
*
* non_number_stuff = regexp(('[^']+'|''|[^*#@0,.E])*)
*
*
* Regexp groups:
*
* 0: number_pattern_re
* 1: prefix
* 2: -
* 3: -
* 4: padding
* 5: (integer_fraction_pattern | significant_pattern)
* 6: integer_fraction_pattern
* 7: integer_pattern
* 8: fraction_pattern
* 9: significant_pattern
* 10: scientific_notation
* 11: suffix
* 12: -
*/
var numberPatternRe = ( /^(('([^']|'')*'|[^*#@0,.E])*)(\*.)?((([#,]*[0,]*0+)(\.0*[0-9]*#*)?)|([#,]*@+#*))(E\+?0+)?(('[^']+'|''|[^*#@0,.E])*)$/ );
/**
* format( number, pattern )

@@ -885,2 +977,18 @@ *

if ( options.compact ) {
// The compact digits number pattern is always `0+`, so override the following properties.
// Note: minimumIntegerDigits would actually range from `0` to `000` based on the scale of
// the value to be formatted, though we're always using 1 as a simplification, because the
// number won't be zero-padded since we chose the right format based on the scale, i.e.,
// we'd never see something like `003M` anyway.
properties[ 2 ] = negativeSuffix[ 2 ] = 1; // minimumIntegerDigits
properties[ 3 ] = negativeSuffix[ 3 ] = 0; // minimumFractionDigits
properties[ 4 ] = negativeSuffix[ 4 ] = 0; // maximumFractionDigits
properties[ 5 ] = negativeSuffix[ 5 ] = // minimumSignificantDigits &
properties[ 6 ] = negativeSuffix[ 6 ] = undefined ; // maximumSignificantDigits
properties[20] = numberCompact( options.compact, cldr );
}
getOptions( "minimumIntegerDigits", 2 );

@@ -921,2 +1029,3 @@ getOptions( "minimumFractionDigits", 3 );

// 19: @nuDigitsMap [Array] Digits map if numbering system is different than `latn`.
// 20: @compactMap [Object] Map of per-digit-count format patterns for specified compact mode.
return properties;

@@ -1386,3 +1495,3 @@ };

Globalize.prototype.numberFormatter = function( options ) {
var args, cldr, pattern, properties, returnFn;
var args, cldr, pattern, pluralGenerator, properties, returnFn;

@@ -1412,6 +1521,11 @@ validateParameterTypePlainObject( options, "options" );

returnFn = numberFormatterFn( properties );
if ( options.compact ) {
pluralGenerator = this.pluralGenerator();
returnFn = numberFormatterFn( properties, pluralGenerator );
runtimeBind( args, cldr, returnFn, [ properties, pluralGenerator ] );
} else {
returnFn = numberFormatterFn( properties );
runtimeBind( args, cldr, returnFn, [ properties ] );
}
runtimeBind( args, cldr, returnFn, [ properties ] );
return returnFn;

@@ -1418,0 +1532,0 @@ };

/**
* Globalize v1.3.0
* Globalize v1.4.0-alpha.0
*

@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize

*
* Date: 2017-07-03T21:37Z
* Date: 2017-10-05T18:50Z
*/
/*!
* Globalize v1.3.0 2017-07-03T21:37Z Released under the MIT license
* Globalize v1.4.0-alpha.0 2017-10-05T18:50Z Released under the MIT license
* http://git.io/TrdQbw

@@ -16,0 +16,0 @@ */

/**
* Globalize v1.3.0
* Globalize v1.4.0-alpha.0
*

@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize

*
* Date: 2017-07-03T21:37Z
* Date: 2017-10-05T18:50Z
*/
/*!
* Globalize v1.3.0 2017-07-03T21:37Z Released under the MIT license
* Globalize v1.4.0-alpha.0 2017-10-05T18:50Z Released under the MIT license
* http://git.io/TrdQbw

@@ -16,0 +16,0 @@ */

/**
* Globalize v1.3.0
* Globalize v1.4.0-alpha.0
*

@@ -10,6 +10,6 @@ * http://github.com/jquery/globalize

*
* Date: 2017-07-03T21:37Z
* Date: 2017-10-05T18:50Z
*/
/*!
* Globalize v1.3.0 2017-07-03T21:37Z Released under the MIT license
* Globalize v1.4.0-alpha.0 2017-10-05T18:50Z Released under the MIT license
* http://git.io/TrdQbw

@@ -16,0 +16,0 @@ */

/*!
* Globalize v1.3.0
* Globalize v1.4.0-alpha.0
*

@@ -10,3 +10,3 @@ * http://github.com/jquery/globalize

*
* Date: 2017-07-03T21:37Z
* Date: 2017-10-05T18:50Z
*/

@@ -13,0 +13,0 @@

@@ -23,2 +23,4 @@ ## .currencyFormatter( currency [, options] ) ➜ function( value )

#### Static Formatter
Prior to using any currency methods, you must load `cldr/main/{locale}/currencies.json`, `cldr/supplemental/currencyData.json`, and the CLDR content required by the number module. If using plural messages, you also must load the CLDR content required by the plural module. Read [CLDR content][] if you need more information.

@@ -41,2 +43,4 @@

#### Instance Formatter
You can use the instance method `.currencyFormatter()`, which uses the instance locale.

@@ -67,2 +71,4 @@

#### Configuring style
For the accounting variation of the symbol format, use `style: "accounting"`.

@@ -115,2 +121,4 @@

#### Configuring inherited number options
Override the number of digits, grouping separators, rounding function or any other [`.numberFormatter()` options](../number/number-formatter.md).

@@ -138,2 +146,33 @@

#### Formatting Compact Currencies
```js
var shortFormatter = Globalize( "en" ).currencyFormatter( "USD", {
compact: "short"
});
var longFormatter = Globalize( "en" ).currencyFormatter( "USD", {
compact: "long"
});
shortFormatter( 12830000000 );
// > "$13B"
longFormatter( 12830000000 );
// > "$13 billion"
```
The minimumSignificantDigits and maximumSignificantDigits options are specially useful to control the number of digits to display.
```js
Globalize( "en" ).formatCurrency( 12830000000, "USD", {
compact: "short",
minimumSignificantDigits: 3,
maximumSignificantDigits: 3
});
// > "$12.8B"
```
#### Performance Suggestion
For improved performance on iterations, first create the formatter. Then, reuse it on each loop.

@@ -140,0 +179,0 @@

@@ -24,3 +24,3 @@ ## .dateToPartsFormatter( [options] ) ➜ function( value )

{ type: "day", value: "17" },
{ type: "weekday", value "Monday" }
{ type: "weekday", value: "Monday" }
]

@@ -27,0 +27,0 @@ ```

@@ -33,2 +33,6 @@ ## .numberFormatter( [options] ) ➜ function( value )

#### options.compact
Optional. String `short` or `long` indicating which compact number format should be used to represent the number.
### Examples

@@ -143,2 +147,33 @@

#### Formatting Compact Numbers
Long numbers can be represented in a compact format, with `short` using abbreviated units and `long` using the full unit name.
```javascript
var shortFormatter = Globalize( "en" ).numberFormatter({
compact: "short"
});
var longFormatter = Globalize( "en" ).numberFormatter({
compact: "long"
});
shortFormatter( 27588910 );
// > "28M"
longFormatter( 27588910 );
// > "28 million"
```
The minimumSignificantDigits and maximumSignificantDigits options are specially useful to control the number of digits to display.
```js
Globalize( "en" ).formatNumber( 27588910, {
compact: "short",
minimumSignificantDigits: 3,
maximumSignificantDigits: 3
});
// > "27.6M"
```
#### Configuring Rounding

@@ -145,0 +180,0 @@

@@ -6,3 +6,3 @@ {

"globalize": "^1.3.0",
"globalize-webpack-plugin": ">=0.4.0 <1.0.0 || ^1.1.0",
"globalize-webpack-plugin": "0.4.x",
"html-webpack-plugin": "^1.1.0",

@@ -9,0 +9,0 @@ "iana-tz-data": "^2017.1.0",

{
"name": "globalize",
"version": "1.3.0",
"version": "1.4.0-alpha.0",
"description": "A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -463,2 +463,5 @@ # Globalize

// > "50%"
.numberFormatter({ compact: "short", maximumFractionDigits: 0 })( 14305 )
// > "14K"
```

@@ -465,0 +468,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc