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 🙏

© 2025 – Pkg Stats / Ryan Hefner

yaps.js

v1.0.5

Published

A lightweight and small PubSub library written in JavaScript (ES6)!

Readme

yaps.js (Yet Another PubSub)

version minified size dependencies licence

A lightweight and small PubSub library written in JavaScript (ES6)!

Quick and Easy

  • via npm: npm i yaps.js -s

  • (or) use minified file directly from cdn: https://cdn.jsdelivr.net/npm/yaps.js/yaps.min.js

    (Note: if using minified file in a browser, yaps will be available globally)

Pros?

  1. Fairly simple and straight forward.
  2. < 1Kb size of minified file.
  3. Minified version is compatible with previous versions of ES6.
  4. Dependency free.

Interfaces

Subscribe

let handlerIdentifier = yaps.subscribe(topic, handlerFunc);

Returns: unique identifier/token of handler

Unsubscribe

yaps.unsubscribe(handlerIdentifier);

Returns: yaps object

Publish

yaps.publish(topic, argument1, argument2, ...);

Returns: yaps object

Examples

import or require
import yaps from 'yaps.js';

// OR CommonJS (node)
const yaps = require('yaps.js');
Basic example (works for all)
// index.js

// require if working with node
const yaps = require('yaps.js');

// import if using ES6 modules (say in React)
// import yaps from 'yaps.js'

let taskModule = require('./tasks');

/* create a subscriber to get notified when there is a new task*/
let id = yaps.subscribe('taskAdded', function() {
    console.log('Updated Tasks: ', taskModule.getTasks());
});

taskModule.addTask("Don't forget to star yaps.js!");    

/* unsubscribe */
yaps.unsubscribe(id);

taskModule.addTask("With the winds we go");
// tasks.js

// require if working with node
const yaps = require('yaps.js');

// import if using ES6 modules (say in React)
// import yaps from 'yaps.js'

let tasks = [];

function addTask(task) {
    tasks.push(task);

    /* notify any subscriber subscribed to this topic */
    yaps.publish('taskAdded', task);

}

function getTasks() {
    return tasks;
}

module.exports = {
    addTask,
    getTasks
};
Tip (for handling multiple subscribers)

// hold all the identifiers
let subscriptions = [];

// subscribe to topic 'exampleTopic'

subscriptions.push(yaps.subscribe('exampleTopic', mySubscriptionHandler1));
subscriptions.push(yaps.subscribe('exampleTopic', mySubscriptionHandler2));

function mySubscriptionHandler1(arg1, arg2) {
    console.log(arg1, arg2);
}

function mySubscriptionHandler2(arg1) {
    console.log(arg1);
}

// broadcast topic

yaps.publish('exampleTopic', 'hello', 'world');
// Output: 
// hello world
// hello

yaps.publish('exampleTopic', ['hello', 'world']);
// Output: 
// ['hello', 'world'] undefined
// ['hello']

// unsubscribe all handlers
subscriptions.forEach(handlerId => {
    yaps.unsubscribe(handlerId);
});

yaps.publish('exampleTopic', 'hello', 'world');
// No output as all the handlers were unsubscribed

Changelog

https://github.com/shahnawaz/yaps.js/releases

Willing to Contribute?

Contribution guidelines will be added soon, feel free to send a PR.

License

MIT