mirror of
https://github.com/186526/handlers.js
synced 2024-10-13 00:29:43 +00:00
Add Txiki.js Adapter.
This commit is contained in:
53
types/txiki.d.ts
vendored
Normal file
53
types/txiki.d.ts
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
type Transport = "tcp" | "udp" | "pipe";
|
||||
|
||||
interface ListenOptions {
|
||||
backlog?: number
|
||||
// Disables dual stack mode.
|
||||
ipv6Only?: boolean;
|
||||
// Used on UDP only. Enable address reusing (when binding). What that means is that multiple threads or processes can bind to the same address without error (provided they all set the flag) but only the last one to bind will receive any traffic, in effect "stealing" the port from the previous listener.
|
||||
reuseAddr?: boolean;
|
||||
}
|
||||
|
||||
declare namespace tjs {
|
||||
const versions: { curl: string; quickjs: string; tjs: string; uv: string; wasm3: string };
|
||||
|
||||
export interface Address {
|
||||
readonly family: number;
|
||||
readonly flowinfo?: number;
|
||||
readonly ip: string;
|
||||
readonly port: number;
|
||||
readonly scopeId?: number;
|
||||
}
|
||||
|
||||
export interface Connection {
|
||||
readonly localAddress: Address;
|
||||
readonly readable: ReadableStream<Uint8Array>;
|
||||
|
||||
readonly remoteAddress: Address;
|
||||
readonly writeable: WritableStream<Uint8Array>
|
||||
|
||||
close(): void
|
||||
read(buf: Uint8Array): Promise<number>
|
||||
write(buf: Uint8Array): Promise<number>
|
||||
|
||||
setKeepAlive(enable?: boolean): void
|
||||
setNoDelay(enable?: boolean): void
|
||||
shutdown(): void
|
||||
}
|
||||
|
||||
export interface Listener extends AsyncIterable<Connection> {
|
||||
readonly localAddress: Address;
|
||||
|
||||
accept(): Promise<Connection>;
|
||||
close(): void;
|
||||
|
||||
[Symbol.asyncIterator](): AsyncIterableIterator<Connection>;
|
||||
}
|
||||
|
||||
export function listen(
|
||||
transport: Transport,
|
||||
host: string,
|
||||
port?: string | number,
|
||||
options?: ListenOptions
|
||||
): Promise<Listener>
|
||||
}
|
Reference in New Issue
Block a user