cyp/app/js/parser.js

11 lines
273 B
JavaScript
Raw Normal View History

2019-03-20 03:45:23 +08:00
export function linesToStruct(lines) {
let result = {};
lines.forEach(line => {
let cindex = line.indexOf(":");
if (cindex == -1) { throw new Error(`Malformed line "${line}"`); }
result[line.substring(0, cindex)] = line.substring(cindex+2);
});
return result;
}