
Product
Introducing the Alert Details Page: A Better Way to Explore Alerts
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.
Convert any object into an event-emitter, and emits events with the name of any any method called on the object.
Convert any object into an event-emitter, and emits events with the name of any any method called on the object.
Wraps each method on an object so that an event is emitted with the name of the method along with the arguments passed to the method.
Example
// an old object with a property that has a function value
var obj = {cache: {}};
obj.set = function(key, val) {
obj[key] = val;
return obj;
};
// pass an instance of your favorite event emitter,
// see `example.js` for a working example
toEmitter(emitter, obj);
// now `obj` is an emitter, and `obj.set` will emit a `set` event.
obj.on('set', function(key, value) {
console.log('set:', key, value);
});
obj.set('foo', 'bar');
Install with npm
$ npm i to-emitter --save
var Emitter = require('component-emitter');
var toEmitter = require('to-emitter');
var obj = {
cache: {},
set: function (key, val) {
obj.cache[key] = val
return obj;
},
get: function (key) {
return obj.cache[key];
}
};
obj.set('foo', 'bar');
var emitter = Emitter({});
toEmitter(emitter, obj);
obj.on('set', function (key, val) {
console.log('set:', key, val);
});
obj.on('get', function (key) {
console.log('get:', key);
});
obj.set('a', 'b');
obj.set('c', 'd');
obj.get('a');
obj.get('c');
visit over an array of objects.Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Jon Schlinkert
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on August 06, 2015.
FAQs
Convert any object into an event-emitter, and emits events with the name of any any method called on the object.
We found that to-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.

Product
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.

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.