Socket
Socket
Sign inDemoInstall

@formatjs/intl-unified-numberformat

Package Overview
Dependencies
Maintainers
2
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@formatjs/intl-unified-numberformat - npm Package Compare versions

Comparing version 2.1.5 to 2.1.6

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [2.1.6](https://github.com/formatjs/formatjs/compare/@formatjs/intl-unified-numberformat@2.1.5...@formatjs/intl-unified-numberformat@2.1.6) (2019-11-25)
### Bug Fixes
* **@formatjs/intl-unified-numberformat:** fix crash in numberformat ([e3115e2](https://github.com/formatjs/formatjs/commit/e3115e2462cb282edc98d4dbe71ffbf7eb3da5c8)), closes [#293](https://github.com/formatjs/formatjs/issues/293)
## [2.1.5](https://github.com/formatjs/formatjs/compare/@formatjs/intl-unified-numberformat@2.1.4...@formatjs/intl-unified-numberformat@2.1.5) (2019-11-23)

@@ -8,0 +19,0 @@

2

dist/core.d.ts

@@ -31,3 +31,3 @@ import { Unit } from './units-constants';

private patternData?;
constructor(locales: string | string[], options?: UnifiedNumberFormatOptions);
constructor(locales?: string | string[], options?: UnifiedNumberFormatOptions);
format(num: number): string;

@@ -34,0 +34,0 @@ formatToParts(num: number): Intl.NumberFormatPart[];

@@ -73,2 +73,3 @@ "use strict";

this.nf = new NativeNumberFormat(locales, __assign(__assign({}, coreOpts), { style: style === 'unit' ? 'decimal' : style }));
intl_utils_1.setInternalSlot(UnifiedNumberFormat.__INTERNAL_SLOT_MAP__, this, 'unit', undefined);
this.pl = new Intl.PluralRules(locales);

@@ -75,0 +76,0 @@ }

@@ -55,3 +55,3 @@ (function (global, factory) {

if (!slots) {
throw new TypeError('PluralRules has not been initialized');
throw new TypeError(pl + " InternalSlot has not been initialized");
}

@@ -414,2 +414,3 @@ return slots[field];

this.nf = new NativeNumberFormat(locales, __assign$1(__assign$1({}, coreOpts), { style: style === 'unit' ? 'decimal' : style }));
setInternalSlot(UnifiedNumberFormat.__INTERNAL_SLOT_MAP__, this, 'unit', undefined);
this.pl = new Intl.PluralRules(locales);

@@ -416,0 +417,0 @@ }

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).IntlUnifiedNumberFormat={})}(this,function(e){"use strict";function f(e){if(null==e)throw new TypeError("undefined/null cannot be converted to object");return Object(e)}function s(e,t,n,r,o){var a=e[t];if(void 0===a)return o;if("boolean"!==n&&"string"!==n)throw new TypeError("invalid type");if("boolean"===n&&(a=Boolean(a)),"string"===n&&(a=String(a)),void 0!==r&&!r.filter(function(e){return e==a}).length)throw new RangeError(a+" in not within "+r);return a}function p(e,t,n,r){e.get(t)||e.set(t,Object.create(null)),e.get(t)[n]=r}function o(e,t,n){var r=e.get(t);if(!r)throw new TypeError("PluralRules has not been initialized");return r[n]}function L(e){var t=Intl.getCanonicalLocales;return"function"==typeof t?t(e):Intl.NumberFormat.supportedLocalesOf(e||"")}function m(e,t,n){if(void 0===n&&(n=Error),!e)throw new n(t)}var r,t=(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),a=function(){return(a=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function v(e){var O=function(u){return function(e,t){for(var n={locale:""},r=0,o=t;r<o.length;r++){var a=o[r],i=a.replace(c,""),l=h(e,i);if(l)return n.locale=l,a!==i&&(n.extension=a.slice(i.length+1,a.length)),n}return n.locale=u(),n}}(e),g=function(u){return function(e,t){for(var n={locale:""},r=0,o=t;r<o.length;r++){var a=o[r],i=a.replace(c,""),l=h(e,i);if(l)return n.locale=l,a!==i&&(n.extension=a.slice(i.length+1,a.length)),n}return n.locale=u(),n}}(e);return function(e,t,n,r,o){for(var a,i=(a="lookup"===n.localeMatcher?O(e,t):g(e,t)).locale,l={locale:"",dataLocale:i},u="-u",c=0,f=r;c<f.length;c++){var s=f[c],p=o[i];m("object"==typeof p&&null!==p,"locale data "+s+" must be an object");var v=p[s];m(Array.isArray(v),"keyLocaleData must be an array");var h=v[0];m("string"==typeof h||null===h,"value must be string or null");var y="";if(a.extension){var _=w(a.extension,s);void 0!==_&&(""!==_?~v.indexOf(_)&&(y="-"+s+"-"+(h=_)):~_.indexOf("true")&&(h="true",y="-"+s))}if(s in n){var d=n[s];m("string"==typeof d||null==d,"optionsValue must be String, Undefined or Null"),~v.indexOf(d)&&d!==h&&(h=d,y="")}l[s]=h,u+=y}if(2<u.length){var b=i.indexOf("-x-");if(-1===b)i+=u;else i=i.slice(0,b)+u+i.slice(b,i.length);i=L(i)[0]}return l.locale=i,l}}function w(e,t){m(2===t.length,"key must have 2 elements");var n=e.length,r="-"+t+"-",o=e.indexOf(r);if(-1!==o){for(var a=o+4,i=a,l=a,u=!1;!u;){var c=e.indexOf("-",l);2===(-1===c?n-l:c-l)?u=!0:-1===c?(i=n,u=!0):l=(i=c)+1}return e.slice(a,i)}if(r="-"+t,-1!==(o=e.indexOf(r))&&o+3===n)return""}var c=/-u(?:-[0-9a-z]{2,8})+/gi;function h(e,t){for(var n=t;;){if(~e.indexOf(n))return n;var r=n.lastIndexOf("-");if(!~r)return;2<=r&&"-"===n[r-2]&&(r-=2),n=n.slice(0,r)}}function i(e,t){for(var n=[],r=0,o=t;r<o.length;r++){var a=h(e,o[r].replace(c,""));a&&n.push(a)}return n}var n,l=(n=Error,t(u,n),u);function u(){var e=null!==n&&n.apply(this,arguments)||this;return e.type="MISSING_LOCALE_DATA",e}var y=function(){return(y=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},_=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},d=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var a=arguments[t],i=0,l=a.length;i<l;i++,o++)r[o]=a[i];return r};var b=Intl.NumberFormat,O=(g.prototype.format=function(e){var t=this.nf.format(e);if(this.patternData){var n=o(g.__INTERNAL_SLOT_MAP__,this,"unitDisplay"),r=this.pl.select(e);return this.patternData[n]["one"===r?"one":"other"].replace("{0}",t)}return t},g.prototype.formatToParts=function(e){return this.nf.formatToParts(e)},g.prototype.resolvedOptions=function(){var e=this.nf.resolvedOptions(),t=o(g.__INTERNAL_SLOT_MAP__,this,"unit");return t&&(e.style="unit",e.unit=t,e.unitDisplay=o(g.__INTERNAL_SLOT_MAP__,this,"unitDisplay")),e},g.supportedLocalesOf=function(e,t){return function(e,t,n){return void 0!==n&&s(n=f(n),"localeMatcher","string",["lookup","best fit"],"best fit"),i(e,t)}(g.availableLocales,L(e),t)},g.__addLocaleData=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=function(t){Object.keys(d(t.availableLocales,Object.keys(t.aliases),Object.keys(t.parentLocales)).reduce(function(e,t){return e[t]=!0,e},{})).forEach(function(e){try{g.localeData[e]=function(e,t){var n=function(e,t,n){var r=[e];t[e]&&(e=t[e],r.push(e));var o=n[e];o&&r.push(o);for(var a=e.split("-"),i=a.length;1<i;i--)r.push(a.slice(0,i-1).join("-"));return r}(e,t.aliases,t.parentLocales),r=n.map(function(e){return t.data[e]}).filter(Boolean);if(!r.length)throw new l('Missing locale data for "'+e+'", lookup hierarchy: '+n.join(", "));return r.reverse(),r.reduce(function(e,t){return a(a({},e),t)},{})}(e,t)}catch(e){}})},r=0,o=e;r<o.length;r++)n(o[r]);g.availableLocales=Object.keys(g.localeData),g.__defaultLocale||(g.__defaultLocale=g.availableLocales[0])},g.getDefaultLocale=function(){return g.__defaultLocale},g.localeData={},g.availableLocales=[],g.__defaultLocale="en",g.relevantExtensionKeys=[],g.polyfilled=!0,g.__INTERNAL_SLOT_MAP__=new WeakMap,g);function g(e,t){void 0===t&&(t={});var n=(t=void 0===t?Object.create(null):f(t)).style,r=t.unit,o=(t.unitDisplay,_(t,["style","unit","unitDisplay"]));if("unit"===n){if(!r)throw new TypeError("Unit is required for `style: unit`");p(g.__INTERNAL_SLOT_MAP__,this,"unit",r),p(g.__INTERNAL_SLOT_MAP__,this,"unitDisplay",s(t,"unitDisplay","string",["long","short","narrow"],"short"));var a=L(e),i=Object.create(null),l=s(t,"localeMatcher","string",["best fit","lookup"],"best fit");i.localeMatcher=l;var u=g.localeData,c=v(g.getDefaultLocale)(g.availableLocales,a,i,g.relevantExtensionKeys,u);p(g.__INTERNAL_SLOT_MAP__,this,"locale",c.locale),this.patternData=u[c.locale][r]}this.nf=new b(e,y(y({},o),{style:"unit"===n?"decimal":n})),this.pl=new Intl.PluralRules(e)}e.UnifiedNumberFormat=O,e.isUnitSupported=function(e){try{new Intl.NumberFormat(void 0,{style:"unit",unit:e})}catch(e){return!1}return!0},Object.defineProperty(e,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).IntlUnifiedNumberFormat={})}(this,function(t){"use strict";function f(t){if(null==t)throw new TypeError("undefined/null cannot be converted to object");return Object(t)}function s(t,e,n,r,o){var a=t[e];if(void 0===a)return o;if("boolean"!==n&&"string"!==n)throw new TypeError("invalid type");if("boolean"===n&&(a=Boolean(a)),"string"===n&&(a=String(a)),void 0!==r&&!r.filter(function(t){return t==a}).length)throw new RangeError(a+" in not within "+r);return a}function p(t,e,n,r){t.get(e)||t.set(e,Object.create(null)),t.get(e)[n]=r}function o(t,e,n){var r=t.get(e);if(!r)throw new TypeError(e+" InternalSlot has not been initialized");return r[n]}function L(t){var e=Intl.getCanonicalLocales;return"function"==typeof e?e(t):Intl.NumberFormat.supportedLocalesOf(t||"")}function m(t,e,n){if(void 0===n&&(n=Error),!t)throw new n(e)}var r,e=(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),a=function(){return(a=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function v(t){var b=function(u){return function(t,e){for(var n={locale:""},r=0,o=e;r<o.length;r++){var a=o[r],i=a.replace(c,""),l=h(t,i);if(l)return n.locale=l,a!==i&&(n.extension=a.slice(i.length+1,a.length)),n}return n.locale=u(),n}}(t),g=function(u){return function(t,e){for(var n={locale:""},r=0,o=e;r<o.length;r++){var a=o[r],i=a.replace(c,""),l=h(t,i);if(l)return n.locale=l,a!==i&&(n.extension=a.slice(i.length+1,a.length)),n}return n.locale=u(),n}}(t);return function(t,e,n,r,o){for(var a,i=(a="lookup"===n.localeMatcher?b(t,e):g(t,e)).locale,l={locale:"",dataLocale:i},u="-u",c=0,f=r;c<f.length;c++){var s=f[c],p=o[i];m("object"==typeof p&&null!==p,"locale data "+s+" must be an object");var v=p[s];m(Array.isArray(v),"keyLocaleData must be an array");var h=v[0];m("string"==typeof h||null===h,"value must be string or null");var _="";if(a.extension){var y=w(a.extension,s);void 0!==y&&(""!==y?~v.indexOf(y)&&(_="-"+s+"-"+(h=y)):~y.indexOf("true")&&(h="true",_="-"+s))}if(s in n){var d=n[s];m("string"==typeof d||null==d,"optionsValue must be String, Undefined or Null"),~v.indexOf(d)&&d!==h&&(h=d,_="")}l[s]=h,u+=_}if(2<u.length){var O=i.indexOf("-x-");if(-1===O)i+=u;else i=i.slice(0,O)+u+i.slice(O,i.length);i=L(i)[0]}return l.locale=i,l}}function w(t,e){m(2===e.length,"key must have 2 elements");var n=t.length,r="-"+e+"-",o=t.indexOf(r);if(-1!==o){for(var a=o+4,i=a,l=a,u=!1;!u;){var c=t.indexOf("-",l);2===(-1===c?n-l:c-l)?u=!0:-1===c?(i=n,u=!0):l=(i=c)+1}return t.slice(a,i)}if(r="-"+e,-1!==(o=t.indexOf(r))&&o+3===n)return""}var c=/-u(?:-[0-9a-z]{2,8})+/gi;function h(t,e){for(var n=e;;){if(~t.indexOf(n))return n;var r=n.lastIndexOf("-");if(!~r)return;2<=r&&"-"===n[r-2]&&(r-=2),n=n.slice(0,r)}}function i(t,e){for(var n=[],r=0,o=e;r<o.length;r++){var a=h(t,o[r].replace(c,""));a&&n.push(a)}return n}var n,l=(n=Error,e(u,n),u);function u(){var t=null!==n&&n.apply(this,arguments)||this;return t.type="MISSING_LOCALE_DATA",t}var _=function(){return(_=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},y=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n},d=function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),o=0;for(e=0;e<n;e++)for(var a=arguments[e],i=0,l=a.length;i<l;i++,o++)r[o]=a[i];return r};var O=Intl.NumberFormat,b=(g.prototype.format=function(t){var e=this.nf.format(t);if(this.patternData){var n=o(g.__INTERNAL_SLOT_MAP__,this,"unitDisplay"),r=this.pl.select(t);return this.patternData[n]["one"===r?"one":"other"].replace("{0}",e)}return e},g.prototype.formatToParts=function(t){return this.nf.formatToParts(t)},g.prototype.resolvedOptions=function(){var t=this.nf.resolvedOptions(),e=o(g.__INTERNAL_SLOT_MAP__,this,"unit");return e&&(t.style="unit",t.unit=e,t.unitDisplay=o(g.__INTERNAL_SLOT_MAP__,this,"unitDisplay")),t},g.supportedLocalesOf=function(t,e){return function(t,e,n){return void 0!==n&&s(n=f(n),"localeMatcher","string",["lookup","best fit"],"best fit"),i(t,e)}(g.availableLocales,L(t),e)},g.__addLocaleData=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=function(e){Object.keys(d(e.availableLocales,Object.keys(e.aliases),Object.keys(e.parentLocales)).reduce(function(t,e){return t[e]=!0,t},{})).forEach(function(t){try{g.localeData[t]=function(t,e){var n=function(t,e,n){var r=[t];e[t]&&(t=e[t],r.push(t));var o=n[t];o&&r.push(o);for(var a=t.split("-"),i=a.length;1<i;i--)r.push(a.slice(0,i-1).join("-"));return r}(t,e.aliases,e.parentLocales),r=n.map(function(t){return e.data[t]}).filter(Boolean);if(!r.length)throw new l('Missing locale data for "'+t+'", lookup hierarchy: '+n.join(", "));return r.reverse(),r.reduce(function(t,e){return a(a({},t),e)},{})}(t,e)}catch(t){}})},r=0,o=t;r<o.length;r++)n(o[r]);g.availableLocales=Object.keys(g.localeData),g.__defaultLocale||(g.__defaultLocale=g.availableLocales[0])},g.getDefaultLocale=function(){return g.__defaultLocale},g.localeData={},g.availableLocales=[],g.__defaultLocale="en",g.relevantExtensionKeys=[],g.polyfilled=!0,g.__INTERNAL_SLOT_MAP__=new WeakMap,g);function g(t,e){void 0===e&&(e={});var n=(e=void 0===e?Object.create(null):f(e)).style,r=e.unit,o=(e.unitDisplay,y(e,["style","unit","unitDisplay"]));if("unit"===n){if(!r)throw new TypeError("Unit is required for `style: unit`");p(g.__INTERNAL_SLOT_MAP__,this,"unit",r),p(g.__INTERNAL_SLOT_MAP__,this,"unitDisplay",s(e,"unitDisplay","string",["long","short","narrow"],"short"));var a=L(t),i=Object.create(null),l=s(e,"localeMatcher","string",["best fit","lookup"],"best fit");i.localeMatcher=l;var u=g.localeData,c=v(g.getDefaultLocale)(g.availableLocales,a,i,g.relevantExtensionKeys,u);p(g.__INTERNAL_SLOT_MAP__,this,"locale",c.locale),this.patternData=u[c.locale][r]}this.nf=new O(t,_(_({},o),{style:"unit"===n?"decimal":n})),p(g.__INTERNAL_SLOT_MAP__,this,"unit",void 0),this.pl=new Intl.PluralRules(t)}t.UnifiedNumberFormat=b,t.isUnitSupported=function(t){try{new Intl.NumberFormat(void 0,{style:"unit",unit:t})}catch(t){return!1}return!0},Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=intl-unified-numberformat.min.js.map

