-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathreadlines.d.ts
More file actions
51 lines (44 loc) · 1.22 KB
/
readlines.d.ts
File metadata and controls
51 lines (44 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
declare class LineByLine {
/**
* File descriptor. Set to `null` after the file is closed.
*/
fd: number | null;
/**
* Whether reading from stdin (fd 0).
*/
readonly isStdin: boolean;
/**
* Creates a new line-by-line file reader.
* Automatically handles LF (\n), CRLF (\r\n), and CR (\r) line endings.
* Supports reading from stdin (fd 0).
* @param file - Path to file, file descriptor, or 0 for stdin
* @param options - Configuration options
*/
constructor(
file: string | number,
options?: {
/** Number of bytes to read at once. Default: 1024 */
readChunk?: number;
}
);
/**
* Returns the next line as a Buffer, or `null` if end of file is reached.
* The newline character is not included in the returned buffer.
*/
next(): Buffer | null;
/**
* Resets the reader to the beginning of the file.
* Note: reset() does not work with stdin.
*/
reset(): void;
/**
* Manually closes the file. Subsequent `next()` calls will return `null`.
* Note: Does not close stdin when reading from fd 0.
*/
close(): void;
/**
* Returns true if the last line has been read and there are no more lines.
*/
isLast(): boolean;
}
export = LineByLine;