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 🙏

© 2024 – Pkg Stats / Ryan Hefner

skedula

v1.0.3

Published

Easily schedule interval-based processes in Node.js!

Downloads

12

Readme

⏰ Skedula

Easily (node-cron-based) schedule interval-based processes in Node.js!

Why use Skedula over setInterval?

Skedula uses node-cron in the backend to schedule tasks when a CRON expression ticks, rather than waiting to execute a function using system time. This improves program efficiency greatly.

⬇ Installation

If you're using npm:

npm install skedula

Or, if you're using yarn:

yarn add skedula

💥 Usage

In JavaScript:

const { Skedula } = require('skedula')

// Log every second
const scheduledTask = Skedula.secondInterval(() => {
    console.log('This should log every second.')
}, 1)

// Stop in 5 seconds
setTimeout(() => { scheduledTask.stop() }, 5000)

In TypeScript:

import { Skedula } from 'skedula'

// Log every second
const scheduledTask = Skedula.secondInterval(() => {
    console.log('This should log every second.')
}, 1)

// Stop in 5 seconds
setTimeout(() => { scheduledTask.stop() }, 5000)

Documentation

Skedula Functions

secondInterval (returns void)

Run a function every n seconds.

  • callback ((..args:any[])=>void) The function to call.
  • every (number) The interval, in seconds.
  • ...args (any[]?) The arguments to pass into the function.

minuteInterval (returns void)

Run a function every n minutes.

  • callback ((..args:any[])=>void) The function to call.
  • every (number) The interval, in minutes.
  • ...args (any[]?) The arguments to pass into the function.

hourInterval (returns void)

Run a function every n hours.

  • callback ((..args:any[])=>void) The function to call.
  • every (number) The interval, in hours.
  • ...args (any[]?) The arguments to pass into the function.

dailyInterval (returns void)

Run a function every n days.

  • callback ((..args:any[])=>void) The function to call.
  • every (number) The interval, in days.
  • ...args (any[]?) The arguments to pass into the function.

schedule

Schedule a function called precisely at a certain time, range, or interval.

  • callback ((..args:any[])=>void) The function to call.
  • args (any[], default []) The arguments to pass into the function.
  • dayOfWeek (DayOfWeek or Interval<Range<DayOfWeek> or DayOfWeek or SkedulaWildcard> or Range<DayOfWeek> or SkedulaWildcard, default *) The day of the week to call the function. Leave undefined or null for every day of the week.
  • month (Month or Interval<Range<Month> or Month or SkedulaWildcard> or Range<Month> or SkedulaWildcard, default *) The month to call the function. Leave undefined or null for every month of the year.
  • day (Day or Interval<Range<Day> or Day or SkedulaWildcard> or Range<Day> or SkedulaWildcard, default *) The day of the month to call the function. Leave undefined or null for every day of the month.
  • hour (Hour or Interval<Range<Hour> or Hour or SkedulaWildcard> or Range<Hour> or SkedulaWildcard, default *) The hour of the day to call the function. Leave undefined or null for every hour of the day.
  • minute (Minute or Interval<Range<Minute> or Minute or SkedulaWildcard> or Range<Minute> or SkedulaWildcard, default *) The minute of the hour to call the function. Leave undefined or null for every minute of every hour.
  • second (Second or Interval<Range<Second> or Second or SkedulaWildcard> or Range<Second> or SkedulaWildcard, default *) The second of the minute to call the function. Leave undefined or null for every second of every minute.

Skedula Objects

DayOfMonth

export type DayOfMonth = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31

DayOfWeek

export enum DayOfWeek {
	SUNDAY = 0,
	MONDAY = 1,
	TUESDAY = 2,
	WEDNESDAY = 3,
	THURSDAY = 4,
	FRIDAY = 5,
	SATURDAY = 6,
}

Month

export enum Month {
	JANUARY = 0,
	FEBRUARY = 1,
	MARCH = 2,
	APRIL = 3,
	MAY = 4,
	JUNE = 5,
	JULY = 6,
	AUGUST = 7,
	SEPTEMBER = 8,
	OCTOBER = 9,
	NOVEMBER = 10,
	DECEMBER = 11,
}

SkedulaWildcard

type SkedulaWildcard = '*'

Author

Anthony Krivonos (Portfolio | LinkedIn)