Generic Parser - cloudthrottle/dcc-ex--commands GitHub Wiki

Description

Using genericParser(command: string) will attempt to parse the command string trying all available parsers.

Usage

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'
// }

Error

const command = `<unknown>` // would come from the Command Station
const result = await genericParser().parse(command)

console.log(result);
// AggregateError: All promises were rejected
⚠️ **GitHub.com Fallback** ⚠️