
Security News
Microsoft Releases Open Source Toolkit for AI Agent Runtime Security
Microsoft has released an open source toolkit for enforcing runtime security policies on AI agents as adoption accelerates faster than governance controls.
listenersctrl
Advanced tools
Managing event listeners in the browser environment
A tool for associating an element with a number of callback functions that allows shortcut connection / disconnection of them as event listeners.
import { ListenersCtrl, ListenersAggt } from 'listenersctrl.js';
var wLstn = ListenersCtrl(window);
/**(connect one listener and then replace it with the other)**/
wLstn.Append('click', function(ev) { alert('f()'); });
//.................................................//
wLstn.Apply('click', function(ev) { alert('g()'); });
/*(associate listeners but connect them to the element later on)*/
wLstn.AssociateArray([
['click', function(ev) { alert('f()'); }],
['click', function(ev) { alert('g()'); }],
]);
//...........................................//
wLstn.Connect();
/****(using markers to specify a group of listeners)******/
wLstn.AppendArray([
['click', function(ev) { alert('g1()'); }],
['click', function(ev) { alert('g2()'); }],
]).As('g');
//..........................................//
wLstn.Select('g').Disconn();
/***************(remove all listeners)***************/
wLstn.Clear();
ListenersAggt.Element('#cssSelector')
.Associate('click', function(ev) { alert('f()'); });
ListenersAggt.Element('#cssSelector', 'a')
.Associate('click', function(ev) { alert('g()'); });
ListenersAggt.Alias('a').Connect();
var eLstn = ListenersCtrl('#cssSelector');
eLstn.Associate('click', function(ev) { alert('f()'); });
eLstn.Associate('click', function(ev) { alert('g()'); });
eLstn.Connect();
If an instance was created by ListenersCtrl function, it is not accessible by ListenersAggt methods
( Methods Invoke and InvokeConn can also be supplied with an argument or an array of arguments which every callback function will be called with )
/*(connecting and disconnecting listeners of specific event type)*/
wLstn.Select(null, {type:'click'}).Connect();
wLstn.Select(null, {type:'click'}).Disconn();
/*************(reversing the order of invocation)*****************/
wLstn.Append('click', function(ev) { alert('f()'); }).As('a');
wLstn.Append('click', function(ev) { alert('g()'); }).As('b');
wLstn.Append('click', function(ev) { alert('h()'); }).As('c');
wLstn.Select('b').Append().Select('a').Append();
/*******************(merging two markers)************************/
wLstn.Append('click', function(ev) { alert('f()'); }).As(0);
wLstn.Append('click', function(ev) { alert('g()'); }).As(1);
wLstn.Select(0).As(1);
wLstn.Select(0).Count(); //0;
wLstn.Select(1).Count(); //2;
An example of utilizing can be found in the file example.html
FAQs
Managing event listeners in the browser environment
We found that listenersctrl 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
Microsoft has released an open source toolkit for enforcing runtime security policies on AI agents as adoption accelerates faster than governance controls.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.