Socket
Socket
Sign inDemoInstall

@deveox/humanize

Package Overview
Dependencies
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deveox/humanize - npm Package Compare versions

Comparing version 0.1.48 to 0.1.49

22

CHANGELOG.md

@@ -0,1 +1,23 @@

### [0.1.49](https://github.com/deveox/humanize/compare/v0.1.48...v0.1.49) (2022-08-05)
### Bug Fixes
* **Dates:** added format validation ([1cb46ed](https://github.com/deveox/humanize/commit/1cb46ed835f817ca8ac35e029a500194b6b80a59))
* **Dates:** added format validation ([926c9b8](https://github.com/deveox/humanize/commit/926c9b852ba140ac88bc435f261acda4b3ce1f45))
### Continuous Integration
* **Github Actions:** add pull request check on synchronize ([4b6ddc7](https://github.com/deveox/humanize/commit/4b6ddc7008354aa9a689817d15424dcc0e20938d))
### Tests
* **Dates:** added tests ([ec36c41](https://github.com/deveox/humanize/commit/ec36c416616ba5d1144714181fb744f49fcf1505))
* **Dates:** added tests ([dc7bce6](https://github.com/deveox/humanize/commit/dc7bce6214476de7b279fbf9bd3972ac2248d1ff))
* **Dates:** removed broken test ([7c0f754](https://github.com/deveox/humanize/commit/7c0f7546482442e721422a3b34d0e3d3bfe8d023))
* **Dates:** removed broken test ([4a3f053](https://github.com/deveox/humanize/commit/4a3f053a5e51d856d567eddfe1817c638ce334c0))
### [0.1.48](https://github.com/deveox/humanize/compare/v0.1.47...v0.1.48) (2022-08-05)

@@ -2,0 +24,0 @@

2

dist/@deveox/humanize.iife.js

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

(function(Z){"use strict";const rt={Y:{exponent:24,word:"septillion",name:"yotta"},Z:{exponent:21,word:"sextillion",name:"zetta"},E:{exponent:18,word:"quintillion",name:"exa"},P:{exponent:15,word:"quadrillion",name:"peta"},T:{exponent:12,word:"trillion",name:"tera"},G:{exponent:9,word:"billion",name:"giga"},M:{exponent:6,word:"million",name:"mega"},k:{exponent:3,word:"thousand",name:"kilo"},h:{exponent:2,word:"hundred",name:"hecto"},da:{exponent:1,word:"ten",name:"deco"}};function it(a,p=1,l="symbol",u=rt){let h=st(a),f=!1;return h<0&&(f=!0,h=h<0n?-h:h),f?"-"+G(h,p,l,u):G(h,p,l,u)}function G(a,p,l,u){if(a>=1&&a<10)return String(a);let h="";u={...u};for(let f=0;f<p;f++){for(const M in u){const x=BigInt(10)**BigInt(u[M].exponent);if(a>=x){const O=a%x,m=a/x;h+=`${ot(Number(m),l,M,u)} `,O?a=O:a=BigInt(0),delete u[M];break}}if(!h)break}return a&&String(a).split("").forEach((f,M)=>{h+=f,(M+1)%3===0&&(h+=" ")}),h.trimEnd()}function ot(a,p,l,u){switch(p){case"word":return at(a,u[l].word);case"name":return`${a} ${u[l].name}`}return`${a} ${l}`}function st(a){switch(typeof a){case"bigint":return a;case"number":return BigInt(a);case"string":return BigInt(Number.parseFloat(a));default:throw new Error("invalid type provided")}}function at(a,p){return a===1?`${a} ${p}`:`${a} ${p}s`}var Q=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},K={exports:{}};(function(a,p){(function(l,u){a.exports=u()})(Q,function(){var l=1e3,u=6e4,h=36e5,f="millisecond",M="second",x="minute",O="hour",m="day",_="week",y="month",z="quarter",T="year",I="date",Y="Invalid Date",C=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,W=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,j={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},U=function(s,n,t){var r=String(s);return!r||r.length>=n?s:""+Array(n+1-r.length).join(t)+s},E={s:U,z:function(s){var n=-s.utcOffset(),t=Math.abs(n),r=Math.floor(t/60),e=t%60;return(n<=0?"+":"-")+U(r,2,"0")+":"+U(e,2,"0")},m:function s(n,t){if(n.date()<t.date())return-s(t,n);var r=12*(t.year()-n.year())+(t.month()-n.month()),e=n.clone().add(r,y),o=t-e<0,i=n.clone().add(r+(o?-1:1),y);return+(-(r+(t-e)/(o?e-i:i-e))||0)},a:function(s){return s<0?Math.ceil(s)||0:Math.floor(s)},p:function(s){return{M:y,y:T,w:_,d:m,D:I,h:O,m:x,s:M,ms:f,Q:z}[s]||String(s||"").toLowerCase().replace(/s$/,"")},u:function(s){return s===void 0}},b="en",D={};D[b]=j;var B=function(s){return s instanceof J},H=function s(n,t,r){var e;if(!n)return b;if(typeof n=="string"){var o=n.toLowerCase();D[o]&&(e=o),t&&(D[o]=t,e=o);var i=n.split("-");if(!e&&i.length>1)return s(i[0])}else{var d=n.name;D[d]=n,e=d}return!r&&e&&(b=e),e||!r&&b},v=function(s,n){if(B(s))return s.clone();var t=typeof n=="object"?n:{};return t.date=s,t.args=arguments,new J(t)},c=E;c.l=H,c.i=B,c.w=function(s,n){return v(s,{locale:n.$L,utc:n.$u,x:n.$x,$offset:n.$offset})};var J=function(){function s(t){this.$L=H(t.locale,null,!0),this.parse(t)}var n=s.prototype;return n.parse=function(t){this.$d=function(r){var e=r.date,o=r.utc;if(e===null)return new Date(NaN);if(c.u(e))return new Date;if(e instanceof Date)return new Date(e);if(typeof e=="string"&&!/Z$/i.test(e)){var i=e.match(C);if(i){var d=i[2]-1||0,g=(i[7]||"0").substring(0,3);return o?new Date(Date.UTC(i[1],d,i[3]||1,i[4]||0,i[5]||0,i[6]||0,g)):new Date(i[1],d,i[3]||1,i[4]||0,i[5]||0,i[6]||0,g)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},n.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},n.$utils=function(){return c},n.isValid=function(){return this.$d.toString()!==Y},n.isSame=function(t,r){var e=v(t);return this.startOf(r)<=e&&e<=this.endOf(r)},n.isAfter=function(t,r){return v(t)<this.startOf(r)},n.isBefore=function(t,r){return this.endOf(r)<v(t)},n.$g=function(t,r,e){return c.u(t)?this[r]:this.set(e,t)},n.unix=function(){return Math.floor(this.valueOf()/1e3)},n.valueOf=function(){return this.$d.getTime()},n.startOf=function(t,r){var e=this,o=!!c.u(r)||r,i=c.p(t),d=function(A,S){var L=c.w(e.$u?Date.UTC(e.$y,S,A):new Date(e.$y,S,A),e);return o?L:L.endOf(m)},g=function(A,S){return c.w(e.toDate()[A].apply(e.toDate("s"),(o?[0,0,0,0]:[23,59,59,999]).slice(S)),e)},$=this.$W,w=this.$M,N=this.$D,k="set"+(this.$u?"UTC":"");switch(i){case T:return o?d(1,0):d(31,11);case y:return o?d(1,w):d(0,w+1);case _:var F=this.$locale().weekStart||0,V=($<F?$+7:$)-F;return d(o?N-V:N+(6-V),w);case m:case I:return g(k+"Hours",0);case O:return g(k+"Minutes",1);case x:return g(k+"Seconds",2);case M:return g(k+"Milliseconds",3);default:return this.clone()}},n.endOf=function(t){return this.startOf(t,!1)},n.$set=function(t,r){var e,o=c.p(t),i="set"+(this.$u?"UTC":""),d=(e={},e[m]=i+"Date",e[I]=i+"Date",e[y]=i+"Month",e[T]=i+"FullYear",e[O]=i+"Hours",e[x]=i+"Minutes",e[M]=i+"Seconds",e[f]=i+"Milliseconds",e)[o],g=o===m?this.$D+(r-this.$W):r;if(o===y||o===T){var $=this.clone().set(I,1);$.$d[d](g),$.init(),this.$d=$.set(I,Math.min(this.$D,$.daysInMonth())).$d}else d&&this.$d[d](g);return this.init(),this},n.set=function(t,r){return this.clone().$set(t,r)},n.get=function(t){return this[c.p(t)]()},n.add=function(t,r){var e,o=this;t=Number(t);var i=c.p(r),d=function(w){var N=v(o);return c.w(N.date(N.date()+Math.round(w*t)),o)};if(i===y)return this.set(y,this.$M+t);if(i===T)return this.set(T,this.$y+t);if(i===m)return d(1);if(i===_)return d(7);var g=(e={},e[x]=u,e[O]=h,e[M]=l,e)[i]||1,$=this.$d.getTime()+t*g;return c.w($,this)},n.subtract=function(t,r){return this.add(-1*t,r)},n.format=function(t){var r=this,e=this.$locale();if(!this.isValid())return e.invalidDate||Y;var o=t||"YYYY-MM-DDTHH:mm:ssZ",i=c.z(this),d=this.$H,g=this.$m,$=this.$M,w=e.weekdays,N=e.months,k=function(S,L,q,P){return S&&(S[L]||S(r,o))||q[L].slice(0,P)},F=function(S){return c.s(d%12||12,S,"0")},V=e.meridiem||function(S,L,q){var P=S<12?"AM":"PM";return q?P.toLowerCase():P},A={YY:String(this.$y).slice(-2),YYYY:this.$y,M:$+1,MM:c.s($+1,2,"0"),MMM:k(e.monthsShort,$,N,3),MMMM:k(N,$),D:this.$D,DD:c.s(this.$D,2,"0"),d:String(this.$W),dd:k(e.weekdaysMin,this.$W,w,2),ddd:k(e.weekdaysShort,this.$W,w,3),dddd:w[this.$W],H:String(d),HH:c.s(d,2,"0"),h:F(1),hh:F(2),a:V(d,g,!0),A:V(d,g,!1),m:String(g),mm:c.s(g,2,"0"),s:String(this.$s),ss:c.s(this.$s,2,"0"),SSS:c.s(this.$ms,3,"0"),Z:i};return o.replace(W,function(S,L){return L||A[S]||i.replace(":","")})},n.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},n.diff=function(t,r,e){var o,i=c.p(r),d=v(t),g=(d.utcOffset()-this.utcOffset())*u,$=this-d,w=c.m(this,d);return w=(o={},o[T]=w/12,o[y]=w,o[z]=w/3,o[_]=($-g)/6048e5,o[m]=($-g)/864e5,o[O]=$/h,o[x]=$/u,o[M]=$/l,o)[i]||$,e?w:c.a(w)},n.daysInMonth=function(){return this.endOf(y).$D},n.$locale=function(){return D[this.$L]},n.locale=function(t,r){if(!t)return this.$L;var e=this.clone(),o=H(t,r,!0);return o&&(e.$L=o),e},n.clone=function(){return c.w(this.$d,this)},n.toDate=function(){return new Date(this.valueOf())},n.toJSON=function(){return this.isValid()?this.toISOString():null},n.toISOString=function(){return this.$d.toISOString()},n.toString=function(){return this.$d.toUTCString()},s}(),nt=J.prototype;return v.prototype=nt,[["$ms",f],["$s",M],["$m",x],["$H",O],["$W",m],["$M",y],["$y",T],["$D",I]].forEach(function(s){nt[s[1]]=function(n){return this.$g(n,s[0],s[1])}}),v.extend=function(s,n){return s.$i||(s(n,J,v),s.$i=!0),v},v.locale=H,v.isDayjs=B,v.unix=function(s){return v(1e3*s)},v.en=D[b],v.Ls=D,v.p={},v})})(K);const X=K.exports;var tt={exports:{}};(function(a,p){(function(l,u){a.exports=u()})(Q,function(){return function(l,u,h){l=l||{};var f=u.prototype,M={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function x(m,_,y,z){return f.fromToBase(m,_,y,z)}h.en.relativeTime=M,f.fromToBase=function(m,_,y,z,T){for(var I,Y,C,W=y.$locale().relativeTime||M,j=l.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],U=j.length,E=0;E<U;E+=1){var b=j[E];b.d&&(I=z?h(m).diff(y,b.d,!0):y.diff(m,b.d,!0));var D=(l.rounding||Math.round)(Math.abs(I));if(C=I>0,D<=b.r||!b.r){D<=1&&E>0&&(b=j[E-1]);var B=W[b.l];T&&(D=T(""+D)),Y=typeof B=="string"?B.replace("%d",D):B(D,_,b.l,C);break}}if(_)return Y;var H=C?W.future:W.past;return typeof H=="function"?H(Y):H.replace("%s",Y)},f.to=function(m,_){return x(m,_,this,!0)},f.from=function(m,_){return x(m,_,this)};var O=function(m){return m.$u?h.utc():h()};f.toNow=function(m){return this.to(O(this),m)},f.fromNow=function(m){return this.from(O(this),m)}}})})(tt);const ut=tt.exports;X.extend(ut);function ft(a,p="date-time"){if(!a)return"never";const l=typeof a=="number"?new Date(a*1e3):new Date(a),u=X(l);if(u.year()<1800)return"centuries ago";let f;switch(p){case"period":f=u.fromNow();break;case"date":f=u.format("L");break;case"date-period":f=`${u.format("L")} (${u.fromNow()})`;break;case"time-period":f=`${u.format("L HH:mm:ss")} (${u.fromNow()})`;break;case"day":f=u.format("MMM DD");break;case"min":f=u.format("L HH:mm");break;case"time":f=`${u.format("HH:mm:ss")}`;break;default:f=u.format("L HH:mm:ss")}return f==="Invalid date"?"--":f}const dt="bytes should be positive number",ct="second argument is not valid unit",et=BigInt(1024),R=["b","kb","mb","gb","tb","ptb"];function ht(a=0,p="b"){if(a<0)throw new Error(dt);if(!R.includes(p))throw new Error(ct);let l=BigInt(Math.round(a));const u=R.indexOf(p),h=R.slice(u);let f=h[0];for(let M=0;M<h.length&&(f=h[M],l>=et);M++)l=l/et;return`${Math.round(Number(l)*100)/100} ${f.toUpperCase()}`}Z.formatDate=ft,Z.formatInt=it,Z.formatSize=ht,Object.defineProperties(Z,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})})(this["@deveox/humanize"]=this["@deveox/humanize"]||{});
(function(V){"use strict";const rt={Y:{exponent:24,word:"septillion",name:"yotta"},Z:{exponent:21,word:"sextillion",name:"zetta"},E:{exponent:18,word:"quintillion",name:"exa"},P:{exponent:15,word:"quadrillion",name:"peta"},T:{exponent:12,word:"trillion",name:"tera"},G:{exponent:9,word:"billion",name:"giga"},M:{exponent:6,word:"million",name:"mega"},k:{exponent:3,word:"thousand",name:"kilo"},h:{exponent:2,word:"hundred",name:"hecto"},da:{exponent:1,word:"ten",name:"deco"}};function it(a,y=1,l="symbol",u=rt){let h=st(a),f=!1;return h<0&&(f=!0,h=h<0n?-h:h),f?"-"+G(h,y,l,u):G(h,y,l,u)}function G(a,y,l,u){if(a>=1&&a<10)return String(a);let h="";u={...u};for(let f=0;f<y;f++){for(const M in u){const x=BigInt(10)**BigInt(u[M].exponent);if(a>=x){const O=a%x,m=a/x;h+=`${ot(Number(m),l,M,u)} `,O?a=O:a=BigInt(0),delete u[M];break}}if(!h)break}return a&&String(a).split("").forEach((f,M)=>{h+=f,(M+1)%3===0&&(h+=" ")}),h.trimEnd()}function ot(a,y,l,u){switch(y){case"word":return at(a,u[l].word);case"name":return`${a} ${u[l].name}`}return`${a} ${l}`}function st(a){switch(typeof a){case"bigint":return a;case"number":return BigInt(a);case"string":return BigInt(Number.parseFloat(a));default:throw new Error("invalid type provided")}}function at(a,y){return a===1?`${a} ${y}`:`${a} ${y}s`}var Q=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},K={exports:{}};(function(a,y){(function(l,u){a.exports=u()})(Q,function(){var l=1e3,u=6e4,h=36e5,f="millisecond",M="second",x="minute",O="hour",m="day",_="week",p="month",B="quarter",T="year",I="date",Y="Invalid Date",C=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,W=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,j={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},U=function(s,n,t){var r=String(s);return!r||r.length>=n?s:""+Array(n+1-r.length).join(t)+s},E={s:U,z:function(s){var n=-s.utcOffset(),t=Math.abs(n),r=Math.floor(t/60),e=t%60;return(n<=0?"+":"-")+U(r,2,"0")+":"+U(e,2,"0")},m:function s(n,t){if(n.date()<t.date())return-s(t,n);var r=12*(t.year()-n.year())+(t.month()-n.month()),e=n.clone().add(r,p),o=t-e<0,i=n.clone().add(r+(o?-1:1),p);return+(-(r+(t-e)/(o?e-i:i-e))||0)},a:function(s){return s<0?Math.ceil(s)||0:Math.floor(s)},p:function(s){return{M:p,y:T,w:_,d:m,D:I,h:O,m:x,s:M,ms:f,Q:B}[s]||String(s||"").toLowerCase().replace(/s$/,"")},u:function(s){return s===void 0}},b="en",D={};D[b]=j;var A=function(s){return s instanceof Z},H=function s(n,t,r){var e;if(!n)return b;if(typeof n=="string"){var o=n.toLowerCase();D[o]&&(e=o),t&&(D[o]=t,e=o);var i=n.split("-");if(!e&&i.length>1)return s(i[0])}else{var d=n.name;D[d]=n,e=d}return!r&&e&&(b=e),e||!r&&b},v=function(s,n){if(A(s))return s.clone();var t=typeof n=="object"?n:{};return t.date=s,t.args=arguments,new Z(t)},c=E;c.l=H,c.i=A,c.w=function(s,n){return v(s,{locale:n.$L,utc:n.$u,x:n.$x,$offset:n.$offset})};var Z=function(){function s(t){this.$L=H(t.locale,null,!0),this.parse(t)}var n=s.prototype;return n.parse=function(t){this.$d=function(r){var e=r.date,o=r.utc;if(e===null)return new Date(NaN);if(c.u(e))return new Date;if(e instanceof Date)return new Date(e);if(typeof e=="string"&&!/Z$/i.test(e)){var i=e.match(C);if(i){var d=i[2]-1||0,g=(i[7]||"0").substring(0,3);return o?new Date(Date.UTC(i[1],d,i[3]||1,i[4]||0,i[5]||0,i[6]||0,g)):new Date(i[1],d,i[3]||1,i[4]||0,i[5]||0,i[6]||0,g)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},n.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},n.$utils=function(){return c},n.isValid=function(){return this.$d.toString()!==Y},n.isSame=function(t,r){var e=v(t);return this.startOf(r)<=e&&e<=this.endOf(r)},n.isAfter=function(t,r){return v(t)<this.startOf(r)},n.isBefore=function(t,r){return this.endOf(r)<v(t)},n.$g=function(t,r,e){return c.u(t)?this[r]:this.set(e,t)},n.unix=function(){return Math.floor(this.valueOf()/1e3)},n.valueOf=function(){return this.$d.getTime()},n.startOf=function(t,r){var e=this,o=!!c.u(r)||r,i=c.p(t),d=function(z,S){var L=c.w(e.$u?Date.UTC(e.$y,S,z):new Date(e.$y,S,z),e);return o?L:L.endOf(m)},g=function(z,S){return c.w(e.toDate()[z].apply(e.toDate("s"),(o?[0,0,0,0]:[23,59,59,999]).slice(S)),e)},$=this.$W,w=this.$M,N=this.$D,k="set"+(this.$u?"UTC":"");switch(i){case T:return o?d(1,0):d(31,11);case p:return o?d(1,w):d(0,w+1);case _:var R=this.$locale().weekStart||0,F=($<R?$+7:$)-R;return d(o?N-F:N+(6-F),w);case m:case I:return g(k+"Hours",0);case O:return g(k+"Minutes",1);case x:return g(k+"Seconds",2);case M:return g(k+"Milliseconds",3);default:return this.clone()}},n.endOf=function(t){return this.startOf(t,!1)},n.$set=function(t,r){var e,o=c.p(t),i="set"+(this.$u?"UTC":""),d=(e={},e[m]=i+"Date",e[I]=i+"Date",e[p]=i+"Month",e[T]=i+"FullYear",e[O]=i+"Hours",e[x]=i+"Minutes",e[M]=i+"Seconds",e[f]=i+"Milliseconds",e)[o],g=o===m?this.$D+(r-this.$W):r;if(o===p||o===T){var $=this.clone().set(I,1);$.$d[d](g),$.init(),this.$d=$.set(I,Math.min(this.$D,$.daysInMonth())).$d}else d&&this.$d[d](g);return this.init(),this},n.set=function(t,r){return this.clone().$set(t,r)},n.get=function(t){return this[c.p(t)]()},n.add=function(t,r){var e,o=this;t=Number(t);var i=c.p(r),d=function(w){var N=v(o);return c.w(N.date(N.date()+Math.round(w*t)),o)};if(i===p)return this.set(p,this.$M+t);if(i===T)return this.set(T,this.$y+t);if(i===m)return d(1);if(i===_)return d(7);var g=(e={},e[x]=u,e[O]=h,e[M]=l,e)[i]||1,$=this.$d.getTime()+t*g;return c.w($,this)},n.subtract=function(t,r){return this.add(-1*t,r)},n.format=function(t){var r=this,e=this.$locale();if(!this.isValid())return e.invalidDate||Y;var o=t||"YYYY-MM-DDTHH:mm:ssZ",i=c.z(this),d=this.$H,g=this.$m,$=this.$M,w=e.weekdays,N=e.months,k=function(S,L,q,J){return S&&(S[L]||S(r,o))||q[L].slice(0,J)},R=function(S){return c.s(d%12||12,S,"0")},F=e.meridiem||function(S,L,q){var J=S<12?"AM":"PM";return q?J.toLowerCase():J},z={YY:String(this.$y).slice(-2),YYYY:this.$y,M:$+1,MM:c.s($+1,2,"0"),MMM:k(e.monthsShort,$,N,3),MMMM:k(N,$),D:this.$D,DD:c.s(this.$D,2,"0"),d:String(this.$W),dd:k(e.weekdaysMin,this.$W,w,2),ddd:k(e.weekdaysShort,this.$W,w,3),dddd:w[this.$W],H:String(d),HH:c.s(d,2,"0"),h:R(1),hh:R(2),a:F(d,g,!0),A:F(d,g,!1),m:String(g),mm:c.s(g,2,"0"),s:String(this.$s),ss:c.s(this.$s,2,"0"),SSS:c.s(this.$ms,3,"0"),Z:i};return o.replace(W,function(S,L){return L||z[S]||i.replace(":","")})},n.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},n.diff=function(t,r,e){var o,i=c.p(r),d=v(t),g=(d.utcOffset()-this.utcOffset())*u,$=this-d,w=c.m(this,d);return w=(o={},o[T]=w/12,o[p]=w,o[B]=w/3,o[_]=($-g)/6048e5,o[m]=($-g)/864e5,o[O]=$/h,o[x]=$/u,o[M]=$/l,o)[i]||$,e?w:c.a(w)},n.daysInMonth=function(){return this.endOf(p).$D},n.$locale=function(){return D[this.$L]},n.locale=function(t,r){if(!t)return this.$L;var e=this.clone(),o=H(t,r,!0);return o&&(e.$L=o),e},n.clone=function(){return c.w(this.$d,this)},n.toDate=function(){return new Date(this.valueOf())},n.toJSON=function(){return this.isValid()?this.toISOString():null},n.toISOString=function(){return this.$d.toISOString()},n.toString=function(){return this.$d.toUTCString()},s}(),nt=Z.prototype;return v.prototype=nt,[["$ms",f],["$s",M],["$m",x],["$H",O],["$W",m],["$M",p],["$y",T],["$D",I]].forEach(function(s){nt[s[1]]=function(n){return this.$g(n,s[0],s[1])}}),v.extend=function(s,n){return s.$i||(s(n,Z,v),s.$i=!0),v},v.locale=H,v.isDayjs=A,v.unix=function(s){return v(1e3*s)},v.en=D[b],v.Ls=D,v.p={},v})})(K);const X=K.exports;var tt={exports:{}};(function(a,y){(function(l,u){a.exports=u()})(Q,function(){return function(l,u,h){l=l||{};var f=u.prototype,M={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function x(m,_,p,B){return f.fromToBase(m,_,p,B)}h.en.relativeTime=M,f.fromToBase=function(m,_,p,B,T){for(var I,Y,C,W=p.$locale().relativeTime||M,j=l.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],U=j.length,E=0;E<U;E+=1){var b=j[E];b.d&&(I=B?h(m).diff(p,b.d,!0):p.diff(m,b.d,!0));var D=(l.rounding||Math.round)(Math.abs(I));if(C=I>0,D<=b.r||!b.r){D<=1&&E>0&&(b=j[E-1]);var A=W[b.l];T&&(D=T(""+D)),Y=typeof A=="string"?A.replace("%d",D):A(D,_,b.l,C);break}}if(_)return Y;var H=C?W.future:W.past;return typeof H=="function"?H(Y):H.replace("%s",Y)},f.to=function(m,_){return x(m,_,this,!0)},f.from=function(m,_){return x(m,_,this)};var O=function(m){return m.$u?h.utc():h()};f.toNow=function(m){return this.to(O(this),m)},f.fromNow=function(m){return this.from(O(this),m)}}})})(tt);const ut=tt.exports,ft="second argument is not valid format";X.extend(ut);const dt=["period","time","time-period","date","date-period","day","min","date-time"];function ct(a,y="date-time"){if(!a)return"never";if(!dt.includes(y))throw new Error(ft);const l=typeof a=="number"?new Date(a*1e3):new Date(a),u=X(l);if(u.year()<1800)return"centuries ago";let f;switch(y){case"period":f=u.fromNow();break;case"date":f=u.format("L");break;case"date-period":f=`${u.format("L")} (${u.fromNow()})`;break;case"time-period":f=`${u.format("L HH:mm:ss")} (${u.fromNow()})`;break;case"day":f=u.format("MMM DD");break;case"min":f=u.format("L HH:mm");break;case"time":f=`${u.format("HH:mm:ss")}`;break;default:f=u.format("L HH:mm:ss")}return f==="Invalid date"?"--":f}const ht="bytes should be positive number",lt="second argument is not valid unit",et=BigInt(1024),P=["b","kb","mb","gb","tb","ptb"];function mt(a=0,y="b"){if(a<0)throw new Error(ht);if(!P.includes(y))throw new Error(lt);let l=BigInt(Math.round(a));const u=P.indexOf(y),h=P.slice(u);let f=h[0];for(let M=0;M<h.length&&(f=h[M],l>=et);M++)l=l/et;return`${Math.round(Number(l)*100)/100} ${f.toUpperCase()}`}V.formatDate=ct,V.formatInt=it,V.formatSize=mt,Object.defineProperties(V,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})})(this["@deveox/humanize"]=this["@deveox/humanize"]||{});
{
"name": "@deveox/humanize",
"version": "0.1.48",
"version": "0.1.49",
"description": "Formats number, dates and file sizes as human readable strings",

@@ -5,0 +5,0 @@ "main": "./dist/@deveox/humanize.cjs",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc