src/util.js
/**
 *Parses an input file into dimensions, rovers, and commands
 *
 * @param {string} input the full file contents where the first line is dimensions
 * @returns {object} dimensions of plateau and an array of rovers
 */
Parses an input file into dimensions, rovers, and commands
@param {string} input the full file contents where the first line is dimensions
@returns {object} dimensions of plateau and an array of rovers
Parses an input file into dimensions rovers and commands @param { string } input the full file contents where the first line is dimensions @returns { object } dimensions of plateau and an array of rovers
function parseFile (input) {
  const lines = input.trim().split('\n')
  const dimensions = parsePlateau(lines.shift())
  const rovers = []
  for (let i = 1; i < lines.length; i += 2) {
    const { location, direction } = parseRover(lines[i - 1])
    rovers.push({
      location,
      direction,
      commands: parseCommands(lines[i])
    })
  }
  return {
    dimensions,
    rovers
  }
}
function parseFile ( input ) { const lines = input . trim ( ) . split ( '\n' ) const dimensions = parsePlateau ( lines . shift ( ) ) const rovers = [ ] for ( let i = 1 ; i < lines . length ; i += 2 ) { const { location , direction } = parseRover ( lines [ i - 1 ] ) rovers . push ( { location , direction , commands : parseCommands ( lines [ i ] ) } ) } return { dimensions , rovers } }
Parses an input file into dimensions, rovers, and commands
 @param {string} input the full file contents where the first line is dimensions
 @returns {object} dimensions of plateau and an array of rovers
Parses an input file into dimensions rovers and commands @param { string } input the full file contents where the first line is dimensions @returns { object } dimensions of plateau and an array of rovers
// first line is plateau dimensions // all remaining pairs of lines are rover+command