-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
59 lines (51 loc) · 1.26 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const nodes = {
Config: require('./_config'),
Global: require('./_global'),
GlobalSection: require('./_globalSection'),
Header: require('./_header'),
Project: require('./_project'),
Root: require('./_root')
}
function SlnParser() {
for(const key in nodes) {
this[`read${key}`] = nodes[key].read;
this[`write${key}`] = nodes[key].write;
}
}
SlnParser.prototype.read = function(lines) {
this.curr = 0;
this.lines = lines;
return this.readRoot();
}
SlnParser.prototype.readLine = function () {
const line = this.lines[this.curr];
if (line == null) {
return null;
}
this.curr += 1;
return line.trim();
}
SlnParser.prototype.currLine = function () {
const line = this.lines[this.curr];
if (line == null) {
return null;
}
return line.trim();
}
SlnParser.prototype.nextLine = function () {
this.curr += 1;
const line = this.lines[this.curr];
if (line == null) {
return null;
}
return line.trim();
}
SlnParser.prototype.write = function(node) {
this.output = '';
this.writeRoot(node);
return this.output;
}
SlnParser.prototype.writeLine = function(line) {
this.output += `${line}\r\n`;
}
module.exports = { SlnParser: new SlnParser() }