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

@skyloom/eventscheduler

v1.0.2

Published

A simple event scheduling system with serialization.

Readme

@skyloom/eventscheduler

Description

A simple event scheduling system with serialization. The EventScheduler class allows you to schedule, execute, pause, resume, and remove events based on unique IDs, categories, and callback functions. It supports automatic repetition of events and provides methods to save and load scheduled events.

Installation

npm install @skyloom/eventscheduler

Usage

import { EventScheduler, EventHandler, EventStatus } from "@skyloom/eventscheduler";

// Initialize the Event Scheduler
const scheduler = new EventScheduler();

// Define an event handler
const exampleHandler: EventHandler = {
  execute: async (scheduler, params) => {
    console.log("Event executed with params:", params);
  },
};

// Register the event handler
scheduler.registerCallback("exampleEvent", exampleHandler);

//event id
const eventId = "your-id-here";
// Add an event to the scheduler
scheduler.addEvent(eventId, "exampleEvent", { message: "Hello, World!" }, 5000, false);

// Pause the event
scheduler.pauseEvent(eventId);

// Resume the event
await scheduler.resumeEvent(eventId);

// Remove the event
scheduler.removeEvent(eventId);

// Save all events to a string
const serializedEvents = scheduler.saveEvents();

// Load events from a string
scheduler.loadEvents(serializedEvents);

API

EventScheduler

  • registerCallback(lookupName: string, callback: EventHandler): void

    • Registers a callback function for a specific event type.
  • addEvent(id: string = nanoid(), lookupName: string, params: any, duration: number, autoRepeat: boolean = false): string

    • Adds a new event to the scheduler.
  • removeEvent(id: string): void

    • Removes an event by its ID.
  • pauseEvent(id: string): void

    • Pauses an event by its ID.
  • resumeEvent(id: string): Promise<void>

    • Resumes a paused event by its ID.
  • pauseAll(): Promise<void>

    • Pauses all events.
  • resumeAll(): Promise<void>

    • Resumes all paused events.
  • executeImmediately(id: string): Promise<void>

    • Executes an event's callback immediately.
  • saveEvents(): string

    • Saves all events to a string in JSON format.
  • loadEvents(serializedData: string): void

    • Loads events from a JSON string.

EventHandler

export interface EventHandler {
  execute(scheduler: EventScheduler, params: any): Promise<void>;
}

Event

export interface Event {
  id: string; // Unique ID for the event
  lookupName: string; // Key for the callback function
  params: any; // Parameters for the callback
  status: EventStatus; // Current status
  addedAtTime: number; // Timestamp when the event was added
  remainingTime: number; // Remaining time before execution
  duration: number; // Total duration in milliseconds
  autoRepeat: boolean; // Whether the event should repeat
  jobId?: NodeJS.Timeout; // Timeout reference for scheduling
}