
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
co-powered emitter mixin for objects

npm install co-emitter
The Emitter may be used as a mixin or a standalone object.
Standalone:
var Emitter = require('co-emitter');
var emitter = new Emitter();
emitter.on('say', function *(message) {
yield delay(200);
console.log("I say: " + message);
return true;
});
co(function *() {
var result = yield emitter.emit('say', 'hello')
});
// result == true, and console.logs "I say: hello""
Mixin:
var user = { name: 'Tobi' };
Emitter(user);
yield user.emit('some event');
Prototype mixin:
var User = function() {
this.name = 'Tobi';
};
Emitter(User.prototype);
var user = new User();
yield user.emit('some event');
Registers generator as a listener for name.
fn* can be:
var emitter = new Emitter();
var listenerA = function *() {},
listenerB = function *() {},
listenerC = function *() {};
// All of these would be equal
emitter.on('test', listenerA);
emitter.on('test', listenerB);
emitter.on('test', listenerC);
// or
emitter.on('test', [listenerA, listenerB, listenerC]);
// or
emitter.on('test', listenerA, listenerB, listenerC);
Registers generator as a listener for name. This generator runs once and is
then removed.
var emitter = new Emitter();
emitter.once('test', function*() { console.log("Yay!"); });
yield emitter.emit('test');
Runs the registered listeners for event. Passes in optional args to the
listeners.
args can be an array, or multiple arguments.
Returns the result of the last run listener. If results are omitted, returns original arguments.
var result = yield emitter.emit('add', 2, 2);
console.log(result) // 4
If you want an event to be synchronous, and not have to yield to
emitter.emit, you can do so by using normal functions for your listeners.
var callCount = 0;
emitter.on('call', function() {
callCount++;
});
emitter.emit('call');
emitter.emit('call');
If you wan't to wait for async operations to have finished, you may do so by
using yield within generators.
emitter.on('saving', function *() {
userStatistics.saveCount += 1;
yield userStatistics.save();
});
// Elsewhere...
yield emitter.emit('saving'); // wait for `saving`'s async to have finished.
You may not use both generators and normal functions as listeners for a single event. If you need async and sync for a single event, use a non-yielding generator for the sync.
emitter.on('saving', function*() {
userStatistics.saveCount += 1;
});
emitter.on('saving', function *() {
yield userStatistics.save();
});
// Elsewhere...
yield emitter.emit('saving'); // wait for `saving`'s async to have finished.
Because we are using one async function (or a generator), we must use yield
when calling emit.
Listeners run with a middleware pattern, results from one listener can be piped into the next. For example:
var emitter = new Emitter();
var uppercase = function *(str) {
return str.toUpperCase();
};
var firstChar = function *(str) {
return str.charAt(0)
};
emitter.on('upperFirst', uppercase, firstChar);
var result = yield emitter.emit('upperFirst', 'hello world');
// result == 'H'
If you do not return a value, it will use the initial arguments passed in/ the value of the last returning listener.
Removes a given listener for a specific listener.
event is provided, all listeners will be removed.listener is provided, all listeners for given event will be removed.event and listener provided, removes listener from eventConvenience method to call off with no event or listener, thereby removing
all listeners.
Returns whether or not any listeners exist for event.
Returns an array of all listeners for a given event. If no listeners exist, returns an empty array.
FAQs
Emitter that works with generator methods using co
The npm package co-emitter receives a total of 8 weekly downloads. As such, co-emitter popularity was classified as not popular.
We found that co-emitter 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
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.