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

vbstyle-event-models

v1.0.8

Published

A thread-safe TypeScript library providing event models, message routing, and event scheduling utilities with mutex lock implementation.

Readme

VB.NET-Style Event Models (TypeScript Edition)

A TypeScript library providing event models, message routing, and event scheduling utilities with thread safety, inspired by VB.NET's event model.

This library is now written in pure TypeScript with proper type definitions, ensuring type safety and better developer experience. It compiles to CommonJS modules for wide compatibility.

Install this package via NPM: npm install vbstyle-event-models (with TypeScript as a peer dependency, current version 1.0.8)

NOTE: To compile a single TypeScript source file with this package imported in it, use this command on the terminal: npx tsc [FILENAME].ts --lib "es2015,dom"

Features

  • BasicEventModel: A simple event model for registering and invoking event handlers
  • MessageRouter: A singleton message router for publish-subscribe pattern
  • QueueEventScheduler: A queue-based event scheduler with thread safety
  • MutexLock: A simple mutex lock implementation for thread safety

Usage

BasicEventModel

import { BasicEventModel, EventHandler, EventArgs } from 'vbstyle-event-models';

// Create an event model
const eventModel = new BasicEventModel();

// Define an event handler
const handler: EventHandler = (sender, e) => {
    console.log('Event triggered:', { sender, args: e });
};

// Add the handler
eventModel.addHandler(handler);

// Raise the event
eventModel.raiseEvent('sender', ['arg1', 'arg2']);

// Remove the handler
eventModel.removeHandler(handler);

MessageRouter

import { MessageRouter } from 'vbstyle-event-models';

// Get the singleton instance
const router = MessageRouter.instance;

// Subscribe to a message type
await router.subscribe('userCreated', (user) => {
    console.log('User created:', user);
});

// Send a message
await router.send('userCreated', { id: 1, name: 'John' });

// Unsubscribe from a message type
await router.unsubscribe('userCreated', handler);

// Clear all subscribers for a message type
await router.clearSubscribers('userCreated');

// Get total subscriber count
const count = router.subscriberCount;
console.log('Total subscribers:', count);

QueueEventScheduler

import { QueueEventScheduler } from 'vbstyle-event-models';

// Create an event scheduler
const scheduler = new QueueEventScheduler();

// Schedule events
await scheduler.scheduleEvent((sender, e) => {
    console.log('Event 1 executed', { sender, args: e });
});

await scheduler.scheduleEvent((sender, e) => {
    console.log('Event 2 executed', { sender, args: e });
});

// Process all events
await scheduler.processEvents('sender', ['arg1', 'arg2']);

// Clear pending events
await scheduler.clearEvents();

// Get pending event count
const count = scheduler.pendingEventCount;
console.log('Pending events:', count);

MutexLock

import { MutexLock } from 'vbstyle-event-models';

// Create a mutex lock
const lock = new MutexLock();

// Acquire the lock
await lock.acquireLock();
try {
    // Critical section
    console.log('Lock acquired');
} finally {
    // Release the lock
    lock.releaseLock();
    console.log('Lock released');
}

// Check if locked
console.log('Is locked:', lock.isLocked);

// Get waiter count
console.log('Waiters:', lock.waiterCount);

License

BSD 3-Clause