-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
38 lines (32 loc) · 789 Bytes
/
utils.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
var cli_table = require('cli-table');
module.exports = {
//checks if all rows in row_data are of same length are not!
lengthCheck: function (row_data) {
var l = row_data[0].length;
var response = true;
for(var i=0;i<row_data.length;i++) {
if(row_data[i].length != l) {
response = false;
}
}
return response;
},
getRowDimension: function (row_data) {
return row_data[0].length;
},
tablify(complete_table,header_dimension){
var headers=[];
var index=0;
if(header_dimension){
headers = complete_table[0];
index=1;
}
var output = new cli_table({
head: headers
});
for(i=index;i<complete_table.length;i++){
output.push(complete_table[i]);
}
return output.toString();
}
};