UNPKG

outers

Version:

outers - a all in one package for your day to day use

279 lines 12.1 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Millenia = exports.Centuries = exports.Decades = exports.Years = exports.Months = exports.Weeks = exports.Days = exports.Hours = exports.Minutes = exports.Seconds = exports.Ms = void 0; /** * Executes a given function repeatedly at a specified interval. * @param Function The function to be executed. * @param ms The interval in milliseconds at which the function should be executed. * @param firstEffect Determines whether the function should be executed immediately or not. * @returns A function that can be used to clear the interval when needed. */ const Ms = (Function, ms, firstEffect) => __awaiter(void 0, void 0, void 0, function* () { const executeFunction = () => __awaiter(void 0, void 0, void 0, function* () { try { yield Function(); } catch (error) { console.error("Error occurred during function execution:", error); } }); if (firstEffect === true) { yield executeFunction(); } const intervalId = setInterval(executeFunction, ms); // Returning a function to clear the interval when needed return () => clearInterval(intervalId); }); exports.Ms = Ms; /** * Executes a given function repeatedly at a specified interval. * * @param Function - The function to be executed. * @param Seconds - The interval in seconds at which the function should be executed. * @param firstEffect - A boolean indicating whether the function should be executed immediately. * @returns A function that can be used to clear the interval. */ const Seconds = (Function, Seconds, firstEffect) => __awaiter(void 0, void 0, void 0, function* () { const executeFunction = () => __awaiter(void 0, void 0, void 0, function* () { try { yield Function(); } catch (error) { console.error("Error occurred during function execution:", error); } }); if (firstEffect === true) { yield executeFunction(); } const intervalId = setInterval(executeFunction, Seconds * 1000); // Returning a function to clear the interval when needed return () => clearInterval(intervalId); }); exports.Seconds = Seconds; /** * Executes a given function repeatedly at a specified interval. * * @param Function - The function to be executed. * @param Minutes - The interval in minutes at which the function should be executed. * @param firstEffect - A boolean indicating whether the function should be executed immediately. * @returns A function that can be used to clear the interval when needed. */ const Minutes = (Function, Minutes, firstEffect) => __awaiter(void 0, void 0, void 0, function* () { const executeFunction = () => __awaiter(void 0, void 0, void 0, function* () { try { yield Function(); } catch (error) { console.error("Error occurred during function execution:", error); } }); if (firstEffect === true) { yield executeFunction(); } const intervalId = setInterval(executeFunction, Minutes * 60 * 1000); // Returning a function to clear the interval when needed return () => clearInterval(intervalId); }); exports.Minutes = Minutes; /** * Executes a given function at regular intervals. * @param Function - The function to be executed. * @param Hours - The interval duration in hours. * @param firstEffect - Determines whether to execute the function immediately or not. * @returns A function that can be used to clear the interval. */ const Hours = (Function, Hours, firstEffect) => __awaiter(void 0, void 0, void 0, function* () { const executeFunction = () => __awaiter(void 0, void 0, void 0, function* () { try { yield Function(); } catch (error) { console.error("Error occurred during function execution:", error); } }); if (firstEffect === true) { yield executeFunction(); } const intervalId = setInterval(executeFunction, Hours * 60 * 60 * 1000); // Returning a function to clear the interval when needed return () => clearInterval(intervalId); }); exports.Hours = Hours; /** * Executes a function repeatedly at a specified interval, with an optional initial execution. * @param Function - The function to be executed. * @param Days - The number of days between each execution of the function. * @param firstEffect - Determines whether the function should be executed immediately. * @returns A function that can be used to clear the interval. */ const Days = (Function, Days, firstEffect) => __awaiter(void 0, void 0, void 0, function* () { const executeFunction = () => __awaiter(void 0, void 0, void 0, function* () { try { yield Function(); } catch (error) { console.error("Error occurred during function execution:", error); } }); if (firstEffect === true) { yield executeFunction(); } const intervalId = setInterval(executeFunction, Days * 24 * 60 * 60 * 1000); // Returning a function to clear the interval when needed return () => clearInterval(intervalId); }); exports.Days = Days; /** * Executes a function repeatedly at a specified interval for a given number of weeks. * @param Function - The function to be executed. * @param Weeks - The number of weeks to repeat the function execution. * @param firstEffect - A boolean indicating whether to execute the function immediately. * @returns A function that can be used to clear the interval. */ const Weeks = (Function, Weeks, firstEffect) => __awaiter(void 0, void 0, void 0, function* () { const executeFunction = () => __awaiter(void 0, void 0, void 0, function* () { try { yield Function(); } catch (error) { console.error("Error occurred during function execution:", error); } }); if (firstEffect === true) { yield executeFunction(); } const intervalId = setInterval(executeFunction, Weeks * 7 * 24 * 60 * 60 * 1000); // Returning a function to clear the interval when needed return () => clearInterval(intervalId); }); exports.Weeks = Weeks; /** * Executes a function at regular intervals for a specified number of months. * @param Function - The function to be executed. * @param Months - The number of months between each execution of the function. * @param firstEffect - Determines whether the function should be executed immediately. * @returns A function that can be used to clear the interval. */ const Months = (Function, Months, firstEffect) => __awaiter(void 0, void 0, void 0, function* () { const executeFunction = () => __awaiter(void 0, void 0, void 0, function* () { try { yield Function(); } catch (error) { console.error("Error occurred during function execution:", error); } }); if (firstEffect === true) { yield executeFunction(); } const intervalId = setInterval(executeFunction, Months * 30 * 24 * 60 * 60 * 1000); // Returning a function to clear the interval when needed return () => clearInterval(intervalId); }); exports.Months = Months; /** * Executes a function periodically at specified intervals. * @param Function - The function to be executed. * @param Years - The number of years between each execution of the function. * @param firstEffect - A boolean indicating whether to execute the function immediately. * @returns A function that can be used to clear the interval. */ const Years = (Function, Years, firstEffect) => __awaiter(void 0, void 0, void 0, function* () { const executeFunction = () => __awaiter(void 0, void 0, void 0, function* () { try { yield Function(); } catch (error) { console.error("Error occurred during function execution:", error); } }); if (firstEffect === true) { yield executeFunction(); } const intervalId = setInterval(executeFunction, Years * 365 * 24 * 60 * 60 * 1000); // Returning a function to clear the interval when needed return () => clearInterval(intervalId); }); exports.Years = Years; /** * Executes a function repeatedly at a specified interval for a given number of decades. * @param Function - The function to be executed. * @param Decades - The number of decades to execute the function for. * @param firstEffect - A boolean indicating whether to execute the function immediately. * @returns A function that can be used to clear the interval. */ const Decades = (Function, Decades, firstEffect) => __awaiter(void 0, void 0, void 0, function* () { const executeFunction = () => __awaiter(void 0, void 0, void 0, function* () { try { yield Function(); } catch (error) { console.error("Error occurred during function execution:", error); } }); if (firstEffect === true) { yield executeFunction(); } const intervalId = setInterval(executeFunction, Decades * 10 * 365 * 24 * 60 * 60 * 1000); // Returning a function to clear the interval when needed return () => clearInterval(intervalId); }); exports.Decades = Decades; /** * Executes a given function periodically at specified intervals. * @param Function - The function to be executed. * @param Centuries - The number of centuries between each execution. * @param firstEffect - Determines whether the function should be executed immediately. * @returns A function that can be used to clear the interval. */ const Centuries = (Function, Centuries, firstEffect) => __awaiter(void 0, void 0, void 0, function* () { const executeFunction = () => __awaiter(void 0, void 0, void 0, function* () { try { yield Function(); } catch (error) { console.error("Error occurred during function execution:", error); } }); if (firstEffect === true) { yield executeFunction(); } const intervalId = setInterval(executeFunction, Centuries * 100 * 365 * 24 * 60 * 60 * 1000); // Returning a function to clear the interval when needed return () => clearInterval(intervalId); }); exports.Centuries = Centuries; /** * Executes a given function repeatedly at a specified interval. * @param Function - The function to be executed. * @param Millenia - The interval in milliseconds at which the function should be executed. * @param firstEffect - A boolean indicating whether the function should be executed immediately. * @returns A function that can be used to clear the interval. */ const Millenia = (Function, Millenia, firstEffect) => __awaiter(void 0, void 0, void 0, function* () { const executeFunction = () => __awaiter(void 0, void 0, void 0, function* () { try { yield Function(); } catch (error) { console.error("Error occurred during function execution:", error); } }); if (firstEffect === true) { yield executeFunction(); } const intervalId = setInterval(executeFunction, Millenia * 1000 * 365 * 24 * 60 * 60 * 1000); // Returning a function to clear the interval when needed return () => clearInterval(intervalId); }); exports.Millenia = Millenia; //# sourceMappingURL=Retry.function.js.map