Initial import from local backup (Documents-Playground/pakerpale)
This commit is contained in:
467
node_modules/javascript-time-ago/commonjs/JavascriptTimeAgo.js
generated
vendored
Normal file
467
node_modules/javascript-time-ago/commonjs/JavascriptTimeAgo.js
generated
vendored
Normal file
@@ -0,0 +1,467 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _relativeTimeFormat = _interopRequireDefault(require("relative-time-format"));
|
||||
|
||||
var _cache = _interopRequireDefault(require("./cache"));
|
||||
|
||||
var _grade = _interopRequireDefault(require("./grade"));
|
||||
|
||||
var _locale = _interopRequireDefault(require("./locale"));
|
||||
|
||||
var _style = require("./style");
|
||||
|
||||
var _LocaleDataStore = require("./LocaleDataStore");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
// const EXTRA_STYLES = [
|
||||
// 'long-convenient',
|
||||
// 'long-time',
|
||||
// 'short-convenient',
|
||||
// 'short-time',
|
||||
// 'tiny'
|
||||
// ]
|
||||
// Valid time units.
|
||||
var UNITS = ['now', // The rest are the same as in `Intl.RelativeTimeFormat`.
|
||||
'second', 'minute', 'hour', 'day', 'week', 'month', 'quarter', 'year'];
|
||||
|
||||
var JavascriptTimeAgo =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
/**
|
||||
* @param {(string|string[])} locales=[] - Preferred locales (or locale).
|
||||
*/
|
||||
function JavascriptTimeAgo() {
|
||||
var locales = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||||
|
||||
_classCallCheck(this, JavascriptTimeAgo);
|
||||
|
||||
// Convert `locales` to an array.
|
||||
if (typeof locales === 'string') {
|
||||
locales = [locales];
|
||||
} // Choose the most appropriate locale
|
||||
// (one of the previously added ones)
|
||||
// based on the list of preferred `locales` supplied by the user.
|
||||
|
||||
|
||||
this.locale = (0, _locale.default)(locales.concat(_relativeTimeFormat.default.getDefaultLocale()), _LocaleDataStore.getLocaleData); // Use `Intl.NumberFormat` for formatting numbers (when available).
|
||||
|
||||
if (typeof Intl !== 'undefined' && Intl.NumberFormat) {
|
||||
this.numberFormat = new Intl.NumberFormat(this.locale);
|
||||
} // Cache `Intl.RelativeTimeFormat` instance.
|
||||
|
||||
|
||||
this.relativeTimeFormatCache = new _cache.default();
|
||||
} // Formats the relative date/time.
|
||||
//
|
||||
// @return {string} Returns the formatted relative date/time.
|
||||
//
|
||||
// @param {(Object|string)} [style] - Relative date/time formatting style.
|
||||
//
|
||||
// @param {string[]} [style.units] - A list of allowed time units
|
||||
// (e.g. ['second', 'minute', 'hour', …])
|
||||
//
|
||||
// @param {Function} [style.custom] - `function ({ elapsed, time, date, now })`.
|
||||
// If this function returns a value, then
|
||||
// the `.format()` call will return that value.
|
||||
// Otherwise it has no effect.
|
||||
//
|
||||
// @param {string} [style.flavour] - e.g. "long", "short", "tiny", etc.
|
||||
//
|
||||
// @param {Object[]} [style.gradation] - Time scale gradation steps.
|
||||
//
|
||||
// @param {string} style.gradation[].unit - Time interval measurement unit.
|
||||
// (e.g. ['second', 'minute', 'hour', …])
|
||||
//
|
||||
// @param {Number} style.gradation[].factor - Time interval measurement unit factor.
|
||||
// (e.g. `60` for 'minute')
|
||||
//
|
||||
// @param {Number} [style.gradation[].granularity] - A step for the unit's "amount" value.
|
||||
// (e.g. `5` for '0 minutes', '5 minutes', etc)
|
||||
//
|
||||
// @param {Number} [style.gradation[].threshold] - Time interval measurement unit threshold.
|
||||
// (e.g. `45` seconds for 'minute').
|
||||
// There can also be specific `threshold_[unit]`
|
||||
// thresholds for fine-tuning.
|
||||
//
|
||||
|
||||
|
||||
_createClass(JavascriptTimeAgo, [{
|
||||
key: "format",
|
||||
value: function format(input) {
|
||||
var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _style.defaultStyle;
|
||||
|
||||
if (typeof style === 'string') {
|
||||
switch (style) {
|
||||
case 'twitter':
|
||||
style = _style.twitterStyle;
|
||||
break;
|
||||
|
||||
case 'time':
|
||||
style = _style.timeStyle;
|
||||
break;
|
||||
|
||||
default:
|
||||
style = _style.defaultStyle;
|
||||
}
|
||||
}
|
||||
|
||||
var _getDateAndTimeBeingF = getDateAndTimeBeingFormatted(input),
|
||||
date = _getDateAndTimeBeingF.date,
|
||||
time = _getDateAndTimeBeingF.time; // Get locale messages for this formatting flavour
|
||||
|
||||
|
||||
var _this$getLocaleData = this.getLocaleData(style.flavour),
|
||||
flavour = _this$getLocaleData.flavour,
|
||||
localeData = _this$getLocaleData.localeData; // Can pass a custom `now`, e.g. for testing purposes.
|
||||
// Technically it doesn't belong to `style`
|
||||
// but since this is an undocumented internal feature,
|
||||
// taking it from the `style` argument will do (for now).
|
||||
|
||||
|
||||
var now = style.now || Date.now(); // how much time elapsed (in seconds)
|
||||
|
||||
var elapsed = (now - time) / 1000; // in seconds
|
||||
// `custom` – A function of `{ elapsed, time, date, now, locale }`.
|
||||
// If this function returns a value, then the `.format()` call will return that value.
|
||||
// Otherwise the relative date/time is formatted as usual.
|
||||
// This feature is currently not used anywhere and is here
|
||||
// just for providing the ultimate customization point
|
||||
// in case anyone would ever need that. Prefer using
|
||||
// `gradation[step].format(value, locale)` instead.
|
||||
//
|
||||
// I guess `custom` is deprecated and will be removed
|
||||
// in some future major version release.
|
||||
//
|
||||
|
||||
if (style.custom) {
|
||||
var custom = style.custom({
|
||||
now: now,
|
||||
date: date,
|
||||
time: time,
|
||||
elapsed: elapsed,
|
||||
locale: this.locale
|
||||
});
|
||||
|
||||
if (custom !== undefined) {
|
||||
return custom;
|
||||
}
|
||||
} // Available time interval measurement units.
|
||||
|
||||
|
||||
var units = getTimeIntervalMeasurementUnits(localeData, style.units); // If no available time unit is suitable, just output an empty string.
|
||||
|
||||
if (units.length === 0) {
|
||||
console.error("Units \"".concat(units.join(', '), "\" were not found in locale data for \"").concat(this.locale, "\"."));
|
||||
return '';
|
||||
} // Choose the appropriate time measurement unit
|
||||
// and get the corresponding rounded time amount.
|
||||
|
||||
|
||||
var step = (0, _grade.default)(elapsed, now, units, style.gradation); // If no time unit is suitable, just output an empty string.
|
||||
// E.g. when "now" unit is not available
|
||||
// and "second" has a threshold of `0.5`
|
||||
// (e.g. the "canonical" grading scale).
|
||||
|
||||
if (!step) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (step.format) {
|
||||
return step.format(date || time, this.locale);
|
||||
}
|
||||
|
||||
var unit = step.unit,
|
||||
factor = step.factor,
|
||||
granularity = step.granularity;
|
||||
var amount = Math.abs(elapsed) / factor; // Apply granularity to the time amount
|
||||
// (and fallback to the previous step
|
||||
// if the first level of granularity
|
||||
// isn't met by this amount)
|
||||
|
||||
if (granularity) {
|
||||
// Recalculate the elapsed time amount based on granularity
|
||||
amount = Math.round(amount / granularity) * granularity;
|
||||
} // `Intl.RelativeTimeFormat` doesn't operate in "now" units.
|
||||
|
||||
|
||||
if (unit === 'now') {
|
||||
return getNowMessage(localeData, -1 * Math.sign(elapsed));
|
||||
}
|
||||
|
||||
switch (flavour) {
|
||||
case 'long':
|
||||
case 'short':
|
||||
case 'narrow':
|
||||
// Format `value` using `Intl.RelativeTimeFormat`.
|
||||
return this.getFormatter(flavour).format(-1 * Math.sign(elapsed) * Math.round(amount), unit);
|
||||
|
||||
default:
|
||||
// Format `value`.
|
||||
// (mimicks `Intl.RelativeTimeFormat` with the addition of extra styles)
|
||||
return this.formatValue(-1 * Math.sign(elapsed) * Math.round(amount), unit, localeData);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Mimicks what `Intl.RelativeTimeFormat` does for additional locale styles.
|
||||
* @param {number} value
|
||||
* @param {string} unit
|
||||
* @param {object} localeData — Relative time messages for the flavor.
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: "formatValue",
|
||||
value: function formatValue(value, unit, localeData) {
|
||||
return this.getRule(value, unit, localeData).replace('{0}', this.formatNumber(Math.abs(value)));
|
||||
}
|
||||
/**
|
||||
* Returns formatting rule for `value` in `units` (either in past or in future).
|
||||
* @param {number} value - Time interval value.
|
||||
* @param {string} unit - Time interval measurement unit.
|
||||
* @param {object} localeData — Relative time messages for the flavor.
|
||||
* @return {string}
|
||||
* @example
|
||||
* // Returns "{0} days ago"
|
||||
* getRule(-2, "day")
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: "getRule",
|
||||
value: function getRule(value, unit, localeData) {
|
||||
var unitRules = localeData[unit]; // Bundle size optimization technique.
|
||||
|
||||
if (typeof unitRules === 'string') {
|
||||
return unitRules;
|
||||
} // Choose either "past" or "future" based on time `value` sign.
|
||||
// If "past" is same as "future" then they're stored as "other".
|
||||
// If there's only "other" then it's being collapsed.
|
||||
|
||||
|
||||
var quantifierRules = unitRules[value <= 0 ? 'past' : 'future'] || unitRules; // Bundle size optimization technique.
|
||||
|
||||
if (typeof quantifierRules === 'string') {
|
||||
return quantifierRules;
|
||||
} // Quantify `value`.
|
||||
|
||||
|
||||
var quantify = (0, _LocaleDataStore.getLocaleData)(this.locale).quantify;
|
||||
var quantifier = quantify && quantify(Math.abs(value)); // There seems to be no such locale in CLDR
|
||||
// for which `quantify` is missing
|
||||
// and still `past` and `future` messages
|
||||
// contain something other than "other".
|
||||
|
||||
/* istanbul ignore next */
|
||||
|
||||
quantifier = quantifier || 'other'; // "other" rule is supposed to always be present.
|
||||
// If only "other" rule is present then "rules" is not an object and is a string.
|
||||
|
||||
return quantifierRules[quantifier] || quantifierRules.other;
|
||||
}
|
||||
/**
|
||||
* Formats a number into a string.
|
||||
* Uses `Intl.NumberFormat` when available.
|
||||
* @param {number} number
|
||||
* @return {string}
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: "formatNumber",
|
||||
value: function formatNumber(number) {
|
||||
return this.numberFormat ? this.numberFormat.format(number) : String(number);
|
||||
}
|
||||
/**
|
||||
* Returns an `Intl.RelativeTimeFormat` for a given `flavor`.
|
||||
* @param {string} flavor
|
||||
* @return {object} `Intl.RelativeTimeFormat` instance
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: "getFormatter",
|
||||
value: function getFormatter(flavor) {
|
||||
// `Intl.RelativeTimeFormat` instance creation is assumed a
|
||||
// lengthy operation so the instances are cached and reused.
|
||||
return this.relativeTimeFormatCache.get(this.locale, flavor) || this.relativeTimeFormatCache.put(this.locale, flavor, new _relativeTimeFormat.default(this.locale, {
|
||||
style: flavor
|
||||
}));
|
||||
}
|
||||
/**
|
||||
* Gets locale messages for this formatting flavour
|
||||
*
|
||||
* @param {(string|string[])} flavour - Relative date/time formatting flavour.
|
||||
* If it's an array then all flavours are tried in order.
|
||||
*
|
||||
* @returns {Object} Returns an object of shape { flavour, localeData }
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: "getLocaleData",
|
||||
value: function getLocaleData() {
|
||||
var flavour = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||||
// Get relative time formatting rules for this locale
|
||||
var localeData = (0, _LocaleDataStore.getLocaleData)(this.locale); // Convert `flavour` to an array.
|
||||
|
||||
if (typeof flavour === 'string') {
|
||||
flavour = [flavour];
|
||||
} // "long" flavour is the default one.
|
||||
// (it's always present)
|
||||
|
||||
|
||||
flavour = flavour.concat('long'); // Find a suitable flavour.
|
||||
|
||||
for (var _iterator = flavour, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref;
|
||||
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) break;
|
||||
_ref = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) break;
|
||||
_ref = _i.value;
|
||||
}
|
||||
|
||||
var _ = _ref;
|
||||
|
||||
if (localeData[_]) {
|
||||
return {
|
||||
flavour: _,
|
||||
localeData: localeData[_]
|
||||
};
|
||||
}
|
||||
} // Can't happen - "long" flavour is always present.
|
||||
// throw new Error(`None of the flavours - ${flavour.join(', ')} - was found for locale "${this.locale}".`)
|
||||
|
||||
}
|
||||
}]);
|
||||
|
||||
return JavascriptTimeAgo;
|
||||
}();
|
||||
/**
|
||||
* Gets default locale.
|
||||
* @return {string} locale
|
||||
*/
|
||||
|
||||
|
||||
exports.default = JavascriptTimeAgo;
|
||||
JavascriptTimeAgo.getDefaultLocale = _relativeTimeFormat.default.getDefaultLocale;
|
||||
/**
|
||||
* Sets default locale.
|
||||
* @param {string} locale
|
||||
*/
|
||||
|
||||
JavascriptTimeAgo.setDefaultLocale = _relativeTimeFormat.default.setDefaultLocale;
|
||||
/**
|
||||
* Adds locale data for a specific locale.
|
||||
* @param {Object} localeData
|
||||
*/
|
||||
|
||||
JavascriptTimeAgo.addLocale = function (localeData) {
|
||||
(0, _LocaleDataStore.addLocaleData)(localeData);
|
||||
|
||||
_relativeTimeFormat.default.addLocale(localeData);
|
||||
};
|
||||
/**
|
||||
* (legacy alias)
|
||||
* Adds locale data for a specific locale.
|
||||
* @param {Object} localeData
|
||||
* @deprecated
|
||||
*/
|
||||
|
||||
|
||||
JavascriptTimeAgo.locale = JavascriptTimeAgo.addLocale; // Normalizes `.format()` `time` argument.
|
||||
|
||||
function getDateAndTimeBeingFormatted(input) {
|
||||
if (input.constructor === Date || isMockedDate(input)) {
|
||||
return {
|
||||
date: input,
|
||||
time: input.getTime()
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof input === 'number') {
|
||||
return {
|
||||
time: input // `date` is not required for formatting
|
||||
// relative times unless "twitter" preset is used.
|
||||
// date : new Date(input)
|
||||
|
||||
};
|
||||
} // For some weird reason istanbul doesn't see this `throw` covered.
|
||||
|
||||
/* istanbul ignore next */
|
||||
|
||||
|
||||
throw new Error("Unsupported relative time formatter input: ".concat(_typeof(input), ", ").concat(input));
|
||||
} // During testing via some testing libraries `Date`s aren't actually `Date`s.
|
||||
// https://github.com/catamphetamine/javascript-time-ago/issues/22
|
||||
|
||||
|
||||
function isMockedDate(object) {
|
||||
return _typeof(object) === 'object' && typeof object.getTime === 'function';
|
||||
} // Get available time interval measurement units.
|
||||
|
||||
|
||||
function getTimeIntervalMeasurementUnits(localeData, restrictedSetOfUnits) {
|
||||
// All available time interval measurement units.
|
||||
var units = Object.keys(localeData); // If only a specific set of available
|
||||
// time measurement units can be used.
|
||||
|
||||
if (restrictedSetOfUnits) {
|
||||
// Reduce available time interval measurement units
|
||||
// based on user's preferences.
|
||||
units = restrictedSetOfUnits.filter(function (_) {
|
||||
return units.indexOf(_) >= 0;
|
||||
});
|
||||
} // Stock `Intl.RelativeTimeFormat` locale data doesn't have "now" units.
|
||||
// So either "now" is present in extended locale data
|
||||
// or it's taken from ".second.current".
|
||||
|
||||
|
||||
if ((!restrictedSetOfUnits || restrictedSetOfUnits.indexOf('now') >= 0) && units.indexOf('now') < 0) {
|
||||
if (localeData.second.current) {
|
||||
units.unshift('now');
|
||||
}
|
||||
}
|
||||
|
||||
return units;
|
||||
}
|
||||
|
||||
function getNowMessage(localeData, value) {
|
||||
// Specific "now" message form extended locale data (if present).
|
||||
if (localeData.now) {
|
||||
// Bundle size optimization technique.
|
||||
if (typeof localeData.now === 'string') {
|
||||
return localeData.now;
|
||||
} // Not handling `value === 0` as `localeData.now.current` here
|
||||
// because it wouldn't make sense: "now" is a moment,
|
||||
// so one can't possibly differentiate between a
|
||||
// "previous" moment, a "current" moment and a "next moment".
|
||||
// It can only be differentiated between "past" and "future".
|
||||
|
||||
|
||||
if (value <= 0) {
|
||||
return localeData.now.past;
|
||||
} else {
|
||||
return localeData.now.future;
|
||||
}
|
||||
} // Use ".second.current" as "now" message.
|
||||
|
||||
|
||||
return localeData.second.current; // If this function was called then
|
||||
// it means that either "now" unit messages are
|
||||
// available or ".second.current" message is present.
|
||||
}
|
||||
//# sourceMappingURL=JavascriptTimeAgo.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/JavascriptTimeAgo.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/JavascriptTimeAgo.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
264
node_modules/javascript-time-ago/commonjs/JavascriptTimeAgo.test.js
generated
vendored
Normal file
264
node_modules/javascript-time-ago/commonjs/JavascriptTimeAgo.test.js
generated
vendored
Normal file
@@ -0,0 +1,264 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.convenientGradationTest = convenientGradationTest;
|
||||
|
||||
var _JavascriptTimeAgo = _interopRequireDefault(require("../source/JavascriptTimeAgo"));
|
||||
|
||||
var _gradation = require("../source/gradation");
|
||||
|
||||
var _style = require("../source/style");
|
||||
|
||||
var _LocaleDataStore = require("../source/LocaleDataStore");
|
||||
|
||||
var _en = _interopRequireDefault(require("../locale/en"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
// Just so this function code is covered.
|
||||
_JavascriptTimeAgo.default.setDefaultLocale('en');
|
||||
|
||||
describe("time ago", function () {
|
||||
it("should try various flavours if some are not found", function () {
|
||||
var timeAgo = new _JavascriptTimeAgo.default('en');
|
||||
timeAgo.format(Date.now(), {
|
||||
flavour: ['exotic', 'short']
|
||||
}).should.equal('now');
|
||||
});
|
||||
it("should not use Intl.NumberFormat if it's not available", function () {
|
||||
var NumberFormat = Intl.NumberFormat;
|
||||
delete Intl.NumberFormat;
|
||||
var timeAgo = new _JavascriptTimeAgo.default('en');
|
||||
timeAgo.format(Date.now() + 60 * 1000).should.equal('in a minute');
|
||||
Intl.NumberFormat = NumberFormat;
|
||||
});
|
||||
it("should work when \"past\"/\"future\" messages are same for all quantifiers", function () {
|
||||
var timeAgo = new _JavascriptTimeAgo.default('en');
|
||||
timeAgo.format(Date.now() + 365 * 24 * 60 * 60 * 1000, {
|
||||
flavour: ['short-convenient']
|
||||
}).should.equal('in 1 yr.');
|
||||
});
|
||||
it("should work when \"now\" is a string (doesn't differentiate between \"past\" and \"future\")", function () {
|
||||
var timeAgo = new _JavascriptTimeAgo.default('en');
|
||||
timeAgo.format(Date.now(), {
|
||||
flavour: ['short-time']
|
||||
}).should.equal('now');
|
||||
});
|
||||
it("should format \"now\" for \"past\" time", function () {
|
||||
var timeAgo = new _JavascriptTimeAgo.default('en');
|
||||
timeAgo.format(Date.now() + 10, {
|
||||
flavour: ['long-convenient']
|
||||
}).should.equal('in a moment');
|
||||
});
|
||||
it("should accept a string style argument", function () {
|
||||
var timeAgo = new _JavascriptTimeAgo.default('en');
|
||||
timeAgo.format(Date.now(), 'twitter').should.equal('');
|
||||
timeAgo.format(Date.now(), 'time').should.equal('just now');
|
||||
timeAgo.format(Date.now(), 'exotic').should.equal('just now');
|
||||
});
|
||||
it("should accept empty constructor parameters", function () {
|
||||
var timeAgo = new _JavascriptTimeAgo.default();
|
||||
timeAgo.format(new Date()).should.equal('just now');
|
||||
});
|
||||
it("should accept Dates", function () {
|
||||
var timeAgo = new _JavascriptTimeAgo.default('en');
|
||||
timeAgo.format(new Date()).should.equal('just now');
|
||||
});
|
||||
it("should accept mocked Dates when testing", function () {
|
||||
var timeAgo = new _JavascriptTimeAgo.default('en');
|
||||
var mockedDate = {
|
||||
getTime: function getTime() {
|
||||
return Date.now();
|
||||
}
|
||||
};
|
||||
timeAgo.format(mockedDate).should.equal('just now');
|
||||
});
|
||||
it("should not accept anything but Dates and timestamps", function () {
|
||||
var timeAgo = new _JavascriptTimeAgo.default('en');
|
||||
|
||||
var thrower = function thrower() {
|
||||
return timeAgo.format('Jan 14, 2017');
|
||||
};
|
||||
|
||||
thrower.should.throw('Unsupported relative time formatter input: string, Jan 14, 2017');
|
||||
});
|
||||
it("should return an empty string if the passed units are not available in locale data", function () {
|
||||
var timeAgo = new _JavascriptTimeAgo.default('en');
|
||||
timeAgo.format(Date.now(), {
|
||||
units: ['femtosecond']
|
||||
}).should.equal('');
|
||||
});
|
||||
it("should return an empty string if no unit is suitable", function () {
|
||||
var timeAgo = new _JavascriptTimeAgo.default('en');
|
||||
var now = Date.now(); // Remove 'now' unit formatting rule temporarily
|
||||
|
||||
var justNowFormatter = (0, _LocaleDataStore.getLocaleData)('en').long.now;
|
||||
var currentSecondMessage = (0, _LocaleDataStore.getLocaleData)('en').long.second.current;
|
||||
delete (0, _LocaleDataStore.getLocaleData)('en').long.now;
|
||||
delete (0, _LocaleDataStore.getLocaleData)('en').long.second.current;
|
||||
timeAgo.format(now, {
|
||||
now: now
|
||||
}).should.equal(''); // Restore 'now' unit formating rule
|
||||
|
||||
(0, _LocaleDataStore.getLocaleData)('en').long.now = justNowFormatter;
|
||||
(0, _LocaleDataStore.getLocaleData)('en').long.second.current = currentSecondMessage;
|
||||
});
|
||||
it("should format for a style with \"custom\" function", function () {
|
||||
var timeAgo = new _JavascriptTimeAgo.default('en'); // `custom` returns a string
|
||||
|
||||
timeAgo.format(Date.now(), {
|
||||
custom: function custom(_ref) {
|
||||
var now = _ref.now,
|
||||
time = _ref.time,
|
||||
date = _ref.date,
|
||||
locale = _ref.locale;
|
||||
return locale;
|
||||
}
|
||||
}).should.equal('en'); // `custom` returns `undefined`
|
||||
|
||||
timeAgo.format(Date.now(), {
|
||||
custom: function custom(_ref2) {
|
||||
var now = _ref2.now,
|
||||
time = _ref2.time,
|
||||
date = _ref2.date,
|
||||
locale = _ref2.locale;
|
||||
return;
|
||||
}
|
||||
}).should.equal('now');
|
||||
});
|
||||
it("should format time correctly for English language (short)", function () {
|
||||
convenientGradationTest(['now', '1 min. ago', '2 min. ago', '5 min. ago', '10 min. ago', '15 min. ago', '20 min. ago', '25 min. ago', '30 min. ago', '35 min. ago', '40 min. ago', '45 min. ago', '50 min. ago', '1 hr. ago', '2 hr. ago', '3 hr. ago', '4 hr. ago', '5 hr. ago', '6 hr. ago', '7 hr. ago', '8 hr. ago', '9 hr. ago', '10 hr. ago', '11 hr. ago', '12 hr. ago', '13 hr. ago', '14 hr. ago', '15 hr. ago', '16 hr. ago', '17 hr. ago', '18 hr. ago', '19 hr. ago', '20 hr. ago', '1 day ago', '2 days ago', '3 days ago', '4 days ago', '5 days ago', '1 wk. ago', '2 wk. ago', '3 wk. ago', '1 mo. ago', '2 mo. ago', '3 mo. ago', '4 mo. ago', '5 mo. ago', '6 mo. ago', '7 mo. ago', '8 mo. ago', '9 mo. ago', '9 mo. ago', '10 mo. ago', '1 yr. ago', '2 yr. ago', '3 yr. ago', '100 yr. ago'], 'en', {
|
||||
flavour: 'short'
|
||||
});
|
||||
});
|
||||
it("should format time correctly for English language (long)", function () {
|
||||
convenientGradationTest(['just now', 'a minute ago', '2 minutes ago', '5 minutes ago', '10 minutes ago', '15 minutes ago', '20 minutes ago', '25 minutes ago', '30 minutes ago', '35 minutes ago', '40 minutes ago', '45 minutes ago', '50 minutes ago', 'an hour ago', '2 hours ago', '3 hours ago', '4 hours ago', '5 hours ago', '6 hours ago', '7 hours ago', '8 hours ago', '9 hours ago', '10 hours ago', '11 hours ago', '12 hours ago', '13 hours ago', '14 hours ago', '15 hours ago', '16 hours ago', '17 hours ago', '18 hours ago', '19 hours ago', '20 hours ago', 'a day ago', '2 days ago', '3 days ago', '4 days ago', '5 days ago', 'a week ago', '2 weeks ago', '3 weeks ago', 'a month ago', '2 months ago', '3 months ago', '4 months ago', '5 months ago', '6 months ago', '7 months ago', '8 months ago', '9 months ago', '9 months ago', '10 months ago', 'a year ago', '2 years ago', '3 years ago', '100 years ago'], 'en', _style.defaultStyle);
|
||||
});
|
||||
it("should format time correctly for Russian language (short)", function () {
|
||||
convenientGradationTest(['сейчас', '1 мин. назад', '2 мин. назад', '5 мин. назад', '10 мин. назад', '15 мин. назад', '20 мин. назад', '25 мин. назад', '30 мин. назад', '35 мин. назад', '40 мин. назад', '45 мин. назад', '50 мин. назад', '1 ч. назад', '2 ч. назад', '3 ч. назад', '4 ч. назад', '5 ч. назад', '6 ч. назад', '7 ч. назад', '8 ч. назад', '9 ч. назад', '10 ч. назад', '11 ч. назад', '12 ч. назад', '13 ч. назад', '14 ч. назад', '15 ч. назад', '16 ч. назад', '17 ч. назад', '18 ч. назад', '19 ч. назад', '20 ч. назад', '1 дн. назад', '2 дн. назад', '3 дн. назад', '4 дн. назад', '5 дн. назад', '1 нед. назад', '2 нед. назад', '3 нед. назад', '1 мес. назад', '2 мес. назад', '3 мес. назад', '4 мес. назад', '5 мес. назад', '6 мес. назад', '7 мес. назад', '8 мес. назад', '9 мес. назад', '9 мес. назад', '10 мес. назад', '1 г. назад', '2 г. назад', '3 г. назад', '100 л. назад'], 'ru', {
|
||||
flavour: 'short'
|
||||
});
|
||||
});
|
||||
it("should format time correctly for Russian language (long)", function () {
|
||||
convenientGradationTest(['только что', '1 минуту назад', '2 минуты назад', '5 минут назад', '10 минут назад', '15 минут назад', '20 минут назад', '25 минут назад', '30 минут назад', '35 минут назад', '40 минут назад', '45 минут назад', '50 минут назад', '1 час назад', '2 часа назад', '3 часа назад', '4 часа назад', '5 часов назад', '6 часов назад', '7 часов назад', '8 часов назад', '9 часов назад', '10 часов назад', '11 часов назад', '12 часов назад', '13 часов назад', '14 часов назад', '15 часов назад', '16 часов назад', '17 часов назад', '18 часов назад', '19 часов назад', '20 часов назад', '1 день назад', '2 дня назад', '3 дня назад', '4 дня назад', '5 дней назад', '1 неделю назад', '2 недели назад', '3 недели назад', '1 месяц назад', '2 месяца назад', '3 месяца назад', '4 месяца назад', '5 месяцев назад', '6 месяцев назад', '7 месяцев назад', '8 месяцев назад', '9 месяцев назад', '9 месяцев назад', '10 месяцев назад', '1 год назад', '2 года назад', '3 года назад', '100 лет назад'], 'ru', _style.defaultStyle);
|
||||
});
|
||||
it("should format future dates", function () {
|
||||
new _JavascriptTimeAgo.default('en').format(Date.now() + 60 * 60 * 1000).should.equal('in an hour');
|
||||
new _JavascriptTimeAgo.default('ru').format(Date.now() + 45.1 * 1000).should.equal('через 1 минуту');
|
||||
});
|
||||
it("should have generated missing quantifier functions", function () {
|
||||
new _JavascriptTimeAgo.default('ccp').format(Date.now() + 60 * 1000).should.equal('1 𑄟𑄨𑄚𑄨𑄘𑄬');
|
||||
});
|
||||
it("should throw for non-existing locales", function () {
|
||||
(function () {
|
||||
return _JavascriptTimeAgo.default.addLocale();
|
||||
}).should.throw('No locale data passed');
|
||||
});
|
||||
});
|
||||
|
||||
function convenientGradationTest(convenientGradationLabels, timeAgo) {
|
||||
var style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
|
||||
if (typeof timeAgo === 'string') {
|
||||
timeAgo = new _JavascriptTimeAgo.default(timeAgo);
|
||||
}
|
||||
|
||||
var now = Date.now();
|
||||
|
||||
var elapsed = function elapsed(time) {
|
||||
return timeAgo.format(now - time * 1000, _objectSpread({
|
||||
now: now
|
||||
}, style));
|
||||
};
|
||||
|
||||
if (convenientGradation.length !== convenientGradationLabels.length) {
|
||||
throw new Error("Array length mismatch. Gradation steps: ".concat(convenientGradation.length, ", labels: ").concat(convenientGradationLabels.length));
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
|
||||
while (i < convenientGradation.length) {
|
||||
for (var _iterator = convenientGradation[i], _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref3;
|
||||
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) break;
|
||||
_ref3 = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) break;
|
||||
_ref3 = _i.value;
|
||||
}
|
||||
|
||||
var time = _ref3;
|
||||
elapsed(time).should.equal(convenientGradationLabels[i]);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
var convenientGradation = [// 'just now':
|
||||
[0, 44.9], // 'a minute ago':
|
||||
[45.1, 1.49 * 60], // '2 minutes ago':
|
||||
[1.51 * 60, 2.49 * 60], // '5 minutes ago':
|
||||
[2.51 * 60, 7.49 * 60], // '10 minutes ago':
|
||||
[7.51 * 60, 12.49 * 60], // '15 minutes ago':
|
||||
[12.51 * 60, 17.49 * 60], // '20 minutes ago':
|
||||
[17.51 * 60, 22.49 * 60], // '25 minutes ago':
|
||||
[22.51 * 60, 27.49 * 60], // '30 minutes ago':
|
||||
[27.51 * 60, 32.49 * 60], // '35 minutes ago':
|
||||
[32.51 * 60, 37.49 * 60], // '40 minutes ago':
|
||||
[37.51 * 60, 42.49 * 60], // '45 minutes ago':
|
||||
[42.51 * 60, 47.49 * 60], // '50 minutes ago':
|
||||
[47.51 * 60, 52.49 * 60], // 'an hour ago':
|
||||
[55.01 * 60, 1.49 * 60 * 60], // '2 hours ago':
|
||||
[1.51 * 60 * 60, 2.49 * 60 * 60], // '3 hours ago':
|
||||
[2.51 * 60 * 60, 3.49 * 60 * 60], // '4 hours ago':
|
||||
[3.51 * 60 * 60, 4.49 * 60 * 60], // '5 hours ago':
|
||||
[4.51 * 60 * 60, 5.49 * 60 * 60], // '6 hours ago':
|
||||
[5.51 * 60 * 60, 6.49 * 60 * 60], // '7 hours ago':
|
||||
[6.51 * 60 * 60, 7.49 * 60 * 60], // '8 hours ago':
|
||||
[7.51 * 60 * 60, 8.49 * 60 * 60], // '9 hours ago':
|
||||
[8.51 * 60 * 60, 9.49 * 60 * 60], // '10 hours ago':
|
||||
[9.51 * 60 * 60, 10.49 * 60 * 60], // '11 hours ago':
|
||||
[10.51 * 60 * 60, 11.49 * 60 * 60], // '12 hours ago':
|
||||
[11.51 * 60 * 60, 12.49 * 60 * 60], // '13 hours ago':
|
||||
[12.51 * 60 * 60, 13.49 * 60 * 60], // '14 hours ago':
|
||||
[13.51 * 60 * 60, 14.49 * 60 * 60], // '15 hours ago':
|
||||
[14.51 * 60 * 60, 15.49 * 60 * 60], // '16 hours ago':
|
||||
[15.51 * 60 * 60, 16.49 * 60 * 60], // '17 hours ago':
|
||||
[16.51 * 60 * 60, 17.49 * 60 * 60], // '18 hours ago':
|
||||
[17.51 * 60 * 60, 18.49 * 60 * 60], // '19 hours ago':
|
||||
[18.51 * 60 * 60, 19.49 * 60 * 60], // '20 hours ago':
|
||||
[19.51 * 60 * 60, 20.49 * 60 * 60], // 'a day ago':
|
||||
[20.51 * 60 * 60, 1.49 * _gradation.day], // '2 days ago':
|
||||
[1.51 * _gradation.day, 2.49 * _gradation.day], // '3 days ago':
|
||||
[2.51 * _gradation.day, 3.49 * _gradation.day], // '4 days ago':
|
||||
[3.51 * _gradation.day, 4.49 * _gradation.day], // '5 days ago':
|
||||
[4.51 * _gradation.day, 5.49 * _gradation.day], // 'a week ago':
|
||||
[5.51 * _gradation.day, 1.49 * 7 * _gradation.day], // '2 weeks ago':
|
||||
[1.51 * 7 * _gradation.day, 2.49 * 7 * _gradation.day], // '3 weeks ago':
|
||||
[2.51 * 7 * _gradation.day, 3.49 * 7 * _gradation.day], // 'a month ago':
|
||||
[3.51 * 7 * _gradation.day, 1.49 * _gradation.month], // '2 months ago':
|
||||
[1.51 * _gradation.month, 2.49 * _gradation.month], // '3 months ago':
|
||||
[2.51 * _gradation.month, 3.49 * _gradation.month], // '4 months ago':
|
||||
[3.51 * _gradation.month, 4.49 * _gradation.month], // '5 months ago':
|
||||
[4.51 * _gradation.month, 5.49 * _gradation.month], // '6 months ago':
|
||||
[5.51 * _gradation.month, 6.49 * _gradation.month], // '7 months ago':
|
||||
[6.51 * _gradation.month, 7.49 * _gradation.month], // '8 months ago':
|
||||
[7.51 * _gradation.month, 8.49 * _gradation.month], // '9 months ago':
|
||||
[8.51 * _gradation.month, 8.99 * _gradation.month], // '9 months ago':
|
||||
[9.01 * _gradation.month, 9.49 * _gradation.month], // '10 months ago':
|
||||
[9.51 * _gradation.month, 10.49 * _gradation.month], // 'a year ago':
|
||||
[10.51 * _gradation.month, 1.49 * _gradation.year], // '2 years ago':
|
||||
[1.51 * _gradation.year, 2.49 * _gradation.year], // '3 years ago':
|
||||
[2.51 * _gradation.year, 3.49 * _gradation.year], // '100 years ago':
|
||||
[99.51 * _gradation.year, 100.49 * _gradation.year]];
|
||||
//# sourceMappingURL=JavascriptTimeAgo.test.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/JavascriptTimeAgo.test.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/JavascriptTimeAgo.test.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
28
node_modules/javascript-time-ago/commonjs/LocaleDataStore.js
generated
vendored
Normal file
28
node_modules/javascript-time-ago/commonjs/LocaleDataStore.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getLocaleData = getLocaleData;
|
||||
exports.addLocaleData = addLocaleData;
|
||||
// Fallback locale.
|
||||
// (when not a single one of the supplied "preferred" locales is available)
|
||||
var defaultLocale = 'en'; // For all locales added
|
||||
// their relative time formatter messages will be stored here.
|
||||
|
||||
var localesData = {};
|
||||
|
||||
function getLocaleData(locale) {
|
||||
return localesData[locale];
|
||||
}
|
||||
|
||||
function addLocaleData(localeData) {
|
||||
if (!localeData) {
|
||||
throw new Error('[javascript-time-ago] No locale data passed.');
|
||||
} // This locale data is stored in a global variable
|
||||
// and later used when calling `.format(time)`.
|
||||
|
||||
|
||||
localesData[localeData.locale] = localeData;
|
||||
}
|
||||
//# sourceMappingURL=LocaleDataStore.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/LocaleDataStore.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/LocaleDataStore.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../source/LocaleDataStore.js"],"names":["defaultLocale","localesData","getLocaleData","locale","addLocaleData","localeData","Error"],"mappings":";;;;;;;AAAA;AACA;AACA,IAAIA,aAAa,GAAG,IAApB,C,CAEA;AACA;;AACA,IAAMC,WAAW,GAAG,EAApB;;AAEO,SAASC,aAAT,CAAuBC,MAAvB,EAA+B;AACrC,SAAOF,WAAW,CAACE,MAAD,CAAlB;AACA;;AAEM,SAASC,aAAT,CAAuBC,UAAvB,EAAmC;AACzC,MAAI,CAACA,UAAL,EAAiB;AAChB,UAAM,IAAIC,KAAJ,CAAU,8CAAV,CAAN;AACA,GAHwC,CAIzC;AACA;;;AACAL,EAAAA,WAAW,CAACI,UAAU,CAACF,MAAZ,CAAX,GAAiCE,UAAjC;AACA","sourcesContent":["// Fallback locale.\r\n// (when not a single one of the supplied \"preferred\" locales is available)\r\nlet defaultLocale = 'en'\r\n\r\n// For all locales added\r\n// their relative time formatter messages will be stored here.\r\nconst localesData = {}\r\n\r\nexport function getLocaleData(locale) {\r\n\treturn localesData[locale]\r\n}\r\n\r\nexport function addLocaleData(localeData) {\r\n\tif (!localeData) {\r\n\t\tthrow new Error('[javascript-time-ago] No locale data passed.')\r\n\t}\r\n\t// This locale data is stored in a global variable\r\n\t// and later used when calling `.format(time)`.\r\n\tlocalesData[localeData.locale] = localeData\r\n}"],"file":"LocaleDataStore.js"}
|
||||
31
node_modules/javascript-time-ago/commonjs/PropTypes.js
generated
vendored
Normal file
31
node_modules/javascript-time-ago/commonjs/PropTypes.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.style = void 0;
|
||||
|
||||
var _propTypes = require("prop-types");
|
||||
|
||||
var threshold = (0, _propTypes.oneOfType)([_propTypes.number, _propTypes.func]);
|
||||
var gradation = (0, _propTypes.arrayOf)((0, _propTypes.oneOfType)([(0, _propTypes.shape)({
|
||||
unit: _propTypes.string.isRequired,
|
||||
factor: _propTypes.number,
|
||||
granularity: _propTypes.number,
|
||||
threshold: threshold // Specific `threshold_[unit]` properties may also be defined
|
||||
|
||||
}), (0, _propTypes.shape)({
|
||||
format: _propTypes.func.isRequired,
|
||||
threshold: threshold // Specific `threshold_[unit]` properties may also be defined
|
||||
|
||||
})])); // Date/time formatting style.
|
||||
// E.g. 'twitter', 'fuzzy', or custom (`{ gradation: […], units: […], flavour: 'long', custom: function }`)
|
||||
|
||||
var style = (0, _propTypes.oneOfType)([_propTypes.string, (0, _propTypes.shape)({
|
||||
gradation: gradation,
|
||||
units: (0, _propTypes.arrayOf)(_propTypes.string),
|
||||
flavour: (0, _propTypes.oneOfType)([_propTypes.string, (0, _propTypes.arrayOf)(_propTypes.string)]),
|
||||
custom: _propTypes.func
|
||||
})]);
|
||||
exports.style = style;
|
||||
//# sourceMappingURL=PropTypes.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/PropTypes.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/PropTypes.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../source/PropTypes.js"],"names":["threshold","number","func","gradation","unit","string","isRequired","factor","granularity","format","style","units","flavour","custom"],"mappings":";;;;;;;AAAA;;AASA,IAAMA,SAAS,GAAG,0BAAU,CAC3BC,iBAD2B,EAE3BC,eAF2B,CAAV,CAAlB;AAKA,IAAMC,SAAS,GAAG,wBAAQ,0BAAU,CACnC,sBAAM;AACLC,EAAAA,IAAI,EAAUC,kBAAOC,UADhB;AAELC,EAAAA,MAAM,EAAQN,iBAFT;AAGLO,EAAAA,WAAW,EAAGP,iBAHT;AAILD,EAAAA,SAAS,EAATA,SAJK,CAKL;;AALK,CAAN,CADmC,EAQnC,sBAAM;AACLS,EAAAA,MAAM,EAAGP,gBAAKI,UADT;AAELN,EAAAA,SAAS,EAATA,SAFK,CAGL;;AAHK,CAAN,CARmC,CAAV,CAAR,CAAlB,C,CAeA;AACA;;AACO,IAAMU,KAAK,GAAG,0BAAU,CAC9BL,iBAD8B,EAE9B,sBAAM;AACLF,EAAAA,SAAS,EAATA,SADK;AAELQ,EAAAA,KAAK,EAAK,wBAAQN,iBAAR,CAFL;AAGLO,EAAAA,OAAO,EAAG,0BAAU,CACnBP,iBADmB,EAEnB,wBAAQA,iBAAR,CAFmB,CAAV,CAHL;AAOLQ,EAAAA,MAAM,EAAGX;AAPJ,CAAN,CAF8B,CAAV,CAAd","sourcesContent":["import {\r\n\toneOfType,\r\n\tarrayOf,\r\n\tstring,\r\n\tnumber,\r\n\tshape,\r\n\tfunc\r\n} from 'prop-types'\r\n\r\nconst threshold = oneOfType([\r\n\tnumber,\r\n\tfunc\r\n])\r\n\r\nconst gradation = arrayOf(oneOfType([\r\n\tshape({\r\n\t\tunit : string.isRequired,\r\n\t\tfactor : number,\r\n\t\tgranularity : number,\r\n\t\tthreshold\r\n\t\t// Specific `threshold_[unit]` properties may also be defined\r\n\t}),\r\n\tshape({\r\n\t\tformat : func.isRequired,\r\n\t\tthreshold\r\n\t\t// Specific `threshold_[unit]` properties may also be defined\r\n\t})\r\n]))\r\n\r\n// Date/time formatting style.\r\n// E.g. 'twitter', 'fuzzy', or custom (`{ gradation: […], units: […], flavour: 'long', custom: function }`)\r\nexport const style = oneOfType([\r\n\tstring,\r\n\tshape({\r\n\t\tgradation,\r\n\t\tunits : arrayOf(string),\r\n\t\tflavour : oneOfType([\r\n\t\t\tstring,\r\n\t\t\tarrayOf(string)\r\n\t\t]),\r\n\t\tcustom : func\r\n\t})\r\n])"],"file":"PropTypes.js"}
|
||||
84
node_modules/javascript-time-ago/commonjs/cache.js
generated
vendored
Normal file
84
node_modules/javascript-time-ago/commonjs/cache.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
/**
|
||||
* A basic in-memory cache.
|
||||
*
|
||||
* import Cache from 'javascript-time-ago/Cache'
|
||||
* const cache = new Cache()
|
||||
* const object = cache.get('key1', 'key2', ...) || cache.put('key1', 'key2', ..., createObject())
|
||||
*/
|
||||
var Cache =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Cache() {
|
||||
_classCallCheck(this, Cache);
|
||||
|
||||
_defineProperty(this, "cache", {});
|
||||
}
|
||||
|
||||
_createClass(Cache, [{
|
||||
key: "get",
|
||||
value: function get() {
|
||||
var cache = this.cache;
|
||||
|
||||
for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
keys[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
for (var _i = 0; _i < keys.length; _i++) {
|
||||
var key = keys[_i];
|
||||
|
||||
if (_typeof(cache) !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
cache = cache[key];
|
||||
}
|
||||
|
||||
return cache;
|
||||
}
|
||||
}, {
|
||||
key: "put",
|
||||
value: function put() {
|
||||
for (var _len2 = arguments.length, keys = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
keys[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
var value = keys.pop();
|
||||
var lastKey = keys.pop();
|
||||
var cache = this.cache;
|
||||
|
||||
for (var _i2 = 0; _i2 < keys.length; _i2++) {
|
||||
var key = keys[_i2];
|
||||
|
||||
if (_typeof(cache[key]) !== 'object') {
|
||||
cache[key] = {};
|
||||
}
|
||||
|
||||
cache = cache[key];
|
||||
}
|
||||
|
||||
return cache[lastKey] = value;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Cache;
|
||||
}();
|
||||
|
||||
exports.default = Cache;
|
||||
//# sourceMappingURL=cache.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/cache.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/cache.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../source/cache.js"],"names":["Cache","cache","keys","key","value","pop","lastKey"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;IAOqBA,K;;;;;;mCACZ,E;;;;;0BAEK;AACZ,UAAIC,KAAK,GAAG,KAAKA,KAAjB;;AADY,wCAANC,IAAM;AAANA,QAAAA,IAAM;AAAA;;AAEZ,4BAAkBA,IAAlB,eAAwB;AAAnB,YAAMC,GAAG,GAAID,IAAJ,IAAT;;AACJ,YAAI,QAAOD,KAAP,MAAiB,QAArB,EAA+B;AAC9B;AACA;;AACDA,QAAAA,KAAK,GAAGA,KAAK,CAACE,GAAD,CAAb;AACA;;AACD,aAAOF,KAAP;AACA;;;0BAEY;AAAA,yCAANC,IAAM;AAANA,QAAAA,IAAM;AAAA;;AACZ,UAAME,KAAK,GAAGF,IAAI,CAACG,GAAL,EAAd;AACA,UAAMC,OAAO,GAAGJ,IAAI,CAACG,GAAL,EAAhB;AACA,UAAIJ,KAAK,GAAG,KAAKA,KAAjB;;AACA,8BAAkBC,IAAlB,gBAAwB;AAAnB,YAAMC,GAAG,GAAID,IAAJ,KAAT;;AACJ,YAAI,QAAOD,KAAK,CAACE,GAAD,CAAZ,MAAsB,QAA1B,EAAoC;AACnCF,UAAAA,KAAK,CAACE,GAAD,CAAL,GAAa,EAAb;AACA;;AACDF,QAAAA,KAAK,GAAGA,KAAK,CAACE,GAAD,CAAb;AACA;;AACD,aAAOF,KAAK,CAACK,OAAD,CAAL,GAAiBF,KAAxB;AACA","sourcesContent":["/**\r\n * A basic in-memory cache.\r\n *\r\n * import Cache from 'javascript-time-ago/Cache'\r\n * const cache = new Cache()\r\n * const object = cache.get('key1', 'key2', ...) || cache.put('key1', 'key2', ..., createObject())\r\n */\r\nexport default class Cache {\r\n\tcache = {}\r\n\r\n\tget(...keys) {\r\n\t\tlet cache = this.cache\r\n\t\tfor (const key of keys) {\r\n\t\t\tif (typeof cache !== 'object') {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t\tcache = cache[key]\r\n\t\t}\r\n\t\treturn cache\r\n\t}\r\n\r\n\tput(...keys) {\r\n\t\tconst value = keys.pop()\r\n\t\tconst lastKey = keys.pop()\r\n\t\tlet cache = this.cache\r\n\t\tfor (const key of keys) {\r\n\t\t\tif (typeof cache[key] !== 'object') {\r\n\t\t\t\tcache[key] = {}\r\n\t\t\t}\r\n\t\t\tcache = cache[key]\r\n\t\t}\r\n\t\treturn cache[lastKey] = value\r\n\t}\r\n}"],"file":"cache.js"}
|
||||
17
node_modules/javascript-time-ago/commonjs/cache.test.js
generated
vendored
Normal file
17
node_modules/javascript-time-ago/commonjs/cache.test.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
var _cache = _interopRequireDefault(require("./cache"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
describe('cache', function () {
|
||||
it('should cache', function () {
|
||||
var cache = new _cache.default();
|
||||
var value = {};
|
||||
expect(cache.get('123', '456')).to.be.undefined;
|
||||
expect(cache.put('123', '456', value)).to.equal(value);
|
||||
expect(cache.get('123', '456')).to.equal(value);
|
||||
expect(cache.put('123', '789', 123)).to.equal(123);
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=cache.test.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/cache.test.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/cache.test.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../source/cache.test.js"],"names":["describe","it","cache","Cache","value","expect","get","to","be","undefined","put","equal"],"mappings":";;AAAA;;;;AAEAA,QAAQ,CAAC,OAAD,EAAU,YAClB;AACCC,EAAAA,EAAE,CAAC,cAAD,EAAiB,YACnB;AACC,QAAMC,KAAK,GAAG,IAAIC,cAAJ,EAAd;AAEA,QAAMC,KAAK,GAAG,EAAd;AACAC,IAAAA,MAAM,CAACH,KAAK,CAACI,GAAN,CAAU,KAAV,EAAiB,KAAjB,CAAD,CAAN,CAAgCC,EAAhC,CAAmCC,EAAnC,CAAsCC,SAAtC;AACAJ,IAAAA,MAAM,CAACH,KAAK,CAACQ,GAAN,CAAU,KAAV,EAAiB,KAAjB,EAAwBN,KAAxB,CAAD,CAAN,CAAuCG,EAAvC,CAA0CI,KAA1C,CAAgDP,KAAhD;AACAC,IAAAA,MAAM,CAACH,KAAK,CAACI,GAAN,CAAU,KAAV,EAAiB,KAAjB,CAAD,CAAN,CAAgCC,EAAhC,CAAmCI,KAAnC,CAAyCP,KAAzC;AAEAC,IAAAA,MAAM,CAACH,KAAK,CAACQ,GAAN,CAAU,KAAV,EAAiB,KAAjB,EAAwB,GAAxB,CAAD,CAAN,CAAqCH,EAArC,CAAwCI,KAAxC,CAA8C,GAA9C;AACA,GAVC,CAAF;AAWA,CAbO,CAAR","sourcesContent":["import Cache from './cache'\r\n\r\ndescribe('cache', () =>\r\n{\r\n\tit('should cache', () =>\r\n\t{\r\n\t\tconst cache = new Cache()\r\n\r\n\t\tconst value = {}\r\n\t\texpect(cache.get('123', '456')).to.be.undefined\r\n\t\texpect(cache.put('123', '456', value)).to.equal(value)\r\n\t\texpect(cache.get('123', '456')).to.equal(value)\r\n\r\n\t\texpect(cache.put('123', '789', 123)).to.equal(123)\r\n\t})\r\n})\r\n"],"file":"cache.test.js"}
|
||||
71
node_modules/javascript-time-ago/commonjs/gradation/canonical.js
generated
vendored
Normal file
71
node_modules/javascript-time-ago/commonjs/gradation/canonical.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _helpers = require("./helpers");
|
||||
|
||||
// just now
|
||||
// 1 second ago
|
||||
// 2 seconds ago
|
||||
// …
|
||||
// 59 seconds ago
|
||||
// 1 minute ago
|
||||
// 2 minutes ago
|
||||
// …
|
||||
// 59 minutes ago
|
||||
// 1 hour ago
|
||||
// 2 hours ago
|
||||
// …
|
||||
// 24 hours ago
|
||||
// 1 day ago
|
||||
// 2 days ago
|
||||
// …
|
||||
// 7 days ago
|
||||
// 1 week ago
|
||||
// 2 weeks ago
|
||||
// …
|
||||
// 3 weeks ago
|
||||
// 1 month ago
|
||||
// 2 months ago
|
||||
// …
|
||||
// 11 months ago
|
||||
// 1 year ago
|
||||
// 2 years ago
|
||||
// …
|
||||
var _default = [{
|
||||
factor: 1,
|
||||
unit: 'now'
|
||||
}, {
|
||||
threshold: 0.5,
|
||||
factor: 1,
|
||||
unit: 'second'
|
||||
}, {
|
||||
threshold: 59.5,
|
||||
factor: 60,
|
||||
unit: 'minute'
|
||||
}, {
|
||||
threshold: 59.5 * 60,
|
||||
factor: 60 * 60,
|
||||
unit: 'hour'
|
||||
}, {
|
||||
threshold: 23.5 * 60 * 60,
|
||||
factor: _helpers.day,
|
||||
unit: 'day'
|
||||
}, {
|
||||
threshold: 6.5 * _helpers.day,
|
||||
factor: 7 * _helpers.day,
|
||||
unit: 'week'
|
||||
}, {
|
||||
threshold: 3.5 * 7 * _helpers.day,
|
||||
factor: _helpers.month,
|
||||
unit: 'month'
|
||||
}, {
|
||||
threshold: 11.5 * _helpers.month,
|
||||
factor: _helpers.year,
|
||||
unit: 'year'
|
||||
}];
|
||||
exports.default = _default;
|
||||
//# sourceMappingURL=canonical.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/gradation/canonical.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/gradation/canonical.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../source/gradation/canonical.js"],"names":["factor","unit","threshold","day","month","year"],"mappings":";;;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;eAEA,CACC;AACCA,EAAAA,MAAM,EAAE,CADT;AAECC,EAAAA,IAAI,EAAE;AAFP,CADD,EAKC;AACCC,EAAAA,SAAS,EAAE,GADZ;AAECF,EAAAA,MAAM,EAAE,CAFT;AAGCC,EAAAA,IAAI,EAAE;AAHP,CALD,EAUC;AACCC,EAAAA,SAAS,EAAE,IADZ;AAECF,EAAAA,MAAM,EAAE,EAFT;AAGCC,EAAAA,IAAI,EAAE;AAHP,CAVD,EAeC;AACCC,EAAAA,SAAS,EAAE,OAAO,EADnB;AAECF,EAAAA,MAAM,EAAE,KAAK,EAFd;AAGCC,EAAAA,IAAI,EAAE;AAHP,CAfD,EAoBC;AACCC,EAAAA,SAAS,EAAE,OAAO,EAAP,GAAY,EADxB;AAECF,EAAAA,MAAM,EAAEG,YAFT;AAGCF,EAAAA,IAAI,EAAE;AAHP,CApBD,EAyBC;AACCC,EAAAA,SAAS,EAAE,MAAMC,YADlB;AAECH,EAAAA,MAAM,EAAE,IAAIG,YAFb;AAGCF,EAAAA,IAAI,EAAE;AAHP,CAzBD,EA8BC;AACCC,EAAAA,SAAS,EAAE,MAAM,CAAN,GAAUC,YADtB;AAECH,EAAAA,MAAM,EAAEI,cAFT;AAGCH,EAAAA,IAAI,EAAE;AAHP,CA9BD,EAmCC;AACCC,EAAAA,SAAS,EAAE,OAAOE,cADnB;AAECJ,EAAAA,MAAM,EAAEK,aAFT;AAGCJ,EAAAA,IAAI,EAAE;AAHP,CAnCD,C","sourcesContent":["import { day, month, year } from './helpers'\r\n\r\n// just now\r\n// 1 second ago\r\n// 2 seconds ago\r\n// …\r\n// 59 seconds ago\r\n// 1 minute ago\r\n// 2 minutes ago\r\n// …\r\n// 59 minutes ago\r\n// 1 hour ago\r\n// 2 hours ago\r\n// …\r\n// 24 hours ago\r\n// 1 day ago\r\n// 2 days ago\r\n// …\r\n// 7 days ago\r\n// 1 week ago\r\n// 2 weeks ago\r\n// …\r\n// 3 weeks ago\r\n// 1 month ago\r\n// 2 months ago\r\n// …\r\n// 11 months ago\r\n// 1 year ago\r\n// 2 years ago\r\n// …\r\nexport default\r\n[\r\n\t{\r\n\t\tfactor: 1,\r\n\t\tunit: 'now'\r\n\t},\r\n\t{\r\n\t\tthreshold: 0.5,\r\n\t\tfactor: 1,\r\n\t\tunit: 'second'\r\n\t},\r\n\t{\r\n\t\tthreshold: 59.5,\r\n\t\tfactor: 60,\r\n\t\tunit: 'minute'\r\n\t},\r\n\t{\r\n\t\tthreshold: 59.5 * 60,\r\n\t\tfactor: 60 * 60,\r\n\t\tunit: 'hour'\r\n\t},\r\n\t{\r\n\t\tthreshold: 23.5 * 60 * 60,\r\n\t\tfactor: day,\r\n\t\tunit: 'day'\r\n\t},\r\n\t{\r\n\t\tthreshold: 6.5 * day,\r\n\t\tfactor: 7 * day,\r\n\t\tunit: 'week'\r\n\t},\r\n\t{\r\n\t\tthreshold: 3.5 * 7 * day,\r\n\t\tfactor: month,\r\n\t\tunit: 'month'\r\n\t},\r\n\t{\r\n\t\tthreshold: 11.5 * month,\r\n\t\tfactor: year,\r\n\t\tunit: 'year'\r\n\t}\r\n]"],"file":"canonical.js"}
|
||||
29
node_modules/javascript-time-ago/commonjs/gradation/canonical.test.js
generated
vendored
Normal file
29
node_modules/javascript-time-ago/commonjs/gradation/canonical.test.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
|
||||
var _grade = _interopRequireDefault(require("../grade"));
|
||||
|
||||
var _canonical = _interopRequireDefault(require("./canonical"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
// Perhaps this should be part of `grade.test.js` instead.
|
||||
describe('canonical gradation', function () {
|
||||
it('should grade correctly', function () {
|
||||
var test = function test(elapsed) {
|
||||
return (0, _grade.default)(elapsed, null, ['second', 'minute', 'hour', 'day', 'month', 'year'], _canonical.default);
|
||||
};
|
||||
|
||||
expect(test(0)).to.be.undefined;
|
||||
expect(test(0.5).unit).to.equal('second');
|
||||
expect(test(0.5).factor).to.equal(1);
|
||||
expect(test(59.4).unit).to.equal('second');
|
||||
expect(test(59.4).factor).to.equal(1);
|
||||
expect(test(59.5).unit).to.equal('minute');
|
||||
expect(test(59.5).factor).to.equal(60);
|
||||
expect(test(59.5 * 60 - 1).unit).to.equal('minute');
|
||||
expect(test(59.5 * 60 - 1).factor).to.equal(60);
|
||||
expect(test(59.5 * 60).unit).to.equal('hour');
|
||||
expect(test(59.5 * 60).factor).to.equal(60 * 60);
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=canonical.test.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/gradation/canonical.test.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/gradation/canonical.test.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../source/gradation/canonical.test.js"],"names":["describe","it","test","elapsed","gradation","expect","to","be","undefined","unit","equal","factor"],"mappings":";;AAAA;;AACA;;;;AAEA;AAEAA,QAAQ,CAAC,qBAAD,EAAwB,YAChC;AACCC,EAAAA,EAAE,CAAC,wBAAD,EAA2B,YAC7B;AACC,QAAMC,IAAI,GAAG,SAAPA,IAAO,CAACC,OAAD;AAAA,aAAa,oBAAMA,OAAN,EAAe,IAAf,EAAqB,CAC9C,QAD8C,EAE9C,QAF8C,EAG9C,MAH8C,EAI9C,KAJ8C,EAK9C,OAL8C,EAM9C,MAN8C,CAArB,EAOvBC,kBAPuB,CAAb;AAAA,KAAb;;AASAC,IAAAA,MAAM,CAACH,IAAI,CAAC,CAAD,CAAL,CAAN,CAAgBI,EAAhB,CAAmBC,EAAnB,CAAsBC,SAAtB;AAEAH,IAAAA,MAAM,CAACH,IAAI,CAAC,GAAD,CAAJ,CAAUO,IAAX,CAAN,CAAuBH,EAAvB,CAA0BI,KAA1B,CAAgC,QAAhC;AACAL,IAAAA,MAAM,CAACH,IAAI,CAAC,GAAD,CAAJ,CAAUS,MAAX,CAAN,CAAyBL,EAAzB,CAA4BI,KAA5B,CAAkC,CAAlC;AAEAL,IAAAA,MAAM,CAACH,IAAI,CAAC,IAAD,CAAJ,CAAWO,IAAZ,CAAN,CAAwBH,EAAxB,CAA2BI,KAA3B,CAAiC,QAAjC;AACAL,IAAAA,MAAM,CAACH,IAAI,CAAC,IAAD,CAAJ,CAAWS,MAAZ,CAAN,CAA0BL,EAA1B,CAA6BI,KAA7B,CAAmC,CAAnC;AAEAL,IAAAA,MAAM,CAACH,IAAI,CAAC,IAAD,CAAJ,CAAWO,IAAZ,CAAN,CAAwBH,EAAxB,CAA2BI,KAA3B,CAAiC,QAAjC;AACAL,IAAAA,MAAM,CAACH,IAAI,CAAC,IAAD,CAAJ,CAAWS,MAAZ,CAAN,CAA0BL,EAA1B,CAA6BI,KAA7B,CAAmC,EAAnC;AAEAL,IAAAA,MAAM,CAACH,IAAI,CAAC,OAAO,EAAP,GAAY,CAAb,CAAJ,CAAoBO,IAArB,CAAN,CAAiCH,EAAjC,CAAoCI,KAApC,CAA0C,QAA1C;AACAL,IAAAA,MAAM,CAACH,IAAI,CAAC,OAAO,EAAP,GAAY,CAAb,CAAJ,CAAoBS,MAArB,CAAN,CAAmCL,EAAnC,CAAsCI,KAAtC,CAA4C,EAA5C;AAEAL,IAAAA,MAAM,CAACH,IAAI,CAAC,OAAO,EAAR,CAAJ,CAAgBO,IAAjB,CAAN,CAA6BH,EAA7B,CAAgCI,KAAhC,CAAsC,MAAtC;AACAL,IAAAA,MAAM,CAACH,IAAI,CAAC,OAAO,EAAR,CAAJ,CAAgBS,MAAjB,CAAN,CAA+BL,EAA/B,CAAkCI,KAAlC,CAAwC,KAAK,EAA7C;AACA,GA3BC,CAAF;AA4BA,CA9BO,CAAR","sourcesContent":["import grade from '../grade'\r\nimport gradation from './canonical'\r\n\r\n// Perhaps this should be part of `grade.test.js` instead.\r\n\r\ndescribe('canonical gradation', () =>\r\n{\r\n\tit('should grade correctly', () =>\r\n\t{\r\n\t\tconst test = (elapsed) => grade(elapsed, null, [\r\n\t\t\t'second',\r\n\t\t\t'minute',\r\n\t\t\t'hour',\r\n\t\t\t'day',\r\n\t\t\t'month',\r\n\t\t\t'year'\r\n\t\t], gradation)\r\n\r\n\t\texpect(test(0)).to.be.undefined\r\n\r\n\t\texpect(test(0.5).unit).to.equal('second')\r\n\t\texpect(test(0.5).factor).to.equal(1)\r\n\r\n\t\texpect(test(59.4).unit).to.equal('second')\r\n\t\texpect(test(59.4).factor).to.equal(1)\r\n\r\n\t\texpect(test(59.5).unit).to.equal('minute')\r\n\t\texpect(test(59.5).factor).to.equal(60)\r\n\r\n\t\texpect(test(59.5 * 60 - 1).unit).to.equal('minute')\r\n\t\texpect(test(59.5 * 60 - 1).factor).to.equal(60)\r\n\r\n\t\texpect(test(59.5 * 60).unit).to.equal('hour')\r\n\t\texpect(test(59.5 * 60).factor).to.equal(60 * 60)\r\n\t})\r\n})"],"file":"canonical.test.js"}
|
||||
77
node_modules/javascript-time-ago/commonjs/gradation/convenient.js
generated
vendored
Normal file
77
node_modules/javascript-time-ago/commonjs/gradation/convenient.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _helpers = require("./helpers");
|
||||
|
||||
// just now
|
||||
// 1 minute ago
|
||||
// 2 minutes ago
|
||||
// 5 minutes ago
|
||||
// 10 minutes ago
|
||||
// 15 minutes ago
|
||||
// 20 minutes ago
|
||||
// an hour ago
|
||||
// 2 hours ago
|
||||
// …
|
||||
// 20 hours ago
|
||||
// a day ago
|
||||
// 2 days ago
|
||||
// 5 days ago
|
||||
// a week ago
|
||||
// 2 weeks ago
|
||||
// 3 weeks ago
|
||||
// a month ago
|
||||
// 2 months ago
|
||||
// 4 months ago
|
||||
// a year ago
|
||||
// 2 years ago
|
||||
// …
|
||||
var _default = [{
|
||||
factor: 1,
|
||||
unit: 'now'
|
||||
}, {
|
||||
threshold: 1,
|
||||
threshold_for_now: 45,
|
||||
factor: 1,
|
||||
unit: 'second'
|
||||
}, {
|
||||
threshold: 45,
|
||||
factor: 60,
|
||||
unit: 'minute'
|
||||
}, {
|
||||
threshold: 2.5 * 60,
|
||||
factor: 60,
|
||||
granularity: 5,
|
||||
unit: 'minute'
|
||||
}, {
|
||||
threshold: 22.5 * 60,
|
||||
factor: 30 * 60,
|
||||
unit: 'half-hour'
|
||||
}, {
|
||||
threshold: 42.5 * 60,
|
||||
threshold_for_minute: 52.5 * 60,
|
||||
factor: 60 * 60,
|
||||
unit: 'hour'
|
||||
}, {
|
||||
threshold: 20.5 / 24 * _helpers.day,
|
||||
factor: _helpers.day,
|
||||
unit: 'day'
|
||||
}, {
|
||||
threshold: 5.5 * _helpers.day,
|
||||
factor: 7 * _helpers.day,
|
||||
unit: 'week'
|
||||
}, {
|
||||
threshold: 3.5 * 7 * _helpers.day,
|
||||
factor: _helpers.month,
|
||||
unit: 'month'
|
||||
}, {
|
||||
threshold: 10.5 * _helpers.month,
|
||||
factor: _helpers.year,
|
||||
unit: 'year'
|
||||
}];
|
||||
exports.default = _default;
|
||||
//# sourceMappingURL=convenient.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/gradation/convenient.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/gradation/convenient.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../source/gradation/convenient.js"],"names":["factor","unit","threshold","threshold_for_now","granularity","threshold_for_minute","day","month","year"],"mappings":";;;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;eAEA,CACC;AACCA,EAAAA,MAAM,EAAE,CADT;AAECC,EAAAA,IAAI,EAAE;AAFP,CADD,EAKC;AACCC,EAAAA,SAAS,EAAE,CADZ;AAECC,EAAAA,iBAAiB,EAAE,EAFpB;AAGCH,EAAAA,MAAM,EAAE,CAHT;AAICC,EAAAA,IAAI,EAAE;AAJP,CALD,EAWC;AACCC,EAAAA,SAAS,EAAE,EADZ;AAECF,EAAAA,MAAM,EAAE,EAFT;AAGCC,EAAAA,IAAI,EAAE;AAHP,CAXD,EAgBC;AACCC,EAAAA,SAAS,EAAE,MAAM,EADlB;AAECF,EAAAA,MAAM,EAAE,EAFT;AAGCI,EAAAA,WAAW,EAAE,CAHd;AAICH,EAAAA,IAAI,EAAE;AAJP,CAhBD,EAsBC;AACCC,EAAAA,SAAS,EAAE,OAAO,EADnB;AAECF,EAAAA,MAAM,EAAE,KAAK,EAFd;AAGCC,EAAAA,IAAI,EAAE;AAHP,CAtBD,EA2BC;AACCC,EAAAA,SAAS,EAAE,OAAO,EADnB;AAECG,EAAAA,oBAAoB,EAAE,OAAO,EAF9B;AAGCL,EAAAA,MAAM,EAAE,KAAK,EAHd;AAICC,EAAAA,IAAI,EAAE;AAJP,CA3BD,EAiCC;AACCC,EAAAA,SAAS,EAAG,OAAO,EAAR,GAAcI,YAD1B;AAECN,EAAAA,MAAM,EAAEM,YAFT;AAGCL,EAAAA,IAAI,EAAE;AAHP,CAjCD,EAsCC;AACCC,EAAAA,SAAS,EAAE,MAAMI,YADlB;AAECN,EAAAA,MAAM,EAAE,IAAIM,YAFb;AAGCL,EAAAA,IAAI,EAAE;AAHP,CAtCD,EA2CC;AACCC,EAAAA,SAAS,EAAE,MAAM,CAAN,GAAUI,YADtB;AAECN,EAAAA,MAAM,EAAEO,cAFT;AAGCN,EAAAA,IAAI,EAAE;AAHP,CA3CD,EAgDC;AACCC,EAAAA,SAAS,EAAE,OAAOK,cADnB;AAECP,EAAAA,MAAM,EAAEQ,aAFT;AAGCP,EAAAA,IAAI,EAAE;AAHP,CAhDD,C","sourcesContent":["import { day, month, year } from './helpers'\r\n\r\n// just now\r\n// 1 minute ago\r\n// 2 minutes ago\r\n// 5 minutes ago\r\n// 10 minutes ago\r\n// 15 minutes ago\r\n// 20 minutes ago\r\n// an hour ago\r\n// 2 hours ago\r\n// …\r\n// 20 hours ago\r\n// a day ago\r\n// 2 days ago\r\n// 5 days ago\r\n// a week ago\r\n// 2 weeks ago\r\n// 3 weeks ago\r\n// a month ago\r\n// 2 months ago\r\n// 4 months ago\r\n// a year ago\r\n// 2 years ago\r\n// …\r\nexport default\r\n[\r\n\t{\r\n\t\tfactor: 1,\r\n\t\tunit: 'now'\r\n\t},\r\n\t{\r\n\t\tthreshold: 1,\r\n\t\tthreshold_for_now: 45,\r\n\t\tfactor: 1,\r\n\t\tunit: 'second'\r\n\t},\r\n\t{\r\n\t\tthreshold: 45,\r\n\t\tfactor: 60,\r\n\t\tunit: 'minute'\r\n\t},\r\n\t{\r\n\t\tthreshold: 2.5 * 60,\r\n\t\tfactor: 60,\r\n\t\tgranularity: 5,\r\n\t\tunit: 'minute'\r\n\t},\r\n\t{\r\n\t\tthreshold: 22.5 * 60,\r\n\t\tfactor: 30 * 60,\r\n\t\tunit: 'half-hour'\r\n\t},\r\n\t{\r\n\t\tthreshold: 42.5 * 60,\r\n\t\tthreshold_for_minute: 52.5 * 60,\r\n\t\tfactor: 60 * 60,\r\n\t\tunit: 'hour'\r\n\t},\r\n\t{\r\n\t\tthreshold: (20.5 / 24) * day,\r\n\t\tfactor: day,\r\n\t\tunit: 'day'\r\n\t},\r\n\t{\r\n\t\tthreshold: 5.5 * day,\r\n\t\tfactor: 7 * day,\r\n\t\tunit: 'week'\r\n\t},\r\n\t{\r\n\t\tthreshold: 3.5 * 7 * day,\r\n\t\tfactor: month,\r\n\t\tunit: 'month'\r\n\t},\r\n\t{\r\n\t\tthreshold: 10.5 * month,\r\n\t\tfactor: year,\r\n\t\tunit: 'year'\r\n\t}\r\n]"],"file":"convenient.js"}
|
||||
37
node_modules/javascript-time-ago/commonjs/gradation/convenient.test.js
generated
vendored
Normal file
37
node_modules/javascript-time-ago/commonjs/gradation/convenient.test.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
|
||||
var _grade = _interopRequireDefault(require("../grade"));
|
||||
|
||||
var _convenient = _interopRequireDefault(require("./convenient"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
// Perhaps this should be part of `grade.test.js` instead.
|
||||
describe('convenient gradation', function () {
|
||||
it('should grade correctly', function () {
|
||||
var test = function test(elapsed) {
|
||||
return (0, _grade.default)(elapsed, null, ['second', 'minute', 'hour', 'day', 'month', 'year'], _convenient.default);
|
||||
};
|
||||
|
||||
expect(test(0)).to.be.undefined;
|
||||
expect(test(1).unit).to.equal('second');
|
||||
expect(test(1).factor).to.equal(1);
|
||||
expect(test(44).unit).to.equal('second');
|
||||
expect(test(44).factor).to.equal(1);
|
||||
expect(test(45).unit).to.equal('minute');
|
||||
expect(test(45).factor).to.equal(60);
|
||||
expect(test(45).granularity).to.be.undefined;
|
||||
expect(test(2.5 * 60 - 1).unit).to.equal('minute');
|
||||
expect(test(2.5 * 60 - 1).factor).to.equal(60);
|
||||
expect(test(2.5 * 60 - 1).granularity).to.be.undefined;
|
||||
expect(test(2.5 * 60).unit).to.equal('minute');
|
||||
expect(test(2.5 * 60).factor).to.equal(60);
|
||||
expect(test(2.5 * 60).granularity).to.equal(5);
|
||||
expect(test(52.5 * 60 - 1).unit).to.equal('minute');
|
||||
expect(test(52.5 * 60 - 1).factor).to.equal(60);
|
||||
expect(test(52.5 * 60 - 1).granularity).to.equal(5);
|
||||
expect(test(52.5 * 60).unit).to.equal('hour');
|
||||
expect(test(52.5 * 60).factor).to.equal(60 * 60);
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=convenient.test.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/gradation/convenient.test.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/gradation/convenient.test.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../source/gradation/convenient.test.js"],"names":["describe","it","test","elapsed","gradation","expect","to","be","undefined","unit","equal","factor","granularity"],"mappings":";;AAAA;;AACA;;;;AAEA;AAEAA,QAAQ,CAAC,sBAAD,EAAyB,YACjC;AACCC,EAAAA,EAAE,CAAC,wBAAD,EAA2B,YAC7B;AACC,QAAMC,IAAI,GAAG,SAAPA,IAAO,CAACC,OAAD;AAAA,aAAa,oBAAMA,OAAN,EAAe,IAAf,EAAqB,CAC9C,QAD8C,EAE9C,QAF8C,EAG9C,MAH8C,EAI9C,KAJ8C,EAK9C,OAL8C,EAM9C,MAN8C,CAArB,EAOvBC,mBAPuB,CAAb;AAAA,KAAb;;AASAC,IAAAA,MAAM,CAACH,IAAI,CAAC,CAAD,CAAL,CAAN,CAAgBI,EAAhB,CAAmBC,EAAnB,CAAsBC,SAAtB;AAEAH,IAAAA,MAAM,CAACH,IAAI,CAAC,CAAD,CAAJ,CAAQO,IAAT,CAAN,CAAqBH,EAArB,CAAwBI,KAAxB,CAA8B,QAA9B;AACAL,IAAAA,MAAM,CAACH,IAAI,CAAC,CAAD,CAAJ,CAAQS,MAAT,CAAN,CAAuBL,EAAvB,CAA0BI,KAA1B,CAAgC,CAAhC;AAEAL,IAAAA,MAAM,CAACH,IAAI,CAAC,EAAD,CAAJ,CAASO,IAAV,CAAN,CAAsBH,EAAtB,CAAyBI,KAAzB,CAA+B,QAA/B;AACAL,IAAAA,MAAM,CAACH,IAAI,CAAC,EAAD,CAAJ,CAASS,MAAV,CAAN,CAAwBL,EAAxB,CAA2BI,KAA3B,CAAiC,CAAjC;AAEAL,IAAAA,MAAM,CAACH,IAAI,CAAC,EAAD,CAAJ,CAASO,IAAV,CAAN,CAAsBH,EAAtB,CAAyBI,KAAzB,CAA+B,QAA/B;AACAL,IAAAA,MAAM,CAACH,IAAI,CAAC,EAAD,CAAJ,CAASS,MAAV,CAAN,CAAwBL,EAAxB,CAA2BI,KAA3B,CAAiC,EAAjC;AACAL,IAAAA,MAAM,CAACH,IAAI,CAAC,EAAD,CAAJ,CAASU,WAAV,CAAN,CAA6BN,EAA7B,CAAgCC,EAAhC,CAAmCC,SAAnC;AAEAH,IAAAA,MAAM,CAACH,IAAI,CAAC,MAAM,EAAN,GAAW,CAAZ,CAAJ,CAAmBO,IAApB,CAAN,CAAgCH,EAAhC,CAAmCI,KAAnC,CAAyC,QAAzC;AACAL,IAAAA,MAAM,CAACH,IAAI,CAAC,MAAM,EAAN,GAAW,CAAZ,CAAJ,CAAmBS,MAApB,CAAN,CAAkCL,EAAlC,CAAqCI,KAArC,CAA2C,EAA3C;AACAL,IAAAA,MAAM,CAACH,IAAI,CAAC,MAAM,EAAN,GAAW,CAAZ,CAAJ,CAAmBU,WAApB,CAAN,CAAuCN,EAAvC,CAA0CC,EAA1C,CAA6CC,SAA7C;AAEAH,IAAAA,MAAM,CAACH,IAAI,CAAC,MAAM,EAAP,CAAJ,CAAeO,IAAhB,CAAN,CAA4BH,EAA5B,CAA+BI,KAA/B,CAAqC,QAArC;AACAL,IAAAA,MAAM,CAACH,IAAI,CAAC,MAAM,EAAP,CAAJ,CAAeS,MAAhB,CAAN,CAA8BL,EAA9B,CAAiCI,KAAjC,CAAuC,EAAvC;AACAL,IAAAA,MAAM,CAACH,IAAI,CAAC,MAAM,EAAP,CAAJ,CAAeU,WAAhB,CAAN,CAAmCN,EAAnC,CAAsCI,KAAtC,CAA4C,CAA5C;AAEAL,IAAAA,MAAM,CAACH,IAAI,CAAC,OAAO,EAAP,GAAY,CAAb,CAAJ,CAAoBO,IAArB,CAAN,CAAiCH,EAAjC,CAAoCI,KAApC,CAA0C,QAA1C;AACAL,IAAAA,MAAM,CAACH,IAAI,CAAC,OAAO,EAAP,GAAY,CAAb,CAAJ,CAAoBS,MAArB,CAAN,CAAmCL,EAAnC,CAAsCI,KAAtC,CAA4C,EAA5C;AACAL,IAAAA,MAAM,CAACH,IAAI,CAAC,OAAO,EAAP,GAAY,CAAb,CAAJ,CAAoBU,WAArB,CAAN,CAAwCN,EAAxC,CAA2CI,KAA3C,CAAiD,CAAjD;AAEAL,IAAAA,MAAM,CAACH,IAAI,CAAC,OAAO,EAAR,CAAJ,CAAgBO,IAAjB,CAAN,CAA6BH,EAA7B,CAAgCI,KAAhC,CAAsC,MAAtC;AACAL,IAAAA,MAAM,CAACH,IAAI,CAAC,OAAO,EAAR,CAAJ,CAAgBS,MAAjB,CAAN,CAA+BL,EAA/B,CAAkCI,KAAlC,CAAwC,KAAK,EAA7C;AACA,GArCC,CAAF;AAsCA,CAxCO,CAAR","sourcesContent":["import grade from '../grade'\r\nimport gradation from './convenient'\r\n\r\n// Perhaps this should be part of `grade.test.js` instead.\r\n\r\ndescribe('convenient gradation', () =>\r\n{\r\n\tit('should grade correctly', () =>\r\n\t{\r\n\t\tconst test = (elapsed) => grade(elapsed, null, [\r\n\t\t\t'second',\r\n\t\t\t'minute',\r\n\t\t\t'hour',\r\n\t\t\t'day',\r\n\t\t\t'month',\r\n\t\t\t'year'\r\n\t\t], gradation)\r\n\r\n\t\texpect(test(0)).to.be.undefined\r\n\r\n\t\texpect(test(1).unit).to.equal('second')\r\n\t\texpect(test(1).factor).to.equal(1)\r\n\r\n\t\texpect(test(44).unit).to.equal('second')\r\n\t\texpect(test(44).factor).to.equal(1)\r\n\r\n\t\texpect(test(45).unit).to.equal('minute')\r\n\t\texpect(test(45).factor).to.equal(60)\r\n\t\texpect(test(45).granularity).to.be.undefined\r\n\r\n\t\texpect(test(2.5 * 60 - 1).unit).to.equal('minute')\r\n\t\texpect(test(2.5 * 60 - 1).factor).to.equal(60)\r\n\t\texpect(test(2.5 * 60 - 1).granularity).to.be.undefined\r\n\r\n\t\texpect(test(2.5 * 60).unit).to.equal('minute')\r\n\t\texpect(test(2.5 * 60).factor).to.equal(60)\r\n\t\texpect(test(2.5 * 60).granularity).to.equal(5)\r\n\r\n\t\texpect(test(52.5 * 60 - 1).unit).to.equal('minute')\r\n\t\texpect(test(52.5 * 60 - 1).factor).to.equal(60)\r\n\t\texpect(test(52.5 * 60 - 1).granularity).to.equal(5)\r\n\r\n\t\texpect(test(52.5 * 60).unit).to.equal('hour')\r\n\t\texpect(test(52.5 * 60).factor).to.equal(60 * 60)\r\n\t})\r\n})"],"file":"convenient.test.js"}
|
||||
64
node_modules/javascript-time-ago/commonjs/gradation/helpers.js
generated
vendored
Normal file
64
node_modules/javascript-time-ago/commonjs/gradation/helpers.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getStep = getStep;
|
||||
exports.getDate = getDate;
|
||||
exports.year = exports.month = exports.day = exports.hour = exports.minute = void 0;
|
||||
var minute = 60; // in seconds
|
||||
|
||||
exports.minute = minute;
|
||||
var hour = 60 * minute; // in seconds
|
||||
|
||||
exports.hour = hour;
|
||||
var day = 24 * hour; // in seconds
|
||||
// https://www.quora.com/What-is-the-average-number-of-days-in-a-month
|
||||
|
||||
exports.day = day;
|
||||
var month = 30.44 * day; // in seconds
|
||||
// "400 years have 146097 days (taking into account leap year rules)"
|
||||
|
||||
exports.month = month;
|
||||
var year = 146097 / 400 * day; // in seconds
|
||||
|
||||
/**
|
||||
* Returns a step of gradation corresponding to the unit.
|
||||
* @param {Object[]} gradation
|
||||
* @param {string} unit
|
||||
* @return {?Object}
|
||||
*/
|
||||
|
||||
exports.year = year;
|
||||
|
||||
function getStep(gradation, unit) {
|
||||
for (var _iterator = gradation, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref;
|
||||
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) break;
|
||||
_ref = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) break;
|
||||
_ref = _i.value;
|
||||
}
|
||||
|
||||
var step = _ref;
|
||||
|
||||
if (step.unit === unit) {
|
||||
return step;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Converts value to a `Date`
|
||||
* @param {(number|Date)} value
|
||||
* @return {Date}
|
||||
*/
|
||||
|
||||
|
||||
function getDate(value) {
|
||||
return value instanceof Date ? value : new Date(value);
|
||||
}
|
||||
//# sourceMappingURL=helpers.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/gradation/helpers.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/gradation/helpers.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../source/gradation/helpers.js"],"names":["minute","hour","day","month","year","getStep","gradation","unit","step","getDate","value","Date"],"mappings":";;;;;;;;AAAO,IAAMA,MAAM,GAAG,EAAf,C,CAAkB;;;AAElB,IAAMC,IAAI,GAAG,KAAKD,MAAlB,C,CAAyB;;;AAEzB,IAAME,GAAG,GAAG,KAAKD,IAAjB,C,CAAsB;AAE7B;;;AACO,IAAME,KAAK,GAAG,QAAQD,GAAtB,C,CAA0B;AAEjC;;;AACO,IAAME,IAAI,GAAI,SAAS,GAAV,GAAiBF,GAA9B,C,CAAkC;;AAEzC;;;;;;;;;AAMO,SAASG,OAAT,CAAiBC,SAAjB,EAA4BC,IAA5B,EAAkC;AACxC,uBAAmBD,SAAnB,kHAA8B;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA,QAAnBE,IAAmB;;AAC7B,QAAIA,IAAI,CAACD,IAAL,KAAcA,IAAlB,EAAwB;AACvB,aAAOC,IAAP;AACA;AACD;AACD;AAED;;;;;;;AAKO,SAASC,OAAT,CAAiBC,KAAjB,EAAwB;AAC9B,SAAOA,KAAK,YAAYC,IAAjB,GAAwBD,KAAxB,GAAgC,IAAIC,IAAJ,CAASD,KAAT,CAAvC;AACA","sourcesContent":["export const minute = 60 // in seconds\r\n\r\nexport const hour = 60 * minute // in seconds\r\n\r\nexport const day = 24 * hour // in seconds\r\n\r\n// https://www.quora.com/What-is-the-average-number-of-days-in-a-month\r\nexport const month = 30.44 * day // in seconds\r\n\r\n// \"400 years have 146097 days (taking into account leap year rules)\"\r\nexport const year = (146097 / 400) * day // in seconds\r\n\r\n/**\r\n * Returns a step of gradation corresponding to the unit.\r\n * @param {Object[]} gradation\r\n * @param {string} unit\r\n * @return {?Object}\r\n */\r\nexport function getStep(gradation, unit) {\r\n\tfor (const step of gradation) {\r\n\t\tif (step.unit === unit) {\r\n\t\t\treturn step\r\n\t\t}\r\n\t}\r\n}\r\n\r\n/**\r\n * Converts value to a `Date`\r\n * @param {(number|Date)} value\r\n * @return {Date}\r\n */\r\nexport function getDate(value) {\r\n\treturn value instanceof Date ? value : new Date(value)\r\n}"],"file":"helpers.js"}
|
||||
12
node_modules/javascript-time-ago/commonjs/gradation/helpers.test.js
generated
vendored
Normal file
12
node_modules/javascript-time-ago/commonjs/gradation/helpers.test.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var _helpers = require("./helpers");
|
||||
|
||||
describe('gradation helpers', function () {
|
||||
it('should convert value to Date', function () {
|
||||
var today = new Date();
|
||||
(0, _helpers.getDate)(today.getTime()).getTime().should.equal(today.getTime());
|
||||
(0, _helpers.getDate)(today).getTime().should.equal(today.getTime());
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=helpers.test.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/gradation/helpers.test.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/gradation/helpers.test.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../source/gradation/helpers.test.js"],"names":["describe","it","today","Date","getTime","should","equal"],"mappings":";;AAAA;;AAEAA,QAAQ,CAAC,mBAAD,EAAsB,YAC9B;AACCC,EAAAA,EAAE,CAAC,8BAAD,EAAiC,YACnC;AACC,QAAMC,KAAK,GAAG,IAAIC,IAAJ,EAAd;AACA,0BAAQD,KAAK,CAACE,OAAN,EAAR,EAAyBA,OAAzB,GAAmCC,MAAnC,CAA0CC,KAA1C,CAAgDJ,KAAK,CAACE,OAAN,EAAhD;AACA,0BAAQF,KAAR,EAAeE,OAAf,GAAyBC,MAAzB,CAAgCC,KAAhC,CAAsCJ,KAAK,CAACE,OAAN,EAAtC;AACA,GALC,CAAF;AAMA,CARO,CAAR","sourcesContent":["import { getDate } from './helpers'\r\n\r\ndescribe('gradation helpers', () =>\r\n{\r\n\tit('should convert value to Date', () =>\r\n\t{\r\n\t\tconst today = new Date()\r\n\t\tgetDate(today.getTime()).getTime().should.equal(today.getTime())\r\n\t\tgetDate(today).getTime().should.equal(today.getTime())\r\n\t})\r\n})"],"file":"helpers.test.js"}
|
||||
68
node_modules/javascript-time-ago/commonjs/gradation/index.js
generated
vendored
Normal file
68
node_modules/javascript-time-ago/commonjs/gradation/index.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "canonical", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _canonical.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "convenient", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _convenient.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "minute", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _helpers.minute;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "hour", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _helpers.hour;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "day", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _helpers.day;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "month", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _helpers.month;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "year", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _helpers.year;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "getStep", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _helpers.getStep;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "getDate", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _helpers.getDate;
|
||||
}
|
||||
});
|
||||
|
||||
var _canonical = _interopRequireDefault(require("./canonical"));
|
||||
|
||||
var _convenient = _interopRequireDefault(require("./convenient"));
|
||||
|
||||
var _helpers = require("./helpers");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/gradation/index.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/gradation/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../source/gradation/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA;;AACA;;AACA","sourcesContent":["// A gradation is a mapping from a time interval (in seconds)\r\n// to the most appropriate time interval measurement unit\r\n// for describing it, along with the amount of such units.\r\n//\r\n// E.g. for \"canonical\" gradation:\r\n//\r\n// 0 -> 1 'now'\r\n// 0.5 -> 1 'second'\r\n// 60 -> 1 'minute'\r\n// 91 -> 2 'minute's\r\n// ...\r\n//\r\n// Each gradation unit can have:\r\n//\r\n// * unit - (required) The name of the time interval measurement unit.\r\n//\r\n// * factor - (required) The amount of seconds will be divided by this number for this unit.\r\n//\r\n// * granularity - A step for the unit's resulting \"amount\" value.\r\n//\r\n// * threshold - Min value (in seconds) for this unit. Is required for non-first unit.\r\n//\r\n// * threshold_for_[unit] - A specific threshold required for moving from `[unit]` to this unit.\r\n// E.g. if \"now\" unit is present in time units gradation\r\n// then `threshold_for_now` can be set to `45` seconds.\r\n// Otherwise, if \"now\" unit is omitted from time units gradation,\r\n// then `elapsed(0)` will output \"0 seconds\" because there's no `threshold`.\r\n//\r\n// A user can supply his own gradation.\r\n//\r\n// Don't name a gradation \"default\"\r\n// because that would conflict with the\r\n// CommonJS \"interoperability\" export layer.\r\n//\r\nexport { default as canonical } from './canonical'\r\nexport { default as convenient } from './convenient'\r\nexport { minute, hour, day, month, year, getStep, getDate } from './helpers'"],"file":"index.js"}
|
||||
164
node_modules/javascript-time-ago/commonjs/grade.js
generated
vendored
Normal file
164
node_modules/javascript-time-ago/commonjs/grade.js
generated
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = grade;
|
||||
|
||||
var _gradation = require("./gradation");
|
||||
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
/**
|
||||
* Takes seconds `elapsed` and measures them against
|
||||
* `gradation` to return the suitable `gradation` step.
|
||||
*
|
||||
* @param {number} elapsed - Time interval (in seconds). Is < 0 for past dates and > 0 for future dates.
|
||||
*
|
||||
* @param {string[]} units - A list of allowed time units
|
||||
* (e.g. ['second', 'minute', 'hour', …])
|
||||
*
|
||||
* @param {Object} [gradation] - Time scale gradation steps.
|
||||
*
|
||||
* E.g.:
|
||||
* [
|
||||
* { unit: 'second', factor: 1 },
|
||||
* { unit: 'minute', factor: 60, threshold: 60 },
|
||||
* { format(), threshold: 24 * 60 * 60 },
|
||||
* …
|
||||
* ]
|
||||
*
|
||||
* @return {?Object} `gradation` step.
|
||||
*/
|
||||
function grade(elapsed, now, units) {
|
||||
var gradation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _gradation.convenient;
|
||||
// Leave only allowed time measurement units.
|
||||
// E.g. omit "quarter" unit.
|
||||
gradation = getAllowedSteps(gradation, units); // If no steps of gradation fit the conditions
|
||||
// then return nothing.
|
||||
|
||||
if (gradation.length === 0) {
|
||||
return;
|
||||
} // Find the most appropriate gradation step
|
||||
|
||||
|
||||
var i = findGradationStep(elapsed, now, gradation);
|
||||
var step = gradation[i]; // If time elapsed is too small and even
|
||||
// the first gradation step doesn't suit it
|
||||
// then return nothing.
|
||||
|
||||
if (i === -1) {
|
||||
return;
|
||||
} // Apply granularity to the time amount
|
||||
// (and fall back to the previous step
|
||||
// if the first level of granularity
|
||||
// isn't met by this amount)
|
||||
|
||||
|
||||
if (step.granularity) {
|
||||
// Recalculate the elapsed time amount based on granularity
|
||||
var amount = Math.round(Math.abs(elapsed) / step.factor / step.granularity) * step.granularity; // If the granularity for this step
|
||||
// is too high, then fallback
|
||||
// to the previous step of gradation.
|
||||
// (if there is any previous step of gradation)
|
||||
|
||||
if (amount === 0 && i > 0) {
|
||||
return gradation[i - 1];
|
||||
}
|
||||
}
|
||||
|
||||
return step;
|
||||
}
|
||||
/**
|
||||
* Gets threshold for moving from `fromStep` to `next_step`.
|
||||
* @param {Object} fromStep - From step.
|
||||
* @param {Object} next_step - To step.
|
||||
* @param {number} now - The current timestamp.
|
||||
* @param {boolean} future - Is `true` for future dates ("in 5 minutes").
|
||||
* @return {number}
|
||||
* @throws Will throw if no threshold is found.
|
||||
*/
|
||||
|
||||
|
||||
function getThreshold(fromStep, toStep, now, future) {
|
||||
var threshold; // Allows custom thresholds when moving
|
||||
// from a specific step to a specific step.
|
||||
|
||||
if (fromStep && (fromStep.id || fromStep.unit)) {
|
||||
threshold = toStep["threshold_for_".concat(fromStep.id || fromStep.unit)];
|
||||
} // If no custom threshold is set for this transition
|
||||
// then use the usual threshold for the next step.
|
||||
|
||||
|
||||
if (threshold === undefined) {
|
||||
threshold = toStep.threshold;
|
||||
} // Convert threshold to a number.
|
||||
|
||||
|
||||
if (typeof threshold === 'function') {
|
||||
threshold = threshold(now, future);
|
||||
} // Throw if no threshold is found.
|
||||
|
||||
|
||||
if (fromStep && typeof threshold !== 'number') {
|
||||
// Babel transforms `typeof` into some "branches"
|
||||
// so istanbul will show this as "branch not covered".
|
||||
|
||||
/* istanbul ignore next */
|
||||
var type = _typeof(threshold);
|
||||
|
||||
throw new Error("Each step of a gradation must have a threshold defined except for the first one. Got \"".concat(threshold, "\", ").concat(type, ". Step: ").concat(JSON.stringify(toStep)));
|
||||
}
|
||||
|
||||
return threshold;
|
||||
}
|
||||
/**
|
||||
* @param {number} elapsed - Time elapsed (in seconds).
|
||||
* @param {number} now - Current timestamp.
|
||||
* @param {Object} gradation - Gradation.
|
||||
* @param {number} i - Gradation step currently being tested.
|
||||
* @return {number} Gradation step index.
|
||||
*/
|
||||
|
||||
|
||||
function findGradationStep(elapsed, now, gradation) {
|
||||
var i = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
||||
|
||||
// If the threshold for moving from previous step
|
||||
// to this step is too high then return the previous step.
|
||||
if (Math.abs(elapsed) < getThreshold(gradation[i - 1], gradation[i], now, elapsed < 0)) {
|
||||
return i - 1;
|
||||
} // If it's the last step of gradation then return it.
|
||||
|
||||
|
||||
if (i === gradation.length - 1) {
|
||||
return i;
|
||||
} // Move to the next step.
|
||||
|
||||
|
||||
return findGradationStep(elapsed, now, gradation, i + 1);
|
||||
}
|
||||
/**
|
||||
* Leaves only allowed gradation steps.
|
||||
* @param {Object[]} gradation
|
||||
* @param {string[]} units - Allowed time units.
|
||||
* @return {Object[]}
|
||||
*/
|
||||
|
||||
|
||||
function getAllowedSteps(gradation, units) {
|
||||
return gradation.filter(function (_ref) {
|
||||
var unit = _ref.unit;
|
||||
|
||||
// If this step has a `unit` defined
|
||||
// then this `unit` must be in the list of `units` allowed.
|
||||
if (unit) {
|
||||
return units.indexOf(unit) >= 0;
|
||||
} // A gradation step is not required to specify a `unit`.
|
||||
// E.g. for Twitter gradation it specifies `format()` instead.
|
||||
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=grade.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/grade.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/grade.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
38
node_modules/javascript-time-ago/commonjs/grade.test.js
generated
vendored
Normal file
38
node_modules/javascript-time-ago/commonjs/grade.test.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
|
||||
var _grade = _interopRequireDefault(require("../source/grade"));
|
||||
|
||||
var _gradation = require("../source/gradation");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
describe('grade', function () {
|
||||
it('should return nothing if no time units are applicable', function () {
|
||||
expect((0, _grade.default)(0, null, ['femtosecond'], _gradation.canonical)).to.be.undefined;
|
||||
});
|
||||
it('should throw if a non-first step does not have a threshold', function () {
|
||||
expect((0, _grade.default)(2, null, ['second'], [{
|
||||
unit: 'second'
|
||||
}])).to.deep.equal({
|
||||
unit: 'second'
|
||||
});
|
||||
expect(function () {
|
||||
(0, _grade.default)(2, null, ['second', 'minute'], [{
|
||||
unit: 'second'
|
||||
}, {
|
||||
unit: 'minute'
|
||||
}]);
|
||||
}).to.throw('Each step of a gradation must have a threshold defined except for the first one. Got "undefined", undefined. Step: {"unit":"minute"}');
|
||||
});
|
||||
it('should fall back to previous grading scale step if granularity is too high', function () {
|
||||
var gradation = _gradation.canonical.slice();
|
||||
|
||||
gradation[1].unit.should.equal('second');
|
||||
gradation[1].granularity = 3;
|
||||
(0, _grade.default)(1.49, null, ['now', 'second'], gradation).unit.should.equal('now'); // And if there's no previous step, then use the current one.
|
||||
|
||||
gradation.splice(0, 1);
|
||||
(0, _grade.default)(1.49, null, ['now', 'second'], gradation).unit.should.equal('second');
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=grade.test.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/grade.test.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/grade.test.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../source/grade.test.js"],"names":["describe","it","expect","canonical","to","be","undefined","unit","deep","equal","throw","gradation","slice","should","granularity","splice"],"mappings":";;AAAA;;AACA;;;;AAEAA,QAAQ,CAAC,OAAD,EAAU,YAClB;AACCC,EAAAA,EAAE,CAAC,uDAAD,EAA0D,YAC5D;AACCC,IAAAA,MAAM,CAAC,oBAAM,CAAN,EAAS,IAAT,EAAe,CAAC,aAAD,CAAf,EAAgCC,oBAAhC,CAAD,CAAN,CAAmDC,EAAnD,CAAsDC,EAAtD,CAAyDC,SAAzD;AACA,GAHC,CAAF;AAKAL,EAAAA,EAAE,CAAC,4DAAD,EAA+D,YACjE;AACCC,IAAAA,MAAM,CAAC,oBAAM,CAAN,EAAS,IAAT,EAAe,CAAC,QAAD,CAAf,EAA2B,CAAC;AAAEK,MAAAA,IAAI,EAAE;AAAR,KAAD,CAA3B,CAAD,CAAN,CAAyDH,EAAzD,CAA4DI,IAA5D,CAAiEC,KAAjE,CAAuE;AAAEF,MAAAA,IAAI,EAAE;AAAR,KAAvE;AAEAL,IAAAA,MAAM,CAAC,YAAM;AACZ,0BAAM,CAAN,EAAS,IAAT,EAAe,CAAC,QAAD,EAAW,QAAX,CAAf,EAAqC,CAAC;AAAEK,QAAAA,IAAI,EAAE;AAAR,OAAD,EAAqB;AAAEA,QAAAA,IAAI,EAAE;AAAR,OAArB,CAArC;AACA,KAFK,CAAN,CAEGH,EAFH,CAEMM,KAFN,CAGC,sIAHD;AAKA,GATC,CAAF;AAWAT,EAAAA,EAAE,CAAC,4EAAD,EAA+E,YACjF;AACC,QAAMU,SAAS,GAAGR,qBAAUS,KAAV,EAAlB;;AAEAD,IAAAA,SAAS,CAAC,CAAD,CAAT,CAAaJ,IAAb,CAAkBM,MAAlB,CAAyBJ,KAAzB,CAA+B,QAA/B;AACAE,IAAAA,SAAS,CAAC,CAAD,CAAT,CAAaG,WAAb,GAA2B,CAA3B;AAEA,wBAAM,IAAN,EAAY,IAAZ,EAAkB,CAAC,KAAD,EAAQ,QAAR,CAAlB,EAAqCH,SAArC,EAAgDJ,IAAhD,CAAqDM,MAArD,CAA4DJ,KAA5D,CAAkE,KAAlE,EAND,CAQC;;AAEAE,IAAAA,SAAS,CAACI,MAAV,CAAiB,CAAjB,EAAoB,CAApB;AAEA,wBAAM,IAAN,EAAY,IAAZ,EAAkB,CAAC,KAAD,EAAQ,QAAR,CAAlB,EAAqCJ,SAArC,EAAgDJ,IAAhD,CAAqDM,MAArD,CAA4DJ,KAA5D,CAAkE,QAAlE;AACA,GAdC,CAAF;AAeA,CAjCO,CAAR","sourcesContent":["import grade from '../source/grade'\r\nimport { canonical } from '../source/gradation'\r\n\r\ndescribe('grade', () =>\r\n{\r\n\tit('should return nothing if no time units are applicable', () =>\r\n\t{\r\n\t\texpect(grade(0, null, ['femtosecond'], canonical)).to.be.undefined\r\n\t})\r\n\r\n\tit('should throw if a non-first step does not have a threshold', () =>\r\n\t{\r\n\t\texpect(grade(2, null, ['second'], [{ unit: 'second' }])).to.deep.equal({ unit: 'second' })\r\n\r\n\t\texpect(() => {\r\n\t\t\tgrade(2, null, ['second', 'minute'], [{ unit: 'second' }, { unit: 'minute' }])\r\n\t\t}).to.throw(\r\n\t\t\t'Each step of a gradation must have a threshold defined except for the first one. Got \"undefined\", undefined. Step: {\"unit\":\"minute\"}'\r\n\t\t)\r\n\t})\r\n\r\n\tit('should fall back to previous grading scale step if granularity is too high', () =>\r\n\t{\r\n\t\tconst gradation = canonical.slice()\r\n\r\n\t\tgradation[1].unit.should.equal('second')\r\n\t\tgradation[1].granularity = 3\r\n\r\n\t\tgrade(1.49, null, ['now', 'second'], gradation).unit.should.equal('now')\r\n\r\n\t\t// And if there's no previous step, then use the current one.\r\n\r\n\t\tgradation.splice(0, 1)\r\n\r\n\t\tgrade(1.49, null, ['now', 'second'], gradation).unit.should.equal('second')\r\n\t})\r\n})"],"file":"grade.test.js"}
|
||||
89
node_modules/javascript-time-ago/commonjs/locale.js
generated
vendored
Normal file
89
node_modules/javascript-time-ago/commonjs/locale.js
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = chooseLocale;
|
||||
exports.intlDateTimeFormatSupportedLocale = intlDateTimeFormatSupportedLocale;
|
||||
exports.intlDateTimeFormatSupported = intlDateTimeFormatSupported;
|
||||
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
// Chooses the most appropriate locale
|
||||
// (one of the registered ones)
|
||||
// based on the list of preferred `locales` supplied by the user.
|
||||
//
|
||||
// @param {string[]} locales - the list of preferable locales (in [IETF format](https://en.wikipedia.org/wiki/IETF_language_tag)).
|
||||
// @param {Function} isLocaleDataAvailable - tests if a locale is available.
|
||||
//
|
||||
// @returns {string} The most suitable locale
|
||||
//
|
||||
// @example
|
||||
// // Returns 'en'
|
||||
// chooseLocale(['en-US'], undefined, (locale) => locale === 'ru' || locale === 'en')
|
||||
//
|
||||
function chooseLocale(locales, isLocaleDataAvailable) {
|
||||
// This is not an intelligent algorithm,
|
||||
// but it will do for this library's case.
|
||||
// `sr-Cyrl-BA` -> `sr-Cyrl` -> `sr`.
|
||||
for (var _iterator = locales, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref;
|
||||
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) break;
|
||||
_ref = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) break;
|
||||
_ref = _i.value;
|
||||
}
|
||||
|
||||
var locale = _ref;
|
||||
|
||||
if (isLocaleDataAvailable(locale)) {
|
||||
return locale;
|
||||
}
|
||||
|
||||
var parts = locale.split('-');
|
||||
|
||||
while (parts.length > 1) {
|
||||
parts.pop();
|
||||
locale = parts.join('-');
|
||||
|
||||
if (isLocaleDataAvailable(locale)) {
|
||||
return locale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error("No locale data has been registered for any of the locales: ".concat(locales.join(', ')));
|
||||
}
|
||||
/**
|
||||
* Whether can use `Intl.DateTimeFormat` for these `locales`.
|
||||
* Returns the first suitable one.
|
||||
* @param {(string|string[])} locales
|
||||
* @return {?string} The first locale that can be used.
|
||||
*/
|
||||
|
||||
|
||||
function intlDateTimeFormatSupportedLocale(locales) {
|
||||
/* istanbul ignore else */
|
||||
if (intlDateTimeFormatSupported()) {
|
||||
return Intl.DateTimeFormat.supportedLocalesOf(locales)[0];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Whether can use `Intl.DateTimeFormat`.
|
||||
* @return {boolean}
|
||||
*/
|
||||
|
||||
|
||||
function intlDateTimeFormatSupported() {
|
||||
// Babel transforms `typeof` into some "branches"
|
||||
// so istanbul will show this as "branch not covered".
|
||||
|
||||
/* istanbul ignore next */
|
||||
var isIntlAvailable = (typeof Intl === "undefined" ? "undefined" : _typeof(Intl)) === 'object';
|
||||
return isIntlAvailable && typeof Intl.DateTimeFormat === 'function';
|
||||
}
|
||||
//# sourceMappingURL=locale.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/locale.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/locale.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../source/locale.js"],"names":["chooseLocale","locales","isLocaleDataAvailable","locale","parts","split","length","pop","join","Error","intlDateTimeFormatSupportedLocale","intlDateTimeFormatSupported","Intl","DateTimeFormat","supportedLocalesOf","isIntlAvailable"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,YAAT,CAAsBC,OAAtB,EAA+BC,qBAA/B,EACf;AACC;AACA;AACA;AACA,uBAAmBD,OAAnB,kHAA4B;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA,QAAnBE,MAAmB;;AAC3B,QAAID,qBAAqB,CAACC,MAAD,CAAzB,EAAmC;AAClC,aAAOA,MAAP;AACA;;AACD,QAAMC,KAAK,GAAGD,MAAM,CAACE,KAAP,CAAa,GAAb,CAAd;;AACA,WAAOD,KAAK,CAACE,MAAN,GAAe,CAAtB,EAAyB;AACxBF,MAAAA,KAAK,CAACG,GAAN;AACAJ,MAAAA,MAAM,GAAGC,KAAK,CAACI,IAAN,CAAW,GAAX,CAAT;;AACA,UAAIN,qBAAqB,CAACC,MAAD,CAAzB,EAAmC;AAClC,eAAOA,MAAP;AACA;AACD;AACD;;AAED,QAAM,IAAIM,KAAJ,sEAAwER,OAAO,CAACO,IAAR,CAAa,IAAb,CAAxE,EAAN;AACA;AAED;;;;;;;;AAMO,SAASE,iCAAT,CAA2CT,OAA3C,EAAoD;AAC1D;AACA,MAAIU,2BAA2B,EAA/B,EAAmC;AAClC,WAAOC,IAAI,CAACC,cAAL,CAAoBC,kBAApB,CAAuCb,OAAvC,EAAgD,CAAhD,CAAP;AACA;AACD;AACD;;;;;;AAIO,SAASU,2BAAT,GAAuC;AAC7C;AACA;;AACA;AACA,MAAMI,eAAe,GAAG,QAAOH,IAAP,yCAAOA,IAAP,OAAgB,QAAxC;AACA,SAAOG,eAAe,IAAI,OAAOH,IAAI,CAACC,cAAZ,KAA+B,UAAzD;AACA","sourcesContent":["// Chooses the most appropriate locale\r\n// (one of the registered ones)\r\n// based on the list of preferred `locales` supplied by the user.\r\n//\r\n// @param {string[]} locales - the list of preferable locales (in [IETF format](https://en.wikipedia.org/wiki/IETF_language_tag)).\r\n// @param {Function} isLocaleDataAvailable - tests if a locale is available.\r\n//\r\n// @returns {string} The most suitable locale\r\n//\r\n// @example\r\n// // Returns 'en'\r\n// chooseLocale(['en-US'], undefined, (locale) => locale === 'ru' || locale === 'en')\r\n//\r\nexport default function chooseLocale(locales, isLocaleDataAvailable)\r\n{\r\n\t// This is not an intelligent algorithm,\r\n\t// but it will do for this library's case.\r\n\t// `sr-Cyrl-BA` -> `sr-Cyrl` -> `sr`.\r\n\tfor (let locale of locales) {\r\n\t\tif (isLocaleDataAvailable(locale)) {\r\n\t\t\treturn locale\r\n\t\t}\r\n\t\tconst parts = locale.split('-')\r\n\t\twhile (parts.length > 1) {\r\n\t\t\tparts.pop()\r\n\t\t\tlocale = parts.join('-')\r\n\t\t\tif (isLocaleDataAvailable(locale)) {\r\n\t\t\t\treturn locale\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tthrow new Error(`No locale data has been registered for any of the locales: ${locales.join(', ')}`)\r\n}\r\n\r\n/**\r\n * Whether can use `Intl.DateTimeFormat` for these `locales`.\r\n * Returns the first suitable one.\r\n * @param {(string|string[])} locales\r\n * @return {?string} The first locale that can be used.\r\n */\r\nexport function intlDateTimeFormatSupportedLocale(locales) {\r\n\t/* istanbul ignore else */\r\n\tif (intlDateTimeFormatSupported()) {\r\n\t\treturn Intl.DateTimeFormat.supportedLocalesOf(locales)[0]\r\n\t}\r\n}\r\n/**\r\n * Whether can use `Intl.DateTimeFormat`.\r\n * @return {boolean}\r\n */\r\nexport function intlDateTimeFormatSupported() {\r\n\t// Babel transforms `typeof` into some \"branches\"\r\n\t// so istanbul will show this as \"branch not covered\".\r\n\t/* istanbul ignore next */\r\n\tconst isIntlAvailable = typeof Intl === 'object'\r\n\treturn isIntlAvailable && typeof Intl.DateTimeFormat === 'function'\r\n}\r\n"],"file":"locale.js"}
|
||||
46
node_modules/javascript-time-ago/commonjs/locale.test.js
generated
vendored
Normal file
46
node_modules/javascript-time-ago/commonjs/locale.test.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
|
||||
var _locale = _interopRequireWildcard(require("../source/locale"));
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||||
|
||||
describe('locale', function () {
|
||||
it("should tell if can use Intl for date formatting", function () {
|
||||
(0, _locale.intlDateTimeFormatSupportedLocale)('en').should.equal('en');
|
||||
(0, _locale.intlDateTimeFormatSupportedLocale)('en-XX').should.equal('en-XX');
|
||||
(0, _locale.intlDateTimeFormatSupportedLocale)(['en', 'ru']).should.equal('en');
|
||||
});
|
||||
it("should choose the most appropriate locale", function () {
|
||||
function arrayToObject(array) {
|
||||
return array.reduce(function (object, locale) {
|
||||
object[locale] = true;
|
||||
return object;
|
||||
}, {});
|
||||
}
|
||||
|
||||
function choose(locale, locales) {
|
||||
var defaultLocale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'en';
|
||||
|
||||
if (typeof locale === 'string') {
|
||||
locale = [locale];
|
||||
}
|
||||
|
||||
locale = locale.concat(defaultLocale);
|
||||
return (0, _locale.default)(locale, function (_) {
|
||||
return locales.includes(_);
|
||||
});
|
||||
}
|
||||
|
||||
choose('ru-RU', ['en', 'ru']).should.equal('ru');
|
||||
choose('en-GB', ['en', 'ru']).should.equal('en');
|
||||
choose('fr-FR', ['en', 'ru']).should.equal('en');
|
||||
choose(['fr-FR', 'de-DE'], ['en', 'ru']).should.equal('en');
|
||||
choose(['fr-FR', 'de-DE'], ['en', 'de']).should.equal('de');
|
||||
choose(['fr-FR', 'de-DE'], ['en', 'de', 'fr']).should.equal('fr');
|
||||
choose('fr-FR', ['en', 'fr-FR']).should.equal('fr-FR');
|
||||
expect(function () {
|
||||
return choose('fr-FR', ['de', 'ru']);
|
||||
}).to.throw('No locale data has been registered for any of the locales: fr-FR');
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=locale.test.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/locale.test.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/locale.test.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../source/locale.test.js"],"names":["describe","it","should","equal","arrayToObject","array","reduce","object","locale","choose","locales","defaultLocale","concat","_","includes","expect","to","throw"],"mappings":";;AAAA;;;;AAEAA,QAAQ,CAAC,QAAD,EAAW,YACnB;AACCC,EAAAA,EAAE,oDAAoD,YACtD;AACC,mDAAkC,IAAlC,EAAwCC,MAAxC,CAA+CC,KAA/C,CAAqD,IAArD;AACA,mDAAkC,OAAlC,EAA2CD,MAA3C,CAAkDC,KAAlD,CAAwD,OAAxD;AACA,mDAAkC,CAAC,IAAD,EAAO,IAAP,CAAlC,EAAgDD,MAAhD,CAAuDC,KAAvD,CAA6D,IAA7D;AACA,GALC,CAAF;AAOAF,EAAAA,EAAE,8CAA8C,YAChD;AACC,aAASG,aAAT,CAAuBC,KAAvB,EACA;AACC,aAAOA,KAAK,CAACC,MAAN,CAAa,UAACC,MAAD,EAASC,MAAT,EAAoB;AACvCD,QAAAA,MAAM,CAACC,MAAD,CAAN,GAAiB,IAAjB;AACA,eAAOD,MAAP;AACA,OAHM,EAGJ,EAHI,CAAP;AAIA;;AAED,aAASE,MAAT,CAAgBD,MAAhB,EAAwBE,OAAxB,EACA;AAAA,UADiCC,aACjC,uEADiD,IACjD;;AACC,UAAI,OAAOH,MAAP,KAAkB,QAAtB,EAAgC;AAC/BA,QAAAA,MAAM,GAAG,CAACA,MAAD,CAAT;AACA;;AACDA,MAAAA,MAAM,GAAGA,MAAM,CAACI,MAAP,CAAcD,aAAd,CAAT;AACA,aAAO,qBAAaH,MAAb,EAAqB,UAAAK,CAAC;AAAA,eAAIH,OAAO,CAACI,QAAR,CAAiBD,CAAjB,CAAJ;AAAA,OAAtB,CAAP;AACA;;AAEDJ,IAAAA,MAAM,CAAC,OAAD,EAAU,CAAC,IAAD,EAAO,IAAP,CAAV,CAAN,CAA8BP,MAA9B,CAAqCC,KAArC,CAA2C,IAA3C;AACAM,IAAAA,MAAM,CAAC,OAAD,EAAU,CAAC,IAAD,EAAO,IAAP,CAAV,CAAN,CAA8BP,MAA9B,CAAqCC,KAArC,CAA2C,IAA3C;AACAM,IAAAA,MAAM,CAAC,OAAD,EAAU,CAAC,IAAD,EAAO,IAAP,CAAV,CAAN,CAA8BP,MAA9B,CAAqCC,KAArC,CAA2C,IAA3C;AACAM,IAAAA,MAAM,CAAC,CAAC,OAAD,EAAU,OAAV,CAAD,EAAqB,CAAC,IAAD,EAAO,IAAP,CAArB,CAAN,CAAyCP,MAAzC,CAAgDC,KAAhD,CAAsD,IAAtD;AACAM,IAAAA,MAAM,CAAC,CAAC,OAAD,EAAU,OAAV,CAAD,EAAqB,CAAC,IAAD,EAAO,IAAP,CAArB,CAAN,CAAyCP,MAAzC,CAAgDC,KAAhD,CAAsD,IAAtD;AACAM,IAAAA,MAAM,CAAC,CAAC,OAAD,EAAU,OAAV,CAAD,EAAqB,CAAC,IAAD,EAAO,IAAP,EAAa,IAAb,CAArB,CAAN,CAA+CP,MAA/C,CAAsDC,KAAtD,CAA4D,IAA5D;AACAM,IAAAA,MAAM,CAAC,OAAD,EAAU,CAAC,IAAD,EAAO,OAAP,CAAV,CAAN,CAAiCP,MAAjC,CAAwCC,KAAxC,CAA8C,OAA9C;AAEAY,IAAAA,MAAM,CAAC;AAAA,aAAMN,MAAM,CAAC,OAAD,EAAU,CAAC,IAAD,EAAO,IAAP,CAAV,CAAZ;AAAA,KAAD,CAAN,CAA4CO,EAA5C,CAA+CC,KAA/C,CACC,kEADD;AAGA,GA9BC,CAAF;AA+BA,CAxCO,CAAR","sourcesContent":["import chooseLocale, { intlDateTimeFormatSupportedLocale } from '../source/locale'\r\n\r\ndescribe('locale', function()\r\n{\r\n\tit(`should tell if can use Intl for date formatting`, function()\r\n\t{\r\n\t\tintlDateTimeFormatSupportedLocale('en').should.equal('en')\r\n\t\tintlDateTimeFormatSupportedLocale('en-XX').should.equal('en-XX')\r\n\t\tintlDateTimeFormatSupportedLocale(['en', 'ru']).should.equal('en')\r\n\t})\r\n\r\n\tit(`should choose the most appropriate locale`, function()\r\n\t{\r\n\t\tfunction arrayToObject(array)\r\n\t\t{\r\n\t\t\treturn array.reduce((object, locale) => {\r\n\t\t\t\tobject[locale] = true\r\n\t\t\t\treturn object\r\n\t\t\t}, {})\r\n\t\t}\r\n\r\n\t\tfunction choose(locale, locales, defaultLocale = 'en')\r\n\t\t{\r\n\t\t\tif (typeof locale === 'string') {\r\n\t\t\t\tlocale = [locale]\r\n\t\t\t}\r\n\t\t\tlocale = locale.concat(defaultLocale)\r\n\t\t\treturn chooseLocale(locale, _ => locales.includes(_))\r\n\t\t}\r\n\r\n\t\tchoose('ru-RU', ['en', 'ru']).should.equal('ru')\r\n\t\tchoose('en-GB', ['en', 'ru']).should.equal('en')\r\n\t\tchoose('fr-FR', ['en', 'ru']).should.equal('en')\r\n\t\tchoose(['fr-FR', 'de-DE'], ['en', 'ru']).should.equal('en')\r\n\t\tchoose(['fr-FR', 'de-DE'], ['en', 'de']).should.equal('de')\r\n\t\tchoose(['fr-FR', 'de-DE'], ['en', 'de', 'fr']).should.equal('fr')\r\n\t\tchoose('fr-FR', ['en', 'fr-FR']).should.equal('fr-FR')\r\n\r\n\t\texpect(() => choose('fr-FR', ['de', 'ru'])).to.throw(\r\n\t\t\t'No locale data has been registered for any of the locales: fr-FR'\r\n\t\t)\r\n\t})\r\n})"],"file":"locale.test.js"}
|
||||
16
node_modules/javascript-time-ago/commonjs/style/default.js
generated
vendored
Normal file
16
node_modules/javascript-time-ago/commonjs/style/default.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _gradation = require("../gradation");
|
||||
|
||||
var _default = {
|
||||
gradation: _gradation.convenient,
|
||||
flavour: ['long-convenient', 'long'],
|
||||
units: ['now', 'minute', 'hour', 'day', 'week', 'month', 'year']
|
||||
};
|
||||
exports.default = _default;
|
||||
//# sourceMappingURL=default.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/style/default.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/style/default.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../source/style/default.js"],"names":["gradation","convenient","flavour","units"],"mappings":";;;;;;;AAAA;;eAGA;AACCA,EAAAA,SAAS,EAAEC,qBADZ;AAECC,EAAAA,OAAO,EAAE,CAAC,iBAAD,EAAoB,MAApB,CAFV;AAGCC,EAAAA,KAAK,EACL,CACC,KADD,EAEC,QAFD,EAGC,MAHD,EAIC,KAJD,EAKC,MALD,EAMC,OAND,EAOC,MAPD;AAJD,C","sourcesContent":["import { convenient } from '../gradation'\r\n\r\nexport default\r\n{\r\n\tgradation: convenient,\r\n\tflavour: ['long-convenient', 'long'],\r\n\tunits:\r\n\t[\r\n\t\t'now',\r\n\t\t'minute',\r\n\t\t'hour',\r\n\t\t'day',\r\n\t\t'week',\r\n\t\t'month',\r\n\t\t'year'\r\n\t]\r\n}"],"file":"default.js"}
|
||||
32
node_modules/javascript-time-ago/commonjs/style/index.js
generated
vendored
Normal file
32
node_modules/javascript-time-ago/commonjs/style/index.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "timeStyle", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _time.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "twitterStyle", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _twitter.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "defaultStyle", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _default.default;
|
||||
}
|
||||
});
|
||||
|
||||
var _time = _interopRequireDefault(require("./time"));
|
||||
|
||||
var _twitter = _interopRequireDefault(require("./twitter"));
|
||||
|
||||
var _default = _interopRequireDefault(require("./default"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/style/index.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/style/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../source/style/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA;;AACA;;AACA","sourcesContent":["// A preset (style) is an object having shape\r\n// `{ units, gradation, flavour, custom({ elapsed, time, date, now, locale }) }`.\r\n//\r\n// `date` parameter of `custom()` is not guaranteed to be set (can be inferred from `time`).\r\n//\r\nexport { default as timeStyle } from './time'\r\nexport { default as twitterStyle } from './twitter'\r\nexport { default as defaultStyle } from './default'"],"file":"index.js"}
|
||||
39
node_modules/javascript-time-ago/commonjs/style/time.js
generated
vendored
Normal file
39
node_modules/javascript-time-ago/commonjs/style/time.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _gradation = require("../gradation");
|
||||
|
||||
// Similar to the default style but with "ago" omitted.
|
||||
//
|
||||
// just now
|
||||
// 5 minutes
|
||||
// 10 minutes
|
||||
// 15 minutes
|
||||
// 20 minutes
|
||||
// an hour
|
||||
// 2 hours
|
||||
// …
|
||||
// 20 hours
|
||||
// 1 day
|
||||
// 2 days
|
||||
// a week
|
||||
// 2 weeks
|
||||
// 3 weeks
|
||||
// a month
|
||||
// 2 months
|
||||
// 3 months
|
||||
// 4 months
|
||||
// a year
|
||||
// 2 years
|
||||
//
|
||||
var _default = {
|
||||
gradation: _gradation.convenient,
|
||||
flavour: 'long-time',
|
||||
units: ['now', 'minute', 'hour', 'day', 'week', 'month', 'year']
|
||||
};
|
||||
exports.default = _default;
|
||||
//# sourceMappingURL=time.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/style/time.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/style/time.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../source/style/time.js"],"names":["gradation","convenient","flavour","units"],"mappings":";;;;;;;AAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;eAEA;AACCA,EAAAA,SAAS,EAAEC,qBADZ;AAECC,EAAAA,OAAO,EAAE,WAFV;AAGCC,EAAAA,KAAK,EACL,CACC,KADD,EAEC,QAFD,EAGC,MAHD,EAIC,KAJD,EAKC,MALD,EAMC,OAND,EAOC,MAPD;AAJD,C","sourcesContent":["import { convenient } from '../gradation'\r\n\r\n// Similar to the default style but with \"ago\" omitted.\r\n//\r\n// just now\r\n// 5 minutes\r\n// 10 minutes\r\n// 15 minutes\r\n// 20 minutes\r\n// an hour\r\n// 2 hours\r\n// …\r\n// 20 hours\r\n// 1 day\r\n// 2 days\r\n// a week\r\n// 2 weeks\r\n// 3 weeks\r\n// a month\r\n// 2 months\r\n// 3 months\r\n// 4 months\r\n// a year\r\n// 2 years\r\n//\r\nexport default\r\n{\r\n\tgradation: convenient,\r\n\tflavour: 'long-time',\r\n\tunits:\r\n\t[\r\n\t\t'now',\r\n\t\t'minute',\r\n\t\t'hour',\r\n\t\t'day',\r\n\t\t'week',\r\n\t\t'month',\r\n\t\t'year'\r\n\t]\r\n}"],"file":"time.js"}
|
||||
17
node_modules/javascript-time-ago/commonjs/style/time.test.js
generated
vendored
Normal file
17
node_modules/javascript-time-ago/commonjs/style/time.test.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
var _time = _interopRequireDefault(require("./time"));
|
||||
|
||||
var _JavascriptTimeAgo = require("../JavascriptTimeAgo.test");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
describe('"time" style', function () {
|
||||
it('should format "time" style relative time (English)', function () {
|
||||
(0, _JavascriptTimeAgo.convenientGradationTest)(['just now', '1 minute', '2 minutes', '5 minutes', '10 minutes', '15 minutes', '20 minutes', '25 minutes', '30 minutes', '35 minutes', '40 minutes', '45 minutes', '50 minutes', '1 hour', '2 hours', '3 hours', '4 hours', '5 hours', '6 hours', '7 hours', '8 hours', '9 hours', '10 hours', '11 hours', '12 hours', '13 hours', '14 hours', '15 hours', '16 hours', '17 hours', '18 hours', '19 hours', '20 hours', '1 day', '2 days', '3 days', '4 days', '5 days', '1 week', '2 weeks', '3 weeks', '1 month', '2 months', '3 months', '4 months', '5 months', '6 months', '7 months', '8 months', '9 months', '9 months', '10 months', '1 year', '2 years', '3 years', '100 years'], 'en-US', _time.default);
|
||||
});
|
||||
it('should format "time" style relative time (Russian)', function () {
|
||||
(0, _JavascriptTimeAgo.convenientGradationTest)(['только что', '1 минута', '2 минуты', '5 минут', '10 минут', '15 минут', '20 минут', '25 минут', '30 минут', '35 минут', '40 минут', '45 минут', '50 минут', '1 час', '2 часа', '3 часа', '4 часа', '5 часов', '6 часов', '7 часов', '8 часов', '9 часов', '10 часов', '11 часов', '12 часов', '13 часов', '14 часов', '15 часов', '16 часов', '17 часов', '18 часов', '19 часов', '20 часов', '1 день', '2 дня', '3 дня', '4 дня', '5 дней', '1 неделю', '2 недели', '3 недели', '1 месяц', '2 месяца', '3 месяца', '4 месяца', '5 месяцев', '6 месяцев', '7 месяцев', '8 месяцев', '9 месяцев', '9 месяцев', '10 месяцев', '1 год', '2 года', '3 года', '100 лет'], 'ru-RU', _time.default);
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=time.test.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/style/time.test.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/style/time.test.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
113
node_modules/javascript-time-ago/commonjs/style/twitter.js
generated
vendored
Normal file
113
node_modules/javascript-time-ago/commonjs/style/twitter.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _gradation = require("../gradation");
|
||||
|
||||
var _locale = require("../locale");
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
// A cache for `Intl.DateTimeFormat` twitter formatters
|
||||
// for various locales (is a global variable).
|
||||
var formatters = {}; // Twitter style relative time formatting.
|
||||
// ("1m", "2h", "Mar 3", "Apr 4, 2012").
|
||||
// Seconds, minutes and hours are shown relatively,
|
||||
// and other intervals can be shown using full date format.
|
||||
|
||||
var _default = {
|
||||
// Twitter gradation is derived from "canonical" gradation
|
||||
// adjusting its "minute" `threshold` to be 45.
|
||||
gradation: [// Minutes
|
||||
_objectSpread({}, (0, _gradation.getStep)(_gradation.canonical, 'minute'), {
|
||||
threshold: 45
|
||||
}), // Hours
|
||||
(0, _gradation.getStep)(_gradation.canonical, 'hour'), // If `date` and `now` happened the same year,
|
||||
// then only output month and day.
|
||||
{
|
||||
threshold: _gradation.day - 0.5 * _gradation.hour,
|
||||
format: function format(value, locale) {
|
||||
// Whether can use `Intl.DateTimeFormat`.
|
||||
// If `Intl` is not available,
|
||||
// or the locale is not supported,
|
||||
// then don't override the default labels.
|
||||
|
||||
/* istanbul ignore if */
|
||||
if (!(0, _locale.intlDateTimeFormatSupported)()) {
|
||||
return;
|
||||
}
|
||||
/* istanbul ignore else */
|
||||
|
||||
|
||||
if (!formatters[locale]) {
|
||||
formatters[locale] = {};
|
||||
}
|
||||
/* istanbul ignore else */
|
||||
|
||||
|
||||
if (!formatters[locale].this_year) {
|
||||
// "Apr 11" (MMMd)
|
||||
formatters[locale].this_year = new Intl.DateTimeFormat(locale, {
|
||||
month: 'short',
|
||||
day: 'numeric'
|
||||
});
|
||||
} // Output month and day.
|
||||
|
||||
|
||||
return formatters[locale].this_year.format((0, _gradation.getDate)(value));
|
||||
}
|
||||
}, // If `date` and `now` happened in defferent years,
|
||||
// then output day, month and year.
|
||||
{
|
||||
threshold: function threshold(now, future) {
|
||||
if (future) {
|
||||
// Jan 1st 00:00 of the next year.
|
||||
var nextYear = new Date(new Date(now).getFullYear() + 1, 0);
|
||||
return (nextYear.getTime() - now) / 1000;
|
||||
} else {
|
||||
// Jan 1st of the current year.
|
||||
var thisYear = new Date(new Date(now).getFullYear(), 0);
|
||||
return (now - thisYear.getTime()) / 1000;
|
||||
}
|
||||
},
|
||||
format: function format(value, locale) {
|
||||
// Whether can use `Intl.DateTimeFormat`.
|
||||
// If `Intl` is not available,
|
||||
// or the locale is not supported,
|
||||
// then don't override the default labels.
|
||||
|
||||
/* istanbul ignore if */
|
||||
if (!(0, _locale.intlDateTimeFormatSupported)()) {
|
||||
return;
|
||||
}
|
||||
/* istanbul ignore if */
|
||||
|
||||
|
||||
if (!formatters[locale]) {
|
||||
formatters[locale] = {};
|
||||
}
|
||||
/* istanbul ignore else */
|
||||
|
||||
|
||||
if (!formatters[locale].other) {
|
||||
// "Apr 11, 2017" (yMMMd)
|
||||
formatters[locale].other = new Intl.DateTimeFormat(locale, {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric'
|
||||
});
|
||||
} // Output day, month and year.
|
||||
|
||||
|
||||
return formatters[locale].other.format((0, _gradation.getDate)(value));
|
||||
}
|
||||
}],
|
||||
flavour: ['tiny', 'short-time', 'narrow', 'short']
|
||||
};
|
||||
exports.default = _default;
|
||||
//# sourceMappingURL=twitter.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/style/twitter.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/style/twitter.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
87
node_modules/javascript-time-ago/commonjs/style/twitter.test.js
generated
vendored
Normal file
87
node_modules/javascript-time-ago/commonjs/style/twitter.test.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
"use strict";
|
||||
|
||||
var _twitter = _interopRequireDefault(require("./twitter"));
|
||||
|
||||
var _JavascriptTimeAgo = _interopRequireDefault(require("../JavascriptTimeAgo"));
|
||||
|
||||
var _gradation = require("../gradation");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
describe('"twitter" style', function () {
|
||||
it('should fallback from "tiny" to "narrow" for Twitter style for autogenerated locales', function () {
|
||||
var timeAgo = new _JavascriptTimeAgo.default('de');
|
||||
timeAgo.format(Date.now() - 3 * 60 * 60 * 1000, 'twitter').should.equal('vor 3 Std.');
|
||||
});
|
||||
it('should format Twitter style relative time (English)', function () {
|
||||
var timeAgo = new _JavascriptTimeAgo.default('en');
|
||||
var now = new Date(2016, 3, 10, 22, 59).getTime();
|
||||
|
||||
var elapsed = function elapsed(time) {
|
||||
return timeAgo.format(now - time * 1000, _objectSpread({
|
||||
now: now
|
||||
}, _twitter.default));
|
||||
};
|
||||
|
||||
elapsed(0).should.equal('');
|
||||
elapsed(44.9).should.equal('');
|
||||
elapsed(45.1).should.equal('1m');
|
||||
elapsed(1.49 * 60).should.equal('1m');
|
||||
elapsed(1.51 * 60).should.equal('2m');
|
||||
elapsed(2.49 * 60).should.equal('2m');
|
||||
elapsed(2.51 * 60).should.equal('3m'); // …
|
||||
|
||||
elapsed(59.49 * 60).should.equal('59m');
|
||||
elapsed(59.51 * 60).should.equal('1h');
|
||||
elapsed(1.49 * 60 * 60).should.equal('1h');
|
||||
elapsed(1.51 * 60 * 60).should.equal('2h');
|
||||
elapsed(2.49 * 60 * 60).should.equal('2h');
|
||||
elapsed(2.51 * 60 * 60).should.equal('3h'); // …
|
||||
|
||||
elapsed(23.49 * 60 * 60).should.equal('23h');
|
||||
elapsed(_gradation.day + 2 * 60 + 60 * 60).should.equal('Apr 9'); // …
|
||||
// "month" is an approximation.
|
||||
|
||||
elapsed(_gradation.month * 3).should.equal('Jan 10');
|
||||
elapsed(_gradation.month * 4).should.equal('Dec 11, 2015');
|
||||
elapsed(_gradation.year).should.equal('Apr 11, 2015'); // Test future dates.
|
||||
// "month" is an approximation.
|
||||
|
||||
elapsed(-1 * _gradation.month * 8).should.equal('Dec 10');
|
||||
elapsed(-1 * _gradation.month * 9).should.equal('Jan 9, 2017');
|
||||
});
|
||||
it('should format Twitter style relative time (Russian)', function () {
|
||||
var timeAgo = new _JavascriptTimeAgo.default('ru');
|
||||
var now = new Date(2016, 3, 10, 22, 59).getTime();
|
||||
|
||||
var elapsed = function elapsed(time) {
|
||||
return timeAgo.format(now - time * 1000, _objectSpread({
|
||||
now: now
|
||||
}, _twitter.default));
|
||||
};
|
||||
|
||||
elapsed(45.1).should.equal('1м');
|
||||
elapsed(59.51 * 60).should.equal('1ч');
|
||||
elapsed(_gradation.day + 62 * 60).should.equal('9 апр.');
|
||||
elapsed(_gradation.year).should.equal('11 апр. 2015 г.');
|
||||
});
|
||||
it('should format Twitter style relative time (Korean)', function () {
|
||||
var timeAgo = new _JavascriptTimeAgo.default('ko');
|
||||
var now = new Date(2016, 3, 10, 22, 59).getTime();
|
||||
|
||||
var elapsed = function elapsed(time) {
|
||||
return timeAgo.format(now - time * 1000, _objectSpread({
|
||||
now: now
|
||||
}, _twitter.default));
|
||||
};
|
||||
|
||||
elapsed(45.1).should.equal('1분');
|
||||
elapsed(59.51 * 60).should.equal('1시간'); // elapsed(day + 62 * 60).should.equal('9 апр.')
|
||||
// elapsed(year).should.equal('11 апр. 2015 г.')
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=twitter.test.js.map
|
||||
1
node_modules/javascript-time-ago/commonjs/style/twitter.test.js.map
generated
vendored
Normal file
1
node_modules/javascript-time-ago/commonjs/style/twitter.test.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user