Skip to content

endOfLine

Tries to match an end of line (either \r\n, \r or \n)

Available since: v1.0.0-alpha.3

Type declaration

const endOfLine: (name?: string) => Parser;

Example

In this example we are going to parser the string "Hello" followed by a newline.

import { endOfLine, sequenceOf, string } from "rudus";
const parser = sequenceOf([string("Hello"), endOfLine()]);
const result = parser.run(`Hello
`);

The result of the parser above will be:

{
"input": "Hello
",
"isError": false,
"offset": 6,
"result": ["Hello", "<EOL>"]
}