Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

intl-relativeformat

Package Overview
Dependencies
Maintainers
4
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intl-relativeformat - npm Package Compare versions

Comparing version 2.1.3 to 2.2.0

karma.conf-ci.js

11

CHANGELOG.md

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

# [2.2.0](https://github.com/yahoo/intl-relativeformat/compare/intl-relativeformat@2.1.3...intl-relativeformat@2.2.0) (2019-05-29)
### Features
* **intl-relativeformat:** Improve day diffing ([#45](https://github.com/yahoo/intl-relativeformat/issues/45)) ([8f2c649](https://github.com/yahoo/intl-relativeformat/commit/8f2c649))
## [2.1.3](https://github.com/yahoo/intl-relativeformat/compare/intl-relativeformat@2.1.1...intl-relativeformat@2.1.3) (2019-05-28)

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

2

dist/intl-relativeformat.min.js

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).IntlRelativeFormat=t()}(this,function(){"use strict";var u=Object.prototype.hasOwnProperty;function a(e){var t,r,o,n,a=Array.prototype.slice.call(arguments,1);for(t=0,r=a.length;t<r;t+=1)if(o=a[t])for(n in o)u.call(o,n)&&(e[n]=o[n]);return e}var l=function(){try{return!!Object.defineProperty({},"a",{})}catch(e){return!1}}()?Object.defineProperty:function(e,t,r){"get"in r&&e.__defineGetter__?e.__defineGetter__(t,r.get):(!u.call(e,t)||"value"in r)&&(e[t]=r.value)},i=Object.create||function(e,t){var r,o;function n(){}for(o in n.prototype=e,r=new n,t)u.call(t,o)&&l(r,o,t[o]);return r};function n(e,t,r){this.locales=e,this.formats=t,this.pluralFn=r}function s(e){this.id=e}function c(e,t,r,o,n){this.id=e,this.useOrdinal=t,this.offset=r,this.options=o,this.pluralFn=n}function t(e,t,r,o){this.id=e,this.offset=t,this.numberFormat=r,this.string=o}function p(e,t){this.id=e,this.options=t}n.prototype.compile=function(e){return this.pluralStack=[],this.currentPlural=null,this.pluralNumberFormat=null,this.compileMessage(e)},n.prototype.compileMessage=function(e){if(!e||"messageFormatPattern"!==e.type)throw new Error('Message AST is not of type: "messageFormatPattern"');var t,r,o,n=e.elements,a=[];for(t=0,r=n.length;t<r;t+=1)switch((o=n[t]).type){case"messageTextElement":a.push(this.compileMessageText(o));break;case"argumentElement":a.push(this.compileArgument(o));break;default:throw new Error("Message element does not have a valid type")}return a},n.prototype.compileMessageText=function(e){return this.currentPlural&&/(^|[^\\])#/g.test(e.value)?(this.pluralNumberFormat||(this.pluralNumberFormat=new Intl.NumberFormat(this.locales)),new t(this.currentPlural.id,this.currentPlural.format.offset,this.pluralNumberFormat,e.value)):e.value.replace(/\\#/g,"#")},n.prototype.compileArgument=function(e){var t=e.format;if(!t)return new s(e.id);var r,o=this.formats,n=this.locales,a=this.pluralFn;switch(t.type){case"numberFormat":return r=o.number[t.style],{id:e.id,format:new Intl.NumberFormat(n,r).format};case"dateFormat":return r=o.date[t.style],{id:e.id,format:new Intl.DateTimeFormat(n,r).format};case"timeFormat":return r=o.time[t.style],{id:e.id,format:new Intl.DateTimeFormat(n,r).format};case"pluralFormat":return r=this.compileOptions(e),new c(e.id,t.ordinal,t.offset,r,a);case"selectFormat":return r=this.compileOptions(e),new p(e.id,r);default:throw new Error("Message element does not have a valid format type")}},n.prototype.compileOptions=function(e){var t,r,o,n=e.format,a=n.options,i={};for(this.pluralStack.push(this.currentPlural),this.currentPlural="pluralFormat"===n.type?e:null,t=0,r=a.length;t<r;t+=1)i[(o=a[t]).selector]=this.compileMessage(o.value);return this.currentPlural=this.pluralStack.pop(),i},s.prototype.format=function(e){return e||"number"==typeof e?"string"==typeof e?e:String(e):""},c.prototype.getOption=function(e){var t=this.options;return t["="+e]||t[this.pluralFn(e-this.offset,this.useOrdinal)]||t.other},t.prototype.format=function(e){var t=this.numberFormat.format(e-this.offset);return this.string.replace(/(^|[^\\])#/g,"$1"+t).replace(/\\#/g,"#")},p.prototype.getOption=function(e){var t=this.options;return t[e]||t.other};var e,r,o=(e=Be,r=Error,f.prototype=r.prototype,e.prototype=new f,{SyntaxError:Be,parse:function(s){var e,t,r,o,n,a=1<arguments.length?arguments[1]:{},u={},i={start:Pe},l=Pe,c=function(e){return{type:"messageFormatPattern",elements:e,location:ke()}},p=function(e){var t,r,o,n,a,i="";for(t=0,o=e.length;t<o;t+=1)for(r=0,a=(n=e[t]).length;r<a;r+=1)i+=n[r];return i},f=function(e){return{type:"messageTextElement",value:e,location:ke()}},h=/^[^ \t\n\r,.+={}#]/,m={type:"class",value:"[^ \\t\\n\\r,.+={}#]",description:"[^ \\t\\n\\r,.+={}#]"},d="{",y={type:"literal",value:"{",description:'"{"'},v=",",g={type:"literal",value:",",description:'","'},_="}",w={type:"literal",value:"}",description:'"}"'},b=function(e,t){return{type:"argumentElement",id:e,format:t&&t[2],location:ke()}},F="number",A={type:"literal",value:"number",description:'"number"'},x="date",C={type:"literal",value:"date",description:'"date"'},L="time",R={type:"literal",value:"time",description:'"time"'},k=function(e,t){return{type:e+"Format",style:t&&t[2],location:ke()}},T="plural",E={type:"literal",value:"plural",description:'"plural"'},N=function(e){return{type:e.type,ordinal:!1,offset:e.offset||0,options:e.options,location:ke()}},P="selectordinal",O={type:"literal",value:"selectordinal",description:'"selectordinal"'},I=function(e){return{type:e.type,ordinal:!0,offset:e.offset||0,options:e.options,location:ke()}},j="select",M={type:"literal",value:"select",description:'"select"'},S=function(e){return{type:"selectFormat",options:e,location:ke()}},D="=",U={type:"literal",value:"=",description:'"="'},G=function(e,t){return{type:"optionalFormatPattern",selector:e,value:t,location:ke()}},V="offset:",Z={type:"literal",value:"offset:",description:'"offset:"'},$=function(e){return e},B=function(e,t){return{type:"pluralFormat",offset:e,options:t,location:ke()}},W={type:"other",description:"whitespace"},q=/^[ \t\n\r]/,z={type:"class",value:"[ \\t\\n\\r]",description:"[ \\t\\n\\r]"},H={type:"other",description:"optionalWhitespace"},J=/^[0-9]/,K={type:"class",value:"[0-9]",description:"[0-9]"},Q=/^[0-9a-f]/i,X={type:"class",value:"[0-9a-f]i",description:"[0-9a-f]i"},Y="0",ee={type:"literal",value:"0",description:'"0"'},te=/^[1-9]/,re={type:"class",value:"[1-9]",description:"[1-9]"},oe=function(e){return parseInt(e,10)},ne=/^[^{}\\\0-\x1F \t\n\r]/,ae={type:"class",value:"[^{}\\\\\\0-\\x1F\\x7f \\t\\n\\r]",description:"[^{}\\\\\\0-\\x1F\\x7f \\t\\n\\r]"},ie="\\\\",le={type:"literal",value:"\\\\",description:'"\\\\\\\\"'},se=function(){return"\\"},ue="\\#",ce={type:"literal",value:"\\#",description:'"\\\\#"'},pe=function(){return"\\#"},fe="\\{",he={type:"literal",value:"\\{",description:'"\\\\{"'},me=function(){return"{"},de="\\}",ye={type:"literal",value:"\\}",description:'"\\\\}"'},ve=function(){return"}"},ge="\\u",_e={type:"literal",value:"\\u",description:'"\\\\u"'},we=function(e){return String.fromCharCode(parseInt(e,16))},be=function(e){return e.join("")},Fe=0,Ae=0,xe=[{line:1,column:1,seenCR:!1}],Ce=0,Le=[],Re=0;if("startRule"in a){if(!(a.startRule in i))throw new Error("Can't start parsing from rule \""+a.startRule+'".');l=i[a.startRule]}function ke(){return Ee(Ae,Fe)}function Te(e){var t,r,o=xe[e];if(o)return o;for(t=e-1;!xe[t];)t--;for(o={line:(o=xe[t]).line,column:o.column,seenCR:o.seenCR};t<e;)"\n"===(r=s.charAt(t))?(o.seenCR||o.line++,o.column=1,o.seenCR=!1):"\r"===r||"\u2028"===r||"\u2029"===r?(o.line++,o.column=1,o.seenCR=!0):(o.column++,o.seenCR=!1),t++;return xe[e]=o}function Ee(e,t){var r=Te(e),o=Te(t);return{start:{offset:e,line:r.line,column:r.column},end:{offset:t,line:o.line,column:o.column}}}function Ne(e){Fe<Ce||(Ce<Fe&&(Ce=Fe,Le=[]),Le.push(e))}function Pe(){return Oe()}function Oe(){var e,t,r;for(e=Fe,t=[],r=Ie();r!==u;)t.push(r),r=Ie();return t!==u&&(Ae=e,t=c(t)),e=t}function Ie(){var e;return(e=function(){var e,t;return e=Fe,(t=function(){var e,t,r,o,n,a;if(t=[],r=e=Fe,(r=(o=De())!==u?(n=$e())!==u&&(a=De())!==u?o=[o,n,a]:(Fe=r,u):(Fe=r,u))!==u)for(;r!==u;)t.push(r),r=Fe,o=De(),r=o!==u&&(n=$e())!==u&&(a=De())!==u?o=[o,n,a]:(Fe=r,u);else t=u;return t!==u&&(Ae=e,t=p(t)),(e=t)===u&&(e=Fe,t=Se(),e=t!==u?s.substring(e,Fe):t),e}())!==u&&(Ae=e,t=f(t)),e=t}())===u&&(e=function(){var e,t,r,o,n,a,i;return e=Fe,123===s.charCodeAt(Fe)?(t=d,Fe++):(t=u,0===Re&&Ne(y)),e=t!==u?De()!==u&&(r=function(){var e,t,r;if((e=Ve())===u){if(e=Fe,t=[],h.test(s.charAt(Fe))?(r=s.charAt(Fe),Fe++):(r=u,0===Re&&Ne(m)),r!==u)for(;r!==u;)t.push(r),h.test(s.charAt(Fe))?(r=s.charAt(Fe),Fe++):(r=u,0===Re&&Ne(m));else t=u;e=t!==u?s.substring(e,Fe):t}return e}())!==u&&De()!==u?(o=Fe,44===s.charCodeAt(Fe)?(n=v,Fe++):(n=u,0===Re&&Ne(g)),(o=n!==u&&(a=De())!==u&&(i=function(){var e;return(e=function(){var e,t,r,o,n,a;return e=Fe,s.substr(Fe,6)===F?(t=F,Fe+=6):(t=u,0===Re&&Ne(A)),t===u&&(s.substr(Fe,4)===x?(t=x,Fe+=4):(t=u,0===Re&&Ne(C)),t===u&&(s.substr(Fe,4)===L?(t=L,Fe+=4):(t=u,0===Re&&Ne(R)))),e=t!==u?De()!==u?(r=Fe,44===s.charCodeAt(Fe)?(o=v,Fe++):(o=u,0===Re&&Ne(g)),(r=o!==u&&(n=De())!==u&&(a=$e())!==u?o=[o,n,a]:(Fe=r,u))===u&&(r=null),r!==u?(Ae=e,t=k(t,r)):(Fe=e,u)):(Fe=e,u):(Fe=e,u)}())===u&&(e=function(){var e,t,r,o;return e=Fe,s.substr(Fe,6)===T?(t=T,Fe+=6):(t=u,0===Re&&Ne(E)),e=t!==u?De()!==u?(44===s.charCodeAt(Fe)?(r=v,Fe++):(r=u,0===Re&&Ne(g)),r!==u&&De()!==u&&(o=Me())!==u?(Ae=e,t=N(o)):(Fe=e,u)):(Fe=e,u):(Fe=e,u)}())===u&&(e=function(){var e,t,r,o;return e=Fe,s.substr(Fe,13)===P?(t=P,Fe+=13):(t=u,0===Re&&Ne(O)),e=t!==u?De()!==u?(44===s.charCodeAt(Fe)?(r=v,Fe++):(r=u,0===Re&&Ne(g)),r!==u&&De()!==u&&(o=Me())!==u?(Ae=e,t=I(o)):(Fe=e,u)):(Fe=e,u):(Fe=e,u)}())===u&&(e=function(){var e,t,r,o,n;if(e=Fe,s.substr(Fe,6)===j?(t=j,Fe+=6):(t=u,0===Re&&Ne(M)),t!==u)if(De()!==u)if(44===s.charCodeAt(Fe)?(r=v,Fe++):(r=u,0===Re&&Ne(g)),r!==u)if(De()!==u){if(o=[],(n=je())!==u)for(;n!==u;)o.push(n),n=je();else o=u;e=o!==u?(Ae=e,t=S(o)):(Fe=e,u)}else Fe=e,e=u;else Fe=e,e=u;else Fe=e,e=u;else Fe=e,e=u;return e}()),e}())!==u?n=[n,a,i]:(Fe=o,u))===u&&(o=null),o!==u&&(n=De())!==u?(125===s.charCodeAt(Fe)?(a=_,Fe++):(a=u,0===Re&&Ne(w)),a!==u?(Ae=e,t=b(r,o)):(Fe=e,u)):(Fe=e,u)):(Fe=e,u):(Fe=e,u)}()),e}function je(){var e,t,r,o,n;return e=Fe,e=De()!==u&&(t=function(){var e,t,r,o;return t=e=Fe,61===s.charCodeAt(Fe)?(r=D,Fe++):(r=u,0===Re&&Ne(U)),(e=(t=r!==u&&(o=Ve())!==u?r=[r,o]:(Fe=t,u))!==u?s.substring(e,Fe):t)===u&&(e=$e()),e}())!==u&&De()!==u?(123===s.charCodeAt(Fe)?(r=d,Fe++):(r=u,0===Re&&Ne(y)),r!==u&&De()!==u&&(o=Oe())!==u&&De()!==u?(125===s.charCodeAt(Fe)?(n=_,Fe++):(n=u,0===Re&&Ne(w)),n!==u?(Ae=e,G(t,o)):(Fe=e,u)):(Fe=e,u)):(Fe=e,u)}function Me(){var e,t,r,o;if(e=Fe,(t=function(){var e,t,r;return e=Fe,s.substr(Fe,7)===V?(t=V,Fe+=7):(t=u,0===Re&&Ne(Z)),e=t!==u&&De()!==u&&(r=Ve())!==u?(Ae=e,t=$(r)):(Fe=e,u)}())===u&&(t=null),t!==u)if(De()!==u){if(r=[],(o=je())!==u)for(;o!==u;)r.push(o),o=je();else r=u;e=r!==u?(Ae=e,t=B(t,r)):(Fe=e,u)}else Fe=e,e=u;else Fe=e,e=u;return e}function Se(){var e,t;if(Re++,e=[],q.test(s.charAt(Fe))?(t=s.charAt(Fe),Fe++):(t=u,0===Re&&Ne(z)),t!==u)for(;t!==u;)e.push(t),q.test(s.charAt(Fe))?(t=s.charAt(Fe),Fe++):(t=u,0===Re&&Ne(z));else e=u;return Re--,e===u&&(t=u,0===Re&&Ne(W)),e}function De(){var e,t,r;for(Re++,e=Fe,t=[],r=Se();r!==u;)t.push(r),r=Se();return e=t!==u?s.substring(e,Fe):t,Re--,e===u&&(t=u,0===Re&&Ne(H)),e}function Ue(){var e;return J.test(s.charAt(Fe))?(e=s.charAt(Fe),Fe++):(e=u,0===Re&&Ne(K)),e}function Ge(){var e;return Q.test(s.charAt(Fe))?(e=s.charAt(Fe),Fe++):(e=u,0===Re&&Ne(X)),e}function Ve(){var e,t,r,o,n,a;if(e=Fe,48===s.charCodeAt(Fe)?(t=Y,Fe++):(t=u,0===Re&&Ne(ee)),t===u){if(r=t=Fe,te.test(s.charAt(Fe))?(o=s.charAt(Fe),Fe++):(o=u,0===Re&&Ne(re)),o!==u){for(n=[],a=Ue();a!==u;)n.push(a),a=Ue();r=n!==u?o=[o,n]:(Fe=r,u)}else Fe=r,r=u;t=r!==u?s.substring(t,Fe):r}return t!==u&&(Ae=e,t=oe(t)),e=t}function Ze(){var e,t,r,o,n,a,i,l;return ne.test(s.charAt(Fe))?(e=s.charAt(Fe),Fe++):(e=u,0===Re&&Ne(ae)),e===u&&(e=Fe,s.substr(Fe,2)===ie?(t=ie,Fe+=2):(t=u,0===Re&&Ne(le)),t!==u&&(Ae=e,t=se()),(e=t)===u&&(e=Fe,s.substr(Fe,2)===ue?(t=ue,Fe+=2):(t=u,0===Re&&Ne(ce)),t!==u&&(Ae=e,t=pe()),(e=t)===u&&(e=Fe,s.substr(Fe,2)===fe?(t=fe,Fe+=2):(t=u,0===Re&&Ne(he)),t!==u&&(Ae=e,t=me()),(e=t)===u&&(e=Fe,s.substr(Fe,2)===de?(t=de,Fe+=2):(t=u,0===Re&&Ne(ye)),t!==u&&(Ae=e,t=ve()),(e=t)===u&&(e=Fe,s.substr(Fe,2)===ge?(t=ge,Fe+=2):(t=u,0===Re&&Ne(_e)),e=t!==u?(o=r=Fe,(r=(o=(n=Ge())!==u&&(a=Ge())!==u&&(i=Ge())!==u&&(l=Ge())!==u?n=[n,a,i,l]:(Fe=o,u))!==u?s.substring(r,Fe):o)!==u?(Ae=e,t=we(r)):(Fe=e,u)):(Fe=e,u)))))),e}function $e(){var e,t,r;if(e=Fe,t=[],(r=Ze())!==u)for(;r!==u;)t.push(r),r=Ze();else t=u;return t!==u&&(Ae=e,t=be(t)),e=t}if((e=l())!==u&&Fe===s.length)return e;throw e!==u&&Fe<s.length&&Ne({type:"end",description:"end of input"}),t=null,r=Le,o=Ce<s.length?s.charAt(Ce):null,n=Ce<s.length?Ee(Ce,Ce+1):Ee(Ce,Ce),null!==r&&function(e){var t=1;for(e.sort(function(e,t){return e.description<t.description?-1:e.description>t.description?1:0});t<e.length;)e[t-1]===e[t]?e.splice(t,1):t++}(r),new Be(null!==t?t:function(e,t){var r,o=new Array(e.length);for(r=0;r<e.length;r++)o[r]=e[r].description;function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}return"Expected "+(1<e.length?o.slice(0,-1).join(", ")+" or "+o[e.length-1]:o[0])+" but "+(t?'"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(e){return"\\x0"+n(e)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(e){return"\\x"+n(e)}).replace(/[\u0100-\u0FFF]/g,function(e){return"\\u0"+n(e)}).replace(/[\u1000-\uFFFF]/g,function(e){return"\\u"+n(e)})+'"':"end of input")+" found."}(r,o),r,o,n)}});function Be(e,t,r,o){this.message=e,this.expected=t,this.found=r,this.location=o,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,Be)}function f(){this.constructor=e}function h(t,e,r){var o="string"==typeof t?h.__parse(t):t;if(!o||"messageFormatPattern"!==o.type)throw new TypeError("A message must be provided as a String or AST.");r=this._mergeFormats(h.formats,r),l(this,"_locale",{value:this._resolveLocale(e)});var n=this._findPluralRuleFunction(this._locale),a=this._compilePattern(o,e,r,n),i=this;this.format=function(e){try{return i._format(a,e)}catch(e){throw e.variableId?new Error("The intl string context variable '"+e.variableId+"' was not provided to the string '"+t+"'"):e}}}l(h,"formats",{enumerable:!0,value:{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"}}}}),l(h,"__localeData__",{value:i(null)}),l(h,"__addLocaleData",{value:function(e){if(!e||!e.locale)throw new Error("Locale data provided to IntlMessageFormat is missing a `locale` property");h.__localeData__[e.locale.toLowerCase()]=e}}),l(h,"__parse",{value:o.parse}),l(h,"defaultLocale",{enumerable:!0,writable:!0,value:void 0}),h.prototype.resolvedOptions=function(){return{locale:this._locale}},h.prototype._compilePattern=function(e,t,r,o){return new n(t,r,o).compile(e)},h.prototype._findPluralRuleFunction=function(e){for(var t=h.__localeData__,r=t[e.toLowerCase()];r;){if(r.pluralRuleFunction)return r.pluralRuleFunction;r=r.parentLocale&&t[r.parentLocale.toLowerCase()]}throw new Error("Locale data added to IntlMessageFormat is missing a `pluralRuleFunction` for :"+e)},h.prototype._format=function(e,t){var r,o,n,a,i,l,s="";for(r=0,o=e.length;r<o;r+=1)if("string"!=typeof(n=e[r])){if(a=n.id,!t||!u.call(t,a))throw(l=new Error("A value must be provided for: "+a)).variableId=a,l;i=t[a],n.options?s+=this._format(n.getOption(i),t):s+=n.format(i)}else s+=n;return s},h.prototype._mergeFormats=function(e,t){var r,o,n={};for(r in e)u.call(e,r)&&(n[r]=o=i(e[r]),t&&u.call(t,r)&&a(o,t[r]));return n},h.prototype._resolveLocale=function(e){"string"==typeof e&&(e=[e]),e=(e||[]).concat(h.defaultLocale);var t,r,o,n,a=h.__localeData__;for(t=0,r=e.length;t<r;t+=1)for(o=e[t].toLowerCase().split("-");o.length;){if(n=a[o.join("-")])return n.locale;o.pop()}var i=e.pop();throw new Error("No locale data has been added to IntlMessageFormat for: "+e.join(", ")+", or the default locale: "+i)},h.__addLocaleData({locale:"en",pluralRuleFunction:function(e,t){var r=String(e).split("."),o=!r[1],n=Number(r[0])==e,a=n&&r[0].slice(-1),i=n&&r[0].slice(-2);return t?1==a&&11!=i?"one":2==a&&12!=i?"two":3==a&&13!=i?"few":"other":1==e&&o?"one":"other"}}),h.defaultLocale="en";var m=Math.round;var d=Object.prototype.hasOwnProperty,y=Object.prototype.toString,v=function(){try{return!!Object.defineProperty({},"a",{})}catch(e){return!1}}()?Object.defineProperty:function(e,t,r){"get"in r&&e.__defineGetter__?e.__defineGetter__(t,r.get):(!d.call(e,t)||"value"in r)&&(e[t]=r.value)},g=Object.create||function(e,t){var r,o;function n(){}for(o in n.prototype=e,r=new n,t)d.call(t,o)&&v(r,o,t[o]);return r},_=Array.prototype.indexOf||function(e,t){if(!this.length)return-1;for(var r=t||0,o=this.length;r<o;r++)if(this[r]===e)return r;return-1},w=Array.isArray||function(e){return"[object Array]"===y.call(e)},b=Date.now||function(){return(new Date).getTime()},F=["second","second-short","minute","minute-short","hour","hour-short","day","day-short","month","month-short","year","year-short"],A=["best fit","numeric"];function x(e,t){t=t||{},w(e)&&(e=e.concat()),v(this,"_locale",{value:this._resolveLocale(e)}),v(this,"_options",{value:{style:this._resolveStyle(t.style),units:this._isValidUnits(t.units)&&t.units}}),v(this,"_locales",{value:e}),v(this,"_fields",{value:this._findFields(this._locale)}),v(this,"_messages",{value:g(null)});var r=this;this.format=function(e,t){return r._format(e,t)}}return v(x,"__localeData__",{value:g(null)}),v(x,"__addLocaleData",{value:function(){for(var e=0;e<arguments.length;e++){var t=arguments[e];if(!t||!t.locale)throw new Error("Locale data provided to IntlRelativeFormat is missing a `locale` property value");x.__localeData__[t.locale.toLowerCase()]=t,h.__addLocaleData(t)}}}),v(x,"defaultLocale",{enumerable:!0,writable:!0,value:void 0}),v(x,"thresholds",{enumerable:!0,value:{second:45,"second-short":45,minute:45,"minute-short":45,hour:22,"hour-short":22,day:26,"day-short":26,month:11,"month-short":11}}),x.prototype.resolvedOptions=function(){return{locale:this._locale,style:this._options.style,units:this._options.units}},x.prototype._compileMessage=function(e){var t,r=this._locales,o=(this._locale,this._fields[e].relativeTime),n="",a="";for(t in o.future)o.future.hasOwnProperty(t)&&(n+=" "+t+" {"+o.future[t].replace("{0}","#")+"}");for(t in o.past)o.past.hasOwnProperty(t)&&(a+=" "+t+" {"+o.past[t].replace("{0}","#")+"}");return new h("{when, select, future {{0, plural, "+n+"}}past {{0, plural, "+a+"}}}",r)},x.prototype._getMessage=function(e){var t=this._messages;return t[e]||(t[e]=this._compileMessage(e)),t[e]},x.prototype._getRelativeUnits=function(e,t){var r=this._fields[t];if(r.relative)return r.relative[e]},x.prototype._findFields=function(e){for(var t=x.__localeData__,r=t[e.toLowerCase()];r;){if(r.fields)return r.fields;r=r.parentLocale&&t[r.parentLocale.toLowerCase()]}throw new Error("Locale data added to IntlRelativeFormat is missing `fields` for :"+e)},x.prototype._format=function(e,t){var r=t&&void 0!==t.now?t.now:b();if(void 0===e&&(e=r),!isFinite(r))throw new RangeError("The `now` option provided to IntlRelativeFormat#format() is not in valid range.");if(!isFinite(e))throw new RangeError("The date value provided to IntlRelativeFormat#format() is not in valid range.");var o=function(e,t){var r=m((t=+t)-(e=+e)),o=m(r/1e3),n=m(o/60),a=m(n/60),i=m(a/24),l=m(i/7),s=function(e){return 400*e/146097}(i),u=m(12*s),c=m(s);return{millisecond:r,second:o,"second-short":o,minute:n,"minute-short":n,hour:a,"hour-short":a,day:i,"day-short":i,week:l,"week-short":l,month:u,"month-short":u,year:c,"year-short":c}}(r,e),n=this._options.units||this._selectUnits(o),a=o[n];if("numeric"!==this._options.style){var i=this._getRelativeUnits(a,n);if(i)return i}return this._getMessage(n).format({0:Math.abs(a),when:a<0?"past":"future"})},x.prototype._isValidUnits=function(e){if(!e||0<=_.call(F,e))return!0;if("string"==typeof e){var t=/s$/.test(e)&&e.substr(0,e.length-1);if(t&&0<=_.call(F,t))throw new Error('"'+e+'" is not a valid IntlRelativeFormat `units` value, did you mean: '+t)}throw new Error('"'+e+'" is not a valid IntlRelativeFormat `units` value, it must be one of: "'+F.join('", "')+'"')},x.prototype._resolveLocale=function(e){"string"==typeof e&&(e=[e]),e=(e||[]).concat(x.defaultLocale);var t,r,o,n,a=x.__localeData__;for(t=0,r=e.length;t<r;t+=1)for(o=e[t].toLowerCase().split("-");o.length;){if(n=a[o.join("-")])return n.locale;o.pop()}var i=e.pop();throw new Error("No locale data has been added to IntlRelativeFormat for: "+e.join(", ")+", or the default locale: "+i)},x.prototype._resolveStyle=function(e){if(!e)return A[0];if(0<=_.call(A,e))return e;throw new Error('"'+e+'" is not a valid IntlRelativeFormat `style` value, it must be one of: "'+A.join('", "')+'"')},x.prototype._selectUnits=function(e){var t,r,o,n=F.filter(function(e){return e.indexOf("-short")<1});for(t=0,r=n.length;t<r&&(o=n[t],!(Math.abs(e[o])<x.thresholds[o]));t+=1);return o},x.__addLocaleData({locale:"en",pluralRuleFunction:function(e,t){var r=String(e).split("."),o=!r[1],n=Number(r[0])==e,a=n&&r[0].slice(-1),i=n&&r[0].slice(-2);return t?1==a&&11!=i?"one":2==a&&12!=i?"two":3==a&&13!=i?"few":"other":1==e&&o?"one":"other"},fields:{year:{displayName:"year",relative:{0:"this year",1:"next year","-1":"last year"},relativeTime:{future:{one:"in {0} year",other:"in {0} years"},past:{one:"{0} year ago",other:"{0} years ago"}}},"year-short":{displayName:"yr.",relative:{0:"this yr.",1:"next yr.","-1":"last yr."},relativeTime:{future:{one:"in {0} yr.",other:"in {0} yr."},past:{one:"{0} yr. ago",other:"{0} yr. ago"}}},month:{displayName:"month",relative:{0:"this month",1:"next month","-1":"last month"},relativeTime:{future:{one:"in {0} month",other:"in {0} months"},past:{one:"{0} month ago",other:"{0} months ago"}}},"month-short":{displayName:"mo.",relative:{0:"this mo.",1:"next mo.","-1":"last mo."},relativeTime:{future:{one:"in {0} mo.",other:"in {0} mo."},past:{one:"{0} mo. ago",other:"{0} mo. ago"}}},week:{displayName:"week",relativePeriod:"the week of {0}",relative:{0:"this week",1:"next week","-1":"last week"},relativeTime:{future:{one:"in {0} week",other:"in {0} weeks"},past:{one:"{0} week ago",other:"{0} weeks ago"}}},"week-short":{displayName:"wk.",relativePeriod:"the week of {0}",relative:{0:"this wk.",1:"next wk.","-1":"last wk."},relativeTime:{future:{one:"in {0} wk.",other:"in {0} wk."},past:{one:"{0} wk. ago",other:"{0} wk. ago"}}},day:{displayName:"day",relative:{0:"today",1:"tomorrow","-1":"yesterday"},relativeTime:{future:{one:"in {0} day",other:"in {0} days"},past:{one:"{0} day ago",other:"{0} days ago"}}},"day-short":{displayName:"day",relative:{0:"today",1:"tomorrow","-1":"yesterday"},relativeTime:{future:{one:"in {0} day",other:"in {0} days"},past:{one:"{0} day ago",other:"{0} days ago"}}},hour:{displayName:"hour",relative:{0:"this hour"},relativeTime:{future:{one:"in {0} hour",other:"in {0} hours"},past:{one:"{0} hour ago",other:"{0} hours ago"}}},"hour-short":{displayName:"hr.",relative:{0:"this hour"},relativeTime:{future:{one:"in {0} hr.",other:"in {0} hr."},past:{one:"{0} hr. ago",other:"{0} hr. ago"}}},minute:{displayName:"minute",relative:{0:"this minute"},relativeTime:{future:{one:"in {0} minute",other:"in {0} minutes"},past:{one:"{0} minute ago",other:"{0} minutes ago"}}},"minute-short":{displayName:"min.",relative:{0:"this minute"},relativeTime:{future:{one:"in {0} min.",other:"in {0} min."},past:{one:"{0} min. ago",other:"{0} min. ago"}}},second:{displayName:"second",relative:{0:"now"},relativeTime:{future:{one:"in {0} second",other:"in {0} seconds"},past:{one:"{0} second ago",other:"{0} seconds ago"}}},"second-short":{displayName:"sec.",relative:{0:"now"},relativeTime:{future:{one:"in {0} sec.",other:"in {0} sec."},past:{one:"{0} sec. ago",other:"{0} sec. ago"}}}}}),x.defaultLocale="en",x});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).IntlRelativeFormat=t()}(this,function(){"use strict";var u=Object.prototype.hasOwnProperty;function a(e){var t,r,o,n,a=Array.prototype.slice.call(arguments,1);for(t=0,r=a.length;t<r;t+=1)if(o=a[t])for(n in o)u.call(o,n)&&(e[n]=o[n]);return e}var l=function(){try{return!!Object.defineProperty({},"a",{})}catch(e){return!1}}()?Object.defineProperty:function(e,t,r){"get"in r&&e.__defineGetter__?e.__defineGetter__(t,r.get):(!u.call(e,t)||"value"in r)&&(e[t]=r.value)},i=Object.create||function(e,t){var r,o;function n(){}for(o in n.prototype=e,r=new n,t)u.call(t,o)&&l(r,o,t[o]);return r};function n(e,t,r){this.locales=e,this.formats=t,this.pluralFn=r}function s(e){this.id=e}function c(e,t,r,o,n){this.id=e,this.useOrdinal=t,this.offset=r,this.options=o,this.pluralFn=n}function t(e,t,r,o){this.id=e,this.offset=t,this.numberFormat=r,this.string=o}function f(e,t){this.id=e,this.options=t}n.prototype.compile=function(e){return this.pluralStack=[],this.currentPlural=null,this.pluralNumberFormat=null,this.compileMessage(e)},n.prototype.compileMessage=function(e){if(!e||"messageFormatPattern"!==e.type)throw new Error('Message AST is not of type: "messageFormatPattern"');var t,r,o,n=e.elements,a=[];for(t=0,r=n.length;t<r;t+=1)switch((o=n[t]).type){case"messageTextElement":a.push(this.compileMessageText(o));break;case"argumentElement":a.push(this.compileArgument(o));break;default:throw new Error("Message element does not have a valid type")}return a},n.prototype.compileMessageText=function(e){return this.currentPlural&&/(^|[^\\])#/g.test(e.value)?(this.pluralNumberFormat||(this.pluralNumberFormat=new Intl.NumberFormat(this.locales)),new t(this.currentPlural.id,this.currentPlural.format.offset,this.pluralNumberFormat,e.value)):e.value.replace(/\\#/g,"#")},n.prototype.compileArgument=function(e){var t=e.format;if(!t)return new s(e.id);var r,o=this.formats,n=this.locales,a=this.pluralFn;switch(t.type){case"numberFormat":return r=o.number[t.style],{id:e.id,format:new Intl.NumberFormat(n,r).format};case"dateFormat":return r=o.date[t.style],{id:e.id,format:new Intl.DateTimeFormat(n,r).format};case"timeFormat":return r=o.time[t.style],{id:e.id,format:new Intl.DateTimeFormat(n,r).format};case"pluralFormat":return r=this.compileOptions(e),new c(e.id,t.ordinal,t.offset,r,a);case"selectFormat":return r=this.compileOptions(e),new f(e.id,r);default:throw new Error("Message element does not have a valid format type")}},n.prototype.compileOptions=function(e){var t,r,o,n=e.format,a=n.options,i={};for(this.pluralStack.push(this.currentPlural),this.currentPlural="pluralFormat"===n.type?e:null,t=0,r=a.length;t<r;t+=1)i[(o=a[t]).selector]=this.compileMessage(o.value);return this.currentPlural=this.pluralStack.pop(),i},s.prototype.format=function(e){return e||"number"==typeof e?"string"==typeof e?e:String(e):""},c.prototype.getOption=function(e){var t=this.options;return t["="+e]||t[this.pluralFn(e-this.offset,this.useOrdinal)]||t.other},t.prototype.format=function(e){var t=this.numberFormat.format(e-this.offset);return this.string.replace(/(^|[^\\])#/g,"$1"+t).replace(/\\#/g,"#")},f.prototype.getOption=function(e){var t=this.options;return t[e]||t.other};var e,r,o=(e=$e,r=Error,p.prototype=r.prototype,e.prototype=new p,{SyntaxError:$e,parse:function(s){var e,t,r,o,n,a=1<arguments.length?arguments[1]:{},u={},i={start:Ne},l=Ne,c=function(e){return{type:"messageFormatPattern",elements:e,location:Re()}},f=function(e){var t,r,o,n,a,i="";for(t=0,o=e.length;t<o;t+=1)for(r=0,a=(n=e[t]).length;r<a;r+=1)i+=n[r];return i},p=function(e){return{type:"messageTextElement",value:e,location:Re()}},h=/^[^ \t\n\r,.+={}#]/,m={type:"class",value:"[^ \\t\\n\\r,.+={}#]",description:"[^ \\t\\n\\r,.+={}#]"},d="{",v={type:"literal",value:"{",description:'"{"'},y=",",g={type:"literal",value:",",description:'","'},_="}",w={type:"literal",value:"}",description:'"}"'},b=function(e,t){return{type:"argumentElement",id:e,format:t&&t[2],location:Re()}},F="number",A={type:"literal",value:"number",description:'"number"'},x="date",T={type:"literal",value:"date",description:'"date"'},C="time",L={type:"literal",value:"time",description:'"time"'},R=function(e,t){return{type:e+"Format",style:t&&t[2],location:Re()}},k="plural",E={type:"literal",value:"plural",description:'"plural"'},O=function(e){return{type:e.type,ordinal:!1,offset:e.offset||0,options:e.options,location:Re()}},N="selectordinal",P={type:"literal",value:"selectordinal",description:'"selectordinal"'},I=function(e){return{type:e.type,ordinal:!0,offset:e.offset||0,options:e.options,location:Re()}},j="select",M={type:"literal",value:"select",description:'"select"'},D=function(e){return{type:"selectFormat",options:e,location:Re()}},S="=",U={type:"literal",value:"=",description:'"="'},G=function(e,t){return{type:"optionalFormatPattern",selector:e,value:t,location:Re()}},z="offset:",V={type:"literal",value:"offset:",description:'"offset:"'},Z=function(e){return e},$=function(e,t){return{type:"pluralFormat",offset:e,options:t,location:Re()}},B={type:"other",description:"whitespace"},H=/^[ \t\n\r]/,W={type:"class",value:"[ \\t\\n\\r]",description:"[ \\t\\n\\r]"},q={type:"other",description:"optionalWhitespace"},J=/^[0-9]/,K={type:"class",value:"[0-9]",description:"[0-9]"},Q=/^[0-9a-f]/i,X={type:"class",value:"[0-9a-f]i",description:"[0-9a-f]i"},Y="0",ee={type:"literal",value:"0",description:'"0"'},te=/^[1-9]/,re={type:"class",value:"[1-9]",description:"[1-9]"},oe=function(e){return parseInt(e,10)},ne=/^[^{}\\\0-\x1F \t\n\r]/,ae={type:"class",value:"[^{}\\\\\\0-\\x1F\\x7f \\t\\n\\r]",description:"[^{}\\\\\\0-\\x1F\\x7f \\t\\n\\r]"},ie="\\\\",le={type:"literal",value:"\\\\",description:'"\\\\\\\\"'},se=function(){return"\\"},ue="\\#",ce={type:"literal",value:"\\#",description:'"\\\\#"'},fe=function(){return"\\#"},pe="\\{",he={type:"literal",value:"\\{",description:'"\\\\{"'},me=function(){return"{"},de="\\}",ve={type:"literal",value:"\\}",description:'"\\\\}"'},ye=function(){return"}"},ge="\\u",_e={type:"literal",value:"\\u",description:'"\\\\u"'},we=function(e){return String.fromCharCode(parseInt(e,16))},be=function(e){return e.join("")},Fe=0,Ae=0,xe=[{line:1,column:1,seenCR:!1}],Te=0,Ce=[],Le=0;if("startRule"in a){if(!(a.startRule in i))throw new Error("Can't start parsing from rule \""+a.startRule+'".');l=i[a.startRule]}function Re(){return Ee(Ae,Fe)}function ke(e){var t,r,o=xe[e];if(o)return o;for(t=e-1;!xe[t];)t--;for(o={line:(o=xe[t]).line,column:o.column,seenCR:o.seenCR};t<e;)"\n"===(r=s.charAt(t))?(o.seenCR||o.line++,o.column=1,o.seenCR=!1):"\r"===r||"\u2028"===r||"\u2029"===r?(o.line++,o.column=1,o.seenCR=!0):(o.column++,o.seenCR=!1),t++;return xe[e]=o}function Ee(e,t){var r=ke(e),o=ke(t);return{start:{offset:e,line:r.line,column:r.column},end:{offset:t,line:o.line,column:o.column}}}function Oe(e){Fe<Te||(Te<Fe&&(Te=Fe,Ce=[]),Ce.push(e))}function Ne(){return Pe()}function Pe(){var e,t,r;for(e=Fe,t=[],r=Ie();r!==u;)t.push(r),r=Ie();return t!==u&&(Ae=e,t=c(t)),e=t}function Ie(){var e;return(e=function(){var e,t;return e=Fe,(t=function(){var e,t,r,o,n,a;if(t=[],r=e=Fe,(r=(o=Se())!==u?(n=Ze())!==u&&(a=Se())!==u?o=[o,n,a]:(Fe=r,u):(Fe=r,u))!==u)for(;r!==u;)t.push(r),r=Fe,o=Se(),r=o!==u&&(n=Ze())!==u&&(a=Se())!==u?o=[o,n,a]:(Fe=r,u);else t=u;return t!==u&&(Ae=e,t=f(t)),(e=t)===u&&(e=Fe,t=De(),e=t!==u?s.substring(e,Fe):t),e}())!==u&&(Ae=e,t=p(t)),e=t}())===u&&(e=function(){var e,t,r,o,n,a,i;return e=Fe,123===s.charCodeAt(Fe)?(t=d,Fe++):(t=u,0===Le&&Oe(v)),e=t!==u?Se()!==u&&(r=function(){var e,t,r;if((e=ze())===u){if(e=Fe,t=[],h.test(s.charAt(Fe))?(r=s.charAt(Fe),Fe++):(r=u,0===Le&&Oe(m)),r!==u)for(;r!==u;)t.push(r),h.test(s.charAt(Fe))?(r=s.charAt(Fe),Fe++):(r=u,0===Le&&Oe(m));else t=u;e=t!==u?s.substring(e,Fe):t}return e}())!==u&&Se()!==u?(o=Fe,44===s.charCodeAt(Fe)?(n=y,Fe++):(n=u,0===Le&&Oe(g)),(o=n!==u&&(a=Se())!==u&&(i=function(){var e;return(e=function(){var e,t,r,o,n,a;return e=Fe,s.substr(Fe,6)===F?(t=F,Fe+=6):(t=u,0===Le&&Oe(A)),t===u&&(s.substr(Fe,4)===x?(t=x,Fe+=4):(t=u,0===Le&&Oe(T)),t===u&&(s.substr(Fe,4)===C?(t=C,Fe+=4):(t=u,0===Le&&Oe(L)))),e=t!==u?Se()!==u?(r=Fe,44===s.charCodeAt(Fe)?(o=y,Fe++):(o=u,0===Le&&Oe(g)),(r=o!==u&&(n=Se())!==u&&(a=Ze())!==u?o=[o,n,a]:(Fe=r,u))===u&&(r=null),r!==u?(Ae=e,t=R(t,r)):(Fe=e,u)):(Fe=e,u):(Fe=e,u)}())===u&&(e=function(){var e,t,r,o;return e=Fe,s.substr(Fe,6)===k?(t=k,Fe+=6):(t=u,0===Le&&Oe(E)),e=t!==u?Se()!==u?(44===s.charCodeAt(Fe)?(r=y,Fe++):(r=u,0===Le&&Oe(g)),r!==u&&Se()!==u&&(o=Me())!==u?(Ae=e,t=O(o)):(Fe=e,u)):(Fe=e,u):(Fe=e,u)}())===u&&(e=function(){var e,t,r,o;return e=Fe,s.substr(Fe,13)===N?(t=N,Fe+=13):(t=u,0===Le&&Oe(P)),e=t!==u?Se()!==u?(44===s.charCodeAt(Fe)?(r=y,Fe++):(r=u,0===Le&&Oe(g)),r!==u&&Se()!==u&&(o=Me())!==u?(Ae=e,t=I(o)):(Fe=e,u)):(Fe=e,u):(Fe=e,u)}())===u&&(e=function(){var e,t,r,o,n;if(e=Fe,s.substr(Fe,6)===j?(t=j,Fe+=6):(t=u,0===Le&&Oe(M)),t!==u)if(Se()!==u)if(44===s.charCodeAt(Fe)?(r=y,Fe++):(r=u,0===Le&&Oe(g)),r!==u)if(Se()!==u){if(o=[],(n=je())!==u)for(;n!==u;)o.push(n),n=je();else o=u;e=o!==u?(Ae=e,t=D(o)):(Fe=e,u)}else Fe=e,e=u;else Fe=e,e=u;else Fe=e,e=u;else Fe=e,e=u;return e}()),e}())!==u?n=[n,a,i]:(Fe=o,u))===u&&(o=null),o!==u&&(n=Se())!==u?(125===s.charCodeAt(Fe)?(a=_,Fe++):(a=u,0===Le&&Oe(w)),a!==u?(Ae=e,t=b(r,o)):(Fe=e,u)):(Fe=e,u)):(Fe=e,u):(Fe=e,u)}()),e}function je(){var e,t,r,o,n;return e=Fe,e=Se()!==u&&(t=function(){var e,t,r,o;return t=e=Fe,61===s.charCodeAt(Fe)?(r=S,Fe++):(r=u,0===Le&&Oe(U)),(e=(t=r!==u&&(o=ze())!==u?r=[r,o]:(Fe=t,u))!==u?s.substring(e,Fe):t)===u&&(e=Ze()),e}())!==u&&Se()!==u?(123===s.charCodeAt(Fe)?(r=d,Fe++):(r=u,0===Le&&Oe(v)),r!==u&&Se()!==u&&(o=Pe())!==u&&Se()!==u?(125===s.charCodeAt(Fe)?(n=_,Fe++):(n=u,0===Le&&Oe(w)),n!==u?(Ae=e,G(t,o)):(Fe=e,u)):(Fe=e,u)):(Fe=e,u)}function Me(){var e,t,r,o;if(e=Fe,(t=function(){var e,t,r;return e=Fe,s.substr(Fe,7)===z?(t=z,Fe+=7):(t=u,0===Le&&Oe(V)),e=t!==u&&Se()!==u&&(r=ze())!==u?(Ae=e,t=Z(r)):(Fe=e,u)}())===u&&(t=null),t!==u)if(Se()!==u){if(r=[],(o=je())!==u)for(;o!==u;)r.push(o),o=je();else r=u;e=r!==u?(Ae=e,t=$(t,r)):(Fe=e,u)}else Fe=e,e=u;else Fe=e,e=u;return e}function De(){var e,t;if(Le++,e=[],H.test(s.charAt(Fe))?(t=s.charAt(Fe),Fe++):(t=u,0===Le&&Oe(W)),t!==u)for(;t!==u;)e.push(t),H.test(s.charAt(Fe))?(t=s.charAt(Fe),Fe++):(t=u,0===Le&&Oe(W));else e=u;return Le--,e===u&&(t=u,0===Le&&Oe(B)),e}function Se(){var e,t,r;for(Le++,e=Fe,t=[],r=De();r!==u;)t.push(r),r=De();return e=t!==u?s.substring(e,Fe):t,Le--,e===u&&(t=u,0===Le&&Oe(q)),e}function Ue(){var e;return J.test(s.charAt(Fe))?(e=s.charAt(Fe),Fe++):(e=u,0===Le&&Oe(K)),e}function Ge(){var e;return Q.test(s.charAt(Fe))?(e=s.charAt(Fe),Fe++):(e=u,0===Le&&Oe(X)),e}function ze(){var e,t,r,o,n,a;if(e=Fe,48===s.charCodeAt(Fe)?(t=Y,Fe++):(t=u,0===Le&&Oe(ee)),t===u){if(r=t=Fe,te.test(s.charAt(Fe))?(o=s.charAt(Fe),Fe++):(o=u,0===Le&&Oe(re)),o!==u){for(n=[],a=Ue();a!==u;)n.push(a),a=Ue();r=n!==u?o=[o,n]:(Fe=r,u)}else Fe=r,r=u;t=r!==u?s.substring(t,Fe):r}return t!==u&&(Ae=e,t=oe(t)),e=t}function Ve(){var e,t,r,o,n,a,i,l;return ne.test(s.charAt(Fe))?(e=s.charAt(Fe),Fe++):(e=u,0===Le&&Oe(ae)),e===u&&(e=Fe,s.substr(Fe,2)===ie?(t=ie,Fe+=2):(t=u,0===Le&&Oe(le)),t!==u&&(Ae=e,t=se()),(e=t)===u&&(e=Fe,s.substr(Fe,2)===ue?(t=ue,Fe+=2):(t=u,0===Le&&Oe(ce)),t!==u&&(Ae=e,t=fe()),(e=t)===u&&(e=Fe,s.substr(Fe,2)===pe?(t=pe,Fe+=2):(t=u,0===Le&&Oe(he)),t!==u&&(Ae=e,t=me()),(e=t)===u&&(e=Fe,s.substr(Fe,2)===de?(t=de,Fe+=2):(t=u,0===Le&&Oe(ve)),t!==u&&(Ae=e,t=ye()),(e=t)===u&&(e=Fe,s.substr(Fe,2)===ge?(t=ge,Fe+=2):(t=u,0===Le&&Oe(_e)),e=t!==u?(o=r=Fe,(r=(o=(n=Ge())!==u&&(a=Ge())!==u&&(i=Ge())!==u&&(l=Ge())!==u?n=[n,a,i,l]:(Fe=o,u))!==u?s.substring(r,Fe):o)!==u?(Ae=e,t=we(r)):(Fe=e,u)):(Fe=e,u)))))),e}function Ze(){var e,t,r;if(e=Fe,t=[],(r=Ve())!==u)for(;r!==u;)t.push(r),r=Ve();else t=u;return t!==u&&(Ae=e,t=be(t)),e=t}if((e=l())!==u&&Fe===s.length)return e;throw e!==u&&Fe<s.length&&Oe({type:"end",description:"end of input"}),t=null,r=Ce,o=Te<s.length?s.charAt(Te):null,n=Te<s.length?Ee(Te,Te+1):Ee(Te,Te),null!==r&&function(e){var t=1;for(e.sort(function(e,t){return e.description<t.description?-1:e.description>t.description?1:0});t<e.length;)e[t-1]===e[t]?e.splice(t,1):t++}(r),new $e(null!==t?t:function(e,t){var r,o=new Array(e.length);for(r=0;r<e.length;r++)o[r]=e[r].description;function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}return"Expected "+(1<e.length?o.slice(0,-1).join(", ")+" or "+o[e.length-1]:o[0])+" but "+(t?'"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(e){return"\\x0"+n(e)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(e){return"\\x"+n(e)}).replace(/[\u0100-\u0FFF]/g,function(e){return"\\u0"+n(e)}).replace(/[\u1000-\uFFFF]/g,function(e){return"\\u"+n(e)})+'"':"end of input")+" found."}(r,o),r,o,n)}});function $e(e,t,r,o){this.message=e,this.expected=t,this.found=r,this.location=o,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,$e)}function p(){this.constructor=e}function h(t,e,r){var o="string"==typeof t?h.__parse(t):t;if(!o||"messageFormatPattern"!==o.type)throw new TypeError("A message must be provided as a String or AST.");r=this._mergeFormats(h.formats,r),l(this,"_locale",{value:this._resolveLocale(e)});var n=this._findPluralRuleFunction(this._locale),a=this._compilePattern(o,e,r,n),i=this;this.format=function(e){try{return i._format(a,e)}catch(e){throw e.variableId?new Error("The intl string context variable '"+e.variableId+"' was not provided to the string '"+t+"'"):e}}}l(h,"formats",{enumerable:!0,value:{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"}}}}),l(h,"__localeData__",{value:i(null)}),l(h,"__addLocaleData",{value:function(e){if(!e||!e.locale)throw new Error("Locale data provided to IntlMessageFormat is missing a `locale` property");h.__localeData__[e.locale.toLowerCase()]=e}}),l(h,"__parse",{value:o.parse}),l(h,"defaultLocale",{enumerable:!0,writable:!0,value:void 0}),h.prototype.resolvedOptions=function(){return{locale:this._locale}},h.prototype._compilePattern=function(e,t,r,o){return new n(t,r,o).compile(e)},h.prototype._findPluralRuleFunction=function(e){for(var t=h.__localeData__,r=t[e.toLowerCase()];r;){if(r.pluralRuleFunction)return r.pluralRuleFunction;r=r.parentLocale&&t[r.parentLocale.toLowerCase()]}throw new Error("Locale data added to IntlMessageFormat is missing a `pluralRuleFunction` for :"+e)},h.prototype._format=function(e,t){var r,o,n,a,i,l,s="";for(r=0,o=e.length;r<o;r+=1)if("string"!=typeof(n=e[r])){if(a=n.id,!t||!u.call(t,a))throw(l=new Error("A value must be provided for: "+a)).variableId=a,l;i=t[a],n.options?s+=this._format(n.getOption(i),t):s+=n.format(i)}else s+=n;return s},h.prototype._mergeFormats=function(e,t){var r,o,n={};for(r in e)u.call(e,r)&&(n[r]=o=i(e[r]),t&&u.call(t,r)&&a(o,t[r]));return n},h.prototype._resolveLocale=function(e){"string"==typeof e&&(e=[e]),e=(e||[]).concat(h.defaultLocale);var t,r,o,n,a=h.__localeData__;for(t=0,r=e.length;t<r;t+=1)for(o=e[t].toLowerCase().split("-");o.length;){if(n=a[o.join("-")])return n.locale;o.pop()}var i=e.pop();throw new Error("No locale data has been added to IntlMessageFormat for: "+e.join(", ")+", or the default locale: "+i)},h.__addLocaleData({locale:"en",pluralRuleFunction:function(e,t){var r=String(e).split("."),o=!r[1],n=Number(r[0])==e,a=n&&r[0].slice(-1),i=n&&r[0].slice(-2);return t?1==a&&11!=i?"one":2==a&&12!=i?"two":3==a&&13!=i?"few":"other":1==e&&o?"one":"other"}}),h.defaultLocale="en";var m=Math.round;var d=6e4,v=864e5;function y(e){var t=new Date(e);return t.setHours(0,0,0,0),t}function g(e,t){var r=m((t=+t)-(e=+e)),o=m(r/1e3),n=m(o/60),a=m(n/60),i=function(e,t){var r=y(e),o=y(t),n=r.getTime()-r.getTimezoneOffset()*d,a=o.getTime()-o.getTimezoneOffset()*d;return Math.round((n-a)/v)}(t,e),l=m(i/7),s=function(e){return 400*e/146097}(i),u=m(12*s),c=m(s);return{millisecond:r,second:o,"second-short":o,minute:n,"minute-short":n,hour:a,"hour-short":a,day:i,"day-short":i,week:l,"week-short":l,month:u,"month-short":u,year:c,"year-short":c}}var _=Object.prototype.hasOwnProperty,w=Object.prototype.toString,b=function(){try{return!!Object.defineProperty({},"a",{})}catch(e){return!1}}()?Object.defineProperty:function(e,t,r){"get"in r&&e.__defineGetter__?e.__defineGetter__(t,r.get):(!_.call(e,t)||"value"in r)&&(e[t]=r.value)},F=Object.create||function(e,t){var r,o;function n(){}for(o in n.prototype=e,r=new n,t)_.call(t,o)&&b(r,o,t[o]);return r},A=Array.prototype.indexOf||function(e,t){if(!this.length)return-1;for(var r=t||0,o=this.length;r<o;r++)if(this[r]===e)return r;return-1},x=Array.isArray||function(e){return"[object Array]"===w.call(e)},T=Date.now||function(){return(new Date).getTime()},C=["second","second-short","minute","minute-short","hour","hour-short","day","day-short","month","month-short","year","year-short"],L=["best fit","numeric"];function R(e,t){t=t||{},x(e)&&(e=e.concat()),b(this,"_locale",{value:this._resolveLocale(e)}),b(this,"_options",{value:{style:this._resolveStyle(t.style),units:this._isValidUnits(t.units)&&t.units}}),b(this,"_locales",{value:e}),b(this,"_fields",{value:this._findFields(this._locale)}),b(this,"_messages",{value:F(null)});var r=this;this.format=function(e,t){return r._format(e,t)}}return b(R,"__localeData__",{value:F(null)}),b(R,"__addLocaleData",{value:function(){for(var e=0;e<arguments.length;e++){var t=arguments[e];if(!t||!t.locale)throw new Error("Locale data provided to IntlRelativeFormat is missing a `locale` property value");R.__localeData__[t.locale.toLowerCase()]=t,h.__addLocaleData(t)}}}),b(R,"defaultLocale",{enumerable:!0,writable:!0,value:void 0}),b(R,"thresholds",{enumerable:!0,value:{second:45,"second-short":45,minute:45,"minute-short":45,hour:22,"hour-short":22,day:26,"day-short":26,month:11,"month-short":11}}),R.prototype.resolvedOptions=function(){return{locale:this._locale,style:this._options.style,units:this._options.units}},R.prototype._compileMessage=function(e){var t,r=this._locales,o=(this._locale,this._fields[e].relativeTime),n="",a="";for(t in o.future)o.future.hasOwnProperty(t)&&(n+=" "+t+" {"+o.future[t].replace("{0}","#")+"}");for(t in o.past)o.past.hasOwnProperty(t)&&(a+=" "+t+" {"+o.past[t].replace("{0}","#")+"}");return new h("{when, select, future {{0, plural, "+n+"}}past {{0, plural, "+a+"}}}",r)},R.prototype._getMessage=function(e){var t=this._messages;return t[e]||(t[e]=this._compileMessage(e)),t[e]},R.prototype._getRelativeUnits=function(e,t){var r=this._fields[t];if(r.relative)return r.relative[e]},R.prototype._findFields=function(e){for(var t=R.__localeData__,r=t[e.toLowerCase()];r;){if(r.fields)return r.fields;r=r.parentLocale&&t[r.parentLocale.toLowerCase()]}throw new Error("Locale data added to IntlRelativeFormat is missing `fields` for :"+e)},R.prototype._format=function(e,t){var r=t&&void 0!==t.now?t.now:T();if(void 0===e&&(e=r),!isFinite(r))throw new RangeError("The `now` option provided to IntlRelativeFormat#format() is not in valid range.");if(!isFinite(e))throw new RangeError("The date value provided to IntlRelativeFormat#format() is not in valid range.");var o=g(r,e),n=this._options.units||this._selectUnits(o),a=o[n];if("numeric"!==this._options.style){var i=this._getRelativeUnits(a,n);if(i)return i}return this._getMessage(n).format({0:Math.abs(a),when:a<0?"past":"future"})},R.prototype._isValidUnits=function(e){if(!e||0<=A.call(C,e))return!0;if("string"==typeof e){var t=/s$/.test(e)&&e.substr(0,e.length-1);if(t&&0<=A.call(C,t))throw new Error('"'+e+'" is not a valid IntlRelativeFormat `units` value, did you mean: '+t)}throw new Error('"'+e+'" is not a valid IntlRelativeFormat `units` value, it must be one of: "'+C.join('", "')+'"')},R.prototype._resolveLocale=function(e){"string"==typeof e&&(e=[e]),e=(e||[]).concat(R.defaultLocale);var t,r,o,n,a=R.__localeData__;for(t=0,r=e.length;t<r;t+=1)for(o=e[t].toLowerCase().split("-");o.length;){if(n=a[o.join("-")])return n.locale;o.pop()}var i=e.pop();throw new Error("No locale data has been added to IntlRelativeFormat for: "+e.join(", ")+", or the default locale: "+i)},R.prototype._resolveStyle=function(e){if(!e)return L[0];if(0<=A.call(L,e))return e;throw new Error('"'+e+'" is not a valid IntlRelativeFormat `style` value, it must be one of: "'+L.join('", "')+'"')},R.prototype._selectUnits=function(e){var t,r,o,n=C.filter(function(e){return e.indexOf("-short")<1});for(t=0,r=n.length;t<r&&(o=n[t],!(Math.abs(e[o])<R.thresholds[o]));t+=1);return o},R.__addLocaleData({locale:"en",pluralRuleFunction:function(e,t){var r=String(e).split("."),o=!r[1],n=Number(r[0])==e,a=n&&r[0].slice(-1),i=n&&r[0].slice(-2);return t?1==a&&11!=i?"one":2==a&&12!=i?"two":3==a&&13!=i?"few":"other":1==e&&o?"one":"other"},fields:{year:{displayName:"year",relative:{0:"this year",1:"next year","-1":"last year"},relativeTime:{future:{one:"in {0} year",other:"in {0} years"},past:{one:"{0} year ago",other:"{0} years ago"}}},"year-short":{displayName:"yr.",relative:{0:"this yr.",1:"next yr.","-1":"last yr."},relativeTime:{future:{one:"in {0} yr.",other:"in {0} yr."},past:{one:"{0} yr. ago",other:"{0} yr. ago"}}},month:{displayName:"month",relative:{0:"this month",1:"next month","-1":"last month"},relativeTime:{future:{one:"in {0} month",other:"in {0} months"},past:{one:"{0} month ago",other:"{0} months ago"}}},"month-short":{displayName:"mo.",relative:{0:"this mo.",1:"next mo.","-1":"last mo."},relativeTime:{future:{one:"in {0} mo.",other:"in {0} mo."},past:{one:"{0} mo. ago",other:"{0} mo. ago"}}},week:{displayName:"week",relativePeriod:"the week of {0}",relative:{0:"this week",1:"next week","-1":"last week"},relativeTime:{future:{one:"in {0} week",other:"in {0} weeks"},past:{one:"{0} week ago",other:"{0} weeks ago"}}},"week-short":{displayName:"wk.",relativePeriod:"the week of {0}",relative:{0:"this wk.",1:"next wk.","-1":"last wk."},relativeTime:{future:{one:"in {0} wk.",other:"in {0} wk."},past:{one:"{0} wk. ago",other:"{0} wk. ago"}}},day:{displayName:"day",relative:{0:"today",1:"tomorrow","-1":"yesterday"},relativeTime:{future:{one:"in {0} day",other:"in {0} days"},past:{one:"{0} day ago",other:"{0} days ago"}}},"day-short":{displayName:"day",relative:{0:"today",1:"tomorrow","-1":"yesterday"},relativeTime:{future:{one:"in {0} day",other:"in {0} days"},past:{one:"{0} day ago",other:"{0} days ago"}}},hour:{displayName:"hour",relative:{0:"this hour"},relativeTime:{future:{one:"in {0} hour",other:"in {0} hours"},past:{one:"{0} hour ago",other:"{0} hours ago"}}},"hour-short":{displayName:"hr.",relative:{0:"this hour"},relativeTime:{future:{one:"in {0} hr.",other:"in {0} hr."},past:{one:"{0} hr. ago",other:"{0} hr. ago"}}},minute:{displayName:"minute",relative:{0:"this minute"},relativeTime:{future:{one:"in {0} minute",other:"in {0} minutes"},past:{one:"{0} minute ago",other:"{0} minutes ago"}}},"minute-short":{displayName:"min.",relative:{0:"this minute"},relativeTime:{future:{one:"in {0} min.",other:"in {0} min."},past:{one:"{0} min. ago",other:"{0} min. ago"}}},second:{displayName:"second",relative:{0:"now"},relativeTime:{future:{one:"in {0} second",other:"in {0} seconds"},past:{one:"{0} second ago",other:"{0} seconds ago"}}},"second-short":{displayName:"sec.",relative:{0:"now"},relativeTime:{future:{one:"in {0} sec.",other:"in {0} sec."},past:{one:"{0} sec. ago",other:"{0} sec. ago"}}}}}),R.defaultLocale="en",R});
//# sourceMappingURL=intl-relativeformat.min.js.map

@@ -14,2 +14,24 @@ "use strict";

}
// Thanks to date-fns
// https://github.com/date-fns/date-fns
// MIT © Sasha Koss
var MILLISECONDS_IN_MINUTE = 60000;
var MILLISECONDS_IN_DAY = 86400000;
function startOfDay(dirtyDate) {
var date = new Date(dirtyDate);
date.setHours(0, 0, 0, 0);
return date;
}
function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {
var startOfDayLeft = startOfDay(dirtyDateLeft);
var startOfDayRight = startOfDay(dirtyDateRight);
var timestampLeft = startOfDayLeft.getTime() -
startOfDayLeft.getTimezoneOffset() * MILLISECONDS_IN_MINUTE;
var timestampRight = startOfDayRight.getTime() -
startOfDayRight.getTimezoneOffset() * MILLISECONDS_IN_MINUTE;
// Round the number of days to the nearest integer
// because the number of milliseconds in a day is not constant
// (e.g. it's different in the day of the daylight saving time clock shift)
return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY);
}
function default_1(from, to) {

@@ -19,3 +41,8 @@ // Convert to ms timestamps.

to = +to;
var millisecond = round(to - from), second = round(millisecond / 1000), minute = round(second / 60), hour = round(minute / 60), day = round(hour / 24), week = round(day / 7);
var millisecond = round(to - from), second = round(millisecond / 1000), minute = round(second / 60), hour = round(minute / 60);
// We expect a more precision in rounding when dealing with
// days as it feels wrong when something happended 13 hours ago and
// is regarded as "yesterday" even if the time was this morning.
var day = differenceInCalendarDays(to, from);
var week = round(day / 7);
var rawYears = daysToYears(day), month = round(rawYears * 12), year = round(rawYears);

@@ -22,0 +49,0 @@ return {

{
"name": "intl-relativeformat",
"version": "2.1.3",
"version": "2.2.0",
"description": "Formats JavaScript dates to relative time strings.",

@@ -34,8 +34,8 @@ "keywords": [

"scripts": {
"build": "npm run clean && npm run cldr && tsc -p src && rollup -c rollup.config.js",
"cldr": "node scripts/cldr",
"clean": "rimraf dist lib",
"cldr": "node scripts/cldr",
"test": "mocha tests/runner.js --reporter spec",
"cover": "nyc -x lib/locales.js npm t",
"build": "npm run clean && npm run cldr && tsc -p src && rollup -c rollup.config.js",
"prepublishOnly": "npm run build"
"prepublishOnly": "npm run build",
"test": "mocha -r chai/register-expect tests/index.js --reporter spec"
},

@@ -47,3 +47,3 @@ "homepage": "https://github.com/yahoo/intl-relativeformat",

"license": "BSD-3-Clause",
"gitHead": "269fcf42ff059d3eed8ede78684ca00c27010719"
"gitHead": "26fee81740653f1adfdf7737634ed71429dc5d62"
}
import { uglify } from 'rollup-plugin-uglify';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs'
import typescript from 'rollup-plugin-typescript'

@@ -48,3 +50,13 @@ const resolveConfig = resolve({

plugins: [resolveConfig, uglifyConfig]
},
{
input: './tests/index.js',
output: {
sourcemap: true,
file: 'tests/browser.js',
format: 'umd',
name: 'Test'
},
plugins: [typescript(), resolveConfig, commonjs()]
}
];

@@ -16,2 +16,30 @@ /*

// Thanks to date-fns
// https://github.com/date-fns/date-fns
// MIT © Sasha Koss
var MILLISECONDS_IN_MINUTE = 60000;
var MILLISECONDS_IN_DAY = 86400000;
function startOfDay (dirtyDate) {
var date = new Date(dirtyDate);
date.setHours(0, 0, 0, 0);
return date;
}
function differenceInCalendarDays (dirtyDateLeft, dirtyDateRight) {
var startOfDayLeft = startOfDay(dirtyDateLeft);
var startOfDayRight = startOfDay(dirtyDateRight);
var timestampLeft = startOfDayLeft.getTime() -
startOfDayLeft.getTimezoneOffset() * MILLISECONDS_IN_MINUTE;
var timestampRight = startOfDayRight.getTime() -
startOfDayRight.getTimezoneOffset() * MILLISECONDS_IN_MINUTE;
// Round the number of days to the nearest integer
// because the number of milliseconds in a day is not constant
// (e.g. it's different in the day of the daylight saving time clock shift)
return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY);
}
export default function (from, to) {

@@ -25,6 +53,11 @@ // Convert to ms timestamps.

minute = round(second / 60),
hour = round(minute / 60),
day = round(hour / 24),
week = round(day / 7);
hour = round(minute / 60);
// We expect a more precision in rounding when dealing with
// days as it feels wrong when something happended 13 hours ago and
// is regarded as "yesterday" even if the time was this morning.
var day = differenceInCalendarDays(to, from);
var week = round(day / 7);
var rawYears = daysToYears(day),

@@ -31,0 +64,0 @@ month = round(rawYears * 12),

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 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