
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
JBEvent is a library that provides functions related to JavaScript events.
JBEvent is a library that provides functions related to JavaScript events.
It inherits the prototype of the JBEvent
class to the specified target object and returns the target object.
The target object that inherits the prototype of JBEvent
can use the methods of JBEvent
.
var foo = {
name: 'SomeObject'
};
JBEvent.extends(foo);
foo.on('SomeEvent', function() {
console.log(this.name);
});
foo.fire('SomeEvent'); // 'SomeObject'
Triggers an event corresponding to the specified event name. Executes all event listeners registered with the specified event name.
var foo = {};
JBEvent.extends(foo);
foo.on('SomeEvent', function() {
console.log('Anonymous event listener');
});
foo.on('SomeEvent', function(eve) {
console.log(eve.data);
}, null, 'SomeData');
foo.on('SomeEvent', function(eve) {
console.log(eve.info);
});
foo.fire('SomeEvent', 'SomeInfo');
// 'Anonymous event listener'
// 'SomeData'
// 'SomeInfo'
Triggers the event corresponding to the specified event name, executes the registered event listeners, and removes the executed event listeners. Executes and removes event listeners registered with the specified event name.
var foo = {};
var bar = function() {
console.log('SomeEventListener');
};
JBEvent.extends(foo);
foo.on('SomeEvent', bar);
foo.fire('SomeEvent'); // 'SomeEventListener'
foo.fireOnce('SomeEvent'); // 'SomeEventListener'
foo.fire('SomeEvent'); // bar event listener not called.
Returns whether the specified event listener is registered with the specified event name.
var foo = {};
var bar = function() {};
JBEvent.extends(foo);
foo.on('SomeEvent', bar);
foo.hasListener('SomeEvent', bar); // true
foo.hasListener('OtherEvent', bar); // false
Returns whether an event listener registered with the specified event name exists.
var foo = {};
var bar = function() {};
JBEvent.extends(foo);
foo.on('SomeEvent', bar);
console.log(foo.hasListeners('SomeEvent')); // true
console.log(foo.hasListeners('OtherEvent')); // false
Removes the specified event listener registered for the specified event name.
var foo = {};
var bar = function() {
console.log('SomeEventListener');
};
JBEvent.extends(foo);
foo.on('SomeEvent', bar);
foo.fire('SomeEvent'); // 'SomeEventListener'
foo.off('SomeEvent', bar);
foo.fire('SomeEvent'); // bar event listener not called.
Removes all event listeners for all event names registered on the object.
var foo = {};
var bar = function() {
console.log('SomeEventListener');
};
var baz = function() {
console.log('OtherEventListener');
};
JBEvent.extends(foo);
foo.on('SomeEvent', bar);
foo.on('SomeEvent', function() {
console.log('AnonymousEventListener');
});
foo.on('OtherEvent', baz);
foo.offAll();
foo.fire('SomeEvent');
foo.fire('OtherEvent');
// No event listeners are executed.
Removes all registered event listeners for the specified event name.
var foo = {};
var bar = function() {
console.log('SomeEventListener');
};
JBEvent.extends(foo);
foo.on('SomeEvent', bar);
foo.on('SomeEvent', function() {
console.log('Anonymous event listener');
});
foo.fire('SomeEvent');
// 'SomeEventListener'
// 'Anonymous event listener'
foo.offs('SomeEvent');
foo.fire('SomeEvent');
// No event listeners are executed.
Registers an event listener to execute when an event corresponding to the specified event name occurs.
var foo = {};
JBEvent.extends(foo);
foo.on('SomeEvent', function() {
console.log(this === foo);
});
foo.fire('SomeEvent'); // true
var foo = {};
var bar = {};
JBEvent.extends(foo);
foo.on('SomeEvent', function() {
console.log(this === bar);
}, bar);
foo.fire('SomeEvent'); // true
var foo = {};
JBEvent.extends(foo);
foo.on('SomeEvent', function(eve) {
console.log(eve.data);
}, null, 'SomeData');
foo.fire('SomeEvent'); // 'SomeData'
var foo = {};
JBEvent.extends(foo);
foo.on('SomeEvent', function() {
console.log('Anonymous event listener 1');
});
foo.on('SomeEvent', function() {
console.log('Anonymous event listener 2');
}, null, null, 100);
foo.on('SomeEvent', function() {
console.log('Anonymous event listener 3');
}, null, null, 1);
foo.fire('SomeEvent');
// 'Anonymous event listener 3'
// 'Anonymous event listener 1'
// 'Anonymous event listener 2'
Registers a one-off event listener for the specified event name. Registers a one-off event listener to execute when the event occurs.
Event listeners registered with the once()
method are executed only once when an event occurs, and the event listener is removed after it is executed.
var foo = {};
var bar = function() {
console.log('SomeEventListener');
};
JBEvent.extends(foo);
foo.once('SomeEvent', bar);
foo.fire('SomeEvent'); // 'SomeEventListener'
foo.fire('SomeEvent'); // bar event listener not called.
FAQs
JBEvent is a library that provides functions related to JavaScript events.
We found that jbevent 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
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.