Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

event-lite

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event-lite

Light-weight EventEmitter (less than 1KB when minified)

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1M
decreased by-13.66%
Maintainers
1
Weekly downloads
 
Created

What is event-lite?

event-lite is a lightweight event emitter library for JavaScript. It provides a simple and efficient way to handle events in your application, similar to Node.js's EventEmitter but with a smaller footprint.

What are event-lite's main functionalities?

Adding Event Listeners

This feature allows you to add event listeners to an event emitter instance. In the code sample, an event listener for the 'foo' event is added, and the event is emitted, triggering the listener.

const EventLite = require('event-lite');
const emitter = new EventLite();

function onFoo() {
  console.log('foo event triggered');
}

emitter.on('foo', onFoo);
emitter.emit('foo');

Removing Event Listeners

This feature allows you to remove event listeners from an event emitter instance. In the code sample, the event listener for the 'foo' event is added and then removed, so emitting the event does not trigger the listener.

const EventLite = require('event-lite');
const emitter = new EventLite();

function onFoo() {
  console.log('foo event triggered');
}

emitter.on('foo', onFoo);
emitter.off('foo', onFoo);
emitter.emit('foo');

Once Event Listeners

This feature allows you to add an event listener that will be triggered only once. In the code sample, the event listener for the 'foo' event is added with the 'once' method, so it is triggered only the first time the event is emitted.

const EventLite = require('event-lite');
const emitter = new EventLite();

function onFoo() {
  console.log('foo event triggered');
}

emitter.once('foo', onFoo);
emitter.emit('foo');
emitter.emit('foo');

Other packages similar to event-lite

Keywords

FAQs

Package last updated on 24 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc