PHP 8.2.30
Preview: node-cron.js Size: 2.55 KB
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/node-cron/dist/cjs/node-cron.js

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.nodeCron = exports.getTask = exports.getTasks = void 0;
exports.schedule = schedule;
exports.createTask = createTask;
exports.solvePath = solvePath;
exports.validate = validate;
const inline_scheduled_task_1 = require("./tasks/inline-scheduled-task");
const task_registry_1 = require("./task-registry");
const pattern_validation_1 = __importDefault(require("./pattern/validation/pattern-validation"));
const background_scheduled_task_1 = __importDefault(require("./tasks/background-scheduled-task/background-scheduled-task"));
const path_1 = __importDefault(require("path"));
const url_1 = require("url");
const registry = new task_registry_1.TaskRegistry();
function schedule(expression, func, options) {
    const task = createTask(expression, func, options);
    task.start();
    return task;
}
function createTask(expression, func, options) {
    let task;
    if (func instanceof Function) {
        task = new inline_scheduled_task_1.InlineScheduledTask(expression, func, options);
    }
    else {
        const taskPath = solvePath(func);
        task = new background_scheduled_task_1.default(expression, taskPath, options);
    }
    registry.add(task);
    return task;
}
function solvePath(filePath) {
    if (path_1.default.isAbsolute(filePath))
        return (0, url_1.pathToFileURL)(filePath).href;
    if (filePath.startsWith('file://'))
        return filePath;
    const stackLines = new Error().stack?.split('\n');
    if (stackLines) {
        stackLines?.shift();
        const callerLine = stackLines?.find((line) => { return line.indexOf(__filename) === -1; });
        const match = callerLine?.match(/(file:\/\/)?(((\/?)(\w:))?([/\\].+)):\d+:\d+/);
        if (match) {
            const dir = `${match[5] ?? ""}${path_1.default.dirname(match[6])}`;
            return (0, url_1.pathToFileURL)(path_1.default.resolve(dir, filePath)).href;
        }
    }
    throw new Error(`Could not locate task file ${filePath}`);
}
function validate(expression) {
    try {
        (0, pattern_validation_1.default)(expression);
        return true;
    }
    catch (e) {
        return false;
    }
}
exports.getTasks = registry.all;
exports.getTask = registry.get;
exports.nodeCron = {
    schedule,
    createTask,
    validate,
    getTasks: exports.getTasks,
    getTask: exports.getTask,
};
exports.default = exports.nodeCron;
//# sourceMappingURL=node-cron.js.map

Directory Contents

Dirs: 5 × Files: 12

Name Size Perms Modified Actions
pattern DIR
- drwxr-xr-x 2026-02-21 00:53:58
Edit Download
promise DIR
- drwxr-xr-x 2026-02-21 00:54:22
Edit Download
scheduler DIR
- drwxr-xr-x 2026-02-21 00:54:22
Edit Download
tasks DIR
- drwxr-xr-x 2026-02-21 00:54:22
Edit Download
time DIR
- drwxr-xr-x 2026-02-21 00:54:22
Edit Download
76 B lrw-r--r-- 2026-02-21 00:54:12
Edit Download
663 B lrw-r--r-- 2026-02-21 00:53:38
Edit Download
517 B lrw-r--r-- 2026-02-21 00:54:04
Edit Download
226 B lrw-r--r-- 2026-02-21 00:54:20
Edit Download
1.46 KB lrw-r--r-- 2026-02-21 00:53:50
Edit Download
1.56 KB lrw-r--r-- 2026-02-21 00:54:04
Edit Download
964 B lrw-r--r-- 2026-02-21 00:54:20
Edit Download
2.55 KB lrw-r--r-- 2026-02-21 00:53:56
Edit Download
2.01 KB lrw-r--r-- 2026-02-21 00:54:06
Edit Download
361 B lrw-r--r-- 2026-02-21 00:54:22
Edit Download
837 B lrw-r--r-- 2026-02-21 00:54:00
Edit Download
1015 B lrw-r--r-- 2026-02-21 00:54:08
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).