UNPKG

@types/line-by-line

Version:
89 lines (74 loc) 2.86 kB
# Installation > `npm install --save @types/line-by-line` # Summary This package contains type definitions for line-by-line (https://github.com/Osterjour/line-by-line). # Details Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/line-by-line. ## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/line-by-line/index.d.ts) ````ts /// <reference types="node" /> import { EventEmitter } from "events"; import { Readable } from "stream"; interface LineByLineReaderOptions { /** The encoding to use. */ encoding?: "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "latin1" | "binary" | "hex" | undefined; /** If set to true, empty lines do not emit the "line" event. */ skipEmptyLines?: boolean | undefined; } interface LineByLineReaderFileOptions extends LineByLineReaderOptions { /** The `end` position in bytes to read from the file. */ end?: number | undefined; /** The `start` position in bytes to read from the file. */ start?: number | undefined; } declare class LineByLineReader extends EventEmitter { /** * Constructs a new `LineByLineReader` from a path to a file. * @param filePath The path to the file to read. * @param options Optional. The options used when constructing the new `LineByLineReader` object. */ constructor(filePath: string, options?: LineByLineReaderFileOptions); /** * Constructs a new `LineByLineReader` from a readable stream. * @param stream The stream to read. * @param options Optional. The options used when constructing the new `LineByLineReader` object. */ constructor(stream: Readable, options?: LineByLineReaderOptions); /** * Stops emitting "line" events, closes the file or stream, and emits the "end" event. */ close(): void; /** * Emitted if all lines are read. * @param event * @param listener */ on(event: "end", listener: () => void): this; /** * Emitted if an error occured. * @param event * @param listener A listener that receives the error object. */ on(event: "error", listener: (err: any) => void): this; /** * Emitted on every line read. * @param event * @param listener A listener that receives the line without the line terminator. */ on(event: "line", listener: (line: string) => void): this; /** * Call this method to stop emitting "line" events. */ pause(): void; /** * After calling this method, "line" events get emitted again. */ resume(): void; } export = LineByLineReader; ```` ### Additional Details * Last updated: Tue, 07 Nov 2023 09:09:38 GMT * Dependencies: [@types/node](https://npmjs.com/package/@types/node) # Credits These definitions were written by .