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.

29 lines (28 loc) 1.02 kB
import { SerialParser } from '../types/index.js'; export interface ReadlineOptions { /** Line delimiter. Defaults to `'\n'`. Accepts a string, Uint8Array, or number[]. */ delimiter?: string | Uint8Array | number[]; /** Include the delimiter at the end of each emitted string. Defaults to false. */ includeDelimiter?: boolean; /** Text encoding used to decode bytes. Defaults to `'utf-8'`. */ encoding?: string; } /** * Creates a readline parser that splits the byte stream on a newline (or * custom delimiter) and emits each line as a decoded string. * * @param options - Optional configuration. * @returns A {@link SerialParser} that emits `string` values. * * @example * ```ts * import { AbstractSerialDevice, readline } from 'webserial-core'; * * class MyDevice extends AbstractSerialDevice<string> { * constructor() { * super({ baudRate: 9600, parser: readline() }); * } * } * ``` */ export declare function readline(options?: ReadlineOptions): SerialParser<string>;