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

eso

v0.1.3

Published

Event; Status; Observe :: A pubsub for window events.

Downloads

2

Readme

#eso ###Events Subscriber with Status Control

version 0.1.3
A Common JS Module, that I really should publish onto NPM. The point of this "pubsub emitter", is to sit at a top level of an app instance, ie: app.emitter, and allow you to create app States and Events, and use them together, or at least as a place to keep an organised record of your window events with their relative functions associated.

The Module itself works by returning an API as on require self executes and instantiates new instances of the Status and Listener Objects. They both share data via their private Scope Object, used internally.

##API methods Status By keeping States, callbacks can be made throughout the app when the status changes, as well as limiting the execution of Events.

params denoted with *asterix mean they are not required.

  • get(*all:boolean) Passing true returns the current Status, whereas ommitting the param returns all the available states.
  • add(state:string) Will create a new state by the name given.
  • set(state:string) Sets the current status with the name of the state given. Will fail if the state does not exist.
  • on(state:string, callback:function) When the designated state becomes set, the function given will be ran. Ie: callback is run on that state.

Listener Keeping your eventListeners organised, and lets you create and configure these listeners with what will be passed back to the functions you wish to fire, and whether or not they are limited by the app's current status.

  • create(type:string, returns:Object) Create a window event listener, by passing the event type ie: 'mousemove', and what the event will return, based on the original event object.
  • add(type:string, callback:function, *status:string) Adds a method to an existing eventListener, which can also be set to be only fired if the status matches the modules current scope status. The callback function you give it will be passed the event object you established as the returns object you stipulate in the create method.

##Todo's

  • Add remove methods to API.

##Usage Init

var Emitter = require('./eso);

// attach it to your App.
app.emitter = Emitter;

Make a state

app.emitter.status.add('bigbang'); // now state exists to use

// pass your funtion execute when status matches
app.emitter.status.on('bigbang', function() {
	console.log('and so it begins - quicker than you realise.');
})

// change state, and see console log for output.
app.emitter.status.set('bigbang');

Utilise Event Listeners

// build a window level event listener, returning cursor x co-ords
app.emitter.listeners.create('mousemove', { x: e.clientX });

// add a method to the mousemove event
app.emitter.listeners.add('mousemove', function(res){ 
	console.log(res.x); 
}, 'bigbang')