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

am-event-emmiter

v1.0.1

Published

Custom Event emitter for JavaScript. You can be able to register and Unregister, mute & Unmute event written in core JavaScript no external lib required

Downloads

5

Readme

amEventEmitter

Custom Quick & Easy Java Script Event Emitter no need of any third party library. From this you register multiple events with call back function & can be able to emit event multiple times with data. And pragmatically mute & unmute event which you created.

Installation

Download am.emmiter.js file from this repo and import am.emmiter.js file in you project

<script src="am.emmiter.js"></script>

Examples

Refer index.html in this repo

Features & Usage

Step1: Create Instance

var eventEmitter = new amEventEmitter();

Step2: Register your custom event with Event Name & Callback

eventEmitter.register('event1', function(){
  console.log('Event1 emitted');
});

Step3: Emit your event.

eventEmitter.emit('event1');

consoles Event1 emitted

More Options

Emitting with data
eventEmitter.register('event2', function(data){
  console.log('event2 emitted with data',data);
});

eventEmitter.emit('event2',{'name' : 'Jhon Potter'});
Multiple register to same event
eventEmitter.register('event3', function(data){
  console.log('event3 emitted!! first register',data);
});

eventEmitter.register('event3', function(data){
  console.log('event3 emitted!! second register',data);
});

eventEmitter.emit('event3',{'name' : 'Jhon Potter'});
Emitting single event multiple times with different data
eventEmitter.register('event4', function(data){
  console.log('event4 emitted!! ',data);
});
eventEmitter.emit('event4',{'name' : 'Jhon Potter'});  
eventEmitter.emit('event4',{'name' : 'Harry Potter'});  
Mutting & UnMutting event. call mute method to disable event emit & call unmute method to enable back
eventEmitter.register('event5', function(data){
  console.log('event5 emitted!! ',data);
});
eventEmitter.emit('event5',{'name' : 'Jhon Potter'});  
eventEmitter.mute('event5');
eventEmitter.emit('event5',{'name' : 'Harry Potter'});  
eventEmitter.unmute('event5');
eventEmitter.emit('event5',{'name' : 'Mark welson'}); 

Exception handling

Wrap register, emit, mute and unmute method with try & catch block.

try{
  eventEmitter.register('event4', function(data){
    console.log('event4 emitted!! ',data);
  });
} catch(e){
  console.log('Error',e);
}