-
Notifications
You must be signed in to change notification settings - Fork 0
Generic Parser
David Young edited this page Jan 20, 2022
·
2 revisions
Using genericParser(command: string)
will attempt to parse the command string
trying all available parsers.
const command = `<j 70 "My Loco">` // would come from the Command Station
const result = await genericParser().parse(command)
console.log(result);
// {
// key: 'j',
// parser: "rosterItemParser",
// params: {
// cabId: 70,
// display: 'My Loco',
// functionButtons: []
// },
// status: 'success'
// }
const command = `<unknown>` // would come from the Command Station
const result = await genericParser().parse(command)
console.log(result);
// AggregateError: All promises were rejected