noderl/dist/main.d.ts

36 lines
1.2 KiB
TypeScript

/// <reference types="node" />
/// <reference types="node" />
import { Bert } from "./bert.js";
import { Duplex } from "node:stream";
type WriteCallback = (error: Error | null | undefined) => void;
type ServerHandlerCallback = (reply: "reply" | "noreply", ...extraArgs: any[]) => any;
type ServerHandler = (term: any, from: any, state: any, callback: ServerHandlerCallback) => void;
/**
* Only handles Buffers.
*/
export declare class DumbPort extends Duplex {
private static readonly LEN_LEN;
private buf;
constructor();
_read(): Buffer | null;
_write(obj: any, encodingOrCallback?: BufferEncoding | WriteCallback, callback?: WriteCallback | undefined): void;
}
/**
* Handles full Erlang/Elixir terms.
*/
export declare class Port extends Duplex {
readonly bert: Bert;
private lenBuffer;
constructor(allBinariesAsString?: boolean, mapKeyAsAtom?: boolean, decodeUndefinedValues?: boolean);
_read(): any;
_write(obj: any, encodingOrCallback?: BufferEncoding | WriteCallback, callback?: WriteCallback | undefined): boolean;
}
export declare class Server {
private port;
private handler;
private state;
private handleTerm;
constructor(port: Port, handler: ServerHandler);
}
export {};