@shopify/react-i18n
Advanced tools
Comparing version 0.11.6 to 0.11.7
@@ -9,4 +9,10 @@ # Changelog | ||
<!-- ## [Unreleased] - --> | ||
## [Unreleased] | ||
## [0.11.7] - 2019-03-27 | ||
### Changed | ||
- Memoize `Intl.DateTimeFormat` and `Intl.NumberFormat` [#596](https://github.com/Shopify/quilt/pull/596) | ||
## [0.11.5] - 2019-03-22 | ||
@@ -13,0 +19,0 @@ |
@@ -5,2 +5,3 @@ "use strict"; | ||
var i18n_1 = require("@shopify/i18n"); | ||
var memoize_1 = tslib_1.__importDefault(require("lodash/memoize")); | ||
var decorators_1 = require("@shopify/javascript-utilities/decorators"); | ||
@@ -15,2 +16,10 @@ var types_1 = require("./types"); | ||
var DECIMAL_VALUE_FOR_CURRENCIES_WITHOUT_DECIMALS = '00'; | ||
var memoizedDateTimeFormatter = memoize_1.default(dateTimeFormatter, function (locale, options) { | ||
if (options === void 0) { options = {}; } | ||
return "" + locale + JSON.stringify(options); | ||
}); | ||
var memoizedNumberFormatter = memoize_1.default(numberFormatter, function (locale, options) { | ||
if (options === void 0) { options = {}; } | ||
return "" + locale + JSON.stringify(options); | ||
}); | ||
var I18n = /** @class */ (function () { | ||
@@ -113,3 +122,3 @@ function I18n(translations, _a) { | ||
} | ||
return new Intl.NumberFormat(locale, tslib_1.__assign({ style: as, maximumFractionDigits: precision, currency: currency }, options)).format(amount); | ||
return memoizedNumberFormatter(locale, tslib_1.__assign({ style: as, maximumFractionDigits: precision, currency: currency }, options)).format(amount); | ||
}; | ||
@@ -171,3 +180,3 @@ I18n.prototype.formatCurrency = function (amount, options) { | ||
} | ||
return new Intl.DateTimeFormat(locale, tslib_1.__assign({ timeZone: timeZone }, formatOptions)).format(date); | ||
return memoizedDateTimeFormatter(locale, tslib_1.__assign({ timeZone: timeZone }, formatOptions)).format(date); | ||
}; | ||
@@ -231,1 +240,9 @@ I18n.prototype.weekStartDay = function (argCountry) { | ||
} | ||
function dateTimeFormatter(locale, options) { | ||
if (options === void 0) { options = {}; } | ||
return new Intl.DateTimeFormat(locale, options); | ||
} | ||
function numberFormatter(locale, options) { | ||
if (options === void 0) { options = {}; } | ||
return new Intl.NumberFormat(locale, options); | ||
} |
{ | ||
"name": "@shopify/react-i18n", | ||
"version": "0.11.6", | ||
"version": "0.11.7", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "i18n utilities for React handling translations, formatting, and more.", |
92428
1966