@libp2p/interfaces
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -0,1 +1,2 @@ | ||
import type { Duplex } from 'it-stream-types'; | ||
export interface MuxerFactory { | ||
@@ -33,8 +34,6 @@ new (options: MuxerOptions): Muxer; | ||
} | ||
export interface MuxedStream<T = Uint8Array> extends AsyncIterable<T> { | ||
export interface MuxedStream extends Duplex<Uint8Array> { | ||
close: () => void; | ||
abort: () => void; | ||
reset: () => void; | ||
sink: (source: AsyncIterable<T>) => Promise<void>; | ||
source: AsyncIterable<T>; | ||
timeline: MuxedTimeline; | ||
@@ -41,0 +40,0 @@ id: string; |
/// <reference types="node" /> | ||
import type events from 'events'; | ||
import type { Multiaddr } from '@multiformats/multiaddr'; | ||
import type { Connection } from '../connection'; | ||
import type { Connection } from '../connection/index.js'; | ||
import type { AbortOptions } from '../index.js'; | ||
import type { Duplex } from 'it-stream-types'; | ||
export interface TransportFactory<DialOptions extends { | ||
@@ -17,6 +18,9 @@ signal?: AbortSignal; | ||
} | ||
export interface ListenerOptions { | ||
handler?: ConnectionHandler; | ||
} | ||
/** | ||
* A libp2p transport is understood as something that offers a dial and listen interface to establish connections. | ||
*/ | ||
export interface Transport<DialOptions extends AbortOptions = AbortOptions, ListenerOptions = Record<string, any>> { | ||
export interface Transport<DialOptions extends AbortOptions = AbortOptions, CreateListenerOptions extends ListenerOptions = ListenerOptions> { | ||
/** | ||
@@ -29,3 +33,3 @@ * Dial a given multiaddr. | ||
*/ | ||
createListener: (options: ListenerOptions, handler?: ConnectionHandler) => Listener; | ||
createListener: (options?: CreateListenerOptions) => Listener; | ||
/** | ||
@@ -67,5 +71,3 @@ * Takes a list of `Multiaddr`s and returns only valid addresses for the transport | ||
} | ||
export interface MultiaddrConnection<T = Uint8Array> { | ||
sink: (source: AsyncIterable<T>) => Promise<void>; | ||
source: AsyncIterable<T>; | ||
export interface MultiaddrConnection extends Duplex<Uint8Array, Uint8Array, Promise<void>> { | ||
close: (err?: Error) => Promise<void>; | ||
@@ -72,0 +74,0 @@ conn: unknown; |
{ | ||
"name": "@libp2p/interfaces", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Interfaces for JS Libp2p", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -0,1 +1,2 @@ | ||
import type { Duplex } from 'it-stream-types' | ||
@@ -40,10 +41,8 @@ export interface MuxerFactory { | ||
export interface MuxedStream<T = Uint8Array> extends AsyncIterable<T> { | ||
export interface MuxedStream extends Duplex<Uint8Array> { | ||
close: () => void | ||
abort: () => void | ||
reset: () => void | ||
sink: (source: AsyncIterable<T>) => Promise<void> | ||
source: AsyncIterable<T> | ||
timeline: MuxedTimeline | ||
id: string | ||
} |
@@ -56,3 +56,3 @@ # interface-stream-muxer | ||
const Muxer = require('your-muxer-module') | ||
import pipe from 'it-pipe' | ||
import { pipe } from 'it-pipe' | ||
@@ -59,0 +59,0 @@ // Create a duplex muxer |
import type events from 'events' | ||
import type { Multiaddr } from '@multiformats/multiaddr' | ||
import type { Connection } from '../connection' | ||
import type { Connection } from '../connection/index.js' | ||
import type { AbortOptions } from '../index.js' | ||
import type { Duplex } from 'it-stream-types' | ||
@@ -14,6 +15,10 @@ export interface TransportFactory<DialOptions extends { signal?: AbortSignal }, ListenerOptions> { | ||
export interface ListenerOptions { | ||
handler?: ConnectionHandler | ||
} | ||
/** | ||
* A libp2p transport is understood as something that offers a dial and listen interface to establish connections. | ||
*/ | ||
export interface Transport <DialOptions extends AbortOptions = AbortOptions, ListenerOptions = Record<string, any>> { | ||
export interface Transport <DialOptions extends AbortOptions = AbortOptions, CreateListenerOptions extends ListenerOptions = ListenerOptions> { | ||
/** | ||
@@ -26,3 +31,3 @@ * Dial a given multiaddr. | ||
*/ | ||
createListener: (options: ListenerOptions, handler?: ConnectionHandler) => Listener | ||
createListener: (options?: CreateListenerOptions) => Listener | ||
/** | ||
@@ -69,5 +74,3 @@ * Takes a list of `Multiaddr`s and returns only valid addresses for the transport | ||
export interface MultiaddrConnection<T = Uint8Array> { | ||
sink: (source: AsyncIterable<T>) => Promise<void> | ||
source: AsyncIterable<T> | ||
export interface MultiaddrConnection extends Duplex<Uint8Array, Uint8Array, Promise<void>> { | ||
close: (err?: Error) => Promise<void> | ||
@@ -74,0 +77,0 @@ conn: unknown |
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
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
1300134
1440