globalizejs / globalize

A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
https://globalizejs.com
MIT License
4.8k stars 603 forks source link

Number formatting fails in strict mode #854

Closed ashubham closed 5 years ago

ashubham commented 5 years ago

When bundling for ES6 modules, the scripts are by default loaded in 'strict mode'. The number formatting in globalize seems to be violating strict mode in these lines:

https://github.com/globalizejs/globalize/blob/master/src/number/format-properties.js#L74

properties[ 2 ] = negativeSuffix[ 2 ] = 1; // minimumIntegerDigits
properties[ 3 ] = negativeSuffix[ 3 ] = 0; // minimumFractionDigits
properties[ 4 ] = negativeSuffix[ 4 ] = 0; // maximumFractionDigits

It fails with TypeError: Cannot create property '2' on string ''