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

sioevents

v1.0.0

Published

Events Controller for nodejs module and navigators

Downloads

6

Readme

SioEvents

Events Controller for nodejs module and navigators.

The EventEmitter is preferable used in extended classes.

Install

  npm install sioevents

Include

  import SioEvents from "sioevents";

Full Example

class EventSender extends SioEvents {
    constructor() {
        super();
        /**This listener is going to be fired with all the events */
        this.on("*",(ev)=>{
            console.log("[EventSender] *: ",ev.event,ev.data);
        })
    }
    send(event, data) {
        this.emit(event, data);
    }
    testEmit(t) {
      this.emit("test", {name:t});
    }
}

let sender=new EventSender();

/**The first listener is going to run just the next two times the event its fired and its going to stop further propagation */
sender.on("test",(ev)=>{
  ev.stopPropagation();
  console.log("[First Listener]: ",ev.data);
},2);

/**The second listener is going to run always the event its fired */
sender.on("test",(ev)=>{
  console.log("[Second Listener]: ",ev.data);
});

/**This is going to fire the * listeners */
sender.emit("noTest",{name:"noTest"});

/**This fire 3 test events so we can see all the functionallity of the class */
sender.testEmit("t1");
sender.testEmit("t2");
sender.testEmit("t3");

/**Console
  [EventSender] *:  noTest { name: 'noTest' }
  [First Listener]:  { name: 't1' }    
  [First Listener]:  { name: 't2' }    
  [Second Listener]:  { name: 't3' }   
  [EventSender] *:  test { name: 't3' }
 * 
*/

Add Listener -> .on(eventName, callback,times=Number.POSITIVE_INFINITY);

|Name|Type|Description|Special Values |---|---|---|---| |eventName|String|Name of the event to listen for.|Use "*" to listen to all the events fired. |callback|Function|Function to be called when the event fires. It recives an EventElement Object.| |times|Number|Defines the number of times this callback can run. Default: Infinite times

Add a new listener to listen for a name event

  ev.on("*",(eventElement)=>{
    console.log(eventElement.data);
  })

Emit -> .emit(eventName, data) || .emit(EventElement);

|Name|Type|Description|Special Values |---|---|---|---| |eventName|String|Name of the event to be fired| |data|Any|On the listeners callback EventElement data value. |EventElement|EventElement|Another EventElement recived in a listener.

  ev.emit("eventName",
    {
      value:"Some special data"
    }
  )

EventElement

Created by SioEvents on every event fire.

Properties

|Name|Type|Default|Description| |---|---|---|---| |event|String|It's always setted|Event Name |data|Any|Any|Data the event was fired. If you modify this value subsequent listeners will recive the modified value. |stopped|Boolean|false|It its true if one listener calls EventElement.stopPropagation() |error|Any|false|It is setted if one listener calls EventElement.preventDefault(info). If not info is provided this value is true else the value of this is the info param.

Methods

stopPropagation()

The SioEvent is going to stop calling any other listener on the list

preventDefault(info=null)

It's goint to set the error with the info value

NICE DAY AND WONDERFUL CODING

Author: Adrián Mercado Martínez.

Last modification: 2021-10-29