javascript-time-ago 2.5.12 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -1
- package/README.md +462 -316
- package/bundle/javascript-time-ago.js +1 -1
- package/bundle/javascript-time-ago.js.map +1 -1
- package/bundle/javascript-time-ago.min.js +1 -1
- package/bundle/javascript-time-ago.min.js.map +1 -1
- package/commonjs/FullDateFormatter.js +72 -0
- package/commonjs/FullDateFormatter.js.map +1 -0
- package/commonjs/FullDateFormatter.test.js +26 -0
- package/commonjs/FullDateFormatter.test.js.map +1 -0
- package/commonjs/TimeAgo.js +208 -106
- package/commonjs/TimeAgo.js.map +1 -1
- package/commonjs/TimeAgo.test.js +95 -10
- package/commonjs/TimeAgo.test.js.map +1 -1
- package/commonjs/steps/getStepMinTime.js +26 -19
- package/commonjs/steps/getStepMinTime.js.map +1 -1
- package/commonjs/steps/getTimeToNextUpdate.js +10 -2
- package/commonjs/steps/getTimeToNextUpdate.js.map +1 -1
- package/commonjs/style/twitter.js +2 -3
- package/commonjs/style/twitter.js.map +1 -1
- package/commonjs/style/twitter.test.js +5 -2
- package/commonjs/style/twitter.test.js.map +1 -1
- package/full-date-formatter/index.cjs +4 -0
- package/full-date-formatter/index.cjs.js +9 -0
- package/full-date-formatter/index.d.ts +6 -0
- package/full-date-formatter/index.js +1 -0
- package/full-date-formatter/package.json +15 -0
- package/index.cjs +1 -1
- package/index.cjs.js +2 -2
- package/index.d.ts +14 -4
- package/index.js +3 -1
- package/modules/FullDateFormatter.js +67 -0
- package/modules/FullDateFormatter.js.map +1 -0
- package/modules/FullDateFormatter.test.js +22 -0
- package/modules/FullDateFormatter.test.js.map +1 -0
- package/modules/TimeAgo.js +208 -107
- package/modules/TimeAgo.js.map +1 -1
- package/modules/TimeAgo.test.js +95 -8
- package/modules/TimeAgo.test.js.map +1 -1
- package/modules/steps/getStepMinTime.js +26 -19
- package/modules/steps/getStepMinTime.js.map +1 -1
- package/modules/steps/getTimeToNextUpdate.js +10 -2
- package/modules/steps/getTimeToNextUpdate.js.map +1 -1
- package/modules/style/twitter.js +3 -3
- package/modules/style/twitter.js.map +1 -1
- package/modules/style/twitter.test.js +5 -2
- package/modules/style/twitter.test.js.map +1 -1
- package/package.json +16 -11
package/commonjs/TimeAgo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeAgo.js","names":["_relativeTimeFormat","_interopRequireDefault","require","_cache","_locale","_isStyleObject","_getStep3","_getStepDenominator","_getTimeToNextUpdate","_LocaleDataStore","_roundMinute","_getStyleByName","_round","e","__esModule","_typeof","o","Symbol","iterator","constructor","prototype","_createForOfIteratorHelperLoose","r","t","call","next","bind","Array","isArray","_unsupportedIterableToArray","length","done","value","TypeError","_slicedToArray","_arrayWithHoles","_iterableToArrayLimit","_nonIterableRest","a","_arrayLikeToArray","toString","slice","name","from","test","n","l","i","u","f","Object","push","_classCallCheck","_defineProperties","enumerable","configurable","writable","defineProperty","_toPropertyKey","key","_createClass","_toPrimitive","toPrimitive","String","Number","UNITS","TimeAgo","exports","locales","arguments","undefined","_ref","polyfill","locale","chooseLocale","concat","getDefaultLocale","getLocaleData","Intl","NumberFormat","numberFormat","IntlRelativeTimeFormat","RelativeTimeFormat","IntlPluralRules","PluralRules","RelativeTimeFormatPolyfill","relativeTimeFormatCache","Cache","pluralRulesCache","format","input","style","options","isStyle","defaultStyle","getStyleByName","timestamp","getTimestamp","_this$getLabels","getLabels","flavour","labels","labelsType","now","Date","secondsPassed","future","nowLabel","getNowLabel","custom","date","time","elapsed","units","getTimeIntervalMeasurementUnits","round","_getStep","getStep","gradation","steps","getNextStep","_getStep2","prevStep","step","nextStep","formattedDate","formatDateForStep","getTimeToNextUpdate","timeToNextUpdate","_ref2","_this","formatAs","unit","formatValue","Error","JSON","stringify","amount","Math","abs","getStepDenominator","granularity","getRoundFunction","valueForFormatting","sign","getFormatter","_ref3","getFormattingRule","replace","formatNumber","formattingRules","_ref4","pastOrFuture","quantifierRules","quantifier","getPluralRules","select","other","number","get","put","map","localeData","_iterator","_step","_labelsType","defaultLocale","setDefaultLocale","addDefaultLocale","defaultLocaleHasBeenSpecified","console","error","addLocale","addLocaleData","addLabels","isMockedDate","getTime","object","allowedUnits","keys","filter","indexOf","nowLabels","longLabels","past","second","current","variable","isStyleObject"],"sources":["../source/TimeAgo.js"],"sourcesContent":["import RelativeTimeFormatPolyfill from 'relative-time-format'\r\n\r\nimport Cache from './cache.js'\r\nimport chooseLocale from './locale.js'\r\nimport isStyleObject from './isStyleObject.js'\r\n\r\nimport getStep from './steps/getStep.js'\r\nimport getStepDenominator from './steps/getStepDenominator.js'\r\nimport getTimeToNextUpdate from './steps/getTimeToNextUpdate.js'\r\n\r\nimport {\r\n\taddLocaleData,\r\n\tgetLocaleData\r\n} from './LocaleDataStore.js'\r\n\r\nimport defaultStyle from './style/roundMinute.js'\r\nimport getStyleByName from './style/getStyleByName.js'\r\n\r\nimport { getRoundFunction } from './round.js'\r\n\r\n// Valid time units.\r\nconst UNITS = [\r\n\t'now',\r\n\t// The rest are the same as in `Intl.RelativeTimeFormat`.\r\n\t'second',\r\n\t'minute',\r\n\t'hour',\r\n\t'day',\r\n\t'week',\r\n\t'month',\r\n\t'quarter',\r\n\t'year'\r\n]\r\n\r\nexport default class TimeAgo {\r\n\t/**\r\n\t * @param {(string|string[])} locales=[] - Preferred locales (or locale).\r\n\t * @param {boolean} [polyfill] — Pass `false` to use native `Intl.RelativeTimeFormat` and `Intl.PluralRules` instead of the polyfills.\r\n\t */\r\n\tconstructor(locales = [], { polyfill } = {}) {\r\n\t\t// Convert `locales` to an array.\r\n\t\tif (typeof locales === 'string') {\r\n\t\t\tlocales = [locales]\r\n\t\t}\r\n\r\n\t\t// Choose the most appropriate locale\r\n\t\t// from the list of `locales` added by the user.\r\n\t\t// For example, new TimeAgo(\"en-US\") -> \"en\".\r\n\t\tthis.locale = chooseLocale(\r\n\t\t\tlocales.concat(TimeAgo.getDefaultLocale()),\r\n\t\t\tgetLocaleData\r\n\t\t)\r\n\r\n\t\tif (typeof Intl !== 'undefined') {\r\n\t\t\t// Use `Intl.NumberFormat` for formatting numbers (when available).\r\n\t\t\tif (Intl.NumberFormat) {\r\n\t\t\t\tthis.numberFormat = new Intl.NumberFormat(this.locale)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Some people have requested the ability to use native\r\n\t\t// `Intl.RelativeTimeFormat` and `Intl.PluralRules`\r\n\t\t// instead of the polyfills.\r\n\t\t// https://github.com/catamphetamine/javascript-time-ago/issues/21\r\n\t\tif (polyfill === false) {\r\n\t\t\tthis.IntlRelativeTimeFormat = Intl.RelativeTimeFormat\r\n\t\t\tthis.IntlPluralRules = Intl.PluralRules\r\n\t\t} else {\r\n\t\t\tthis.IntlRelativeTimeFormat = RelativeTimeFormatPolyfill\r\n\t\t\tthis.IntlPluralRules = RelativeTimeFormatPolyfill.PluralRules\r\n\t\t}\r\n\r\n\t\t// Cache `Intl.RelativeTimeFormat` instance.\r\n\t\tthis.relativeTimeFormatCache = new Cache()\r\n\r\n\t\t// Cache `Intl.PluralRules` instance.\r\n\t\tthis.pluralRulesCache = new Cache()\r\n\t}\r\n\r\n\t/**\r\n\t * Formats relative date/time.\r\n\t *\r\n\t * @param {(number|Date)} input — A `Date` or a javascript timestamp.\r\n\t *\r\n\t * @param {(string|object)} style — Date/time formatting style. Either one of the built-in style names or a \"custom\" style definition object having `steps: object[]` and `labels: string[]`.\r\n\t *\r\n\t * @param {number} [options.now] - Sets the current date timestamp.\r\n\t *\r\n\t * @param {boolean} [options.future] — Tells how to format value `0`:\r\n\t * as \"future\" (`true`) or \"past\" (`false`).\r\n\t * Is `false` by default, but should have been `true` actually,\r\n\t * in order to correspond to `Intl.RelativeTimeFormat`\r\n\t * that uses `future` formatting for `0` unless `-0` is passed.\r\n\t *\r\n\t * @param {string} [options.round] — Rounding method. Overrides the style's one.\r\n\t *\r\n\t * @param {boolean} [options.getTimeToNextUpdate] — Pass `true` to return `[formattedDate, timeToNextUpdate]` instead of just `formattedDate`.\r\n\t *\r\n\t * @return {string} The formatted relative date/time. If no eligible `step` is found, then an empty string is returned.\r\n\t */\r\n\tformat(input, style, options) {\r\n\t\tif (!options) {\r\n\t\t\tif (style && !isStyle(style)) {\r\n\t\t\t\toptions = style\r\n\t\t\t\tstyle = undefined\r\n\t\t\t} else {\r\n\t\t\t\toptions = {}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!style) {\r\n\t\t\tstyle = defaultStyle\r\n\t\t}\r\n\r\n\t\tif (typeof style === 'string') {\r\n\t\t\tstyle = getStyleByName(style)\r\n\t\t}\r\n\r\n\t\tconst timestamp = getTimestamp(input)\r\n\r\n\t\t// Get locale messages for this type of labels.\r\n\t\t// \"flavour\" is a legacy name for \"labels\".\r\n\t\tconst { labels, labelsType } = this.getLabels(style.flavour || style.labels)\r\n\r\n\t\tlet now\r\n\t\t// Can pass a custom `now`, e.g. for testing purposes.\r\n\t\t//\r\n\t\t// Legacy way was passing `now` in `style`.\r\n\t\t// That way is deprecated.\r\n\t\tif (style.now !== undefined) {\r\n\t\t\tnow = style.now\r\n\t\t}\r\n\t\t// The new way is passing `now` option to `.format()`.\r\n\t\tif (now === undefined && options.now !== undefined) {\r\n\t\t\tnow = options.now\r\n\t\t}\r\n\t\tif (now === undefined) {\r\n\t\t\tnow = Date.now()\r\n\t\t}\r\n\r\n\t\t// how much time has passed (in seconds)\r\n\t\tconst secondsPassed = (now - timestamp) / 1000 // in seconds\r\n\r\n\t\tconst future = options.future || secondsPassed < 0\r\n\r\n\t\tconst nowLabel = getNowLabel(\r\n\t\t\tlabels,\r\n\t\t\tgetLocaleData(this.locale).now,\r\n\t\t\tgetLocaleData(this.locale).long,\r\n\t\t\tfuture\r\n\t\t)\r\n\r\n\t\t// `custom` – A function of `{ elapsed, time, date, now, locale }`.\r\n\t\t//\r\n\t\t// Looks like `custom` function is deprecated and will be removed\r\n\t\t// in the next major version.\r\n\t\t//\r\n\t\t// If this function returns a value, then the `.format()` call will return that value.\r\n\t\t// Otherwise the relative date/time is formatted as usual.\r\n\t\t// This feature is currently not used anywhere and is here\r\n\t\t// just for providing the ultimate customization point\r\n\t\t// in case anyone would ever need that. Prefer using\r\n\t\t// `steps[step].format(value, locale)` instead.\r\n\t\t//\r\n\t\tif (style.custom) {\r\n\t\t\tconst custom = style.custom({\r\n\t\t\t\tnow,\r\n\t\t\t\tdate: new Date(timestamp),\r\n\t\t\t\ttime: timestamp,\r\n\t\t\t\telapsed: secondsPassed,\r\n\t\t\t\tlocale: this.locale\r\n\t\t\t})\r\n\t\t\tif (custom !== undefined) {\r\n\t\t\t\t// Won't return `timeToNextUpdate` here\r\n\t\t\t\t// because `custom()` seems deprecated.\r\n\t\t\t\treturn custom\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Get the list of available time interval units.\r\n\t\tconst units = getTimeIntervalMeasurementUnits(\r\n\t\t\t// Controlling `style.steps` through `style.units` seems to be deprecated:\r\n\t\t\t// create a new custom `style` instead.\r\n\t\t\tstyle.units,\r\n\t\t\tlabels,\r\n\t\t\tnowLabel\r\n\t\t)\r\n\r\n\t\t// // If no available time unit is suitable, just output an empty string.\r\n\t\t// if (units.length === 0) {\r\n\t\t// \tconsole.error(`None of the \"${units.join(', ')}\" time units have been found in \"${labelsType}\" labels for \"${this.locale}\" locale.`)\r\n\t\t// \treturn ''\r\n\t\t// }\r\n\r\n\t\tconst round = options.round || style.round\r\n\r\n\t\t// Choose the appropriate time measurement unit\r\n\t\t// and get the corresponding rounded time amount.\r\n\t\tconst [prevStep, step, nextStep] = getStep(\r\n\t\t\t// \"gradation\" is a legacy name for \"steps\".\r\n\t\t\t// For historical reasons, \"approximate\" steps are used by default.\r\n\t\t\t// In the next major version, there'll be no default for `steps`.\r\n\t\t\tstyle.gradation || style.steps || defaultStyle.steps,\r\n\t\t\tsecondsPassed,\r\n\t\t\t{ now, units, round, future, getNextStep: true }\r\n\t\t)\r\n\r\n\t\tconst formattedDate = this.formatDateForStep(timestamp, step, secondsPassed, {\r\n\t\t\tlabels,\r\n\t\t\tlabelsType,\r\n\t\t\tnowLabel,\r\n\t\t\tnow,\r\n\t\t\tfuture,\r\n\t\t\tround\r\n\t\t}) || ''\r\n\r\n\t\tif (options.getTimeToNextUpdate) {\r\n\t\t\tconst timeToNextUpdate = getTimeToNextUpdate(timestamp, step, {\r\n\t\t\t\tnextStep,\r\n\t\t\t\tprevStep,\r\n\t\t\t\tnow,\r\n\t\t\t\tfuture,\r\n\t\t\t\tround\r\n\t\t\t})\r\n\t\t\treturn [formattedDate, timeToNextUpdate]\r\n\t\t}\r\n\r\n\t\treturn formattedDate\r\n\t}\r\n\r\n\tformatDateForStep(timestamp, step, secondsPassed, {\r\n\t\tlabels,\r\n\t\tlabelsType,\r\n\t\tnowLabel,\r\n\t\tnow,\r\n\t\tfuture,\r\n\t\tround\r\n\t}) {\r\n\t\t// If no step matches, then output an empty string.\r\n\t\tif (!step) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (step.format) {\r\n\t\t\treturn step.format(timestamp, this.locale, {\r\n\t\t\t\tformatAs: (unit, value) => {\r\n\t\t\t\t\t// Mimicks `Intl.RelativeTimeFormat.format()`.\r\n\t\t\t\t\treturn this.formatValue(value, unit, {\r\n\t\t\t\t\t\tlabels,\r\n\t\t\t\t\t\tfuture\r\n\t\t\t\t\t})\r\n\t\t\t\t},\r\n\t\t\t\tnow,\r\n\t\t\t\tfuture\r\n\t\t\t})\r\n\t\t}\r\n\r\n\t\t// \"unit\" is now called \"formatAs\".\r\n\t\tconst unit = step.unit || step.formatAs\r\n\r\n\t\tif (!unit) {\r\n\t\t\tthrow new Error(`[javascript-time-ago] Each step must define either \\`formatAs\\` or \\`format()\\`. Step: ${JSON.stringify(step)}`)\r\n\t\t}\r\n\r\n\t\t// `Intl.RelativeTimeFormat` doesn't operate in \"now\" units.\r\n\t\t// Therefore, threat \"now\" as a special case.\r\n\t\tif (unit === 'now') {\r\n\t\t\treturn nowLabel\r\n\t\t}\r\n\r\n\t\t// Amount in units.\r\n\t\tlet amount = Math.abs(secondsPassed) / getStepDenominator(step)\r\n\r\n\t\t// Apply granularity to the time amount\r\n\t\t// (and fallback to the previous step\r\n\t\t// if the first level of granularity\r\n\t\t// isn't met by this amount)\r\n\t\t//\r\n\t\t// `granularity` — (advanced) Time interval value \"granularity\".\r\n\t\t// For example, it could be set to `5` for minutes to allow only 5-minute increments\r\n\t\t// when formatting time intervals: `0 minutes`, `5 minutes`, `10 minutes`, etc.\r\n\t\t// Perhaps this feature will be removed because there seem to be no use cases\r\n\t\t// of it in the real world.\r\n\t\t//\r\n\t\tif (step.granularity) {\r\n\t\t\t// Recalculate the amount of seconds passed based on granularity\r\n\t\t\tamount = getRoundFunction(round)(amount / step.granularity) * step.granularity\r\n\t\t}\r\n\r\n\t\tlet valueForFormatting = -1 * Math.sign(secondsPassed) * getRoundFunction(round)(amount)\r\n\r\n\t\t// By default, this library formats a `0` in \"past\" mode,\r\n\t\t// unless `future: true` option is passed.\r\n\t\t// This is different to `relative-time-format`'s behavior\r\n\t\t// which formats a `0` in \"future\" mode by default, unless it's a `-0`.\r\n\t\t// So, convert `0` to `-0` if `future: true` option wasn't passed.\r\n\t\t// `=== 0` matches both `0` and `-0`.\r\n\t\tif (valueForFormatting === 0) {\r\n\t\t\tif (future) {\r\n\t\t\t\tvalueForFormatting = 0\r\n\t\t\t} else {\r\n\t\t\t\tvalueForFormatting = -0\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tswitch (labelsType) {\r\n\t\t\tcase 'long':\r\n\t\t\tcase 'short':\r\n\t\t\tcase 'narrow':\r\n\t\t\t\t// Format the amount using `Intl.RelativeTimeFormat`.\r\n\t\t\t\treturn this.getFormatter(labelsType).format(valueForFormatting, unit)\r\n\t\t\tdefault:\r\n\t\t\t\t// Format the amount.\r\n\t\t\t\t// (mimicks `Intl.RelativeTimeFormat` behavior for other time label styles)\r\n\t\t\t\treturn this.formatValue(valueForFormatting, unit, {\r\n\t\t\t\t\tlabels,\r\n\t\t\t\t\tfuture\r\n\t\t\t\t})\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Mimicks what `Intl.RelativeTimeFormat` does for additional locale styles.\r\n\t * @param {number} value\r\n\t * @param {string} unit\r\n\t * @param {object} options.labels — Relative time labels.\r\n\t * @param {boolean} [options.future] — Tells how to format value `0`: as \"future\" (`true`) or \"past\" (`false`). Is `false` by default, but should have been `true` actually.\r\n\t * @return {string}\r\n\t */\r\n\tformatValue(value, unit, { labels, future }) {\r\n\t\treturn this.getFormattingRule(labels, unit, value, { future })\r\n\t\t\t.replace('{0}', this.formatNumber(Math.abs(value)))\r\n\t}\r\n\r\n\t/**\r\n\t * Returns formatting rule for `value` in `units` (either in past or in future).\r\n\t * @param {object} formattingRules — Relative time labels for different units.\r\n\t * @param {string} unit - Time interval measurement unit.\r\n\t * @param {number} value - Time interval value.\r\n\t * @param {boolean} [options.future] — Tells how to format value `0`: as \"future\" (`true`) or \"past\" (`false`). Is `false` by default.\r\n\t * @return {string}\r\n\t * @example\r\n\t * // Returns \"{0} days ago\"\r\n\t * getFormattingRule(en.long, \"day\", -2, 'en')\r\n\t */\r\n\tgetFormattingRule(formattingRules, unit, value, { future }) {\r\n\t\t// Passing the language is required in order to\r\n\t\t// be able to correctly classify the `value` as a number.\r\n\t\tconst locale = this.locale\r\n\t\tformattingRules = formattingRules[unit]\r\n\t\t// Check for a special \"compacted\" rules case:\r\n\t\t// if formatting rules are the same for \"past\" and \"future\",\r\n\t\t// and also for all possible `value`s, then those rules are\r\n\t\t// stored as a single string.\r\n\t\tif (typeof formattingRules === 'string') {\r\n\t\t\treturn formattingRules\r\n\t\t}\r\n\t\t// Choose either \"past\" or \"future\" based on time `value` sign.\r\n\t\t// If \"past\" is same as \"future\" then they're stored as \"other\".\r\n\t\t// If there's only \"other\" then it's being collapsed.\r\n\t\tconst pastOrFuture = value === 0 ? (future ? 'future' : 'past') : (value < 0 ? 'past' : 'future')\r\n\t\tconst quantifierRules = formattingRules[pastOrFuture] || formattingRules\r\n\t\t// Bundle size optimization technique.\r\n\t\tif (typeof quantifierRules === 'string') {\r\n\t\t\treturn quantifierRules\r\n\t\t}\r\n\t\t// Quantify `value`.\r\n\t\tconst quantifier = this.getPluralRules().select(Math.abs(value))\r\n\t\t// \"other\" rule is supposed to always be present.\r\n\t\t// If only \"other\" rule is present then \"rules\" is not an object and is a string.\r\n\t\treturn quantifierRules[quantifier] || quantifierRules.other\r\n\t}\r\n\r\n\t/**\r\n\t * Formats a number into a string.\r\n\t * Uses `Intl.NumberFormat` when available.\r\n\t * @param {number} number\r\n\t * @return {string}\r\n\t */\r\n\tformatNumber(number) {\r\n\t\treturn this.numberFormat ? this.numberFormat.format(number) : String(number)\r\n\t}\r\n\r\n\t/**\r\n\t * Returns an `Intl.RelativeTimeFormat` for a given `labelsType`.\r\n\t * @param {string} labelsType\r\n\t * @return {object} `Intl.RelativeTimeFormat` instance\r\n\t */\r\n\tgetFormatter(labelsType) {\r\n\t\t// `Intl.RelativeTimeFormat` instance creation is (hypothetically) assumed\r\n\t\t// a lengthy operation so the instances are cached and reused.\r\n\t\treturn this.relativeTimeFormatCache.get(this.locale, labelsType) ||\r\n\t\t\tthis.relativeTimeFormatCache.put(this.locale, labelsType, new this.IntlRelativeTimeFormat(this.locale, { style: labelsType }))\r\n\t}\r\n\r\n\t/**\r\n\t * Returns an `Intl.PluralRules` instance.\r\n\t * @return {object} `Intl.PluralRules` instance\r\n\t */\r\n\tgetPluralRules() {\r\n\t\t// `Intl.PluralRules` instance creation is (hypothetically) assumed\r\n\t\t// a lengthy operation so the instances are cached and reused.\r\n\t\treturn this.pluralRulesCache.get(this.locale) ||\r\n\t\t\tthis.pluralRulesCache.put(this.locale, new this.IntlPluralRules(this.locale))\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Gets localized labels for this type of labels.\r\n\t *\r\n\t * @param {(string|string[])} labelsType - Relative date/time labels type.\r\n\t * If it's an array then all label types are tried\r\n\t * until a suitable one is found.\r\n\t *\r\n\t * @returns {Object} Returns an object of shape { labelsType, labels }\r\n\t */\r\n\tgetLabels(labelsType = []) {\r\n\t\t// Convert `labels` to an array.\r\n\t\tif (typeof labelsType === 'string') {\r\n\t\t\tlabelsType = [labelsType]\r\n\t\t}\r\n\r\n\t\t// Supports legacy \"tiny\" and \"mini-time\" label styles.\r\n\t\tlabelsType = labelsType.map((labelsType) => {\r\n\t\t\tswitch (labelsType) {\r\n\t\t\t\tcase 'tiny':\r\n\t\t\t\tcase 'mini-time':\r\n\t\t\t\t\treturn 'mini'\r\n\t\t\t\tdefault:\r\n\t\t\t\t\treturn labelsType\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t\t// \"long\" labels type is the default one.\r\n\t\t// (it's always present for all languages)\r\n\t\tlabelsType = labelsType.concat('long')\r\n\r\n\t\t// Find a suitable labels type.\r\n\t\tconst localeData = getLocaleData(this.locale)\r\n\t\tfor (const _labelsType of labelsType) {\r\n\t\t\tif (localeData[_labelsType]) {\r\n\t\t\t\treturn {\r\n\t\t\t\t\tlabelsType: _labelsType,\r\n\t\t\t\t\tlabels: localeData[_labelsType]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n/**\r\n * Default locale global variable.\r\n */\r\nlet defaultLocale = 'en'\r\n\r\n/**\r\n * Gets default locale.\r\n * @return {string} locale\r\n */\r\nTimeAgo.getDefaultLocale = () => defaultLocale\r\n\r\n/**\r\n * Sets default locale.\r\n * @param {string} locale\r\n */\r\nTimeAgo.setDefaultLocale = (locale) => defaultLocale = locale\r\n\r\n/**\r\n * Adds locale data for a specific locale and marks the locale as default.\r\n * @param {Object} localeData\r\n */\r\nTimeAgo.addDefaultLocale = function(localeData) {\r\n\tif (defaultLocaleHasBeenSpecified) {\r\n\t\treturn console.error('[javascript-time-ago] `TimeAgo.addDefaultLocale()` can only be called once. To add other locales, use `TimeAgo.addLocale()`.')\r\n\t}\r\n\tdefaultLocaleHasBeenSpecified = true\r\n\tTimeAgo.setDefaultLocale(localeData.locale)\r\n\tTimeAgo.addLocale(localeData)\r\n}\r\n\r\nlet defaultLocaleHasBeenSpecified\r\n\r\n/**\r\n * Adds locale data for a specific locale.\r\n * @param {Object} localeData\r\n */\r\nTimeAgo.addLocale = function(localeData) {\r\n\taddLocaleData(localeData)\r\n\tRelativeTimeFormatPolyfill.addLocale(localeData)\r\n}\r\n\r\n/**\r\n * (legacy alias)\r\n * Adds locale data for a specific locale.\r\n * @param {Object} localeData\r\n * @deprecated\r\n */\r\nTimeAgo.locale = TimeAgo.addLocale\r\n\r\n/**\r\n * Adds custom labels to locale data.\r\n * @param {string} locale\r\n * @param {string} name\r\n * @param {object} labels\r\n */\r\nTimeAgo.addLabels = (locale, name, labels) => {\r\n\tlet localeData = getLocaleData(locale)\r\n\tif (!localeData) {\r\n\t\taddLocaleData({\r\n\t\t\tlocale\r\n\t\t})\r\n\t\tlocaleData = getLocaleData(locale)\r\n\t\t// throw new Error(`[javascript-time-ago] No data for locale \"${locale}\"`)\r\n\t}\r\n\tlocaleData[name] = labels\r\n}\r\n\r\n// Normalizes `.format()` `time` argument.\r\nfunction getTimestamp(input) {\r\n\tif (input.constructor === Date || isMockedDate(input)) {\r\n\t\treturn input.getTime()\r\n\t}\r\n\r\n\tif (typeof input === 'number') {\r\n\t\treturn input\r\n\t}\r\n\r\n\t// For some weird reason istanbul doesn't see this `throw` covered.\r\n\t/* istanbul ignore next */\r\n\tthrow new Error(`Unsupported relative time formatter input: ${typeof input}, ${input}`)\r\n}\r\n\r\n// During testing via some testing libraries `Date`s aren't actually `Date`s.\r\n// https://github.com/catamphetamine/javascript-time-ago/issues/22\r\nfunction isMockedDate(object) {\r\n\treturn typeof object === 'object' && typeof object.getTime === 'function'\r\n}\r\n\r\n// Get available time interval measurement units.\r\nfunction getTimeIntervalMeasurementUnits(allowedUnits, labels, nowLabel) {\r\n\t// Get all time interval measurement units that're available\r\n\t// in locale data for a given time labels style.\r\n\tlet units = Object.keys(labels)\r\n\r\n\t// `now` unit is handled separately and is shipped in its own `now.json` file.\r\n\t// `now.json` isn't present for all locales, so it could be substituted with\r\n\t// \".second.current\".\r\n\t// Add `now` unit if it's available in locale data.\r\n\tif (nowLabel) {\r\n\t\tunits.push('now')\r\n\t}\r\n\r\n\t// If only a specific set of available time measurement units can be used\r\n\t// then only those units are allowed (if they're present in locale data).\r\n\tif (allowedUnits) {\r\n\t\tunits = allowedUnits.filter(unit => unit === 'now' || units.indexOf(unit) >= 0)\r\n\t}\r\n\r\n\treturn units\r\n}\r\n\r\nfunction getNowLabel(labels, nowLabels, longLabels, future) {\r\n\tconst nowLabel = labels.now || (nowLabels && nowLabels.now)\r\n\t// Specific \"now\" message form extended locale data (if present).\r\n\tif (nowLabel) {\r\n\t\t// Bundle size optimization technique.\r\n\t\tif (typeof nowLabel === 'string') {\r\n\t\t\treturn nowLabel\r\n\t\t}\r\n\t\t// Not handling `value === 0` as `localeData.now.current` here\r\n\t\t// because it wouldn't make sense: \"now\" is a moment,\r\n\t\t// so one can't possibly differentiate between a\r\n\t\t// \"previous\" moment, a \"current\" moment and a \"next moment\".\r\n\t\t// It can only be differentiated between \"past\" and \"future\".\r\n\t\tif (future) {\r\n\t\t\treturn nowLabel.future\r\n\t\t} else {\r\n\t\t\treturn nowLabel.past\r\n\t\t}\r\n\t}\r\n\t// Use \".second.current\" as \"now\" message.\r\n\tif (longLabels && longLabels.second && longLabels.second.current) {\r\n\t\treturn longLabels.second.current\r\n\t}\r\n}\r\n\r\nfunction isStyle(variable) {\r\n\treturn typeof variable === 'string' || isStyleObject(variable)\r\n}"],"mappings":";;;;;;AAAA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,cAAA,GAAAJ,sBAAA,CAA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E;EACA;EACA,IAAIM,KAAK,GAAG/D,MAAM,CAACiI,IAAI,CAAC9E,MAAM,CAAC;;EAE/B;EACA;EACA;EACA;EACA,IAAIM,QAAQ,EAAE;IACbM,KAAK,CAAC9D,IAAI,CAAC,KAAK,CAAC;EAClB;;EAEA;EACA;EACA,IAAI+H,YAAY,EAAE;IACjBjE,KAAK,GAAGiE,YAAY,CAACE,MAAM,CAAC,UAAAhD,IAAI;MAAA,OAAIA,IAAI,KAAK,KAAK,IAAInB,KAAK,CAACoE,OAAO,CAACjD,IAAI,CAAC,IAAI,CAAC;IAAA,EAAC;EAChF;EAEA,OAAOnB,KAAK;AACb;AAEA,SAASL,WAAWA,CAACP,MAAM,EAAEiF,SAAS,EAAEC,UAAU,EAAE7E,MAAM,EAAE;EAC3D,IAAMC,QAAQ,GAAGN,MAAM,CAACE,GAAG,IAAK+E,SAAS,IAAIA,SAAS,CAAC/E,GAAI;EAC3D;EACA,IAAII,QAAQ,EAAE;IACb;IACA,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE;MACjC,OAAOA,QAAQ;IAChB;IACA;IACA;IACA;IACA;IACA;IACA,IAAID,MAAM,EAAE;MACX,OAAOC,QAAQ,CAACD,MAAM;IACvB,CAAC,MAAM;MACN,OAAOC,QAAQ,CAAC6E,IAAI;IACrB;EACD;EACA;EACA,IAAID,UAAU,IAAIA,UAAU,CAACE,MAAM,IAAIF,UAAU,CAACE,MAAM,CAACC,OAAO,EAAE;IACjE,OAAOH,UAAU,CAACE,MAAM,CAACC,OAAO;EACjC;AACD;AAEA,SAAS7F,OAAOA,CAAC8F,QAAQ,EAAE;EAC1B,OAAO,OAAOA,QAAQ,KAAK,QAAQ,IAAI,IAAAC,yBAAa,EAACD,QAAQ,CAAC;AAC/D","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"TimeAgo.js","names":["_relativeTimeFormat","_interopRequireDefault","require","_cache","_locale","_isStyleObject","_getStep3","_getStepDenominator","_getTimeToNextUpdate","_LocaleDataStore","_roundMinute","_getStyleByName","_round","e","__esModule","_typeof","o","Symbol","iterator","constructor","prototype","_createForOfIteratorHelperLoose","r","t","call","next","bind","Array","isArray","_unsupportedIterableToArray","length","done","value","TypeError","_slicedToArray","_arrayWithHoles","_iterableToArrayLimit","_nonIterableRest","a","_arrayLikeToArray","toString","slice","name","from","test","n","l","i","u","f","Object","push","_classCallCheck","_defineProperties","enumerable","configurable","writable","defineProperty","_toPropertyKey","key","_createClass","_toPrimitive","toPrimitive","String","Number","TimeAgo","exports","locales","arguments","undefined","_ref","polyfill","locale","chooseLocale","concat","getDefaultLocale","getLocaleData","Intl","NumberFormat","numberFormat","IntlRelativeTimeFormat","RelativeTimeFormat","IntlPluralRules","PluralRules","RelativeTimeFormatPolyfill","relativeTimeFormatCache","Cache","pluralRulesCache","format","input","style","options","_this","isStyle","defaultStyle","getStyleByName","timestamp","getTimestamp","_this$getLabels","getLabels","flavour","labels","labelsType","round","now","nowRealWhenCalled","Date","getTextAndTextRefreshDelayGetterFunctions","_ref2","secondsPassed","future","nowLabel","getNowLabel","custom","text","date","time","elapsed","getText","getTextRefreshDelay","Error","units","getTimeIntervalMeasurementUnits","_getStep","getStep","gradation","steps","getNextStep","_getStep2","prevStep","step","nextStep","formatDateForStep","timeToNextUpdate","getTimeToNextUpdate","getTimeToNextUpdateUncapped","getSafeTimeoutDelay","_getTextAndTextRefres","refresh","defaultRefreshInterval","refreshTimer","scheduleRefresh","delay","setTimeoutSafe","_getTextAndTextRefres2","stopRefreshing","clearTimeout","_ref3","_this2","formatAs","unit","amount","formatValue","JSON","stringify","Math","abs","getStepDenominator","granularity","getRoundFunction","valueForFormatting","sign","getFormatter","_ref4","getFormattingRule","replace","formatNumber","formattingRules","_ref5","pastOrFuture","quantifierRules","quantifier","getPluralRules","select","other","number","get","put","map","localeData","_iterator","_step","_labelsType","defaultLocale","setDefaultLocale","addDefaultLocale","defaultLocaleHasBeenSpecified","console","warn","addLocale","addLocaleData","addLabels","isMockedDate","getTime","object","allowedUnits","keys","filter","indexOf","nowLabels","longLabels","past","second","current","variable","isStyleObject","func","setTimeout","min","SET_TIMEOUT_MAX_SAFE_DELAY"],"sources":["../source/TimeAgo.js"],"sourcesContent":["import RelativeTimeFormatPolyfill from 'relative-time-format'\r\n\r\nimport Cache from './cache.js'\r\nimport chooseLocale from './locale.js'\r\nimport isStyleObject from './isStyleObject.js'\r\n\r\nimport getStep from './steps/getStep.js'\r\nimport getStepDenominator from './steps/getStepDenominator.js'\r\nimport getTimeToNextUpdate from './steps/getTimeToNextUpdate.js'\r\n\r\nimport {\r\n\taddLocaleData,\r\n\tgetLocaleData\r\n} from './LocaleDataStore.js'\r\n\r\nimport defaultStyle from './style/roundMinute.js'\r\nimport getStyleByName from './style/getStyleByName.js'\r\n\r\nimport { getRoundFunction } from './round.js'\r\n\r\nexport default class TimeAgo {\r\n\t/**\r\n\t * @param {(string|string[])} locales=[] - Preferred locales (or locale).\r\n\t * @param {boolean} [polyfill] — Pass `false` to use native `Intl.RelativeTimeFormat` and `Intl.PluralRules` instead of the polyfills.\r\n\t */\r\n\tconstructor(locales = [], { polyfill } = {}) {\r\n\t\t// Convert `locales` to an array.\r\n\t\tif (typeof locales === 'string') {\r\n\t\t\tlocales = [locales]\r\n\t\t}\r\n\r\n\t\t// Choose the most appropriate locale\r\n\t\t// from the list of `locales` added by the user.\r\n\t\t// For example, new TimeAgo(\"en-US\") -> \"en\".\r\n\t\tthis.locale = chooseLocale(\r\n\t\t\tlocales.concat(TimeAgo.getDefaultLocale()),\r\n\t\t\tgetLocaleData\r\n\t\t)\r\n\r\n\t\tif (typeof Intl !== 'undefined') {\r\n\t\t\t// Use `Intl.NumberFormat` for formatting numbers (when available).\r\n\t\t\tif (Intl.NumberFormat) {\r\n\t\t\t\tthis.numberFormat = new Intl.NumberFormat(this.locale)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Some people have requested the ability to use native\r\n\t\t// `Intl.RelativeTimeFormat` and `Intl.PluralRules`\r\n\t\t// instead of the polyfills.\r\n\t\t// https://github.com/catamphetamine/javascript-time-ago/issues/21\r\n\t\tif (polyfill === false) {\r\n\t\t\tthis.IntlRelativeTimeFormat = Intl.RelativeTimeFormat\r\n\t\t\tthis.IntlPluralRules = Intl.PluralRules\r\n\t\t} else {\r\n\t\t\tthis.IntlRelativeTimeFormat = RelativeTimeFormatPolyfill\r\n\t\t\tthis.IntlPluralRules = RelativeTimeFormatPolyfill.PluralRules\r\n\t\t}\r\n\r\n\t\t// Cache `Intl.RelativeTimeFormat` instance.\r\n\t\tthis.relativeTimeFormatCache = new Cache()\r\n\r\n\t\t// Cache `Intl.PluralRules` instance.\r\n\t\tthis.pluralRulesCache = new Cache()\r\n\t}\r\n\r\n\t/**\r\n\t * Formats relative date/time.\r\n\t *\r\n\t * @param {(number|Date)} input — A `Date` or a javascript timestamp.\r\n\t *\r\n\t * @param {(string|object)} style — Date/time formatting style. Either one of the built-in style names or a \"custom\" style definition object having `steps: object[]` and `labels: string[]`.\r\n\t *\r\n\t * @param {number} [options.now] - Sets the current date timestamp.\r\n\t *\r\n\t * @param {boolean} [options.future] — Tells how to format value `0`:\r\n\t * as \"future\" (`true`) or \"past\" (`false`).\r\n\t * Is `false` by default, but should have been `true` actually,\r\n\t * in order to correspond to `Intl.RelativeTimeFormat`\r\n\t * that uses `future` formatting for `0` unless `-0` is passed.\r\n\t *\r\n\t * @param {string} [options.round] — Rounding method. Overrides the style's one.\r\n\t *\r\n\t * @param {boolean} [options.getTimeToNextUpdate] — Pass `true` to return `[formattedDate, timeToNextUpdate]` instead of just `formattedDate`.\r\n\t *\r\n\t * @param {boolean} [options.getTimeToNextUpdateUncapped] — Pass `true` to not apply the workaround for `setTimeout()` bug. https://stackoverflow.com/questions/3468607/why-does-settimeout-break-for-large-millisecond-delay-values\r\n\t *\r\n\t * @param {function} [options.refresh] — When `refresh` function is passed, it will be automatically called with a new text when it's time to refresh the label.\r\n\t *\r\n\t * @return {string} The formatted relative date/time. If no eligible `step` is found, then an empty string is returned.\r\n\t */\r\n\tformat(input, style, options) {\r\n\t\tif (!options) {\r\n\t\t\tif (style && !isStyle(style)) {\r\n\t\t\t\toptions = style\r\n\t\t\t\tstyle = undefined\r\n\t\t\t} else {\r\n\t\t\t\toptions = {}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (!style) {\r\n\t\t\tstyle = defaultStyle\r\n\t\t}\r\n\r\n\t\tif (typeof style === 'string') {\r\n\t\t\tstyle = getStyleByName(style)\r\n\t\t}\r\n\r\n\t\tconst timestamp = getTimestamp(input)\r\n\r\n\t\t// Get locale messages for this type of labels.\r\n\t\t// \"flavour\" is a legacy name for \"labels\".\r\n\t\tconst { labels, labelsType } = this.getLabels(style.flavour || style.labels)\r\n\r\n\t\t// `round` setting could be passed as a parameter to `.format()` function\r\n\t\t// or be configured globally for a style.\r\n\t\tconst round = options.round || style.round\r\n\r\n\t\t// A developer can pass a custom `now`, e.g. for testing purposes.\r\n\t\tlet now\r\n\t\tconst nowRealWhenCalled = Date.now()\r\n\t\t// (deprecated)\r\n\t\t// Legacy way was passing `now` in `style`.\r\n\t\tif (style.now !== undefined) {\r\n\t\t\tnow = style.now\r\n\t\t}\r\n\t\t// One could pass `now` option to `.format()`.\r\n\t\tif (now === undefined && options.now !== undefined) {\r\n\t\t\tnow = options.now\r\n\t\t}\r\n\t\t// The default `now` is `Date.now()`.\r\n\t\tif (now === undefined) {\r\n\t\t\tnow = nowRealWhenCalled\r\n\t\t}\r\n\r\n\t\tconst getTextAndTextRefreshDelayGetterFunctions = ({ now }) => {\r\n\t\t\t// how much time has passed (in seconds)\r\n\t\t\tconst secondsPassed = (now - timestamp) / 1000 // in seconds\r\n\r\n\t\t\tconst future = options.future || secondsPassed < 0\r\n\r\n\t\t\tconst nowLabel = getNowLabel(\r\n\t\t\t\tlabels,\r\n\t\t\t\tgetLocaleData(this.locale).now,\r\n\t\t\t\tgetLocaleData(this.locale).long,\r\n\t\t\t\tfuture\r\n\t\t\t)\r\n\r\n\t\t\t// (deprecated)\r\n\t\t\t//\r\n\t\t\t// `custom` – A function of `{ elapsed, time, date, now, locale }`.\r\n\t\t\t//\r\n\t\t\t// If this function returns a value, then the `.format()` call will return that value.\r\n\t\t\t// Otherwise the relative date/time is formatted as usual.\r\n\t\t\t// This feature is currently not used anywhere and is here\r\n\t\t\t// just for providing the ultimate customization point\r\n\t\t\t// in case anyone would ever need that. Prefer using\r\n\t\t\t// `steps[step].format(value, locale)` instead.\r\n\t\t\t//\r\n\t\t\tif (style.custom) {\r\n\t\t\t\tconst text = style.custom({\r\n\t\t\t\t\tnow,\r\n\t\t\t\t\tdate: new Date(timestamp),\r\n\t\t\t\t\ttime: timestamp,\r\n\t\t\t\t\telapsed: secondsPassed,\r\n\t\t\t\t\tlocale: this.locale\r\n\t\t\t\t})\r\n\t\t\t\tif (text !== undefined) {\r\n\t\t\t\t\t// Won't return `timeToNextUpdate` here\r\n\t\t\t\t\t// because `custom()` seems deprecated.\r\n\t\t\t\t\treturn {\r\n\t\t\t\t\t\tgetText: () => text,\r\n\t\t\t\t\t\tgetTextRefreshDelay: () => {\r\n\t\t\t\t\t\t\tthrow new Error('`getTimeToNextUpdate: true` feature is not supported by legacy \"styles\" that have a `custom` function')\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Get the list of available time interval units.\r\n\t\t\tconst units = getTimeIntervalMeasurementUnits(\r\n\t\t\t\t// Controlling `style.steps` through `style.units` seems to be deprecated:\r\n\t\t\t\t// create a new custom `style` instead.\r\n\t\t\t\tstyle.units,\r\n\t\t\t\tlabels,\r\n\t\t\t\tnowLabel\r\n\t\t\t)\r\n\r\n\t\t\t// Choose the appropriate time measurement unit\r\n\t\t\t// and get the corresponding rounded time amount.\r\n\t\t\tconst [prevStep, step, nextStep] = getStep(\r\n\t\t\t\t// \"gradation\" is a legacy name for \"steps\".\r\n\t\t\t\t// For historical reasons, \"approximate\" steps are used by default.\r\n\t\t\t\t// In the next major version, there'll be no default for `steps`.\r\n\t\t\t\tstyle.gradation || style.steps || defaultStyle.steps,\r\n\t\t\t\tsecondsPassed,\r\n\t\t\t\t{ now, units, round, future, getNextStep: true }\r\n\t\t\t)\r\n\r\n\t\t\tconst getText = () => {\r\n\t\t\t\treturn this.formatDateForStep(timestamp, step, secondsPassed, {\r\n\t\t\t\t\tlabels,\r\n\t\t\t\t\tlabelsType,\r\n\t\t\t\t\tnowLabel,\r\n\t\t\t\t\tnow,\r\n\t\t\t\t\tfuture,\r\n\t\t\t\t\tround\r\n\t\t\t\t}) || ''\r\n\t\t\t}\r\n\r\n\t\t\t// Returns the time (in milliseconds) after which the formatted date label should be refreshed.\r\n\t\t\t//\r\n\t\t\t// It will return `undefined` for a custom style\r\n\t\t\t// that doesn't meet the minimum requirements for this feature.\r\n\t\t\t// See the README for more details.\r\n\t\t\t//\r\n\t\t\tconst getTextRefreshDelay = () => {\r\n\t\t\t\tconst timeToNextUpdate = getTimeToNextUpdate(timestamp, step, {\r\n\t\t\t\t\tnextStep,\r\n\t\t\t\t\tprevStep,\r\n\t\t\t\t\tnow,\r\n\t\t\t\t\tfuture,\r\n\t\t\t\t\tround\r\n\t\t\t\t})\r\n\r\n\t\t\t\t// `timeToNextUpdate` could be `undefined` for a custom style\r\n\t\t\t\t// that doesn't meet the minimum requirements for this feature.\r\n\t\t\t\t// See the README for more details.\r\n\t\t\t\tif (typeof timeToNextUpdate === 'number') {\r\n\t\t\t\t\t// `setTimeout()` function has a bug when it fires immediately\r\n\t\t\t\t\t// when the delay is longer than about `24.85` days.\r\n\t\t\t\t\t// https://stackoverflow.com/questions/3468607/why-does-settimeout-break-for-large-millisecond-delay-values\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// To not burden the end user of this library with manually working around that bug,\r\n\t\t\t\t\t// this library automatically caps the returned delay to a maximum value that\r\n\t\t\t\t\t// still works with `setTimeout()` and doesn't break it.\r\n\t\t\t\t\t//\r\n\t\t\t\t\t// The end user of this library could still opt out of this auto-workaround feature\r\n\t\t\t\t\t// by passing a `getTimeToNextUpdateUncapped: true` option.\r\n\t\t\t\t\t//\r\n\t\t\t\t\tif (options.getTimeToNextUpdateUncapped) {\r\n\t\t\t\t\t\treturn timeToNextUpdate\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn getSafeTimeoutDelay(timeToNextUpdate)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn { getText, getTextRefreshDelay }\r\n\t\t}\r\n\r\n\t\tconst { getText, getTextRefreshDelay } = getTextAndTextRefreshDelayGetterFunctions({ now })\r\n\r\n\t\tif (options.getTimeToNextUpdate) {\r\n\t\t\treturn [getText(), getTextRefreshDelay()]\r\n\t\t}\r\n\r\n\t\tif (options.refresh) {\r\n\t\t\t// `getTextRefreshDelay()` will return `undefined` for a custom style\r\n\t\t\t// that doesn't meet the minimum requirements for this feature.\r\n\t\t\t// See the README for more details.\r\n\t\t\t//\r\n\t\t\t// This is a \"sensible default\" interval for refreshing time labels\r\n\t\t\t// that use such custom style.\r\n\t\t\t//\r\n\t\t\tconst defaultRefreshInterval = 60 * 1000\r\n\r\n\t\t\t// If `refresh` function was passed, schedule it to be called when the time comes,\r\n\t\t\t// after which schedule the next refresh.\r\n\t\t\tlet refreshTimer\r\n\t\t\tconst scheduleRefresh = (delay = defaultRefreshInterval) => {\r\n\t\t\t\trefreshTimer = setTimeoutSafe(() => {\r\n\t\t\t\t\tconst { getText, getTextRefreshDelay } = getTextAndTextRefreshDelayGetterFunctions({\r\n\t\t\t\t\t\tnow: now + (Date.now() - nowRealWhenCalled)\r\n\t\t\t\t\t})\r\n\t\t\t\t\toptions.refresh(getText())\r\n\t\t\t\t\tscheduleRefresh(getTextRefreshDelay())\r\n\t\t\t\t}, delay)\r\n\t\t\t}\r\n\r\n\t\t\tscheduleRefresh(getTextRefreshDelay())\r\n\r\n\t\t\tconst stopRefreshing = () => {\r\n\t\t\t\tclearTimeout(refreshTimer)\r\n\t\t\t}\r\n\r\n\t\t\treturn [getText(), stopRefreshing]\r\n\t\t}\r\n\r\n\t\treturn getText()\r\n\t}\r\n\r\n\tformatDateForStep(timestamp, step, secondsPassed, {\r\n\t\tlabels,\r\n\t\tlabelsType,\r\n\t\tnowLabel,\r\n\t\tnow,\r\n\t\tfuture,\r\n\t\tround\r\n\t}) {\r\n\t\t// If no step matches, then output an empty string.\r\n\t\tif (!step) {\r\n\t\t\treturn\r\n\t\t}\r\n\r\n\t\tif (step.format) {\r\n\t\t\treturn step.format(timestamp, this.locale, {\r\n\t\t\t\tformatAs: (unit, amount) => {\r\n\t\t\t\t\t// Mimicks `Intl.RelativeTimeFormat.format()`.\r\n\t\t\t\t\treturn this.formatValue(amount, unit, {\r\n\t\t\t\t\t\tlabels,\r\n\t\t\t\t\t\tfuture\r\n\t\t\t\t\t})\r\n\t\t\t\t},\r\n\t\t\t\tnow,\r\n\t\t\t\tfuture\r\n\t\t\t})\r\n\t\t}\r\n\r\n\t\t// \"unit\" is now called \"formatAs\".\r\n\t\tconst unit = step.unit || step.formatAs\r\n\r\n\t\tif (!unit) {\r\n\t\t\tthrow new Error(`[javascript-time-ago] Each step must define either \\`formatAs\\` or \\`format()\\`. Step: ${JSON.stringify(step)}`)\r\n\t\t}\r\n\r\n\t\t// `Intl.RelativeTimeFormat` doesn't operate in \"now\" units.\r\n\t\t// Therefore, threat \"now\" as a special case.\r\n\t\tif (unit === 'now') {\r\n\t\t\treturn nowLabel\r\n\t\t}\r\n\r\n\t\t// Amount in units.\r\n\t\tlet amount = Math.abs(secondsPassed) / getStepDenominator(step)\r\n\r\n\t\t// Apply granularity to the time amount\r\n\t\t// (and fallback to the previous step\r\n\t\t// if the first level of granularity\r\n\t\t// isn't met by this amount)\r\n\t\t//\r\n\t\t// `granularity` — (advanced) Time interval value \"granularity\".\r\n\t\t// For example, it could be set to `5` for minutes to allow only 5-minute increments\r\n\t\t// when formatting time intervals: `0 minutes`, `5 minutes`, `10 minutes`, etc.\r\n\t\t// Perhaps this feature will be removed because there seem to be no use cases\r\n\t\t// of it in the real world.\r\n\t\t//\r\n\t\tif (step.granularity) {\r\n\t\t\t// Recalculate the amount of seconds passed based on granularity\r\n\t\t\tamount = getRoundFunction(round)(amount / step.granularity) * step.granularity\r\n\t\t}\r\n\r\n\t\tlet valueForFormatting = -1 * Math.sign(secondsPassed) * getRoundFunction(round)(amount)\r\n\r\n\t\t// By default, this library formats a `0` in \"past\" mode,\r\n\t\t// unless `future: true` option is passed.\r\n\t\t// This is different to `relative-time-format`'s behavior\r\n\t\t// which formats a `0` in \"future\" mode by default, unless it's a `-0`.\r\n\t\t// So, convert `0` to `-0` if `future: true` option wasn't passed.\r\n\t\t// `=== 0` matches both `0` and `-0`.\r\n\t\tif (valueForFormatting === 0) {\r\n\t\t\tif (future) {\r\n\t\t\t\tvalueForFormatting = 0\r\n\t\t\t} else {\r\n\t\t\t\tvalueForFormatting = -0\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tswitch (labelsType) {\r\n\t\t\tcase 'long':\r\n\t\t\tcase 'short':\r\n\t\t\tcase 'narrow':\r\n\t\t\t\t// Format the amount using `Intl.RelativeTimeFormat`.\r\n\t\t\t\treturn this.getFormatter(labelsType).format(valueForFormatting, unit)\r\n\t\t\tdefault:\r\n\t\t\t\t// Format the amount.\r\n\t\t\t\t// (mimicks `Intl.RelativeTimeFormat` behavior for other time label styles)\r\n\t\t\t\treturn this.formatValue(valueForFormatting, unit, {\r\n\t\t\t\t\tlabels,\r\n\t\t\t\t\tfuture\r\n\t\t\t\t})\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Mimicks what `Intl.RelativeTimeFormat` does for additional locale styles.\r\n\t * @param {number} value\r\n\t * @param {string} unit\r\n\t * @param {object} options.labels — Relative time labels.\r\n\t * @param {boolean} [options.future] — Tells how to format value `0`: as \"future\" (`true`) or \"past\" (`false`). Is `false` by default, but should have been `true` actually.\r\n\t * @return {string}\r\n\t */\r\n\tformatValue(value, unit, { labels, future }) {\r\n\t\treturn this.getFormattingRule(labels, unit, value, { future })\r\n\t\t\t.replace('{0}', this.formatNumber(Math.abs(value)))\r\n\t}\r\n\r\n\t/**\r\n\t * Returns formatting rule for `value` in `units` (either in past or in future).\r\n\t * @param {object} formattingRules — Relative time labels for different units.\r\n\t * @param {string} unit - Time interval measurement unit.\r\n\t * @param {number} value - Time interval value.\r\n\t * @param {boolean} [options.future] — Tells how to format value `0`: as \"future\" (`true`) or \"past\" (`false`). Is `false` by default.\r\n\t * @return {string}\r\n\t * @example\r\n\t * // Returns \"{0} days ago\"\r\n\t * getFormattingRule(en.long, \"day\", -2, 'en')\r\n\t */\r\n\tgetFormattingRule(formattingRules, unit, value, { future }) {\r\n\t\t// Passing the language is required in order to\r\n\t\t// be able to correctly classify the `value` as a number.\r\n\t\tconst locale = this.locale\r\n\t\tformattingRules = formattingRules[unit]\r\n\t\t// Check for a special \"compacted\" rules case:\r\n\t\t// if formatting rules are the same for \"past\" and \"future\",\r\n\t\t// and also for all possible `value`s, then those rules are\r\n\t\t// stored as a single string.\r\n\t\tif (typeof formattingRules === 'string') {\r\n\t\t\treturn formattingRules\r\n\t\t}\r\n\t\t// Choose either \"past\" or \"future\" based on time `value` sign.\r\n\t\t// If \"past\" is same as \"future\" then they're stored as \"other\".\r\n\t\t// If there's only \"other\" then it's being collapsed.\r\n\t\tconst pastOrFuture = value === 0 ? (future ? 'future' : 'past') : (value < 0 ? 'past' : 'future')\r\n\t\tconst quantifierRules = formattingRules[pastOrFuture] || formattingRules\r\n\t\t// Bundle size optimization technique.\r\n\t\tif (typeof quantifierRules === 'string') {\r\n\t\t\treturn quantifierRules\r\n\t\t}\r\n\t\t// Quantify `value`.\r\n\t\tconst quantifier = this.getPluralRules().select(Math.abs(value))\r\n\t\t// \"other\" rule is supposed to always be present.\r\n\t\t// If only \"other\" rule is present then \"rules\" is not an object and is a string.\r\n\t\treturn quantifierRules[quantifier] || quantifierRules.other\r\n\t}\r\n\r\n\t/**\r\n\t * Formats a number into a string.\r\n\t * Uses `Intl.NumberFormat` when available.\r\n\t * @param {number} number\r\n\t * @return {string}\r\n\t */\r\n\tformatNumber(number) {\r\n\t\treturn this.numberFormat ? this.numberFormat.format(number) : String(number)\r\n\t}\r\n\r\n\t/**\r\n\t * Returns an `Intl.RelativeTimeFormat` for a given `labelsType`.\r\n\t * @param {string} labelsType\r\n\t * @return {object} `Intl.RelativeTimeFormat` instance\r\n\t */\r\n\tgetFormatter(labelsType) {\r\n\t\t// `Intl.RelativeTimeFormat` instance creation is (hypothetically) assumed\r\n\t\t// a lengthy operation so the instances are cached and reused.\r\n\t\treturn this.relativeTimeFormatCache.get(this.locale, labelsType) ||\r\n\t\t\tthis.relativeTimeFormatCache.put(this.locale, labelsType, new this.IntlRelativeTimeFormat(this.locale, { style: labelsType }))\r\n\t}\r\n\r\n\t/**\r\n\t * Returns an `Intl.PluralRules` instance.\r\n\t * @return {object} `Intl.PluralRules` instance\r\n\t */\r\n\tgetPluralRules() {\r\n\t\t// `Intl.PluralRules` instance creation is (hypothetically) assumed\r\n\t\t// a lengthy operation so the instances are cached and reused.\r\n\t\treturn this.pluralRulesCache.get(this.locale) ||\r\n\t\t\tthis.pluralRulesCache.put(this.locale, new this.IntlPluralRules(this.locale))\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Gets localized labels for this type of labels.\r\n\t *\r\n\t * @param {(string|string[])} labelsType - Relative date/time labels type.\r\n\t * If it's an array then all label types are tried\r\n\t * until a suitable one is found.\r\n\t *\r\n\t * @returns {Object} Returns an object of shape { labelsType, labels }\r\n\t */\r\n\tgetLabels(labelsType = []) {\r\n\t\t// Convert `labels` to an array.\r\n\t\tif (typeof labelsType === 'string') {\r\n\t\t\tlabelsType = [labelsType]\r\n\t\t}\r\n\r\n\t\t// Supports legacy \"tiny\" and \"mini-time\" label styles.\r\n\t\tlabelsType = labelsType.map((labelsType) => {\r\n\t\t\tswitch (labelsType) {\r\n\t\t\t\tcase 'tiny':\r\n\t\t\t\tcase 'mini-time':\r\n\t\t\t\t\treturn 'mini'\r\n\t\t\t\tdefault:\r\n\t\t\t\t\treturn labelsType\r\n\t\t\t}\r\n\t\t})\r\n\r\n\t\t// \"long\" labels type is the default one.\r\n\t\t// (it's always present for all languages)\r\n\t\tlabelsType = labelsType.concat('long')\r\n\r\n\t\t// Find a suitable labels type.\r\n\t\tconst localeData = getLocaleData(this.locale)\r\n\t\tfor (const _labelsType of labelsType) {\r\n\t\t\tif (localeData[_labelsType]) {\r\n\t\t\t\treturn {\r\n\t\t\t\t\tlabelsType: _labelsType,\r\n\t\t\t\t\tlabels: localeData[_labelsType]\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n/**\r\n * Default locale global variable.\r\n */\r\nlet defaultLocale = 'en'\r\n\r\n/**\r\n * Gets default locale.\r\n * @return {string} locale\r\n */\r\nTimeAgo.getDefaultLocale = () => defaultLocale\r\n\r\n/**\r\n * Sets default locale.\r\n * @param {string} locale\r\n */\r\nTimeAgo.setDefaultLocale = (locale) => {\r\n\tdefaultLocale = locale\r\n}\r\n\r\n/**\r\n * Adds locale data for a specific locale and marks the locale as default.\r\n * @param {Object} localeData\r\n */\r\nTimeAgo.addDefaultLocale = function(localeData) {\r\n\t// Warn the user if they've previously already added a default locale (a different one).\r\n\tif (defaultLocaleHasBeenSpecified) {\r\n\t\tif (TimeAgo.getDefaultLocale() !== localeData.locale) {\r\n\t\t\tconsole.warn(`[javascript-time-ago] You're adding \"${localeData.locale}\" as the default locale but you have already added \"${TimeAgo.getDefaultLocale()}\" as the default locale. \"${localeData.locale}\" is the default locale now.`)\r\n\t\t}\r\n\t}\r\n\tdefaultLocaleHasBeenSpecified = true\r\n\r\n\t// `addDefaultLocale()` is just a shortcut to `addLocale()` + `setDefaultLocale()`.\r\n\tTimeAgo.addLocale(localeData)\r\n\tTimeAgo.setDefaultLocale(localeData.locale)\r\n}\r\n\r\nlet defaultLocaleHasBeenSpecified = false\r\n\r\n/**\r\n * Adds locale data for a specific locale.\r\n * @param {Object} localeData\r\n */\r\nTimeAgo.addLocale = function(localeData) {\r\n\taddLocaleData(localeData)\r\n\tRelativeTimeFormatPolyfill.addLocale(localeData)\r\n}\r\n\r\n/**\r\n * (legacy alias)\r\n * Adds locale data for a specific locale.\r\n * @param {Object} localeData\r\n * @deprecated\r\n */\r\nTimeAgo.locale = TimeAgo.addLocale\r\n\r\n/**\r\n * Adds custom labels to locale data.\r\n * @param {string} locale\r\n * @param {string} name\r\n * @param {object} labels\r\n */\r\nTimeAgo.addLabels = (locale, name, labels) => {\r\n\tlet localeData = getLocaleData(locale)\r\n\tif (!localeData) {\r\n\t\taddLocaleData({\r\n\t\t\tlocale\r\n\t\t})\r\n\t\tlocaleData = getLocaleData(locale)\r\n\t\t// throw new Error(`[javascript-time-ago] No data for locale \"${locale}\"`)\r\n\t}\r\n\tlocaleData[name] = labels\r\n}\r\n\r\n// Normalizes `.format()` `time` argument.\r\nfunction getTimestamp(input) {\r\n\tif (input.constructor === Date || isMockedDate(input)) {\r\n\t\treturn input.getTime()\r\n\t}\r\n\r\n\tif (typeof input === 'number') {\r\n\t\treturn input\r\n\t}\r\n\r\n\t// For some weird reason istanbul doesn't see this `throw` covered.\r\n\t/* istanbul ignore next */\r\n\tthrow new Error(`Unsupported relative time formatter input: ${typeof input}, ${input}`)\r\n}\r\n\r\n// During testing via some testing libraries `Date`s aren't actually `Date`s.\r\n// https://github.com/catamphetamine/javascript-time-ago/issues/22\r\nfunction isMockedDate(object) {\r\n\treturn typeof object === 'object' && typeof object.getTime === 'function'\r\n}\r\n\r\n// Get available time interval measurement units.\r\nfunction getTimeIntervalMeasurementUnits(allowedUnits, labels, nowLabel) {\r\n\t// Get all time interval measurement units that're available\r\n\t// in locale data for a given time labels style.\r\n\tlet units = Object.keys(labels)\r\n\r\n\t// `now` unit is handled separately and is shipped in its own `now.json` file.\r\n\t// `now.json` isn't present for all locales, so it could be substituted with\r\n\t// \".second.current\".\r\n\t// Add `now` unit if it's available in locale data.\r\n\tif (nowLabel) {\r\n\t\tunits.push('now')\r\n\t}\r\n\r\n\t// If only a specific set of available time measurement units can be used\r\n\t// then only those units are allowed (if they're present in locale data).\r\n\tif (allowedUnits) {\r\n\t\tunits = allowedUnits.filter(unit => unit === 'now' || units.indexOf(unit) >= 0)\r\n\t}\r\n\r\n\treturn units\r\n}\r\n\r\nfunction getNowLabel(labels, nowLabels, longLabels, future) {\r\n\tconst nowLabel = labels.now || (nowLabels && nowLabels.now)\r\n\t// Specific \"now\" message form extended locale data (if present).\r\n\tif (nowLabel) {\r\n\t\t// Bundle size optimization technique.\r\n\t\tif (typeof nowLabel === 'string') {\r\n\t\t\treturn nowLabel\r\n\t\t}\r\n\t\t// Not handling `value === 0` as `localeData.now.current` here\r\n\t\t// because it wouldn't make sense: \"now\" is a moment,\r\n\t\t// so one can't possibly differentiate between a\r\n\t\t// \"previous\" moment, a \"current\" moment and a \"next moment\".\r\n\t\t// It can only be differentiated between \"past\" and \"future\".\r\n\t\tif (future) {\r\n\t\t\treturn nowLabel.future\r\n\t\t} else {\r\n\t\t\treturn nowLabel.past\r\n\t\t}\r\n\t}\r\n\t// Use \".second.current\" as \"now\" message.\r\n\tif (longLabels && longLabels.second && longLabels.second.current) {\r\n\t\treturn longLabels.second.current\r\n\t}\r\n}\r\n\r\nfunction isStyle(variable) {\r\n\treturn typeof variable === 'string' || isStyleObject(variable)\r\n}\r\n\r\n// `setTimeout()` function has a bug when it fires immediately\r\n// when the delay is longer than about `24.85` days.\r\n// https://stackoverflow.com/questions/3468607/why-does-settimeout-break-for-large-millisecond-delay-values\r\n//\r\n// Since `renderLabel()` function uses `setTimeout()` for recursion,\r\n// that would mean infinite recursion.\r\n//\r\n// `setTimeoutSafe()` function works around that bug\r\n// by capping the delay at the maximum allowed value.\r\n//\r\nfunction setTimeoutSafe(func, delay) {\r\n return setTimeout(func, getSafeTimeoutDelay(delay))\r\n}\r\nfunction getSafeTimeoutDelay(delay) {\r\n return Math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,KAAK,EAAE;EAClC,OAAOa,IAAI,CAACqD,GAAG,CAAClE,KAAK,EAAEmE,0BAA0B,CAAC;AACpD;AACA,IAAMA,0BAA0B,GAAG,UAAU","ignoreList":[]}
|
package/commonjs/TimeAgo.test.js
CHANGED
|
@@ -4,8 +4,12 @@ var _TimeAgo = _interopRequireDefault(require("./TimeAgo.js"));
|
|
|
4
4
|
var _LocaleDataStore = require("./LocaleDataStore.js");
|
|
5
5
|
var _en = _interopRequireDefault(require("../locale/en.json"));
|
|
6
6
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
10
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } // Load locale specific relative date/time messages
|
|
9
13
|
// Just so this function code is covered.
|
|
10
14
|
_TimeAgo["default"].setDefaultLocale('en');
|
|
11
15
|
describe("javascript-time-ago", function () {
|
|
@@ -230,9 +234,8 @@ describe("javascript-time-ago", function () {
|
|
|
230
234
|
});
|
|
231
235
|
it('should format for a style with "custom" function', function () {
|
|
232
236
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
233
|
-
|
|
234
|
-
// `custom` returns a string
|
|
235
237
|
timeAgo.format(Date.now(), {
|
|
238
|
+
// `custom` returns a string
|
|
236
239
|
custom: function custom(_ref) {
|
|
237
240
|
var now = _ref.now,
|
|
238
241
|
time = _ref.time,
|
|
@@ -241,9 +244,8 @@ describe("javascript-time-ago", function () {
|
|
|
241
244
|
return locale;
|
|
242
245
|
}
|
|
243
246
|
}).should.equal('en');
|
|
244
|
-
|
|
245
|
-
// `custom` returns `undefined`
|
|
246
247
|
timeAgo.format(Date.now(), {
|
|
248
|
+
// `custom` returns `undefined`
|
|
247
249
|
custom: function custom(_ref2) {
|
|
248
250
|
var now = _ref2.now,
|
|
249
251
|
time = _ref2.time,
|
|
@@ -253,6 +255,23 @@ describe("javascript-time-ago", function () {
|
|
|
253
255
|
}
|
|
254
256
|
}).should.equal('just now');
|
|
255
257
|
});
|
|
258
|
+
it('should throw an error when formating for a style with "custom" function and `getTimeToNextUpdate: true` parameter is passed', function () {
|
|
259
|
+
var timeAgo = new _TimeAgo["default"]('en');
|
|
260
|
+
expect(function () {
|
|
261
|
+
timeAgo.format(Date.now(), {
|
|
262
|
+
// `custom` returns a string.
|
|
263
|
+
custom: function custom(_ref3) {
|
|
264
|
+
var now = _ref3.now,
|
|
265
|
+
time = _ref3.time,
|
|
266
|
+
date = _ref3.date,
|
|
267
|
+
locale = _ref3.locale;
|
|
268
|
+
return locale;
|
|
269
|
+
}
|
|
270
|
+
}, {
|
|
271
|
+
getTimeToNextUpdate: true
|
|
272
|
+
});
|
|
273
|
+
}).to["throw"]('not supported');
|
|
274
|
+
});
|
|
256
275
|
it('should format future dates', function () {
|
|
257
276
|
new _TimeAgo["default"]('en').format(Date.now() + 60 * 60 * 1000).should.equal('in 1 hour');
|
|
258
277
|
new _TimeAgo["default"]('ru').format(Date.now() + 60 * 1000).should.equal('через 1 минуту');
|
|
@@ -334,6 +353,62 @@ describe("javascript-time-ago", function () {
|
|
|
334
353
|
}).should.equal('in 0 seconds');
|
|
335
354
|
_en["default"]['mini'].second = secondLabels;
|
|
336
355
|
});
|
|
356
|
+
it('should refresh the label when `refresh` parameter is passed', function () {
|
|
357
|
+
var refreshedTimes = 0;
|
|
358
|
+
var timeAgo = new _TimeAgo["default"]('en');
|
|
359
|
+
// in 1 second -> in 0 seconds.
|
|
360
|
+
var _timeAgo$format = timeAgo.format(1000, 'twitter', {
|
|
361
|
+
refresh: function refresh(text) {
|
|
362
|
+
if (refreshedTimes === 0) {
|
|
363
|
+
expect(text).to.equal('0s');
|
|
364
|
+
} else {
|
|
365
|
+
throw new Error('Refresh should have been cancelled');
|
|
366
|
+
}
|
|
367
|
+
refreshedTimes++;
|
|
368
|
+
},
|
|
369
|
+
now: 0,
|
|
370
|
+
round: 'floor'
|
|
371
|
+
}),
|
|
372
|
+
_timeAgo$format2 = _slicedToArray(_timeAgo$format, 2),
|
|
373
|
+
text = _timeAgo$format2[0],
|
|
374
|
+
cancelRefresh = _timeAgo$format2[1];
|
|
375
|
+
expect(text).to.equal('1s');
|
|
376
|
+
expect(cancelRefresh).to.be.a('function');
|
|
377
|
+
// Sidenote: `timeToNextUpdate` is `1`.
|
|
378
|
+
var timeToNextUpdate = 1;
|
|
379
|
+
return delay(timeToNextUpdate + 1).then(function () {
|
|
380
|
+
expect(refreshedTimes).to.equal(1);
|
|
381
|
+
cancelRefresh();
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
it('should get time to next update (capped)', function () {
|
|
385
|
+
var timeAgo = new _TimeAgo["default"]('en');
|
|
386
|
+
// in 1 second -> in 0 seconds.
|
|
387
|
+
timeAgo.format(0.5 * 365 * 24 * 60 * 60 * 1000, 'twitter', {
|
|
388
|
+
getTimeToNextUpdate: true,
|
|
389
|
+
now: 0,
|
|
390
|
+
round: 'floor'
|
|
391
|
+
}).should.deep.equal(['Jul 2', 2147483647]);
|
|
392
|
+
});
|
|
393
|
+
it('should get time to next update (capped)', function () {
|
|
394
|
+
var timeAgo = new _TimeAgo["default"]('en');
|
|
395
|
+
// in 1 second -> in 0 seconds.
|
|
396
|
+
timeAgo.format(0.5 * 365 * 24 * 60 * 60 * 1000, 'twitter', {
|
|
397
|
+
getTimeToNextUpdate: true,
|
|
398
|
+
getTimeToNextUpdateUncapped: true,
|
|
399
|
+
now: 0,
|
|
400
|
+
round: 'floor'
|
|
401
|
+
}).should.deep.equal(['Jul 2', 15681600001]);
|
|
402
|
+
});
|
|
403
|
+
it('should get time to next update (uncapped)', function () {
|
|
404
|
+
var timeAgo = new _TimeAgo["default"]('en');
|
|
405
|
+
// in 1 second -> in 0 seconds.
|
|
406
|
+
timeAgo.format(1000, 'twitter', {
|
|
407
|
+
getTimeToNextUpdate: true,
|
|
408
|
+
now: 0,
|
|
409
|
+
round: 'floor'
|
|
410
|
+
}).should.deep.equal(['1s', 1]);
|
|
411
|
+
});
|
|
337
412
|
it('should get time to next update (round: "floor")', function () {
|
|
338
413
|
var timeAgo = new _TimeAgo["default"]('en');
|
|
339
414
|
// in 1 second -> in 0 seconds.
|
|
@@ -572,8 +647,8 @@ describe("javascript-time-ago", function () {
|
|
|
572
647
|
timeAgo.format(Date.now(), {
|
|
573
648
|
labels: 'long',
|
|
574
649
|
steps: [{
|
|
575
|
-
format: function format(date, locale,
|
|
576
|
-
var formatAs =
|
|
650
|
+
format: function format(date, locale, _ref4) {
|
|
651
|
+
var formatAs = _ref4.formatAs;
|
|
577
652
|
return formatAs('second', 1);
|
|
578
653
|
}
|
|
579
654
|
}]
|
|
@@ -636,11 +711,16 @@ describe("javascript-time-ago", function () {
|
|
|
636
711
|
locale: 'el'
|
|
637
712
|
});
|
|
638
713
|
_TimeAgo["default"].getDefaultLocale().should.equal('el');
|
|
639
|
-
//
|
|
714
|
+
// Doesn't throw an error because the same locale is already specified as default.
|
|
640
715
|
_TimeAgo["default"].addDefaultLocale({
|
|
641
716
|
locale: 'el'
|
|
642
717
|
});
|
|
643
|
-
//
|
|
718
|
+
// Could throw an error or output an error message because another locale is already specified as default.
|
|
719
|
+
// expect(() => {
|
|
720
|
+
_TimeAgo["default"].addDefaultLocale({
|
|
721
|
+
locale: 'es'
|
|
722
|
+
});
|
|
723
|
+
// }).to.throw('but you have already added "el" as the default locale.')
|
|
644
724
|
_TimeAgo["default"].setDefaultLocale('en');
|
|
645
725
|
});
|
|
646
726
|
it('should support "floor" rounding', function () {
|
|
@@ -671,4 +751,9 @@ describe("javascript-time-ago", function () {
|
|
|
671
751
|
}).should.equal('2m');
|
|
672
752
|
});
|
|
673
753
|
});
|
|
754
|
+
function delay(delayTime) {
|
|
755
|
+
return new Promise(function (resolve) {
|
|
756
|
+
setTimeout(resolve, delayTime);
|
|
757
|
+
});
|
|
758
|
+
}
|
|
674
759
|
//# sourceMappingURL=TimeAgo.test.js.map
|