-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.js
More file actions
56 lines (54 loc) · 1.48 KB
/
parser.js
File metadata and controls
56 lines (54 loc) · 1.48 KB
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
const fs = require('fs');
const readline = require('readline');
class Parser {
// may add parameter to constructor
constructor(filename, line) {
this._filename = filename;
this._maxLine = line;
this._count = 0;
this._data = [];
this._rl;
}
// setters & getters
setFilename(value) {
if ( value.length < 1 ) { return; }
this._filename = value;
}
getFilename() {
return this._filename;
}
setMaxLine(value) {
if ( value < 1 ) { return; }
this._maxLine = value;
}
getMaxLine() {
return this._maxLine;
}
readLines() {
this._rl = readline.createInterface({
input: fs.createReadStream(__dirname + this._filename),
output: process.stdout,
terminal: false
}).on("line", (line) => {
if (line[0] !== '@') {
if (line.length > 1) {
this._count++;
console.log(line);
this._data.push(line);
}
}
// Limit
if (this._count == this._maxLine) {
this._rl.close();
}
}).on('close', function() {
// console.log(savedLine);
process.exit(0);
});
}
}
// let parser = new Parser("/esco_v1.0.8.ttl", 500);
let parser = new Parser("/esco_reduced.ttl", 24);
console.log(parser._filename);
console.log(parser._maxLine);
parser.readLines();