npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@saverious/cronjob

v3.0.1

Published

A scheduler to define the time when a task or tasks should execute

Readme

@saverious/cronjob

A job scheduler to define time when a task or tasks should execute

Installation

   npm i @saverious/cronjob

Usage

ESM syntax

    /**
     * cron.addJob      - returns jobID as string
     * cron.addSchedule - returns scheduleID as string
    */
    import { Cron } from '@saverious/cronjob';

    function add(a, b) {
        console.log(`a: ${a}\nb: ${b}`);
        console.log('sum: ', a + b);
    }

    function main () {
        const now = new Date();
        const time = {
            year: now.getFullYear(),
            month: now.getMonth() + 1,
            day: now.getDate(),
            hour: now.getHours(),
            minute: now.getMinutes() + 1
        };

        const cron = new Cron({executeMissedSchedules: false});
        const jobID = cron.addJob('add', () => add(3, 4));
        cron.addSchedule(jobID, time);
        cron.runScheduler();
    }

    main();

CJS syntax

    /**
     * cron.addJob      - returns jobID as string
     * cron.addSchedule - returns scheduleID as string
    */
    const { Cron } = require('@saverious/cronjob');

    function add(a, b) {
        console.log(`a: ${a}\nb: ${b}`);
        console.log('sum: ', a + b);
    }

    function main () {
        const now = new Date();
        const time = {
            year: now.getFullYear(),
            month: now.getMonth() + 1,
            day: now.getDate(),
            hour: now.getHours(),
            minute: now.getMinutes() + 1
        };

        const cron = new Cron({executeMissedSchedules: false});
        const jobID = cron.addJob('add', () => add(3, 4));
        cron.addSchedule(jobID, time);
        cron.runScheduler();
    }

    main();

Cron class

This library exposes a class - Cron - that is used to handle the scheduling. Cron is declared with an optional argument - {executeMissedSchedules: boolean} - that defines how skipped tasks are handled.

const cron = new Cron({executeMissedSchedules: false});

In this case, skipped tasks are those whose time of schedule has passed without them being executed.

Passing true: The skipped task will be executed
Passing false: The skipped task will be deleted

If no argument is defined, the 'executeMissedSchedules' flag defaults to false. The default operation is deletion of the skipped task.

Methods

Cron.addJob(jobName: string, func: Function)

This method defines the name of the task you want to schedule and its corresponding function. The name must be unique. The function returns a job id that uniquely identifies the task.

const jobID = cron.addJob('add', () => add(3, 4));

NOTE: Multiple jobs can be defined too. For instance:

// ... define cron Class
const jobID1 = cron.addJob('job1', () => add(3, 4));
const jobID2 = cron.addJob('job2', () => multiply(3, 4));
const jobID3 = cron.addJob('job3', () => subtract(3, 4));
// ... continue

Cron.addSchedule(jobID: string, time: Object)

This method defines the specific time you want the task to run. The task is identified by the job id from Cron.addJob(). This job id is passed to Cron.addSchedule() as the first parameter.

const scheduleID = cron.addSchedule(jobID, time);

The method returns a schedule id that uniquely identifies the schedule.

NOTE: Multiple schedules can be defined for a single job. For example:

// ... define cron Class and schedules(time)
cron.addSchedule(job1, time1);
cron.addSchedule(job1, time2);
cron.addSchedule(job1, time3);
// ... continue

cron.runScheduler()

This method starts the scheduler. It listens for each schedule and executes each task when its respective scheduled time is reached.

cron.runScheduler();