// robots.txt lexer in JavaScript // PR TO SUBMIT FIXES const split = function(str) { var index = str.indexOf(':'); return [str.slice(0, index), str.slice(index + 1)]; } const struc = function(arr) { return { type: arr[0].toLowerCase(), value: arr[1].toLowerCase() } } const lexer = function(input) { return input.split(/\r\n|\r|\n/) .map(str => str.replace(/ /g, "")) .map(str => str.replace(/#.*$/, "")) .filter(str => str) .map(split) .map(struc) }