Skip to content

endOfInput

Checks if there is nothing left to parse otherwise it fails.

Available since: v1.0.0-alpha.1

Type declaration

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

Example

In this example we are going to parser just the string "Hello" followed by the end of input.

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

The result of the parser above will be:

{
"input": "Hello",
"isError": false,
"offset": 5,
"result": ["Hello", null]
}