
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
A small (2.4KB minified, 1.07KB gzipped) and fast event system with 0 dependencies.
Written in es2020 and built for performance. Great as a pubsub or to add event emitters
to your code.
npm install signal-js
Add a function to signal using on and trigger the function using emit
import signal from 'signal-js';
signal.on('basic', arg => console.log(arg);
signal.emit('basic', 1);
// > 1
Add multiple functions to the same event name
import signal from 'signal-js';
signal.on('multiple', () => console.log(1));
signal.on('multiple', () => console.log(2));
signal.on('multiple', () => console.log(3));
signal.trigger('multiple');
// > 1
// > 2
// > 3
Pass as many parameters as you need
import signal from 'signal-js';
signal.on('params', (one, two, three) => console.log(one, two, three));
signal.emit('params', 1, 2, 3);
// > 1 2 3
Remove events using off
import signal from 'signal-js';
signal.on('test', () => console.log('hi'))
.off('test') // removes all `test` events
.emit('test'); // nothing happens
once can also be used
import signal from 'signal-js';
let idx = 0;
signal.once('tick', () => idx++);
signal.emit('tick')
// idx = 1
signal.emit('tick');
// idx = 1
The exposed signal is a singleton, but other instances can also be created:
import signal from 'signal-js';
signal.on('foo', () => console.log('global'));
const local = signal();
local.on('foo', () => console.log('local'));
const local2 = local();
local2.on('foo', () => console.log('local2'));
signal.emit('foo');
// > "global"
local.emit('foo');
// > "local"
local2.emit('foo');
// > "local2"
.on(eventName, listener)eventName string The name of the eventlistener Function The event handlerAlias: addListener, subscribe, bind
.off(eventName, listener)eventName string The name of the eventlistener Function (optional) The event handlerIf listener is passed, the specific listener will be unbound,
otherwise all listeners under eventName will be unbound.
Alias: removeListener, unsubscribe, unbind
.emit(eventName, [...parameters])eventName string The name of the eventparameters any (optional) The arguments passed to the listenerAlias: dispatch, trigger
.once(eventName, listener)eventName string The name of the eventparameters any The event handlerAdds a one-time listener that will remove itself after being invoked.
.listeners(eventName)eventName string The name of the eventRetrieves registered listeners under the eventName. If no eventName
is passed, returns all listeners.
.keys()Retrieves all eventNames.
.size(eventName)eventName string The name of the eventReturns the quantity of listeners at the given eventName. If no eventName
is passed, returns the quantity of all listeners.
.clear(eventName)listeners and eventNames from the signal at the eventName.
Clears all listeners if no eventName is passed.FAQs
a small, simple es6 event system.
The npm package signal-js receives a total of 177 weekly downloads. As such, signal-js popularity was classified as not popular.
We found that signal-js demonstrated a not healthy version release cadence and project activity because the last version was released 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.