
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
event-wire
Advanced tools
Mediator with dynamic responsibility chains.
Idea if this package is to have hybrid of EventEmitter and chain-of-Responsibility. In short - dynamic channels with wildcards, and guaranteed execution order for listeners.
Features:
npm install event-wire --save
Create new event-wire
instanse.
//
// Simple. Recommended.
//
var wire = require('event-wire')();
//
// Advanced, with enabled support for generators.
//
const wire = require('event-wire')({
co: require('co')
})
//
// Advanced, with alternate promise/coroutine lib
//
const bb = require('bluebird');
const wire = require('event-wire')({
p: bb,
co: (fn, params) => bb.coroutine(fn)(params)
});
Sends message with obj
param into the channel
. Once all sync and
ascync handlers finished, optional callback(err)
(if specified) fired.
If callback not passed, Promise
is returned.
Registers handler
to be executed upon messages in the a single channel
or a sequence of channels stored in channels
parameter. Handler can be
either sync, async or generator function:
wire.on('foobar', function* (obj) {
// do stuff here
yield ...
});
wire.on('foobar', function (/* obj */) {
return new Promise(resolve => { // You can return Promise
setTimeout(() => { resolve(); }, 1000);
});
});
wire.on('foobar', function (obj) {
// do stuff here
// and you can generate error via throw
throw new Error('test');
});
wire.on('foobar', function (obj, callback) {
// do stuff here
callback();
});
If handler returns error, chain will be terminated - all next handlers except "ensured" (see below) will be skipped.
options:
priority
(Number, Default: 0) - execution order (lower is earlier).
Handlers with equal priorities are executed in definition order.
ensure
(Boolean, Default: false) - If true
, will run handler even
if one of previous fired error.
parallel
(Boolean, Default: false) - all adjacent handlers with the same
priority that also have parallel=true
will be executed in parallel.
For example:
wire.on('foobar', { priority: 9, parallel: true }, handler1); // different priority
wire.on('foobar', { priority: 10, parallel: true }, handler2); // handler2 and handler3 are parallel
wire.on('foobar', { priority: 10, parallel: true }, handler3); // handler2 and handler3 are parallel
wire.on('foobar', { priority: 10 }, handler4); // not parallel
wire.on('foobar', { priority: 10, parallel: true }, handler5); // handler5 and handler6 are parallel
wire.on('foobar', { priority: 10, parallel: true }, handler6); // handler5 and handler6 are parallel
wire.on('foobar', { priority: 11, parallel: true }, handler7); // different priority
name
(String) - handler name, if function is anonymous or you need to
keept it intact after code uglifiers.
The same as .on(...)
, but executed only one time.
Aliases of .on(...)
, but with priority -10
and +10
Removes handler
of a channel, or removes ALL handlers of a channel if
handler
is not given.
Exclude calling list of named handlers for given channel (wildard allowed at the end):
wire.skip('server:static.*', [
session_start,
cookies_start
]);
Returns if channel
(String) has at least one subscriber
with zero priority (main handler). Useful for dynamic routing
Returns array of info about every channel. For debug purposes. For example, you can write dumper to check that all expected channels have required handlers. Or to track number of calls.
Internal messaging for debug. Currently supported events:
eachBefore
(handlerInfo, params) - called before every handler execute.eachAfter
(handlerInfo, params) - called after every handler execute.FAQs
Mediator with dynamic responsibility chains.
The npm package event-wire receives a total of 0 weekly downloads. As such, event-wire popularity was classified as not popular.
We found that event-wire 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
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.