@libp2p/interface
Advanced tools
Comparing version 0.1.4-69581367 to 0.1.4-025c082a
@@ -0,1 +1,3 @@ | ||
/// <reference types="node" /> | ||
import { setMaxListeners as nodeSetMaxListeners } from 'events'; | ||
export interface EventCallback<EventType> { | ||
@@ -40,2 +42,3 @@ (evt: EventType): void; | ||
export { TypedEventEmitter as EventEmitter }; | ||
export declare const setMaxListeners: typeof nodeSetMaxListeners; | ||
//# sourceMappingURL=events.d.ts.map |
@@ -0,1 +1,2 @@ | ||
import { setMaxListeners as nodeSetMaxListeners } from 'events'; | ||
/** | ||
@@ -68,2 +69,11 @@ * An implementation of a typed event target | ||
export { TypedEventEmitter as EventEmitter }; | ||
// create a setMaxListeners that doesn't break browser usage | ||
export const setMaxListeners = (n, ...eventTargets) => { | ||
try { | ||
nodeSetMaxListeners(n, ...eventTargets); | ||
} | ||
catch { | ||
// swallow error, gulp | ||
} | ||
}; | ||
//# sourceMappingURL=events.js.map |
@@ -90,2 +90,6 @@ /** | ||
signedPeerRecord?: SignedPeerRecord; | ||
/** | ||
* The connection that the identify protocol ran over | ||
*/ | ||
connection: Connection; | ||
} | ||
@@ -92,0 +96,0 @@ /** |
@@ -6,5 +6,18 @@ import type { Connection } from '../connection/index.js'; | ||
max?: number; | ||
/** | ||
* If true, invoke `onConnect` for this topology on transient (e.g. short-lived | ||
* and/or data-limited) connections. (default: false) | ||
*/ | ||
notifyOnTransient?: boolean; | ||
/** | ||
* Invoked when a new connection is opened to a peer that supports the | ||
* registered protocol | ||
*/ | ||
onConnect?(peerId: PeerId, conn: Connection): void; | ||
/** | ||
* Invoked when the last connection to a peer that supports the registered | ||
* protocol closes | ||
*/ | ||
onDisconnect?(peerId: PeerId): void; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@libp2p/interface", | ||
"version": "0.1.4-69581367", | ||
"version": "0.1.4-025c082a", | ||
"description": "The interface implemented by a libp2p node", | ||
@@ -42,2 +42,5 @@ "license": "Apache-2.0 OR MIT", | ||
], | ||
"browser": { | ||
"events": "./dist/src/events.browser.js" | ||
}, | ||
"exports": { | ||
@@ -178,4 +181,4 @@ ".": { | ||
"sinon": "^17.0.0", | ||
"sinon-ts": "^1.0.0" | ||
"sinon-ts": "^2.0.0" | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
import { setMaxListeners as nodeSetMaxListeners } from 'events' | ||
export interface EventCallback<EventType> { (evt: EventType): void } | ||
@@ -120,1 +122,10 @@ export interface EventObject<EventType> { handleEvent: EventCallback<EventType> } | ||
export { TypedEventEmitter as EventEmitter } | ||
// create a setMaxListeners that doesn't break browser usage | ||
export const setMaxListeners: typeof nodeSetMaxListeners = (n, ...eventTargets) => { | ||
try { | ||
nodeSetMaxListeners(n, ...eventTargets) | ||
} catch { | ||
// swallow error, gulp | ||
} | ||
} |
@@ -102,2 +102,7 @@ /** | ||
signedPeerRecord?: SignedPeerRecord | ||
/** | ||
* The connection that the identify protocol ran over | ||
*/ | ||
connection: Connection | ||
} | ||
@@ -104,0 +109,0 @@ |
@@ -8,4 +8,19 @@ import type { Connection } from '../connection/index.js' | ||
/** | ||
* If true, invoke `onConnect` for this topology on transient (e.g. short-lived | ||
* and/or data-limited) connections. (default: false) | ||
*/ | ||
notifyOnTransient?: boolean | ||
/** | ||
* Invoked when a new connection is opened to a peer that supports the | ||
* registered protocol | ||
*/ | ||
onConnect?(peerId: PeerId, conn: Connection): void | ||
/** | ||
* Invoked when the last connection to a peer that supports the registered | ||
* protocol closes | ||
*/ | ||
onDisconnect?(peerId: PeerId): void | ||
} |
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
Sorry, the diff of this file is not supported yet
259009
134
6212