-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
60 lines (51 loc) · 1.29 KB
/
Copy pathindex.js
File metadata and controls
60 lines (51 loc) · 1.29 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
57
58
59
60
var LineByLineReader = require('line-by-line');
let sleep = require('sleep');
var Table = require('cli-table');
var colors = require('colors');
let headers = ['Ticker', 'Volume', 'OpenSellOrders', 'Ask', 'Bid', 'Last']
let table = new Table({
head: headers,
colWidths: headers.map(function(a) {return 20;})
});
let counter = 0;
let cashmap = new Map();
function addToMap(key, value) {
if (cashmap.has(key)) {
return cashmap.get(key);
} else {
cashmap.set(key, value);
return value;
}
}
function main() {
var lr1 = new LineByLineReader('nodeData.txt');
var lr2 = new LineByLineReader('nodeDataOld.txt');
//console.log('started main');
lr1.on('error', function(err) {
console.log(err);
});
lr1.on('line', function(line) {
line = line.split(',');
if (counter++ < 15){
//console.log("line:\n" + line[6]);
let changed = false;
let addresult = addToMap(line[0], line[4]);
// Colors would go here
if (addresult == line[4]) {
line[0] = line[0].yellow;
}
else if (addresult > line[4])
line[0] = line[0].red;
else if (addresult < line[4])
line[0] = line[0].green;
table.push(line);
}
});
lr1.on('end', function() {
// call chart callback
console.log('\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n')
console.log(table.toString());
//lr1.close();
});
}
main();