Comparing version 0.2.0 to 0.2.1
@@ -0,1 +1,2 @@ | ||
declare const getSeconds: (duration: string) => number; | ||
declare const getDuration: (duration: string) => { | ||
@@ -9,4 +10,3 @@ value: number; | ||
}; | ||
declare const getSeconds: (duration: string) => number; | ||
export { datePlus, divide, getDuration, getSeconds }; |
@@ -1,1 +0,1 @@ | ||
var c=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var m=(t,s)=>{for(var e in s)c(t,e,{get:s[e],enumerable:!0})},y=(t,s,e,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of w(s))!x.call(t,o)&&o!==e&&c(t,o,{get:()=>s[o],enumerable:!(n=v(s,o))||n.enumerable});return t};var M=t=>y(c({},"__esModule",{value:!0}),t);var b={};m(b,{datePlus:()=>a,divide:()=>l,getDuration:()=>u,getSeconds:()=>$});module.exports=M(b);var u=t=>{let s=t.match(/^(?<strValue>[\d.]+)?\s?(?<unit>\w+?)s?$/),{strValue:e,unit:n}=s.groups;return{value:+(e===void 0?1:e),unit:n}},a=(t,s)=>{let e=t.split(/,?\s*and\s*|,\s*/),n=s||new Date;for(let o of e){let{value:d,unit:i}=u(o),p={Days:"Date",Weeks:"Date",Years:"Month",Months:"Month"},g={Weeks:7,Years:12},r=i.charAt(0).toUpperCase()+i.slice(1)+"s",D=g[r]||1;r=p[r]||r;let[f,h]=[`get${r}`,`set${r}`];n=new Date(n[h](n[f]()+d*D))}return n},l=t=>({by:s=>{let e=+new Date,n=+a(t)-e,o=+a(s)-e;return n/o}}),$=t=>l(t).by("seconds");0&&(module.exports={datePlus,divide,getDuration,getSeconds}); | ||
var a=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var D=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},p=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of f(t))!w.call(e,o)&&o!==n&&a(e,o,{get:()=>t[o],enumerable:!(s=g(t,o))||s.enumerable});return e};var x=e=>p(a({},"__esModule",{value:!0}),e);var v={};D(v,{datePlus:()=>h,divide:()=>m,getDuration:()=>l,getSeconds:()=>r});module.exports=x(v);var d={week:604800,day:86400,hour:3600,minute:60,second:1},r=e=>{let t=e.split(/,?\s*and\s*|,\s*/),n=new Date().setMilliseconds(0),s=n;for(let o of t){let{value:i,unit:c}=l(o);if(d[c])s+=d[c]*i*1e3;else{let u=new Date(s);s=+new Date(u.setMonth(u.getMonth()+i*(c==="year"?12:1)))}}return(s-n)/1e3},l=e=>{let t=e.toLowerCase().match(/^(?<strValue>[\d.]+)?\s?(?<unit>\w+?)s?$/),{strValue:n,unit:s}=t.groups;return{value:+(n===void 0?1:n),unit:s}},h=(e,t)=>{let n=new Date(t||null);return new Date(n.setSeconds(n.getSeconds()+r(e)))},m=e=>({by:t=>{let n=r(e),s=r(t);return n/s}});0&&(module.exports={datePlus,divide,getDuration,getSeconds}); |
{ | ||
"name": "itty-time", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Tiny (~530 bytes) time math library for beautiful date handling/TTLs within your APIs.", | ||
@@ -5,0 +5,0 @@ "sourceType": "module", |
Sorry, the diff of this file is not supported yet
10177