
Product
Introducing Supply Chain Attack Campaigns Tracking in the Socket Dashboard
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.
switchboard
Advanced tools
Event listener for the browser and node.js for composite events (i.e., will not trigger until several specified events occur).
A composite event listener. Waits for several events to occur before firing the handler.
Switchboard returns the arguments of each respective emit to the specified handler. These arguments can be named if desired.
node.js:
npm install switchboard
bower:
bower install switchboardjs
<script src="components/switchboardjs/index.js"></script>
Sometimes you have to wait for 2 or more things to happen before a certain part of your program can move forward. Let's say you're rendering a bunch of templates, for example. You want to do it asynchronously, but it's kind of a pain to figure out when everything's done without something kludgey (like a static counter or a jungle of if statements). switchboard.js can hide the kludge for you.
Familiar syntax, too. Just uses the classic EventEmitter 'on/once' pattern. Except instead of a single event name, you specify an array.
You've got two choices, cowboy.
var Switchboard = require('switchboard').Switchboard,
myEmitter = new Switchboard();
var events = ['firstEvent', 'secondEvent', 'thirdEvent'];
myEmitter.on(events, function(args) {
// after calling `myEmitter.emit(e)` for all three events, args is something like:
// { 'firstEvent': [ ... the args ... ],
// 'secondEvent': [ ... the args ... ],
// ...
// }
// etc.
});
var Switchboard = require('switchboard').Switchboard,
myEmitter = new Switchboard();
var events = ['firstEvent', 'secondEvent', 'thirdEvent'];
myEmitter.registerEventArguments({
firstEvent: ['err', 'resultA', 'resultB']
});
// multiple calls to registerEventArguments are a-okay
// (hint: good for loops or for registering callbacks from
// within other callbacks)
myEmitter.registerEventArguments({
secondEvent: ['resultC', 'resultD', 'resultE'],
thirdEvent: ['err', 'myVar', 'someJunk']
});
myEmitter.once(events, function(args) {
console.log(args)
});
Now that you've defined your events, you can go ahead and emit things...
myEmitter.emit('firstEvent', null, 'aaaa', 'bbbbb')
myEmitter.emit('thirdEvent', {err: 'someErr'}, 'mvvvarrr', 'junk~!')
myEmitter.emit('secondEvent', 'CCCC', 222222, 'EEEE')
Which will produce the following output:
{ firstEvent:
{ '0': null,
'1': 'aaaa',
'2': 'bbbbb',
err: null,
resultA: 'aaaa',
resultB: 'bbbbb' },
secondEvent:
{ '0': 'CCCC',
'1': 222222,
'2': 'EEEE',
resultC: 'CCCC',
resultD: 222222,
resultE: 'EEEE' },
thirdEvent:
{ '0': { err: 'someErr' },
'1': 'mvvvarrr',
'2': 'junk~!',
err: { err: 'someErr' },
myVar: 'mvvvarrr',
someJunk: 'junk~!' } }
As you can see, each event's arguments are enumerated as well as being named. The point: you can skip the call to registerEventArguments() if you want.
FAQs
Event listener for the browser and node.js for composite events (i.e., will not trigger until several specified events occur).
The npm package switchboard receives a total of 0 weekly downloads. As such, switchboard popularity was classified as not popular.
We found that switchboard demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.

Security News
Node.js 25.4.0 makes require(esm) stable, formalizing CommonJS and ESM compatibility across supported Node versions.