Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
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.
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' });
EventEmitter3 is a high-performance event emitter. It offers similar functionality to sparkles but with a focus on performance and being a drop-in replacement for existing event emitter implementations.
Mitt is a tiny functional event emitter / pubsub. It provides a similar event-driven communication approach as sparkles but with a smaller footprint and functional API.
Wolfy87's EventEmitter is an implementation of the EventEmitter module found in Node.js. It provides similar event handling capabilities as sparkles but includes additional features such as wildcard event listeners.
Namespaced global event emitter
Sparkles exports a function that returns a singleton EventEmitter
.
This EE can be shared across your application, whether or not node loads
multiple copies.
var sparkles = require('sparkles')(); // make sure to call the function
sparkles.on('my-event', function(evt){
console.log('my-event handled', evt);
});
sparkles.emit('my-event', { my: 'event' });
MIT
FAQs
Namespaced global event emitter
The npm package sparkles receives a total of 1,371,708 weekly downloads. As such, sparkles popularity was classified as popular.
We found that sparkles demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.