Commit 98eb5224 by Tomas Dvorak

jshint validation fixes

parent 757550aa
...@@ -62,7 +62,7 @@ print('Using maxDepth of ' + maxDepth); ...@@ -62,7 +62,7 @@ print('Using maxDepth of ' + maxDepth);
if (typeof sort === 'undefined') { var sort = {_id: -1}; } if (typeof sort === 'undefined') { var sort = {_id: -1}; }
print('Using sort of ' + tojson(sort)); print('Using sort of ' + tojson(sort));
if (typeof outputFormat === 'undefined') { var outputFormat = "ascii" } if (typeof outputFormat === 'undefined') { var outputFormat = "ascii"; }
print('Using outputFormat of ' + outputFormat); print('Using outputFormat of ' + outputFormat);
...@@ -226,16 +226,16 @@ if(outputFormat === 'json') { ...@@ -226,16 +226,16 @@ if(outputFormat === 'json') {
} else { // output nice ascii table with results } else { // output nice ascii table with results
var table = [["key", "types", "occurrences", "percents"], ["", "", "", ""]]; // header + delimiter rows var table = [["key", "types", "occurrences", "percents"], ["", "", "", ""]]; // header + delimiter rows
sortedKeys.forEach(function(key) { sortedKeys.forEach(function(key) {
table.push([key._id.key, key.value.types.toString(), key.totalOccurrences, key.percentContaining]) table.push([key._id.key, key.value.types.toString(), key.totalOccurrences, key.percentContaining]);
}); });
function colMaxWidth(arr, index) { var colMaxWidth = function(arr, index) {
return Math.max.apply(null, arr.map(function(row){return row[index].toString().length})); return Math.max.apply(null, arr.map(function(row){return row[index].toString().length;}));
} };
function pad(width, string, symbol) { return (width <= string.length) ? string : pad(width, string + symbol, symbol); } var pad = function(width, string, symbol) { return (width <= string.length) ? string : pad(width, string + symbol, symbol); };
table.forEach(function(row, ri){ table.forEach(function(row, ri){
print("| " + row.map(function(cell, i) {return pad(colMaxWidth(table, i), cell, ri == 1 ? "-" : " ")}).join(" | ") + " |"); print("| " + row.map(function(cell, i) {return pad(colMaxWidth(table, i), cell, ri == 1 ? "-" : " ");}).join(" | ") + " |");
}); });
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment