0.1.9 • Published 2 years ago

@types/line-by-line v0.1.9

Weekly downloads
596
License
MIT
Repository
github
Last release
2 years ago

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

// Type definitions for line-by-line 0.1
// Project: https://github.com/Osterjour/line-by-line
// Definitions by: DefinitelyTyped <https://github.com/DefinitelyTyped>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <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: Thu, 23 Dec 2021 23:35:02 GMT
  • Dependencies: @types/node
  • Global values: none

Credits

These definitions were written by DefinitelyTyped.

0.1.8

2 years ago

0.1.7

2 years ago

0.1.9

2 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

5 years ago

0.1.3

6 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago