UNPKG

@slippi/slippi-js

Version:
56 lines 1.93 kB
import type { WritableOptions } from "stream"; import { Writable } from "stream"; import type { EventPayloadTypes } from "../types"; import { Command } from "../types"; export declare enum SlpStreamMode { AUTO = "AUTO",// Always reading data, but errors on invalid command MANUAL = "MANUAL" } declare const defaultSettings: { suppressErrors: boolean; mode: SlpStreamMode; }; export type SlpStreamSettings = typeof defaultSettings; export type MessageSizes = Map<Command, number>; export type SlpCommandEventPayload = { command: Command; payload: EventPayloadTypes | MessageSizes; }; export type SlpRawEventPayload = { command: Command; payload: Buffer; }; export declare enum SlpStreamEvent { RAW = "slp-raw", COMMAND = "slp-command" } /** * SlpStream is a writable stream of Slippi data. It passes the data being written in * and emits an event based on what kind of Slippi messages were processed. * * SlpStream emits two events: "slp-raw" and "slp-command". The "slp-raw" event emits the raw buffer * bytes whenever it processes each command. You can manually parse this or write it to a * file. The "slp-command" event returns the parsed payload which you can access the attributes. * * @class SlpStream * @extends {Writable} */ export declare class SlpStream extends Writable { private gameEnded; private settings; private payloadSizes; private previousBuffer; /** *Creates an instance of SlpStream. * @param {Partial<SlpStreamSettings>} [slpOptions] * @param {WritableOptions} [opts] * @memberof SlpStream */ constructor(slpOptions?: Partial<SlpStreamSettings>, opts?: WritableOptions); restart(): void; _write(newData: Buffer, encoding: string, callback: (error?: Error | null, data?: any) => void): void; private _writeCommand; private _processCommand; } export {}; //# sourceMappingURL=slpStream.d.ts.map