UNPKG

@u4/adbkit

Version:

A Typescript client for the Android Debug Bridge.

57 lines 1.79 kB
import { Duplex } from 'stream'; import { AdbUnexpectedDataError } from './errors'; import { AdbError } from './errors'; /** * helper to read in Duplex stream */ export default class Parser { stream: Duplex; private ended; lastMessage: string; constructor(stream: Duplex); /** * read and drop all remaining data in stream * @returns */ end(): Promise<true>; /** * @returns the internal Duplex */ raw(): Duplex; readAll(): Promise<Buffer>; readAscii(howMany: number): Promise<string>; /** * should read code or failed * the correct fail exception will be thow in case of error. * @param codes the expected 4 char code to read */ readCode(...codes: string[]): Promise<string>; readBytes(howMany: number): Promise<Buffer>; /** * pipe howMany bytes to targetStream * @param howMany bytes to transfer * @param targetStream destination stream * @returns Promise that resolves when all bytes are transferred */ readByteFlow(howMany: number, targetStream: Duplex): Promise<void>; readError(): Promise<AdbError>; /** * @returns read a 4-ASCII digits length-prefixed data block */ readValue(): Promise<Buffer>; readValue(encoding: BufferEncoding): Promise<string>; /** * read stream byte per byte until a delimiter is found * @param code delimiter * @returns buffer wothout delimiter */ readUntil(code: number): Promise<Buffer>; searchLine(re: RegExp): Promise<RegExpExecArray>; /** * read socket until \r\n * @returns */ readLine(encoding?: BufferEncoding): Promise<string>; unexpected(data: string, expected: string): AdbUnexpectedDataError; } //# sourceMappingURL=parser.d.ts.map