1.0.3 • Published 1 year ago

@backs/scheduler v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Back's scheduler

Join my discord server or visit my website.

What's this?

It's a task scheduler that uses either cron or setInterval.

Usage

Schedule a task

Using cron time

import Scheduler from "@backs/scheduler"

// Runs every hour
// Returns an id of type string
Scheduler.schedule("0 * * * *", () => console.log("Hello, World!"))

Using set interval

import Scheduler from "@backs/scheduler"

// Runs every 1 hour from the time of execution
// Returns an id of type string
Scheduler.schedule(60 * 60 * 1000, () => console.log("Hello, World!"))

Unscheduling a task

import Scheduler from "@backs/scheduler"

const myTaskID = Scheduler.schedule("0 * * * *", () => console.log("Hello, World!"))

Scheduler.unschedule(myTaskID)

Getting a task

import Scheduler from "@backs/scheduler"

const myTaskID = Scheduler.schedule("0 * * * *", () => console.log("Hello, World!"))

// Returns a Task object
const myTask = Schedule.getTask(myTaskID) 

NOTE

Modifying the task in any way could lead to unexpected errors. If you need to change a task just unschedule it and schedule a new one.

Getting all tasks

import Scheduler from "@backs/scheduler"

const myTaskID = Scheduler.schedule("0 * * * *", () => console.log("Hello, World!"))

// Returns an array of Task objects
const myTasks = Schedule.getTasks() 
1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago