🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@coverbase/time

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coverbase/time - npm Package Compare versions

Package was removed
Sorry, it seems this package was removed from the registry
Comparing version
0.0.2
to
0.0.3
+1
-197
dist/index.js

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

var f = (j) => {
const q = j instanceof Date ? j : new Date(j),
w = new Intl.RelativeTimeFormat("en"),
A = {
years: 31536000,
months: 2592000,
weeks: 604800,
days: 86400,
hours: 3600,
minutes: 60,
seconds: 1,
},
B = (q.getTime() - Date.now()) / 1000;
for (let F in A)
if (A[F] < Math.abs(B)) {
const G = B / A[F];
return w.format(Math.round(G), F);
}
},
_ = (j, q) => {
const w = new Date(j),
A = w.getDate(),
B = new Date(w.getTime());
B.setMonth(w.getMonth() + q + 1, 0);
const F = B.getDate();
if (A >= F) return B;
else w.setFullYear(B.getFullYear(), B.getMonth(), A);
return w;
},
$ = (j, q) => {
const w = new Date(j);
return w.setDate(w.getDate() + q), w;
},
R = (j, q) => {
return T(j, q * 3600000);
},
Q = (j, q) => {
return T(j, q * 60000);
},
O = (j, q) => {
return T(j, q * 1000);
},
T = (j, q) => {
return new Date(j.getTime() + q);
},
W = (j) => {
const q = new Date(j);
return q.setDate(1), q.setHours(0, 0, 0, 0), q;
},
E = (j) => {
const q = new Date(j);
return q.setHours(0, 0, 0, 0), q;
},
I = (j) => {
const q = new Date(j);
return q.setMinutes(0, 0, 0), q;
},
S = (j) => {
const q = new Date(j);
return q.setSeconds(0, 0), q;
},
y = (j) => {
const q = new Date(j);
return q.setMilliseconds(0), q;
};
var H = [
{ name: "minute", min: 0, max: 59 },
{ name: "hour", min: 0, max: 23 },
{ name: "day", min: 1, max: 31 },
{ name: "month", min: 0, max: 11 },
{ name: "weekday", min: 0, max: 6 },
];
var J = (j) => {
if (typeof j === "string") {
const q = j.trim();
if (/^\d+$/.test(q)) {
const w = Number(q);
if (!isNaN(w) && isFinite(w)) return w;
}
} else if (typeof j === "number") {
if (!isNaN(j) && isFinite(j) && j === Math.floor(j)) return j;
}
return;
},
U = (j, q) => {
const w = new Array();
for (let A = j; A <= q; A++) w.push(A);
return w;
},
N = (j) => {
return j.reduce((q, w) => q.concat(w), []);
};
var v = (j, q) => {
const w = q.split(" ");
if (w.length === 5) {
const [A, B, F, G, K] = w.map((L, P) => C(L, H[P]));
let z = Q(new Date(j), 1);
z.setSeconds(0), z.setMilliseconds(0);
let k = 24,
X = !1,
Y = !1,
Z = !1;
while (--k) {
while (G.indexOf(z.getMonth()) === -1) z = W(_(z, 1));
const L = z.getMonth();
while (F.indexOf(z.getDate()) === -1 || K.indexOf(z.getDay()) === -1)
if (((z = E($(z, 1))), L !== z.getMonth())) {
X = !0;
break;
}
if (!X) {
const P = z.getDate();
while (B.indexOf(z.getHours()) === -1)
if (((z = I(R(z, 1))), P !== z.getDate())) {
Y = !0;
break;
}
if (!Y) {
const b = z.getHours();
while (A.indexOf(z.getMinutes()) === -1)
if (((z = S(Q(z, 1))), b !== z.getHours())) {
Z = !0;
break;
}
if (!Z) break;
}
}
}
return z.setSeconds(0), z.setMilliseconds(0), z;
}
},
C = (j, q) => {
const w = j.split(",").map((A) => {
const B = A.split("/");
if (B.length > 2) throw new Error(`Invalid value "${j}"`);
let F;
const G = B[0],
K = B[1];
if (G === "*") F = U(q.min, q.max);
else F = D(G);
const z = V(K);
return c(F, z);
});
return [...new Set(N(w))].sort((A, B) => A - B);
},
D = (j) => {
const q = j.split("-");
if (q.length === 1) {
const w = J(q[0]);
if (w === void 0) throw new Error("Invalid value");
return [w];
} else if (q.length === 2) {
const w = J(q[0]),
A = J(q[1]);
if (w === void 0 || A === void 0) throw new Error("Invalid value");
if (A < w) throw new Error(`Max range is less than min range in "${j}"`);
return U(w, A);
} else throw new Error(`Invalid value "${j}"`);
},
V = (j) => {
if (j) {
const q = J(j);
if (q === void 0) throw new Error(`Invalid interval step value "${j}"`);
return q;
}
return 0;
},
c = (j, q) => {
if (q) {
const w = j[0];
j = j.filter((A) => A % q === w % q || A === w);
}
return j;
};
export {
H as units,
V as toStep,
D as toRange,
C as toPart,
J as toNumber,
c as toInterval,
f as timeSince,
y as startOfSecond,
W as startOfMonth,
S as startOfMinute,
I as startOfHour,
E as startOfDay,
U as range,
v as nextSchedule,
N as flatten,
O as addSeconds,
_ as addMonths,
Q as addMinutes,
T as addMilliseconds,
R as addHours,
$ as addDays,
};
var O=(w)=>{const j=w instanceof Date?w:new Date(w),q=new Intl.RelativeTimeFormat("en"),A={years:31536000,months:2592000,weeks:604800,days:86400,hours:3600,minutes:60,seconds:1},B=(j.getTime()-Date.now())/1000;for(let F in A)if(A[F]<Math.abs(B)){const G=B/A[F];return q.format(Math.round(G),F)}},_=(w,j)=>{const q=new Date(w),A=q.getDate(),B=new Date(q.getTime());B.setMonth(q.getMonth()+j+1,0);const F=B.getDate();if(A>=F)return B;else q.setFullYear(B.getFullYear(),B.getMonth(),A);return q},$=(w,j)=>{const q=new Date(w);return q.setDate(q.getDate()+j),q},E=(w,j)=>{return T(w,j*3600000)},S=(w,j)=>{return T(w,j*60000)},y=(w,j)=>{return T(w,j*1000)},T=(w,j)=>{return new Date(w.getTime()+j)},P=(w)=>{const j=new Date(w);return j.setDate(1),j.setHours(0,0,0,0),j},R=(w)=>{const j=new Date(w);return j.setHours(0,0,0,0),j},W=(w)=>{const j=new Date(w);return j.setMinutes(0,0,0),j},H=(w)=>{const j=new Date(w);return j.setSeconds(0,0),j},f=(w)=>{const j=new Date(w);return j.setMilliseconds(0),j};var I=[{name:"minute",min:0,max:59},{name:"hour",min:0,max:23},{name:"day",min:1,max:31},{name:"month",min:0,max:11},{name:"weekday",min:0,max:6}];var J=(w)=>{if(typeof w==="string"){const j=w.trim();if(/^\d+$/.test(j)){const q=Number(j);if(!isNaN(q)&&isFinite(q))return q}}else if(typeof w==="number"){if(!isNaN(w)&&isFinite(w)&&w===Math.floor(w))return w}return},U=(w,j)=>{const q=new Array;for(let A=w;A<=j;A++)q.push(A);return q},k=(w)=>{return w.reduce((j,q)=>j.concat(q),[])};var v=(w,j)=>{const q=j.split(" ");if(q.length===5){const[A,B,F,G,K]=q.map((L,Q)=>C(L,I[Q]));let z=S(new Date(w),1);z.setSeconds(0),z.setMilliseconds(0);let N=24,X=!1,Y=!1,Z=!1;while(--N){while(G.indexOf(z.getMonth())===-1)z=P(_(z,1));const L=z.getMonth();while(F.indexOf(z.getDate())===-1||K.indexOf(z.getDay())===-1)if(z=R($(z,1)),L!==z.getMonth()){X=!0;break}if(!X){const Q=z.getDate();while(B.indexOf(z.getHours())===-1)if(z=W(E(z,1)),Q!==z.getDate()){Y=!0;break}if(!Y){const b=z.getHours();while(A.indexOf(z.getMinutes())===-1)if(z=H(S(z,1)),b!==z.getHours()){Z=!0;break}if(!Z)break}}}return z.setSeconds(0),z.setMilliseconds(0),z}},C=(w,j)=>{const q=w.split(",").map((A)=>{const B=A.split("/");if(B.length>2)throw new Error(`Invalid value "${w}"`);let F;const G=B[0],K=B[1];if(G==="*")F=U(j.min,j.max);else F=D(G);const z=V(K);return c(F,z)});return[...new Set(k(q))].sort((A,B)=>A-B)},D=(w)=>{const j=w.split("-");if(j.length===1){const q=J(j[0]);if(q===void 0)throw new Error("Invalid value");return[q]}else if(j.length===2){const q=J(j[0]),A=J(j[1]);if(q===void 0||A===void 0)throw new Error("Invalid value");if(A<q)throw new Error(`Max range is less than min range in "${w}"`);return U(q,A)}else throw new Error(`Invalid value "${w}"`)},V=(w)=>{if(w){const j=J(w);if(j===void 0)throw new Error(`Invalid interval step value "${w}"`);return j}return 0},c=(w,j)=>{if(j){const q=w[0];w=w.filter((A)=>A%j===q%j||A===q)}return w};export{I as units,V as toStep,D as toRange,C as toPart,J as toNumber,c as toInterval,O as timeSince,f as startOfSecond,P as startOfMonth,H as startOfMinute,W as startOfHour,R as startOfDay,U as range,v as nextSchedule,k as flatten,y as addSeconds,_ as addMonths,S as addMinutes,T as addMilliseconds,E as addHours,$ as addDays};
+1
-1
{
"name": "@coverbase/time",
"version": "0.0.2",
"version": "0.0.3",
"type": "module",

@@ -5,0 +5,0 @@ "exports": {