Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@whatwg-node/events

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@whatwg-node/events - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0-alpha-20230515120642-be23d36

8

CHANGELOG.md
# @whatwg-node/events
## 0.1.0-alpha-20230515120642-be23d36
### Minor Changes
- [#535](https://github.com/ardatan/whatwg-node/pull/535)
[`ce067f3`](https://github.com/ardatan/whatwg-node/commit/ce067f3875430185c8177acb47c9b2d8d871f24e)
Thanks [@ardatan](https://github.com/ardatan)! - Drop Node 14 support
## 0.0.3

@@ -4,0 +12,0 @@

2

dist/deno-ponyfill.ts

@@ -1,3 +0,1 @@

export const Event = globalThis.Event;
export const EventTarget = globalThis.EventTarget;
export const CustomEvent = globalThis.CustomEvent;

@@ -1,3 +0,1 @@

module.exports.Event = globalThis.Event;
module.exports.EventTarget = globalThis.EventTarget;
module.exports.CustomEvent = globalThis.CustomEvent;
/// <reference lib="dom" />
declare module "@whatwg-node/events" {
export const Event: typeof globalThis.Event;
export const EventTarget: typeof globalThis.EventTarget;
export const CustomEvent: typeof globalThis.CustomEvent;
}

@@ -1,94 +0,1 @@

module.exports.Event = globalThis.Event;
if (!module.exports.Event) {
module.exports.Event = class Event {
constructor(type, options) {
this.bubbles = !!options && !!options.bubbles;
this.cancelable = !!options && !!options.cancelable;
this.composed = !!options && !!options.composed;
this.type = type;
}
}
}
module.exports.EventTarget = globalThis.EventTarget;
if (!module.exports.EventTarget) {
module.exports.EventTarget = class EventTarget {
constructor() {
this.__listeners = new Map();
}
addEventListener(type, listener, options) {
if (arguments.length < 2) {
throw new TypeError(
`TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only ${arguments.length} present.`
);
}
const __listeners = this.__listeners;
const actualType = type.toString();
if (!__listeners.has(actualType)) {
__listeners.set(actualType, new Map());
}
const listenersForType = __listeners.get(actualType);
if (!listenersForType.has(listener)) {
// Any given listener is only registered once
listenersForType.set(listener, options);
}
}
removeEventListener(type, listener, _options) {
if (arguments.length < 2) {
throw new TypeError(
`TypeError: Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only ${arguments.length} present.`
);
}
const __listeners = this.__listeners;
const actualType = type.toString();
if (__listeners.has(actualType)) {
const listenersForType = __listeners.get(actualType);
if (listenersForType.has(listener)) {
listenersForType.delete(listener);
}
}
}
dispatchEvent(event) {
if (!(event instanceof module.exports.Event)) {
throw new TypeError(
`Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.`
);
}
const type = event.type;
const __listeners = this.__listeners;
const listenersForType = __listeners.get(type);
if (listenersForType) {
for (const [listener, options] of listenersForType.entries()) {
try {
if (typeof listener === "function") {
// Listener functions must be executed with the EventTarget as the `this` context.
listener.call(this, event);
} else if (listener && typeof listener.handleEvent === "function") {
// Listener objects have their handleEvent method called, if they have one
listener.handleEvent(event);
}
} catch (err) {
// We need to report the error to the global error handling event,
// but we do not want to break the loop that is executing the events.
// Unfortunately, this is the best we can do, which isn't great, because the
// native EventTarget will actually do this synchronously before moving to the next
// event in the loop.
setTimeout(() => {
throw err;
});
}
if (options && options.once) {
// If this was registered with { once: true }, we need
// to remove it now.
listenersForType.delete(listener);
}
}
}
// Since there are no cancellable events on a base EventTarget,
// this should always return true.
return true;
}
}
}
module.exports.CustomEvent = globalThis.CustomEvent;

@@ -102,2 +9,2 @@ if (!module.exports.CustomEvent) {

}
}
}
{
"name": "@whatwg-node/events",
"version": "0.0.3",
"version": "0.1.0-alpha-20230515120642-be23d36",
"description": "Cross Platform Smart Event API Ponyfill",

@@ -5,0 +5,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc