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

sparkles

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sparkles

Namespaced global event emitter

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created

What is sparkles?

The sparkles npm package is used for creating and managing a global event namespace for your application, allowing different parts of your application to communicate with each other using events. It is a lightweight event emitter.

What are sparkles's main functionalities?

Event Emission

This feature allows you to emit events globally within your application. Any part of your application that has required sparkles and called it as a function will be able to listen for 'my-event' and react accordingly.

const sparkles = require('sparkles')();
sparkles.emit('my-event', { some: 'data' });

Event Listening

This feature allows you to listen for events that have been emitted globally. In this example, when 'my-event' is emitted, the callback function will be executed, and the passed data will be logged to the console.

const sparkles = require('sparkles')();
sparkles.on('my-event', (data) => {
  console.log('Received data:', data);
});

Event Namespacing

Sparkles allows you to create separate event namespaces. This can be useful if you want to avoid event name collisions between different parts of your application.

const sparkles = require('sparkles')('my-namespace');
sparkles.emit('my-event', { some: 'data' });

Other packages similar to sparkles

Keywords

FAQs

Package last updated on 23 Mar 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