@@ -31,3 +31,3 @@ import { Unit } from './units-constants';

private patternData?;
constructor(locales: string | string[], options?: UnifiedNumberFormatOptions);
constructor(locales?: string | string[], options?: UnifiedNumberFormatOptions);
format(num: number): string;

@@ -34,0 +34,0 @@ formatToParts(num: number): Intl.NumberFormatPart[];

@@ -70,2 +70,3 @@ var __assign = (this && this.__assign) || function () {

this.nf = new NativeNumberFormat(locales, __assign(__assign({}, coreOpts), { style: style === 'unit' ? 'decimal' : style }));
setInternalSlot(UnifiedNumberFormat.__INTERNAL_SLOT_MAP__, this, 'unit', undefined);
this.pl = new Intl.PluralRules(locales);

@@ -72,0 +73,0 @@ }

@@ -25,3 +25,3 @@ import { UnifiedNumberFormatLocaleData } from '@formatjs/intl-utils';

private patternData?;
constructor(locales: string | string[], options?: UnifiedNumberFormatOptions);
constructor(locales?: string | string[], options?: UnifiedNumberFormatOptions);
format(num: number): string;

@@ -28,0 +28,0 @@ formatToParts(num: number): Intl.NumberFormatPart[];

{
"name": "@formatjs/intl-unified-numberformat",
"version": "2.1.5",
"version": "2.1.6",
"description": "Ponyfill for intl unified numberformat proposal",

@@ -27,7 +27,7 @@ "keywords": [

"devDependencies": {
"@formatjs/intl-pluralrules": "^1.3.5",
"formatjs-extract-cldr-data": "^9.9.5"
"@formatjs/intl-pluralrules": "^1.3.6",
"formatjs-extract-cldr-data": "^9.9.6"
},
"dependencies": {
"@formatjs/intl-utils": "^1.4.2"
"@formatjs/intl-utils": "^1.4.3"
},

@@ -45,3 +45,3 @@ "scripts": {

},
"gitHead": "a7842673d8ad205171ad7c8cb8bb2f318b427c0c"
"gitHead": "4e2afbd30b8bcf239a6083049a113b7b694ebb80"
}

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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