
Product
Secure Your AI-Generated Code with Socket MCP
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
Listen to any event emitter with a single API.
.on
, .addEventListener
, .subscribe
, ... Why are there so many method names ?
hear is an "universal binder" that allows you to use one method name with the different event emitters, whether it is a DOM node, Node EventEmitter, mediator...
You can also pass a context and hear will handle this for you (no bind
leak).
on
/off
methods. See events.js for API support list.npm i --save hearjs
var hear = require('hearjs');
var emitter = new EventEmitter();
var mediator = new Mediator();
function MyType() {
hear($node, 'click', onEvent, this); // document.querySelector('.node');
hear(emitter, 'onClick', onEvent, this); // EventEmitter
hear(mediator, 'onClick', onEvent, this); // Mediator
}
MyType.prototype.onEvent = function() {
// ...
};
hear.on(emitter, eventName, fn, context)
listen eventName
on the emitter
.
hear.once(emitter, eventName, fn, context)
like .on
but is unbound after first call.
hear.off(emitter, eventName, fn, context)
Unbind an event listener.
If supported by the passed emitter
:
fn
is passed, all the eventName
listeners will be unboundeventName
is passed, the emitter
will be totally unboundCheckout from dev
, merge back against dev
.
Add relevant test cases.
4 spaces, semicolon.
off
method without event/fn argumentFAQs
Listen to any event emitter, with a single API.
We found that hear 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 MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.