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

nanoevents

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nanoevents

Simple and tiny (107 bytes) event emitter library

  • 9.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
97K
decreased by-18.57%
Maintainers
1
Weekly downloads
 
Created

What is nanoevents?

Nanoevents is a tiny (less than 1KB) event emitter library for JavaScript. It provides a simple and efficient way to handle events in your application, making it ideal for both client-side and server-side development.

What are nanoevents's main functionalities?

Event Emission

This feature allows you to emit events with associated data. The `emit` method triggers all listeners attached to the specified event.

const { createNanoEvents } = require('nanoevents');
const emitter = createNanoEvents();
emitter.emit('event', 'data');

Event Listening

This feature allows you to listen for specific events. The `on` method registers a callback function that will be called whenever the specified event is emitted.

const { createNanoEvents } = require('nanoevents');
const emitter = createNanoEvents();
emitter.on('event', data => {
  console.log(data);
});
emitter.emit('event', 'data');

Event Unsubscription

This feature allows you to unsubscribe from events. The `on` method returns an unsubscribe function that can be called to remove the listener.

const { createNanoEvents } = require('nanoevents');
const emitter = createNanoEvents();
const unsubscribe = emitter.on('event', data => {
  console.log(data);
});
emitter.emit('event', 'data');
unsubscribe();
emitter.emit('event', 'data');

Other packages similar to nanoevents

Keywords

FAQs

Package last updated on 14 Oct 2024

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