UNPKG

webserial-core

Version:

A strongly-typed, event-driven, abstract TypeScript library for the Web Serial API with custom parsers, command queue, handshake validation, and auto-reconnect.

30 lines (29 loc) 1.05 kB
import { SerialParser } from '../types/index.js'; export interface ReadyParserOptions { /** Byte sequence that signals the device is ready. Accepts a string, Uint8Array, or number[]. */ delimiter: string | Uint8Array | number[]; /** Called once when the ready sequence is detected. */ onReady?: () => void; } /** * Creates a ready parser that waits for the given delimiter sequence and then * emits all subsequent data as raw `Uint8Array` chunks. * * @param options - Configuration options including the ready delimiter. * @returns A {@link SerialParser} that emits `Uint8Array` values. * * @example * ```ts * import { AbstractSerialDevice, readyParser } from 'webserial-core'; * * class MyDevice extends AbstractSerialDevice<Uint8Array> { * constructor() { * super({ * baudRate: 9600, * parser: readyParser({ delimiter: 'READY\n', onReady: () => console.log('device ready') }), * }); * } * } * ``` */ export declare function readyParser(options: ReadyParserOptions): SerialParser<Uint8Array>;