
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
small-event-system
Advanced tools
A lightweight, type-safe event bus system with DOM integration and smart configuration options.
npm install small-event-system
const eventRegistrations = [
{
event: 'user:login',
listener: (data: { userId: string; timestamp: number }) => {
console.log('User logged in:', data);
},
description: 'Handle user login events',
},
{
event: 'form:submit',
listener: (data: { formId: string; values: Record<string, unknown> }) => {
console.log('Form submitted:', data);
},
description: 'Handle form submission events',
debounce: 300, // Individual event debounce
},
] as const;
import { createEventBus } from 'small-event-system';
const eventBus = createEventBus(eventRegistrations, {
dom: true, // Automatically enable DOM integration
defaultDebounce: {
'user:action': 500, // Default debounce for user actions
'api:request': 1000, // Default debounce for API requests
},
});
await eventBus.emit('user:login', {
userId: 'user123',
timestamp: Date.now(),
});
await eventBus.emit('form:submit', {
formId: 'login-form',
values: { email: 'user@example.com', password: '***' },
});
<!-- DOM integration automatically enabled -->
<button data-event="user:action" data-action="logout">Logout</button>
<button data-event="notification:show" data-message="Hello!" data-type="success">
Show Notification
</button>
interface EventBusOptions {
/**
* Enable DOM integration automatically
* @default false
*/
dom?: boolean;
/**
* Default debounce configuration for events
* @default {}
*/
defaultDebounce?: Record<string, number>;
}
When dom: true is set, the EventBus automatically:
data-event attributes on HTML elementsdata-* attributesYou can set default debounce delays for events:
const eventBus = createEventBus(events, {
defaultDebounce: {
'user:action': 500, // 500ms debounce for user actions
'api:request': 1000, // 1000ms debounce for API requests
'form:input': 300, // 300ms debounce for form inputs
},
});
Individual events can override this with their own debounce property.
const modalEvents = [
{
event: 'modal:open',
listener: (data: { id: string; props?: Record<string, unknown> }) => {
console.log('Opening modal:', data.id, data.props);
},
description: 'Open a modal dialog',
},
{
event: 'modal:close',
listener: (data: { id: string; reason?: string }) => {
console.log('Closing modal:', data.id, 'Reason:', data.reason);
},
description: 'Close a modal dialog',
},
] as const;
const modalEventBus = createEventBus(modalEvents, {
dom: true,
defaultDebounce: {
'modal:action': 150,
'user:interaction': 300,
},
});
// Usage
await modalEventBus.emit('modal:open', { id: 'user-profile', props: { userId: '123' } });
<button data-event="modal:open" data-id="user-profile" data-props='{"userId": "123"}'>
Open Profile
</button>
<button data-event="modal:close" data-id="user-profile" data-reason="user-cancelled">
Close
</button>
<button data-event="modal:action" data-id="user-profile" data-action="save" data-data='{"name": "John"}'>
Save
</button>
Creates a singleton EventBus instance with optional configuration.
Parameters:
events (optional): Array of event registrationsoptions (optional): Configuration optionsReturns: StrictEventBus<T>
emit(event, data): Emit an event with dataon(event, listener): Add an event listeneroff(event, listenerId): Remove an event listenerregisterEvents(registrations): Register multiple eventsisEventRegistered(event): Check if event is registeredgetRegisteredEvents(): Get all registered event namesgetListenerCount(event): Get listener count for an eventhasListeners(event): Check if event has listenersclear(): Clear all listeners and eventsclearEvent(event): Clear specific eventenableDOMIntegration(): Enable DOM integration manuallydisableDOMIntegration(): Disable DOM integrationisDOMIntegrationEnabled(): Check if DOM integration is enabledsetDefaultDebounce(event, delay): Set default debounce for an eventSee the examples/ directory for complete working examples:
basic-usage.ts: Basic usage with configurationmodal-system.ts: Modal system implementationsimple-demo.html: Interactive HTML demoMIT
FAQs
Small event system
The npm package small-event-system receives a total of 0 weekly downloads. As such, small-event-system popularity was classified as not popular.
We found that small-event-system demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.