New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@sapphire/time-utilities

Package Overview
Dependencies
Maintainers
0
Versions
932
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sapphire/time-utilities - npm Package Compare versions

Comparing version 1.7.13-next.d4ebe803.0 to 1.7.13-next.d8701971

98

dist/iife/index.global.js

@@ -7,3 +7,3 @@ var SapphireTimeUtilities = (function (exports) {

// ../utilities/dist/esm/chunk-G5GHKT7C.mjs
// ../utilities/dist/esm/chunk-PAWJFY3S.mjs
var __defProp2 = Object.defineProperty;

@@ -23,6 +23,3 @@ var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");

var __name3 = /* @__PURE__ */ __name((target, value) => __defProp3(target, "name", { value, configurable: true }), "__name");
var __publicField = /* @__PURE__ */ __name((obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
}, "__publicField");
var __publicField = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value), "__publicField");
var partRegex = /^(?:(\*)|(\d+)(?:-(\d+))?)(?:\/(\d+))?$/;

@@ -96,11 +93,8 @@ var wildcardRegex = /\bh\b|\B\?\B/g;

}
if (!origin)
return new Date(Date.UTC(outset.getUTCFullYear(), outset.getUTCMonth(), outset.getUTCDate(), this.hours[0], this.minutes[0]));
if (!origin) return new Date(Date.UTC(outset.getUTCFullYear(), outset.getUTCMonth(), outset.getUTCDate(), this.hours[0], this.minutes[0]));
const now = new Date(outset.getTime() + 6e4);
for (const hour of this.hours) {
if (hour < now.getUTCHours())
continue;
if (hour < now.getUTCHours()) continue;
for (const minute of this.minutes) {
if (hour === now.getUTCHours() && minute < now.getUTCMinutes())
continue;
if (hour === now.getUTCHours() && minute < now.getUTCMinutes()) continue;
return new Date(Date.UTC(outset.getUTCFullYear(), outset.getUTCMonth(), outset.getUTCDate(), hour, minute));

@@ -115,2 +109,10 @@ }

/**
* Returns the string that represents this cron pattern
*
* @returns The string that represents this cron pattern
*/
toString() {
return this.cron;
}
/**
* Normalize the pattern

@@ -120,9 +122,7 @@ * @param cron The pattern to normalize

static normalize(cron) {
if (Reflect.has(predefined, cron))
return Reflect.get(predefined, cron);
if (Reflect.has(predefined, cron)) return Reflect.get(predefined, cron);
const now = /* @__PURE__ */ new Date();
cron = cron.split(" ").map(
(val, i) => val.replace(wildcardRegex, (match) => {
if (match === "h")
return (Math.floor(Math.random() * allowedNum[i][1]) + allowedNum[i][0]).toString();
if (match === "h") return (Math.floor(Math.random() * allowedNum[i][1]) + allowedNum[i][0]).toString();
if (match === "?") {

@@ -153,4 +153,3 @@ switch (i) {

const parts = cron.split(" ");
if (parts.length !== 5)
throw new Error("Invalid Cron Provided");
if (parts.length !== 5) throw new Error("Invalid Cron Provided");
return parts.map((part, i) => _a.parsePart(part, i));

@@ -166,4 +165,3 @@ }

const res = [];
for (const part of cronPart.split(","))
res.push(..._a.parsePart(part, id));
for (const part of cronPart.split(",")) res.push(..._a.parsePart(part, id));
return [...new Set(res)].sort((a, b) => a - b);

@@ -173,6 +171,4 @@ }

let [min, max] = [parseInt(minStr, 10), parseInt(maxStr, 10)];
if (wild)
[min, max] = allowedNum[id];
else if (!max && !step)
return [min];
if (wild) [min, max] = allowedNum[id];
else if (!max && !step) return [min];
[min, max] = [min, max || allowedNum[id][1]].sort((a, b) => a - b);

@@ -189,6 +185,3 @@ return range(min, max, parseInt(step, 10) || 1);

var __name4 = /* @__PURE__ */ __name((target, value) => __defProp4(target, "name", { value, configurable: true }), "__name");
var __publicField2 = /* @__PURE__ */ __name((obj, key, value) => {
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
}, "__publicField");
var __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value), "__publicField");
var Time = /* @__PURE__ */ ((Time2) => {

@@ -568,13 +561,10 @@ Time2[Time2["Nanosecond"] = 1e-6] = "Nanosecond";

const negative = duration < 0;
if (negative)
duration *= -1;
if (negative) duration *= -1;
for (const [type, timeDuration] of kTimeDurations) {
const division = duration / timeDuration;
if (division < 1)
continue;
if (division < 1) continue;
const floored = Math.floor(division);
duration -= floored * timeDuration;
output.push(addUnit(floored, this.units[type], leftSeparator));
if (output.length >= precision)
break;
if (output.length >= precision) break;
}

@@ -587,4 +577,3 @@ return `${negative ? "-" : ""}${output.join(rightSeparator) || addUnit(0, this.units.second, leftSeparator)}`;

function addUnit(time, unit, separator) {
if (Reflect.has(unit, time))
return `${time}${separator}${Reflect.get(unit, time)}`;
if (Reflect.has(unit, time)) return `${time}${separator}${Reflect.get(unit, time)}`;
return `${time}${separator}${unit.DEFAULT}`;

@@ -599,6 +588,3 @@ }

var __name5 = /* @__PURE__ */ __name((target, value) => __defProp5(target, "name", { value, configurable: true }), "__name");
var __publicField3 = /* @__PURE__ */ __name((obj, key, value) => {
__defNormalProp3(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
}, "__publicField");
var __publicField3 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp3(obj, typeof key !== "symbol" ? key + "" : key, value), "__publicField");
var _a4;

@@ -651,6 +637,4 @@ var _TimerManager = (_a4 = class extends null {

static destroy() {
for (const i of this.storedTimeouts)
clearTimeout(i);
for (const i of this.storedIntervals)
clearInterval(i);
for (const i of this.storedTimeouts) clearTimeout(i);
for (const i of this.storedIntervals) clearInterval(i);
this.storedTimeouts.clear();

@@ -669,6 +653,3 @@ this.storedIntervals.clear();

var __name6 = /* @__PURE__ */ __name((target, value) => __defProp6(target, "name", { value, configurable: true }), "__name");
var __publicField4 = /* @__PURE__ */ __name((obj, key, value) => {
__defNormalProp4(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
}, "__publicField");
var __publicField4 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp4(obj, typeof key !== "symbol" ? key + "" : key, value), "__publicField");
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];

@@ -722,8 +703,5 @@ var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

const day = String(time.getDate());
if (day !== "11" && day.endsWith("1"))
return `${day}st`;
if (day !== "12" && day.endsWith("2"))
return `${day}nd`;
if (day !== "13" && day.endsWith("3"))
return `${day}rd`;
if (day !== "11" && day.endsWith("1")) return `${day}st`;
if (day !== "12" && day.endsWith("2")) return `${day}nd`;
if (day !== "13" && day.endsWith("3")) return `${day}rd`;
return `${day}th`;

@@ -888,4 +866,3 @@ }

const parsedTime = _a5.resolveDate(time);
for (const { content, type } of template)
output += content || tokenResolvers.get(type)(parsedTime);
for (const { content, type } of template) output += content || tokenResolvers.get(type)(parsedTime);
return output;

@@ -906,8 +883,6 @@ }

current += currentChar;
while (pattern[i + 1] === currentChar && current.length < tokenMax)
current += pattern[++i];
while (pattern[i + 1] === currentChar && current.length < tokenMax) current += pattern[++i];
template.push({ type: current, content: null });
} else if (currentChar === "[") {
while (i + 1 < pattern.length && pattern[i + 1] !== "]")
current += pattern[++i];
while (i + 1 < pattern.length && pattern[i + 1] !== "]") current += pattern[++i];
i++;

@@ -917,4 +892,3 @@ template.push({ type: "literal", content: current || "[" });

current += currentChar;
while (i + 1 < pattern.length && !tokens2.has(pattern[i + 1]) && pattern[i + 1] !== "[")
current += pattern[++i];
while (i + 1 < pattern.length && !tokens2.has(pattern[i + 1]) && pattern[i + 1] !== "[") current += pattern[++i];
template.push({ type: "literal", content: current });

@@ -959,3 +933,3 @@ }

})({});
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.global.js.map
//# sourceMappingURL=index.global.js.map
{
"name": "@sapphire/time-utilities",
"version": "1.7.13-next.d4ebe803.0",
"version": "1.7.13-next.d8701971",
"description": "A time utility library for JavaScript.",

@@ -13,2 +13,3 @@ "author": "@sapphire",

"exports": {
"browser": "./dist/iife/index.global.js",
"import": {

@@ -21,4 +22,3 @@ "types": "./dist/esm/index.d.mts",

"default": "./dist/cjs/index.cjs"
},
"browser": "./dist/iife/index.global.js"
}
},

@@ -30,3 +30,3 @@ "sideEffects": false,

"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"build:rename-cjs-index": "tsx ../../scripts/rename-cjs-index.cts",
"docs": "typedoc-json-parser",

@@ -72,9 +72,9 @@ "prepack": "yarn build",

"devDependencies": {
"@favware/cliff-jumper": "^3.0.3",
"tsup": "^8.0.2",
"tsx": "^4.10.5",
"@favware/cliff-jumper": "^5.0.0",
"tsup": "^8.3.5",
"tsx": "^4.19.2",
"typedoc": "^0.25.13",
"typedoc-json-parser": "^10.0.0",
"typescript": "^5.4.5"
"typedoc-json-parser": "^10.1.6",
"typescript": "~5.4.5"
}
}

@@ -10,3 +10,2 @@ <div align="center">

[![GitHub](https://img.shields.io/github/license/sapphiredev/utilities)](https://github.com/sapphiredev/utilities/blob/main/LICENSE.md)
[![codecov](https://codecov.io/gh/sapphiredev/utilities/branch/main/graph/badge.svg?token=OEGIV6RFDO)](https://codecov.io/gh/sapphiredev/utilities)
[![npm bundle size](https://img.shields.io/bundlephobia/min/@sapphire/time-utilities?logo=webpack&style=flat-square)](https://bundlephobia.com/result?p=@sapphire/time-utilities)

@@ -13,0 +12,0 @@ [![npm](https://img.shields.io/npm/v/@sapphire/time-utilities?color=crimson&logo=npm&style=flat-square)](https://www.npmjs.com/package/@sapphire/time-utilities)

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc