UNPKG

outers

Version:

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

179 lines 7.05 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; /* eslint-disable @typescript-eslint/no-explicit-any */ /** * Executes the provided function after a specified delay. * @param func The function to be executed. * @param ms The delay in milliseconds. * @returns A promise that resolves after the delay and the function execution. */ const Ms = (func, ms) => __awaiter(void 0, void 0, void 0, function* () { return new Promise((resolve) => { setTimeout(() => __awaiter(void 0, void 0, void 0, function* () { yield func(); resolve(); }), ms); }); }); exports.Ms = Ms; /** * Delays the execution of a function by a specified number of seconds. * @param func - The function to be executed after the delay. * @param seconds - The number of seconds to delay the execution. * @returns A promise that resolves after the specified delay. */ const Seconds = (func, seconds) => { return new Promise((resolve) => { setTimeout(() => __awaiter(void 0, void 0, void 0, function* () { yield func(); resolve(); }), seconds * 1000); }); }; exports.Seconds = Seconds; /** * Delays the execution of a function for a specified number of minutes. * @param func - The function to be executed after the delay. * @param minutes - The number of minutes to delay the execution. * @returns A promise that resolves after the specified delay. */ const Minutes = (func, minutes) => { return new Promise((resolve) => { setTimeout(() => __awaiter(void 0, void 0, void 0, function* () { yield func(); resolve(); }), minutes * 60 * 1000); }); }; exports.Minutes = Minutes; /** * Delays the execution of a function for a specified number of hours. * @param func - The function to be executed after the delay. * @param hours - The number of hours to delay the execution. * @returns A promise that resolves after the specified delay. */ const Hours = (func, hours) => { return new Promise((resolve) => { setTimeout(() => __awaiter(void 0, void 0, void 0, function* () { yield func(); resolve(); }), hours * 60 * 60 * 1000); }); }; exports.Hours = Hours; /** * Delays the execution of a function for a specified number of days. * @param func - The function to be executed after the delay. * @param days - The number of days to delay the execution. * @returns A promise that resolves after the specified delay. */ const Days = (func, days) => { return new Promise((resolve) => { setTimeout(() => __awaiter(void 0, void 0, void 0, function* () { yield func(); resolve(); }), days * 24 * 60 * 60 * 1000); }); }; exports.Days = Days; /** * Delays the execution of a function for a specified number of weeks. * @param func - The function to be executed after the delay. * @param weeks - The number of weeks to delay the execution. * @returns A promise that resolves after the specified delay. */ const Weeks = (func, weeks) => { return new Promise((resolve) => { setTimeout(() => __awaiter(void 0, void 0, void 0, function* () { yield func(); resolve(); }), weeks * 7 * 24 * 60 * 60 * 1000); }); }; exports.Weeks = Weeks; /** * Delays the execution of a function for a specified number of months. * @param func - The function to be executed after the delay. * @param months - The number of months to delay the execution. * @returns A promise that resolves after the specified delay. */ const Months = (func, months) => { return new Promise((resolve) => { setTimeout(() => __awaiter(void 0, void 0, void 0, function* () { yield func(); resolve(); }), months * 30 * 24 * 60 * 60 * 1000); }); }; exports.Months = Months; /** * Delays the execution of a function for a specified number of years. * @param func - The function to be executed after the delay. * @param years - The number of years to delay the execution. * @returns A promise that resolves after the specified delay. */ const Years = (func, years) => { return new Promise((resolve) => { setTimeout(() => __awaiter(void 0, void 0, void 0, function* () { yield func(); resolve(); }), years * 365 * 24 * 60 * 60 * 1000); }); }; exports.Years = Years; /** * Delays the execution of a function for a specified number of decades. * @param func - The function to be executed after the delay. * @param decades - The number of decades to delay the execution. * @returns A promise that resolves after the specified delay. */ const Decades = (func, decades) => { return new Promise((resolve) => { setTimeout(() => __awaiter(void 0, void 0, void 0, function* () { yield func(); resolve(); }), decades * 10 * 365 * 24 * 60 * 60 * 1000); }); }; exports.Decades = Decades; /** * Delays the execution of a function for a specified number of centuries. * @param func - The function to be executed after the delay. * @param centuries - The number of centuries to delay the execution. * @returns A promise that resolves after the specified delay. */ const Centuries = (func, centuries) => { return new Promise((resolve) => { setTimeout(() => __awaiter(void 0, void 0, void 0, function* () { yield func(); resolve(); }), centuries * 100 * 365 * 24 * 60 * 60 * 1000); }); }; exports.Centuries = Centuries; /** * Delays the execution of a function for a specified number of millenia. * @param func - The function to be executed after the delay. * @param millenia - The number of millenia to delay the execution. * @returns A promise that resolves after the specified delay. */ const Millenia = (func, millenia) => { return new Promise((resolve) => { setTimeout(() => __awaiter(void 0, void 0, void 0, function* () { yield func(); resolve(); }), millenia * 1000 * 365 * 24 * 60 * 60 * 1000); }); }; exports.Millenia = Millenia; //# sourceMappingURL=Waiter.function.js.map