intl-messageformat
Advanced tools
Comparing version 5.0.0 to 5.0.1
@@ -6,2 +6,6 @@ # Change Log | ||
## [5.0.1](https://github.com/formatjs/formatjs/compare/intl-messageformat@5.0.0...intl-messageformat@5.0.1) (2019-07-09) | ||
**Note:** Version bump only for package intl-messageformat | ||
# [5.0.0](https://github.com/formatjs/formatjs/compare/intl-messageformat@4.4.0...intl-messageformat@5.0.0) (2019-07-08) | ||
@@ -8,0 +12,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __extends=function(){var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};return function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}}(),__assign=function(){return(__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},SyntaxError=function(a){function i(e,t,r,n){var o=a.call(this)||this;return o.message=e,o.expected=t,o.found=r,o.location=n,o.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(o,i),o}return __extends(i,a),i.buildMessage=function(e,t){function r(e){return e.charCodeAt(0).toString(16).toUpperCase()}function n(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+r(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+r(e)})}function o(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+r(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+r(e)})}function a(e){switch(e.type){case"literal":return'"'+n(e.text)+'"';case"class":var t=e.parts.map(function(e){return Array.isArray(e)?o(e[0])+"-"+o(e[1]):o(e)});return"["+(e.inverted?"^":"")+t+"]";case"any":return"any character";case"end":return"end of input";case"other":return e.description}}return"Expected "+function(e){var t,r,n=e.map(a);if(n.sort(),0<n.length){for(r=t=1;t<n.length;t++)n[t-1]!==n[t]&&(n[r]=n[t],r++);n.length=r}switch(n.length){case 1:return n[0];case 2:return n[0]+" or "+n[1];default:return n.slice(0,-1).join(", ")+", or "+n[n.length-1]}}(e)+" but "+((i=t)?'"'+n(i)+'"':"end of input")+" found.";var i},i}(Error);function isLiteralElement(e){return 0===e.type}function isArgumentElement(e){return 1===e.type}function isNumberElement(e){return 2===e.type}function isDateElement(e){return 3===e.type}function isTimeElement(e){return 4===e.type}function isSelectElement(e){return 5===e.type}function isPluralElement(e){return 6===e.type}function getCacheId(e){return JSON.stringify(e.map(function(e){return e&&"object"==typeof e?orderedProps(e):e}))}function orderedProps(r){return Object.keys(r).sort().map(function(e){var t;return(t={})[e]=r[e],t})}var memoizeFormatConstructor=function(a,i){return void 0===i&&(i={}),function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=getCacheId(t),o=n&&i[n];return o||(o=new((e=a).bind.apply(e,[void 0].concat(t))),n&&(i[n]=o)),o}},__extends$1=function(){var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};return function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}}(),__assign$1=function(){return(__assign$1=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function resolveLocale(e){"string"==typeof e&&(e=[e]);try{return Intl.NumberFormat.supportedLocalesOf(e,{localeMatcher:"best fit"})[0]}catch(e){return IntlMessageFormat.defaultLocale}}function prewarmFormatters(e,r,n,o){e.filter(function(e){return!isArgumentElement(e)&&!isLiteralElement(e)}).forEach(function(t){if(isDateElement(t)){var e=t.style?o.date[t.style]:void 0;return n.getDateTimeFormat(r,e)}if(isTimeElement(t)){e=t.style?o.time[t.style]:void 0;return n.getDateTimeFormat(r,e)}if(isNumberElement(t)){e=t.style?o.number[t.style]:void 0;return n.getNumberFormat(r,e)}return isSelectElement(t)?Object.keys(t.options).forEach(function(e){return prewarmFormatters(t.options[e].value,r,n,o)}):isPluralElement(t)?(n.getPluralRules(r,{type:t.pluralType}),Object.keys(t.options).forEach(function(e){return prewarmFormatters(t.options[e].value,r,n,o)})):void 0})}var ESCAPE_HASH_REGEX=/\\#/g;function formatPatterns(e,t,r,n,o,a){if(1===e.length&&isLiteralElement(e[0]))return e[0].value;for(var i="",s=0,u=e;s<u.length;s++){var c=u[s];if(isLiteralElement(c))i+=c.value.replace(ESCAPE_HASH_REGEX,"#");else{var l=c.value;if(!(o&&l in o))throw new FormatError("The intl string context variable '"+l+"' was not provided to the string '"+a+"'");var m=o[l];if(isArgumentElement(c))i+="string"==typeof m||"number"==typeof m?m:"";else if(isDateElement(c)){var f=c.style?n.date[c.style]:void 0;i+=r.getDateTimeFormat(t,f).format(m)}else if(isTimeElement(c)){f=c.style?n.time[c.style]:void 0;i+=r.getDateTimeFormat(t,f).format(m)}else if(isNumberElement(c)){f=c.style?n.number[c.style]:void 0;i+=r.getNumberFormat(t,f).format(m)}else if(isSelectElement(c)){if(!(p=c.options[m]||c.options.other))throw new RangeError('Invalid values for "'+c.value+'": "'+m+'". Options are "'+Object.keys(c.options).join('", "')+'"');i+=formatPatterns(p.value,t,r,n,o)}else if(isPluralElement(c)){var p;if(!(p=c.options["="+m])){var g=r.getPluralRules(t,{type:c.pluralType}).select(m-(c.offset||0));p=c.options[g]||c.options.other}if(!p)throw new RangeError('Invalid values for "'+c.value+'": "'+m+'". Options are "'+Object.keys(c.options).join('", "')+'"');i+=formatPatterns(p.value,t,r,n,o)}else;}}return i}function mergeConfig(r,n){return n?__assign$1({},r||{},n||{},Object.keys(r).reduce(function(e,t){return e[t]=__assign$1({},r[t],n[t]||{}),e},{})):r}function mergeConfigs(r,n){return n?Object.keys(r).reduce(function(e,t){return e[t]=mergeConfig(r[t],n[t]),e},__assign$1({},r)):r}var FormatError=function(n){function e(e,t){var r=n.call(this,e)||this;return r.variableId=t,r}return __extends$1(e,n),e}(Error);function createDefaultFormatters(e){return void 0===e&&(e={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:memoizeFormatConstructor(Intl.NumberFormat,e.number),getDateTimeFormat:memoizeFormatConstructor(Intl.DateTimeFormat,e.dateTime),getPluralRules:memoizeFormatConstructor(Intl.PluralRules,e.pluralRules)}}var IntlMessageFormat=function(){function a(e,t,r,n){var o=this;if(void 0===t&&(t=a.defaultLocale),this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(e){return formatPatterns(o.ast,o.locale,o.formatters,o.formats,e,o.message)},"string"==typeof e){if(this.message=e,!a.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");this.ast=a.__parse(e)}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=mergeConfigs(a.formats,r),this.locale=resolveLocale(t||[]),this.formatters=n&&n.formatters||createDefaultFormatters(this.formatterCache),prewarmFormatters(this.ast,this.locale,this.formatters,this.formats)}return a.prototype.resolvedOptions=function(){return{locale:this.locale}},a.prototype.getAst=function(){return this.ast},a.defaultLocale="en",a.__parse=void 0,a.formats={number:{currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},a}();exports.IntlMessageFormat=IntlMessageFormat,exports.createDefaultFormatters=createDefaultFormatters,exports.default=IntlMessageFormat; | ||
export * from './lib/core'; |
@@ -304,2 +304,1 @@ "use strict"; | ||
exports.default = IntlMessageFormat; | ||
//# sourceMappingURL=core.js.map |
@@ -16,2 +16,1 @@ "use strict"; | ||
exports.default = core_1.default; | ||
//# sourceMappingURL=index.js.map |
@@ -301,2 +301,1 @@ /* | ||
export default IntlMessageFormat; | ||
//# sourceMappingURL=core.js.map |
@@ -11,2 +11,1 @@ /* | ||
export default IntlMessageFormat; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "intl-messageformat", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.", | ||
@@ -34,12 +34,15 @@ "keywords": [ | ||
"dependencies": { | ||
"intl-format-cache": "^4.0.0", | ||
"intl-messageformat-parser": "^2.0.0" | ||
"intl-format-cache": "^4.0.1", | ||
"intl-messageformat-parser": "^2.0.1" | ||
}, | ||
"scripts": { | ||
"benchmark": "ts-node --project ./tsconfig.cjs.json tests/benchmark", | ||
"build": "npm run tsc && npm run tsc:core && npm run rollup", | ||
"clean": "rimraf dist lib", | ||
"benchmark": "ts-node --project ./tsconfig.cjs.json tests/benchmark", | ||
"build": "tsc && tsc -p tsconfig.cjs.json && rollup -c rollup.config.js", | ||
"karma:ci": "karma start karma.conf-ci.js", | ||
"karma:local": "karma start karma.conf.js", | ||
"rollup": "rollup -c rollup.config.js", | ||
"test": "TS_NODE_PROJECT='./tsconfig.cjs.json' mocha --opts ../../mocha.opts tests/index.ts", | ||
"karma:local": "karma start karma.conf.js", | ||
"karma:ci": "karma start karma.conf-ci.js" | ||
"tsc:core": "tsc -p tsconfig.core.json", | ||
"tsc": "tsc -p src/tsconfig.json && tsc -p src/tsconfig.cjs.json" | ||
}, | ||
@@ -51,3 +54,3 @@ "homepage": "https://github.com/formatjs/formatjs", | ||
"license": "BSD-3-Clause", | ||
"gitHead": "700edc75a439d52f497d3927fb0384966dd5c2b2" | ||
"gitHead": "2c91ba26cf80914198f1893a84a506094102a0e2" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
460702
22
3496
Updatedintl-format-cache@^4.0.1