@libp2p/interfaces
Advanced tools
Comparing version 3.3.1 to 3.3.2-1c6702c8
@@ -10,4 +10,4 @@ /** | ||
constructor(message?: string); | ||
static get code(): string; | ||
static get type(): string; | ||
static readonly code = "ABORT_ERR"; | ||
static readonly type = "aborted"; | ||
} | ||
@@ -14,0 +14,0 @@ export declare class CodeError<T extends Record<string, any> = Record<string, never>> extends Error { |
@@ -7,2 +7,4 @@ /** | ||
export class AbortError extends Error { | ||
code; | ||
type; | ||
constructor(message = 'The operation was aborted') { | ||
@@ -13,10 +15,8 @@ super(message); | ||
} | ||
static get code() { | ||
return 'ABORT_ERR'; | ||
} | ||
static get type() { | ||
return 'aborted'; | ||
} | ||
static code = 'ABORT_ERR'; | ||
static type = 'aborted'; | ||
} | ||
export class CodeError extends Error { | ||
code; | ||
props; | ||
constructor(message, code, props) { | ||
@@ -23,0 +23,0 @@ super(message); |
@@ -1,7 +0,1 @@ | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var _EventEmitter_listeners; | ||
/** | ||
@@ -16,8 +10,5 @@ * Adds types to the EventTarget class. Hopefully this won't be necessary forever. | ||
export class EventEmitter extends EventTarget { | ||
constructor() { | ||
super(...arguments); | ||
_EventEmitter_listeners.set(this, new Map()); | ||
} | ||
#listeners = new Map(); | ||
listenerCount(type) { | ||
const listeners = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(type); | ||
const listeners = this.#listeners.get(type); | ||
if (listeners == null) { | ||
@@ -30,6 +21,6 @@ return 0; | ||
super.addEventListener(type, listener, options); | ||
let list = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(type); | ||
let list = this.#listeners.get(type); | ||
if (list == null) { | ||
list = []; | ||
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").set(type, list); | ||
this.#listeners.set(type, list); | ||
} | ||
@@ -43,3 +34,3 @@ list.push({ | ||
super.removeEventListener(type.toString(), listener ?? null, options); | ||
let list = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(type); | ||
let list = this.#listeners.get(type); | ||
if (list == null) { | ||
@@ -49,7 +40,7 @@ return; | ||
list = list.filter(({ callback }) => callback !== listener); | ||
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").set(type, list); | ||
this.#listeners.set(type, list); | ||
} | ||
dispatchEvent(event) { | ||
const result = super.dispatchEvent(event); | ||
let list = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(event.type); | ||
let list = this.#listeners.get(event.type); | ||
if (list == null) { | ||
@@ -59,3 +50,3 @@ return result; | ||
list = list.filter(({ once }) => !once); | ||
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").set(event.type, list); | ||
this.#listeners.set(event.type, list); | ||
return result; | ||
@@ -67,3 +58,2 @@ } | ||
} | ||
_EventEmitter_listeners = new WeakMap(); | ||
/** | ||
@@ -77,2 +67,4 @@ * CustomEvent is a standard event but it's not supported by node. | ||
class CustomEventPolyfill extends Event { | ||
/** Returns any custom data event was created with. Typically used for synthetic events. */ | ||
detail; | ||
constructor(message, data) { | ||
@@ -79,0 +71,0 @@ super(message, data); |
{ | ||
"name": "@libp2p/interfaces", | ||
"version": "3.3.1", | ||
"version": "3.3.2-1c6702c8", | ||
"description": "Common code shared by the various libp2p interfaces", | ||
"license": "Apache-2.0 OR MIT", | ||
"homepage": "https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/interfaces#readme", | ||
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/interfaces#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/libp2p/js-libp2p-interfaces.git" | ||
"url": "git+https://github.com/libp2p/js-libp2p.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/libp2p/js-libp2p-interfaces/issues" | ||
"url": "https://github.com/libp2p/js-libp2p/issues" | ||
}, | ||
@@ -18,6 +18,2 @@ "keywords": [ | ||
], | ||
"engines": { | ||
"node": ">=16.0.0", | ||
"npm": ">=7.0.0" | ||
}, | ||
"type": "module", | ||
@@ -164,3 +160,3 @@ "types": "./dist/src/index.d.ts", | ||
"devDependencies": { | ||
"aegir": "^38.1.0" | ||
"aegir": "^39.0.5" | ||
}, | ||
@@ -167,0 +163,0 @@ "typedoc": { |
@@ -5,4 +5,4 @@ # @libp2p/interfaces <!-- omit in toc --> | ||
[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io) | ||
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-interfaces.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-interfaces) | ||
[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-interfaces/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p-interfaces/actions/workflows/js-test-and-release.yml?query=branch%3Amaster) | ||
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p) | ||
[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/main.yml?branch=master\&style=flat-square)](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amaster) | ||
@@ -91,3 +91,3 @@ > Common code shared by the various libp2p interfaces | ||
- <https://libp2p.github.io/js-libp2p-interfaces/modules/_libp2p_interfaces.html> | ||
- <https://libp2p.github.io/js-libp2p/modules/_libp2p_interfaces.html> | ||
@@ -94,0 +94,0 @@ ## License |
@@ -17,9 +17,5 @@ | ||
static get code (): string { | ||
return 'ABORT_ERR' | ||
} | ||
static readonly code = 'ABORT_ERR' | ||
static get type (): string { | ||
return 'aborted' | ||
} | ||
static readonly type = 'aborted' | ||
} | ||
@@ -26,0 +22,0 @@ |
@@ -20,3 +20,3 @@ | ||
export class EventEmitter<EventMap extends Record<string, any>> extends EventTarget { | ||
#listeners: Map<any, Listener[]> = new Map() | ||
#listeners = new Map<any, Listener[]>() | ||
@@ -23,0 +23,0 @@ listenerCount (type: string): number { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30328
24
495
2