Socket
Socket
Sign inDemoInstall

javascript-time-ago

Package Overview
Dependencies
1
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.8 to 2.0.9

2

bundle/javascript-time-ago.min.js

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

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("javascript-time-ago",[],e):"object"==typeof exports?exports["javascript-time-ago"]=e():t["javascript-time-ago"]=e()}(window,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([,function(t,e,r){"use strict";r.r(e);var n="en",o={};function a(){return n}function i(t){return o[t]}function u(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).localeMatcher||"lookup";switch(e){case"lookup":case"best fit":return l(t);default:throw new RangeError('Invalid "localeMatcher" option: '.concat(e))}}function l(t){if(i(t))return t;for(var e=t.split("-");t.length>1;)if(e.pop(),i(t=e.join("-")))return t}function f(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function c(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var s=["second","minute","hour","day","week","month","quarter","year"],h=["auto","always"],y=["long","short","narrow"],m=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),c(this,"numeric","always"),c(this,"style","long"),c(this,"localeMatcher","lookup");var n=r.numeric,o=r.style,i=r.localeMatcher;if(n){if(h.indexOf(n)<0)throw new RangeError('Invalid "numeric" option: '.concat(n));this.numeric=n}if(o){if(y.indexOf(o)<0)throw new RangeError('Invalid "style" option: '.concat(o));this.style=o}if(i&&(this.localeMatcher=i),"string"==typeof e&&(e=[e]),e.push(a()),this.locale=t.supportedLocalesOf(e,{localeMatcher:this.localeMatcher})[0],!this.locale)throw new TypeError("No supported locale was found");this.locale=u(this.locale,{localeMatcher:this.localeMatcher}),"undefined"!=typeof Intl&&Intl.NumberFormat&&(this.numberFormat=new Intl.NumberFormat(this.locale))}var e,r,n;return e=t,(r=[{key:"format",value:function(t,e){return this.getRule(t,e).replace("{0}",this.formatNumber(Math.abs(t)))}},{key:"formatToParts",value:function(t,e){var r=this.getRule(t,e),n=r.indexOf("{0}");if(n<0)return[{type:"literal",value:r}];var o=[];return n>0&&o.push({type:"literal",value:r.slice(0,n)}),o.push({unit:e,type:"integer",value:this.formatNumber(Math.abs(t))}),n+"{0}".length<r.length-1&&o.push({type:"literal",value:r.slice(n+"{0}".length)}),o}},{key:"getRule",value:function(t,e){if(s.indexOf(e)<0)throw new RangeError("Unknown time unit: ".concat(e,"."));var r=i(this.locale)[this.style][e];if("auto"===this.numeric)if(-2===t||-1===t){var n=r["previous".concat(-1===t?"":"-"+Math.abs(t))];if(n)return n}else if(1===t||2===t){var o=r["next".concat(1===t?"":"-"+Math.abs(t))];if(o)return o}else if(0===t&&r.current)return r.current;var a=r[t<=0?"past":"future"];if("string"==typeof a)return a;var u=i(this.locale).quantify,l=u&&u(Math.abs(t));return a[l=l||"other"]||a.other}},{key:"formatNumber",value:function(t){return this.numberFormat?this.numberFormat.format(t):String(t)}},{key:"resolvedOptions",value:function(){return{locale:this.locale,style:this.style,numeric:this.numeric}}}])&&f(e.prototype,r),n&&f(e,n),t}();function p(t){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function b(t){return(b="function"==typeof Symbol&&"symbol"===p(Symbol.iterator)?function(t){return p(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":p(t)})(t)}function d(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}m.supportedLocalesOf=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof t&&(t=[t]),t.filter(function(t){return u(t,e)})},m.addLocale=function(t){if(!t)throw new Error("No locale data passed");o[t.locale]=t},m.setDefaultLocale=function(t){n=t},m.getDefaultLocale=a;var v=function(){function t(){var e,r,n;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),n={},(r="cache")in(e=this)?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n}var e,r,n;return e=t,(r=[{key:"get",value:function(){for(var t=this.cache,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];for(var o=0;o<r.length;o++){var a=r[o];if("object"!==b(t))return;t=t[a]}return t}},{key:"put",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];for(var n=e.pop(),o=e.pop(),a=this.cache,i=0;i<e.length;i++){var u=e[i];"object"!==b(a[u])&&(a[u]={}),a=a[u]}return a[o]=n}}])&&d(e.prototype,r),n&&d(e,n),t}(),g=86400;function w(t,e){var r=t,n=Array.isArray(r),o=0;for(r=n?r:r[Symbol.iterator]();;){var a;if(n){if(o>=r.length)break;a=r[o++]}else{if((o=r.next()).done)break;a=o.value}var i=a;if(i.unit===e)return i}}function S(t){return t instanceof Date?t:new Date(t)}var k=[{factor:1,unit:"now"},{threshold:1,threshold_for_now:45,factor:1,unit:"second"},{threshold:45,factor:60,unit:"minute"},{threshold:150,factor:60,granularity:5,unit:"minute"},{threshold:1350,factor:1800,unit:"half-hour"},{threshold:2550,threshold_for_minute:3150,factor:3600,unit:"hour"},{threshold:73800,factor:g,unit:"day"},{threshold:475200,factor:7*g,unit:"week"},{threshold:2116800,factor:2630016,unit:"month"},{threshold:27615168,factor:31556952,unit:"year"}];function O(t){return(O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function j(t){return(j="function"==typeof Symbol&&"symbol"===O(Symbol.iterator)?function(t){return O(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":O(t)})(t)}function M(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:k;if(0!==(n=function(t,e){return t.filter(function(t){var r=t.unit;return!r||e.indexOf(r)>=0})}(n,r)).length){var o=function t(e,r,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(Math.abs(e)<function(t,e,r,n){var o;t&&(t.id||t.unit)&&(o=e["threshold_for_".concat(t.id||t.unit)]);void 0===o&&(o=e.threshold);"function"==typeof o&&(o=o(r,n));if(t&&"number"!=typeof o){var a=j(o);throw new Error('Each step of a gradation must have a threshold defined except for the first one. Got "'.concat(o,'", ').concat(a,". Step: ").concat(JSON.stringify(e)))}return o}(n[o-1],n[o],r,e<0))return o-1;if(o===n.length-1)return o;return t(e,r,n,o+1)}(t,e,n),a=n[o];if(-1!==o){if(a.granularity)if(0===Math.round(Math.abs(t)/a.factor/a.granularity)*a.granularity&&o>0)return n[o-1];return a}}}function D(t){return(D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function F(t){return(F="function"==typeof Symbol&&"symbol"===D(Symbol.iterator)?function(t){return D(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":D(t)})(t)}function x(t){if(T())return Intl.DateTimeFormat.supportedLocalesOf(t)[0]}function T(){return"object"===("undefined"==typeof Intl?"undefined":F(Intl))&&"function"==typeof Intl.DateTimeFormat}var L={gradation:k,flavour:["long-convenient","long"],units:["now","minute","hour","day","week","month","year"]},E=[{factor:1,unit:"now"},{threshold:.5,factor:1,unit:"second"},{threshold:59.5,factor:60,unit:"minute"},{threshold:3570,factor:3600,unit:"hour"},{threshold:84600,factor:g,unit:"day"},{threshold:561600,factor:7*g,unit:"week"},{threshold:2116800,factor:2630016,unit:"month"},{threshold:30245184,factor:31556952,unit:"year"}];function I(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var P={},_={gradation:[function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),n.forEach(function(e){I(t,e,r[e])})}return t}({},w(E,"minute"),{threshold:45}),w(E,"hour"),{threshold:84600,format:function(t,e){if(T())return P[e]||(P[e]={}),P[e].this_year||(P[e].this_year=new Intl.DateTimeFormat(e,{month:"short",day:"numeric"})),P[e].this_year.format(S(t))}},{threshold:function(t,e){return e?(new Date(new Date(t).getFullYear()+1,0).getTime()-t)/1e3:(t-new Date(new Date(t).getFullYear(),0).getTime())/1e3},format:function(t,e){if(T())return P[e]||(P[e]={}),P[e].other||(P[e].other=new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric"})),P[e].other.format(S(t))}}],flavour:["tiny","short-time","narrow","short"]},N={gradation:k,flavour:"long-time",units:["now","minute","hour","day","week","month","year"]},R={};function A(t){return R[t]}function C(t){return(C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function q(t){return(q="function"==typeof Symbol&&"symbol"===C(Symbol.iterator)?function(t){return C(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":C(t)})(t)}function U(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var V=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),"string"==typeof e&&(e=[e]),this.locale=function(t,e){var r=t,n=Array.isArray(r),o=0;for(r=n?r:r[Symbol.iterator]();;){var a;if(n){if(o>=r.length)break;a=r[o++]}else{if((o=r.next()).done)break;a=o.value}var i=a;if(e(i))return i;for(var u=i.split("-");u.length>1;)if(u.pop(),e(i=u.join("-")))return i}throw new Error("No locale data has been registered for any of the locales: ".concat(t.join(", ")))}(e.concat(m.getDefaultLocale()),A),"undefined"!=typeof Intl&&Intl.NumberFormat&&(this.numberFormat=new Intl.NumberFormat(this.locale)),this.relativeTimeFormatCache=new v}var e,r,n;return e=t,(r=[{key:"format",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:L;if("string"==typeof e)switch(e){case"twitter":e=_;break;case"time":e=N;break;default:e=L}var r=function(t){if(t.constructor===Date||(e=t,"object"===q(e)&&"function"==typeof e.getTime))return{date:t,time:t.getTime()};var e;if("number"==typeof t)return{time:t};throw new Error("Unsupported relative time formatter input: ".concat(q(t),", ").concat(t))}(t),n=r.date,o=r.time,a=this.getLocaleData(e.flavour),i=a.flavour,u=a.localeData,l=e.now||Date.now(),f=(l-o)/1e3;if(e.custom){var c=e.custom({now:l,date:n,time:o,elapsed:f,locale:this.locale});if(void 0!==c)return c}var s=function(t,e){var r=Object.keys(t);e&&(r=e.filter(function(t){return r.indexOf(t)>=0}));(!e||e.indexOf("now")>=0)&&r.indexOf("now")<0&&t.second.current&&r.unshift("now");return r}(u,e.units);if(0===s.length)return console.error('Units "'.concat(s.join(", "),'" were not found in locale data for "').concat(this.locale,'".')),"";var h=M(f,l,s,e.gradation);if(!h)return"";if(h.format)return h.format(n||o,this.locale);var y=h.unit,m=h.factor,p=h.granularity,b=Math.abs(f)/m;if(p&&(b=Math.round(b/p)*p),"now"===y)return function(t,e){if(t.now)return"string"==typeof t.now?t.now:e<=0?t.now.past:t.now.future;return t.second.current}(u,-1*Math.sign(f));switch(i){case"long":case"short":case"narrow":return this.getFormatter(i).format(-1*Math.sign(f)*Math.round(b),y);default:return this.formatValue(-1*Math.sign(f)*Math.round(b),y,u)}}},{key:"formatValue",value:function(t,e,r){return this.getRule(t,e,r).replace("{0}",this.formatNumber(Math.abs(t)))}},{key:"getRule",value:function(t,e,r){var n=r[e];if("string"==typeof n)return n;var o=n[t<=0?"past":"future"]||n;if("string"==typeof o)return o;var a=A(this.locale).quantify,i=a&&a(Math.abs(t));return o[i=i||"other"]||o.other}},{key:"formatNumber",value:function(t){return this.numberFormat?this.numberFormat.format(t):String(t)}},{key:"getFormatter",value:function(t){return this.relativeTimeFormatCache.get(this.locale,t)||this.relativeTimeFormatCache.put(this.locale,t,new m(this.locale,{style:t}))}},{key:"getLocaleData",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=A(this.locale);"string"==typeof t&&(t=[t]);var r=t=t.concat("long"),n=Array.isArray(r),o=0;for(r=n?r:r[Symbol.iterator]();;){var a;if(n){if(o>=r.length)break;a=r[o++]}else{if((o=r.next()).done)break;a=o.value}var i=a;if(e[i])return{flavour:i,localeData:e[i]}}}}])&&U(e.prototype,r),n&&U(e,n),t}();V.getDefaultLocale=m.getDefaultLocale,V.setDefaultLocale=m.setDefaultLocale,V.addLocale=function(t){!function(t){if(!t)throw new Error("[javascript-time-ago] No locale data passed.");R[t.locale]=t}(t),m.addLocale(t)},V.locale=V.addLocale,r.d(e,"default",function(){return V}),r.d(e,"intlDateTimeFormatSupported",function(){return T}),r.d(e,"intlDateTimeFormatSupportedLocale",function(){return x})}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("javascript-time-ago",[],e):"object"==typeof exports?exports["javascript-time-ago"]=e():t["javascript-time-ago"]=e()}(window,function(){return function(t){var e={};function r(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(o,n,function(e){return t[e]}.bind(null,n));return o},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([,function(t,e,r){"use strict";r.r(e);var o="en",n={};function a(){return o}function i(t){return n[t]}function u(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).localeMatcher||"lookup";switch(e){case"lookup":case"best fit":return l(t);default:throw new RangeError('Invalid "localeMatcher" option: '.concat(e))}}function l(t){if(i(t))return t;for(var e=t.split("-");t.length>1;)if(e.pop(),i(t=e.join("-")))return t}function f(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function c(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var s=["second","minute","hour","day","week","month","quarter","year"],h=["auto","always"],y=["long","short","narrow"],m=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),c(this,"numeric","always"),c(this,"style","long"),c(this,"localeMatcher","lookup");var o=r.numeric,n=r.style,i=r.localeMatcher;if(o){if(h.indexOf(o)<0)throw new RangeError('Invalid "numeric" option: '.concat(o));this.numeric=o}if(n){if(y.indexOf(n)<0)throw new RangeError('Invalid "style" option: '.concat(n));this.style=n}if(i&&(this.localeMatcher=i),"string"==typeof e&&(e=[e]),e.push(a()),this.locale=t.supportedLocalesOf(e,{localeMatcher:this.localeMatcher})[0],!this.locale)throw new TypeError("No supported locale was found");this.locale=u(this.locale,{localeMatcher:this.localeMatcher}),"undefined"!=typeof Intl&&Intl.NumberFormat&&(this.numberFormat=new Intl.NumberFormat(this.locale))}var e,r,o;return e=t,(r=[{key:"format",value:function(t,e){return this.getRule(t,e).replace("{0}",this.formatNumber(Math.abs(t)))}},{key:"formatToParts",value:function(t,e){var r=this.getRule(t,e),o=r.indexOf("{0}");if(o<0)return[{type:"literal",value:r}];var n=[];return o>0&&n.push({type:"literal",value:r.slice(0,o)}),n.push({unit:e,type:"integer",value:this.formatNumber(Math.abs(t))}),o+"{0}".length<r.length-1&&n.push({type:"literal",value:r.slice(o+"{0}".length)}),n}},{key:"getRule",value:function(t,e){if(s.indexOf(e)<0)throw new RangeError("Unknown time unit: ".concat(e,"."));var r=i(this.locale)[this.style][e];if("auto"===this.numeric)if(-2===t||-1===t){var o=r["previous".concat(-1===t?"":"-"+Math.abs(t))];if(o)return o}else if(1===t||2===t){var n=r["next".concat(1===t?"":"-"+Math.abs(t))];if(n)return n}else if(0===t&&r.current)return r.current;var a=r[t<=0?"past":"future"];if("string"==typeof a)return a;var u=i(this.locale).quantify,l=u&&u(Math.abs(t));return a[l=l||"other"]||a.other}},{key:"formatNumber",value:function(t){return this.numberFormat?this.numberFormat.format(t):String(t)}},{key:"resolvedOptions",value:function(){return{locale:this.locale,style:this.style,numeric:this.numeric}}}])&&f(e.prototype,r),o&&f(e,o),t}();function p(t){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function b(t){return(b="function"==typeof Symbol&&"symbol"===p(Symbol.iterator)?function(t){return p(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":p(t)})(t)}function d(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}m.supportedLocalesOf=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof t&&(t=[t]),t.filter(function(t){return u(t,e)})},m.addLocale=function(t){if(!t)throw new Error("No locale data passed");n[t.locale]=t},m.setDefaultLocale=function(t){o=t},m.getDefaultLocale=a;var v=function(){function t(){var e,r,o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),o={},(r="cache")in(e=this)?Object.defineProperty(e,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[r]=o}var e,r,o;return e=t,(r=[{key:"get",value:function(){for(var t=this.cache,e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];for(var n=0;n<r.length;n++){var a=r[n];if("object"!==b(t))return;t=t[a]}return t}},{key:"put",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];for(var o=e.pop(),n=e.pop(),a=this.cache,i=0;i<e.length;i++){var u=e[i];"object"!==b(a[u])&&(a[u]={}),a=a[u]}return a[n]=o}}])&&d(e.prototype,r),o&&d(e,o),t}(),g=86400;function w(t,e){var r=t,o=Array.isArray(r),n=0;for(r=o?r:r[Symbol.iterator]();;){var a;if(o){if(n>=r.length)break;a=r[n++]}else{if((n=r.next()).done)break;a=n.value}var i=a;if(i.unit===e)return i}}function S(t){return t instanceof Date?t:new Date(t)}var k=[{factor:1,unit:"now"},{threshold:1,threshold_for_now:45,factor:1,unit:"second"},{threshold:45,factor:60,unit:"minute"},{threshold:150,factor:60,granularity:5,unit:"minute"},{threshold:1350,factor:1800,unit:"half-hour"},{threshold:2550,threshold_for_minute:3150,factor:3600,unit:"hour"},{threshold:73800,factor:g,unit:"day"},{threshold:475200,factor:7*g,unit:"week"},{threshold:2116800,factor:2630016,unit:"month"},{threshold:27615168,factor:31556952,unit:"year"}];function O(t){return(O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function j(t){return(j="function"==typeof Symbol&&"symbol"===O(Symbol.iterator)?function(t){return O(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":O(t)})(t)}function M(t,e,r){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:k;if(0!==(o=function(t,e){return t.filter(function(t){var r=t.unit;return!r||e.indexOf(r)>=0})}(o,r)).length){var n=function t(e,r,o){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;if(Math.abs(e)<function(t,e,r,o){var n;t&&(t.id||t.unit)&&(n=e["threshold_for_".concat(t.id||t.unit)]);void 0===n&&(n=e.threshold);"function"==typeof n&&(n=n(r,o));if(t&&"number"!=typeof n){var a=j(n);throw new Error('Each step of a gradation must have a threshold defined except for the first one. Got "'.concat(n,'", ').concat(a,". Step: ").concat(JSON.stringify(e)))}return n}(o[n-1],o[n],r,e<0))return n-1;if(n===o.length-1)return n;return t(e,r,o,n+1)}(t,e,o),a=o[n];if(-1!==n){if(a.granularity)if(0===Math.round(Math.abs(t)/a.factor/a.granularity)*a.granularity&&n>0)return o[n-1];return a}}}function D(t){return(D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function F(t){return(F="function"==typeof Symbol&&"symbol"===D(Symbol.iterator)?function(t){return D(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":D(t)})(t)}function x(t){if(T())return Intl.DateTimeFormat.supportedLocalesOf(t)[0]}function T(){return"object"===("undefined"==typeof Intl?"undefined":F(Intl))&&"function"==typeof Intl.DateTimeFormat}var L={gradation:k,flavour:["long-convenient","long"],units:["now","minute","hour","day","week","month","year"]},E=[{factor:1,unit:"now"},{threshold:.5,factor:1,unit:"second"},{threshold:59.5,factor:60,unit:"minute"},{threshold:3570,factor:3600,unit:"hour"},{threshold:84600,factor:g,unit:"day"},{threshold:561600,factor:7*g,unit:"week"},{threshold:2116800,factor:2630016,unit:"month"},{threshold:30245184,factor:31556952,unit:"year"}];function I(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),o.forEach(function(e){P(t,e,r[e])})}return t}function P(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var _={},N={gradation:[I({},w(E,"minute"),{threshold:59.5}),I({},w(E,"hour"),{threshold:3570}),{threshold:84600,format:function(t,e){if(T())return _[e]||(_[e]={}),_[e].this_year||(_[e].this_year=new Intl.DateTimeFormat(e,{month:"short",day:"numeric"})),_[e].this_year.format(S(t))}},{threshold:function(t,e){return e?(new Date(new Date(t).getFullYear()+1,0).getTime()-t)/1e3:(t-new Date(new Date(t).getFullYear(),0).getTime())/1e3},format:function(t,e){if(T())return _[e]||(_[e]={}),_[e].other||(_[e].other=new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric"})),_[e].other.format(S(t))}}],flavour:["tiny","short-time","narrow","short"]},R={gradation:k,flavour:"long-time",units:["now","minute","hour","day","week","month","year"]},A={};function C(t){return A[t]}function q(t){return(q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function U(t){return(U="function"==typeof Symbol&&"symbol"===q(Symbol.iterator)?function(t){return q(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":q(t)})(t)}function V(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}var Y=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),"string"==typeof e&&(e=[e]),this.locale=function(t,e){var r=t,o=Array.isArray(r),n=0;for(r=o?r:r[Symbol.iterator]();;){var a;if(o){if(n>=r.length)break;a=r[n++]}else{if((n=r.next()).done)break;a=n.value}var i=a;if(e(i))return i;for(var u=i.split("-");u.length>1;)if(u.pop(),e(i=u.join("-")))return i}throw new Error("No locale data has been registered for any of the locales: ".concat(t.join(", ")))}(e.concat(m.getDefaultLocale()),C),"undefined"!=typeof Intl&&Intl.NumberFormat&&(this.numberFormat=new Intl.NumberFormat(this.locale)),this.relativeTimeFormatCache=new v}var e,r,o;return e=t,(r=[{key:"format",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:L;if("string"==typeof e)switch(e){case"twitter":e=N;break;case"time":e=R;break;default:e=L}var r=function(t){if(t.constructor===Date||(e=t,"object"===U(e)&&"function"==typeof e.getTime))return{date:t,time:t.getTime()};var e;if("number"==typeof t)return{time:t};throw new Error("Unsupported relative time formatter input: ".concat(U(t),", ").concat(t))}(t),o=r.date,n=r.time,a=this.getLocaleData(e.flavour),i=a.flavour,u=a.localeData,l=e.now||Date.now(),f=(l-n)/1e3;if(e.custom){var c=e.custom({now:l,date:o,time:n,elapsed:f,locale:this.locale});if(void 0!==c)return c}var s=function(t,e){var r=Object.keys(t);e&&(r=e.filter(function(t){return r.indexOf(t)>=0}));(!e||e.indexOf("now")>=0)&&r.indexOf("now")<0&&t.second.current&&r.unshift("now");return r}(u,e.units);if(0===s.length)return console.error('Units "'.concat(s.join(", "),'" were not found in locale data for "').concat(this.locale,'".')),"";var h=M(f,l,s,e.gradation);if(!h)return"";if(h.format)return h.format(o||n,this.locale);var y=h.unit,m=h.factor,p=h.granularity,b=Math.abs(f)/m;if(p&&(b=Math.round(b/p)*p),"now"===y)return function(t,e){if(t.now)return"string"==typeof t.now?t.now:e<=0?t.now.past:t.now.future;return t.second.current}(u,-1*Math.sign(f));switch(i){case"long":case"short":case"narrow":return this.getFormatter(i).format(-1*Math.sign(f)*Math.round(b),y);default:return this.formatValue(-1*Math.sign(f)*Math.round(b),y,u)}}},{key:"formatValue",value:function(t,e,r){return this.getRule(t,e,r).replace("{0}",this.formatNumber(Math.abs(t)))}},{key:"getRule",value:function(t,e,r){var o=r[e];if("string"==typeof o)return o;var n=o[t<=0?"past":"future"]||o;if("string"==typeof n)return n;var a=C(this.locale).quantify,i=a&&a(Math.abs(t));return n[i=i||"other"]||n.other}},{key:"formatNumber",value:function(t){return this.numberFormat?this.numberFormat.format(t):String(t)}},{key:"getFormatter",value:function(t){return this.relativeTimeFormatCache.get(this.locale,t)||this.relativeTimeFormatCache.put(this.locale,t,new m(this.locale,{style:t}))}},{key:"getLocaleData",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=C(this.locale);"string"==typeof t&&(t=[t]);var r=t=t.concat("long"),o=Array.isArray(r),n=0;for(r=o?r:r[Symbol.iterator]();;){var a;if(o){if(n>=r.length)break;a=r[n++]}else{if((n=r.next()).done)break;a=n.value}var i=a;if(e[i])return{flavour:i,localeData:e[i]}}}}])&&V(e.prototype,r),o&&V(e,o),t}();Y.getDefaultLocale=m.getDefaultLocale,Y.setDefaultLocale=m.setDefaultLocale,Y.addLocale=function(t){!function(t){if(!t)throw new Error("[javascript-time-ago] No locale data passed.");A[t.locale]=t}(t),m.addLocale(t)},Y.locale=Y.addLocale,r.d(e,"default",function(){return Y}),r.d(e,"intlDateTimeFormatSupported",function(){return T}),r.d(e,"intlDateTimeFormatSupportedLocale",function(){return x})}])});
//# sourceMappingURL=javascript-time-ago.min.js.map

@@ -28,5 +28,9 @@ "use strict";

_objectSpread({}, (0, _gradation.getStep)(_gradation.canonical, 'minute'), {
threshold: 45
// Starts showing `1m` after `59s`.
threshold: 59.5
}), // Hours
(0, _gradation.getStep)(_gradation.canonical, 'hour'), // If `date` and `now` happened the same year,
_objectSpread({}, (0, _gradation.getStep)(_gradation.canonical, 'hour'), {
// After `59m` it will show `1h`.
threshold: 59.5 * 60
}), // If `date` and `now` happened the same year,
// then only output month and day.

@@ -33,0 +37,0 @@ {

@@ -31,4 +31,4 @@ "use strict";

elapsed(0).should.equal('');
elapsed(44.9).should.equal('');
elapsed(45.1).should.equal('1m');
elapsed(59.4).should.equal('');
elapsed(59.6).should.equal('1m');
elapsed(1.49 * 60).should.equal('1m');

@@ -68,4 +68,5 @@ elapsed(1.51 * 60).should.equal('2m');

elapsed(45.1).should.equal('1м');
elapsed(59.51 * 60).should.equal('1ч');
elapsed(0).should.equal('');
elapsed(59.51).should.equal('1 мин');
elapsed(59.51 * 60).should.equal('1 ч');
elapsed(_gradation.day + 62 * 60).should.equal('9 апр.');

@@ -84,3 +85,3 @@ elapsed(_gradation.year).should.equal('11 апр. 2015 г.');

elapsed(45.1).should.equal('1분');
elapsed(59.51).should.equal('1분');
elapsed(59.51 * 60).should.equal('1시간'); // elapsed(day + 62 * 60).should.equal('9 апр.')

@@ -87,0 +88,0 @@ // elapsed(year).should.equal('11 апр. 2015 г.')

{
"year": "{0}г",
"month": "{0}мес",
"week": "{0}нед",
"day": "{0}д",
"hour": "{0}ч",
"minute": "{0}м",
"second": "{0}с"
"year": {
"many": "{0} л",
"other": "{0} г"
},
"month": "{0} мес",
"week": "{0} нед",
"day": "{0} д",
"hour": "{0} ч",
"minute": "{0} мин",
"second": "{0} с"
}

@@ -19,5 +19,9 @@ 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; }

_objectSpread({}, getStep(canonical, 'minute'), {
threshold: 45
// Starts showing `1m` after `59s`.
threshold: 59.5
}), // Hours
getStep(canonical, 'hour'), // If `date` and `now` happened the same year,
_objectSpread({}, getStep(canonical, 'hour'), {
// After `59m` it will show `1h`.
threshold: 59.5 * 60
}), // If `date` and `now` happened the same year,
// then only output month and day.

@@ -24,0 +28,0 @@ {

@@ -24,4 +24,4 @@ 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; }

elapsed(0).should.equal('');
elapsed(44.9).should.equal('');
elapsed(45.1).should.equal('1m');
elapsed(59.4).should.equal('');
elapsed(59.6).should.equal('1m');
elapsed(1.49 * 60).should.equal('1m');

@@ -61,4 +61,5 @@ elapsed(1.51 * 60).should.equal('2m');

elapsed(45.1).should.equal('1м');
elapsed(59.51 * 60).should.equal('1ч');
elapsed(0).should.equal('');
elapsed(59.51).should.equal('1 мин');
elapsed(59.51 * 60).should.equal('1 ч');
elapsed(day + 62 * 60).should.equal('9 апр.');

@@ -77,3 +78,3 @@ elapsed(year).should.equal('11 апр. 2015 г.');

elapsed(45.1).should.equal('1분');
elapsed(59.51).should.equal('1분');
elapsed(59.51 * 60).should.equal('1시간'); // elapsed(day + 62 * 60).should.equal('9 апр.')

@@ -80,0 +81,0 @@ // elapsed(year).should.equal('11 апр. 2015 г.')

{
"name": "javascript-time-ago",
"version": "2.0.8",
"version": "2.0.9",
"description": "International highly customizable relative date/time formatting",

@@ -5,0 +5,0 @@ "main": "index.commonjs.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc