API / geotoolkit / util / stream / LineReader / LineReader
stream.LineReader.LineReader
A wrapper class offering line based reading on top of a regular stream.<br> This implementation hides the complexity of the underlying stream to offer line based reading instead.<br> To do so, this reader will (lazily) parse the stream to text and search for \n \r chars.<br> Doing so, it will build a line based index to allow faster access to specific lines further on.
Constructors
- [new LineReader(options)](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit.util.stream.linereader.linereader.md#new linereader(options))
Methods
▸ capture(startRegex, endRegex, index, maxcount, callback): void
Search for the sequence starting by the given regexp and ending by the other regexp.<br> The search starts at the given line number and ends (at worst) after maxcount lines have been read (if maxcount != -1).<br> <br> Note that reaching END-OF-STREAM without finding the searched regexp will not be considered as an error.<br>
| Name | Type | Description |
|---|---|---|
startRegex | string | The start regular expression to search for (as a string) |
endRegex | string | The end regular expression to search for (as a string) |
index | number | Starting line index |
maxcount | number | Maximum count of line that can be read. If the capture did not finish in that range, an error will be reported. -1 for no limit |
callback | captureCallback | The function called with the result |
void
▸ find(regex, index, callback): void
Search for the given regexp starting at the given line number.<br>
| Name | Type | Description |
|---|---|---|
regex | string | The regular expression to search for (as a string) |
index | number | Starting line index |
callback | findCallback | The function called with the result |
void
▸ getClassName(): string
string
▸ readLines(index, count, callback): void
Reads the lines starting at the given line index up to the given count.
| Name | Type | Description |
|---|---|---|
index | number | Starting line index |
count | number | Amount of lines to read |
callback | readLinesCallback | The function called with the result |
void
▸ Static getClassName(): string
string