1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4  value: true
5});
6exports.parsePropertiesFile = parsePropertiesFile;
7exports.propertiesListToString = propertiesListToString;
8function parsePropertiesFile(contents) {
9  const propertiesList = [];
10  const lines = contents.split('\n');
11  for (let i = 0; i < lines.length; i++) {
12    const line = lines[i].trim();
13    if (!line) {
14      propertiesList.push({
15        type: 'empty'
16      });
17    } else if (line.startsWith('#')) {
18      propertiesList.push({
19        type: 'comment',
20        value: line.substring(1).trimStart()
21      });
22    } else {
23      const eok = line.indexOf('=');
24      const key = line.slice(0, eok);
25      const value = line.slice(eok + 1, line.length);
26      propertiesList.push({
27        type: 'property',
28        key,
29        value
30      });
31    }
32  }
33  return propertiesList;
34}
35function propertiesListToString(props) {
36  let output = '';
37  for (let i = 0; i < props.length; i++) {
38    const prop = props[i];
39    if (prop.type === 'empty') {
40      output += '';
41    } else if (prop.type === 'comment') {
42      output += '# ' + prop.value;
43    } else if (prop.type === 'property') {
44      output += `${prop.key}=${prop.value}`;
45    } else {
46      // @ts-ignore: assertion
47      throw new Error(`Invalid properties type "${prop.type}"`);
48    }
49    if (i < props.length - 1) {
50      output += '\n';
51    }
52  }
53  return output;
54}
55//# sourceMappingURL=Properties.js.map