Socket
Socket
Sign inDemoInstall

nanoevents

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nanoevents

Simple and tiny (119 bytes) event emitter library


Version published
Weekly downloads
120K
increased by6.65%
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 21 Sep 2017

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