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

quick-event

v0.1.4

Published

quick-event is a TypeScript event library that provides tools that enable your application components to communicate with each other by dispatching events and listening for them. With eventpp you can easily implement signal/slot mechanism, or observer pat

Downloads

7

Readme

Quick Event ⚡

quick-event is a TypeScript event library that provides tools that enable your application components to communicate with each other by dispatching events and listening for them. With quick-event you can easily implement signal/slot mechanism, or observer pattern.

Quick start

Install

Install with NPM or Yarn

# npm
npm install --save quick-event
# yarn
yarn add --save quick-event

Or link to the source code directly

<script src="dist/quick-event.min.js"></script>

Name QuickEvent is ready to use and no need to import.

Or CDN

<script src="https://unpkg.com/quick-event/dist/quick-event.min.js"></script>

Name QuickEvent is ready to use and no need to import.

How to use

Using CallbackList

import { CallbackList } from 'quick-event';

const callbackList = new CallbackList();
callbackList.append(() => {
  console.log('Got callback 1.');
});
callbackList.append(() => {
  console.log('Got callback 2.');
});
callbackList.dispatch();

Using EventDispatcher

import { EventDispatcher } from 'quick-event';

const dispatcher = new EventDispatcher();

dispatcher.appendListener(3, () => {
  console.log('Got event: 3.');
});

dispatcher.appendListener('my-event', () => {
  console.log('Got event: my-event.');
});
dispatcher.appendListener('my-event, () => {
  console.log('Got another event: my-event.');
});
dispatcher.dispatch(3);
dispatcher.dispatch('my-event');

Using EventQueue

import { EventQueue } from 'quick-event';

const queue = new EventQueue();
queue.appendListener(3, (s: any, n: any) => {
  console.log(`Got event: 3, s is ${s}, n is ${n}`);
});
queue.appendListener(5, (s: any, n: any) => {
  console.log(`Got event: 5, s is ${s}, n is ${n}`);
});
queue.appendListener(5, (s: any, n: any) => {
  console.log(`Got another event: 5, s is ${s}, n is ${n}`);
});

// Enqueue the events, the first argument is always the event type.
// The listeners are not triggered during enqueue.
queue.enqueue(3, 'Hello', 38);
queue.enqueue(5, 'World', 58);

// Process the event queue, dispatch all queued events.
queue.process();

Facts and features

  • Powerful
    • Supports synchronous event dispatching and asynchronous event queue.
    • Supports event filter via mixins.
    • Configurable and extensible.
  • Robust
    • Supports nested event. During the process of handling an event, a listener can safely dispatch event and append/prepend/insert/remove other listeners.
    • Doesn't depend on HTML DOM. eventjs works for non-browser environment.
    • Well tested. Backed by unit tests.
  • Fast
    • Much faster than HTML DOM event listener system.
    • The EventQueue can process 5M events in 1 second (5K events per millisecond, when there are 100 event in the queue).
    • The CallbackList can invoke 1M callbacks in 1 second (1000 callbacks per millisecond).

Documentation

Documentation

Run the unit tests

yarn test

Rewrite

quick-event is rewritten from wqking/eventjs.

Wang Qi(wqking) is my friend and teacher, we have developed some projects together. He's a wide-ranging, experienced developer and I've learned a lot from him.

License

The code in this project is licensed under MIT license.