Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
nanoevents
Advanced tools
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.
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');
EventEmitter3 is a high-performance event emitter for Node.js and the browser. It is more feature-rich compared to Nanoevents, offering wildcard event listeners and more advanced event handling capabilities.
Mitt is another tiny event emitter library. It is similar in size and simplicity to Nanoevents but offers a slightly different API. Mitt is also less than 1KB and is designed for minimal overhead.
The 'events' package is the Node.js core EventEmitter module extracted for use in browser environments. It is more heavyweight compared to Nanoevents but offers a robust set of features and is widely used in the Node.js ecosystem.
Simple and tiny event emitter library for JavaScript.
on
method returns unbind
function. You don’t need to save
callback to variable for removeListener
.emit
and on
methods.
No Node.js EventEmitter compatibility.import { createNanoEvents } from 'nanoevents'
const emitter = createNanoEvents()
const unbind = emitter.on('tick', volume => {
summary += volume
})
emitter.emit('tick', 2)
summary //=> 2
unbind()
emitter.emit('tick', 2)
summary //=> 2
Made at Evil Martians, product consulting for developer tools.
Read full docs here.
9.1.0
EmitterMixin
type (by @fuadsaud).FAQs
Simple and tiny (107 bytes) event emitter library
The npm package nanoevents receives a total of 100,688 weekly downloads. As such, nanoevents popularity was classified as popular.
We found that nanoevents demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.