var generateTable = function(data) { var cliTable = require('cli-table'), res = []; for (var i = 0; i < data.length; i++) { res.push('\n\nBrowser: ', data[i]._browserName + '\n'); var table = new cliTable({ head: ['Metrics', 'Value', 'Unit', 'Source'], colAligns: ['right', 'left'], colWidths: [35, 15, 15, 35] }); for (var key in data[i]) { if (key.indexOf('_') === 0) continue; var val = data[i][key]; table.push([key, val.value + '', val.unit + '', val.source + '']); } table = table.sort(function(a, b) { if (a[3] === b[3]) { return a[0] > b[0] ? 1 : -1; } else { return a[3] > b[3] ? 1 : -1; } }); res.push(table.toString()); } return res.join(''); };
items.forEach(function(row) { var err, percentLine = Math.floor((row.calledLines / row.coveredLines) * 100), percentFunction = Math.floor((row.calledFunctions / row.coveredFunctions) * 100), cell = [ row.path, row.calledLines + '/' + row.coveredLines, percentLine + '%', row.calledFunctions + '/' + row.coveredFunctions, percentFunction + '%' ]; ['calledLines', 'calledFunctions', 'coveredLines', 'coveredFunctions'].forEach(function(prop) { totals[prop] += row[prop]; }); if (percentLine <= options.coverageWarn) { err = true; cell[1] = util.color(String(cell[1]), 'red'); cell[2] = util.color(String(cell[2]), 'red'); } if (percentFunction <= options.coverageWarn) { err = true; cell[3] = util.color(String(cell[3]), 'red'); cell[4] = util.color(String(cell[4]), 'red'); } if (err) { cell[0] = util.color(util.bad, 'red') + ' ' + cell[0]; } else { cell[0] = util.color(util.good, 'green') + ' ' + cell[0]; } table.push(cell); });
david.getUpdatedDependencies(manifest, options, function(err, deps) { if (err) { grunt.log.error('an error occurred.'); next(new Error(err)); } else { if (Object.keys(deps).length) { grunt.log.errorlns('outdated dependencies detected:'); var table = new Table({ head : [ 'Dependency', 'installed', 'stable', 'latest' ], colWidths : [ 50, 11, 10, 10 ] }); for ( var dep in deps) { table.push([dep, deps[dep].required, deps[dep].stable, deps[dep].latest ]); } grunt.log.writeln(table.toString()); } else { grunt.log.writeln('No outdated dependencies detected'); } next(); } });
'test complete table': function (){ var table = new Table({ head: ['Rel', 'Change', 'By', 'When'] , style: { 'padding-left': 1 , 'padding-right': 1 } , colWidths: [6, 21, 25, 17] }); table.push( ['v0.1', 'Testing something cool', '*****@*****.**', '7 minutes ago'] , ['v0.1', 'Testing something cool', '*****@*****.**', '8 minutes ago'] ); var expected = [ '┏━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓' , '┃ Rel ┃ Change ┃ By ┃ When ┃' , '┣━━━━━━╋━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━┫' , '┃ v0.1 ┃ Testing something … ┃ rauchg@gmail.com ┃ 7 minutes ago ┃' , '┣━━━━━━╋━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━┫' , '┃ v0.1 ┃ Testing something … ┃ rauchg@gmail.com ┃ 8 minutes ago ┃' , '┗━━━━━━┻━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━┛' ]; table.toString().should.eql(expected.join("\n")); },
_.each(response.protocols, function(proto) { var protoheader = new Table() console.log(colors.bold('\n#### ' + proto.protocolName + ' ##\n')); protoheader.push( { 'Protocol Name': proto.protocolName }, { 'Scheme': proto.protocolScheme }, { 'Description': proto.description } ); console.log(protoheader.toString()) var table = new Table({ head: ['Endpoint', 'Description'] , colWidths: [30, 30] }); if (proto.operations.length > 0 && proto.operations != "N/A") { _.each(proto.operations, function (op) { var doc = op.doc if (doc == null) doc = '' table.push( [op.resource, doc] ); }); console.log(colors.green('\n' + proto.operations.length + ' operations available\n')); console.log(table.toString()) } else { console.log(colors.bold(colors.red('\nNo operations are available for this protocol, or they cannot be read\n'))); } })
reports.forEach(function(report, index){ // Compare with previous report if ( index === reports.length - 1 ) { report.iterationsPercentIncrease = '' } else { report.iterationsPercentIncrease = report.iterationsPercent - reports[index+1].iterationsPercent + '%' } if ( typeof report.iterationsPercent === 'number' ) { report.iterationsPercent += '%' } if ( typeof report.fasterNextPercent === 'number' ) { report.fasterNextPercent += '%' } if ( typeof report.fasterLastPercent === 'number' ) { report.fasterLastPercent += '%' } table.push([ report.test, report.iterations, report.iterationsPercent, report.iterationsPercentIncrease, report.timePerIteration, report.fasterNextPercent, report.fasterLastPercent, report.duration ]) })
paths.forEach(function(path) { var speed = data[path]; var row = [path, speed.times, ProfileReport.formatNumber(speed.millis / speed.times) + " ms"]; if (hasSecurity) { row.push(ProfileReport.formatNumber(speed.rejected)); } table.push(row); });
_.each(dataSources, function (dataSource) { var currentStatus = dataSource.currentStatus; var errorMsg = currentStatus.error && currentStatus.error.userDetail ? currentStatus.error.userDetail : "NONE"; var dataLength = dataSource.data ? dataSource.data.length : 0; table.push([dataSource._id, dataSource.name, dataSource.service.guid, dataSource.service.title, dataSource.endpoint, currentStatus.status, errorMsg, dataLength, moment(dataSource.lastRefreshed).fromNow()]); }, this);
_.each(list, function (data) { var jobId = data._id; var appId = data.appid; var env = data.environment; var status = data.status; table.push([jobId, appId, env, status]); });
docs.forEach(function(doc){ table.push([ doc.test_site, doc.nt_res_st - doc.nt_req_st, doc.nt_domloading - doc.nt_req_st, doc.nt_res_end - doc.nt_req_st ]) });
sleep_data.forEach(function(record){ table.push([ record.date, record.properties.score_amount_of_sleep, record.properties.score_sleep_latency, record.tags.join(', ').replace(/_/g, ' ') ]); });
underscore.each(data, function (value) { var row = underscore.pick(value, fields); if (row.extra !== undefined) { row.extra = row.extra.join(" "); table.push(underscore.values(row)); } });
this.status = function(){ var table = new Table({ 'head' : ['Name', 'Health', 'Broken Bones', 'Cuts', 'Knives', 'Bandages', 'Splints'], 'colWidths': [8, 8, 15, 6, 8, 10, 9] }); table.push([this.name,this.health,this.broken_bones,this.cuts,this.knives,this.bandages,this.splints]); return table; }
writeSummary(pkgVersions, (title, headers, rows) => { const table = new CliTable({ head: headers, }); table.push(...rows); console.log(`*** ${title} ***`); console.log(table.toString()); });
students.forEach(function(student) { table.push([ student.id, student.name, student.address, student.birth_date.toString('yyyy-MMM-MMM') ]); });
function pushItem(item) { item = fields.map(function(field) { if (field === 'submitted') return item[field].toLocaleString(); return item[field] || ''; }); asciiTable.push(item); }
psi(url, { key: 'AIzaSyAbijQJj5ck79PhPpxBdypNr2oy4BupJw0', strategy: 'desktop' }).then(data => { count++; console.log(count); table.push({ "+": [url, data.ruleGroups.SPEED.score, bytesToSize(data.pageStats.htmlResponseBytes), , bytesToSize(data.pageStats.imageResponseBytes)] }); if (count == listURL.length) { console.log(table.toString()); } });
_.each(properties, function (prop) { prop.guid = prop.guid || "none"; var max = opts.max || 180; if (prop.value.length > max) { prop.value = "TRUNCATED TOO LONG TO DISPLAY. Try --json"; } table.push([prop.guid, prop.name, prop.value]); }, this);
this.ApiDoc.data[this.ApiName].forEach(function(cmd) { table.push([ cmd.cmd, (cmd.method != null ? cmd.method : 'any').toUpperCase(), cmd.description != null ? cmd.description : '-', cmd['return'] != null && cmd['return']['type'] != null ? cmd['return']['type'] : '-' ]); });
data.map(function(file){ out = []; Object.keys(fields).map(function(field){ out.push(file[fields[field]]); }); table.push(out); });
_.each(environments, function(env) { var targets = []; _.each(env.targets, function(target) { targets.push(target._id); }); table.push([env._id, env.label, env.autoDeployOnCreate, env.autoDeployOnUpdate, targets.join(", "), moment(env.modified).fromNow()]); }, this);
function generateTable(data) { var cliTable = require('cli-table'); var Docs = require('browser-perf/docs'); var MAX_IMPORTANCE = 30; var apiDocs = new Docs(); var decimalPoints = { ms: 3, count: 0, fps: 3, percentage: 2, } var res = []; for (var i = 0; i < data.length; i++) { res.push('\n\nBrowser: ', data[i]._browserName + '\n'); var table = new cliTable({ head: ['Metrics', 'Value', 'Unit', 'Source'], colAligns: ['right', 'right', 'left', 'right'], colWidths: [35, 20, 10, 15] }); for (var key in data[i]) { if (key.indexOf('_') === 0) continue; if ((apiDocs.getProp(key, 'importance') || 0) < MAX_IMPORTANCE) continue; var val = data[i][key]; var unit = '' + (apiDocs.getProp(key, 'unit') || ''); if (typeof val === 'number') { if (typeof decimalPoints[unit] !== 'undefined') { val = val.toFixed(decimalPoints[unit]); } else { val = val + ''; } } table.push([key, val + '', unit, '' + (apiDocs.getProp(key, 'source') || '')]); } table = table.sort(function(a, b) { var rankA = apiDocs.getProp(a[0], 'importance') || -1; var rankB = apiDocs.getProp(b[0], 'importance') || -1; if (rankA === rankB) { if (a[3] === b[3]) { return a[0] > b[0] ? 1 : -1; } else { return a[3] > b[3] ? 1 : -1; } } else { return rankA > rankB ? 1 : (rankA < rankB ? -1 : 0); } }) res.push(table.toString()); } return res.join(''); }
instances.items.forEach(function (instance) { var definition = definitions[instance.definitionId]; table.push([ instance.id, definition.name || '', definition.version || '', definition.description || '' ]); });
lr.on('end', function () { var table = new Table({ head: ["District", "Count", "%"], colWidths: [30, 10, 10] }); for (var d in districts) { var pct = Math.round(districts[d] / total * 100); if (pct > 20) { pct = chalk.underline(chalk.red(pct)); } table.push([d, districts[d], pct]); } table.push(["Total", total, "100"]); console.log(table.toString()); });
exports.createTableForAppEnvVars = function (appEnvVars, envValue) { var maxId = 24, maxTS = 20, maxName = 25, maxDevValue = 25, maxLiveValue = 25; for (var i = 0; i < appEnvVars.length; i++) { var appEnvVar = appEnvVars[i].fields; if (strlen(appEnvVar.name) > maxName) { maxName = strlen(appEnvVar.name); } if (strlen(appEnvVar.devValue) > maxDevValue) { maxDevValue = strlen(appEnvVar.devValue); } if (strlen(appEnvVar.liveValue) > maxLiveValue) { maxLiveValue = strlen(appEnvVar.liveValue); } } if (maxName > exports.maxTableCell) { maxName = exports.maxTableCell; } if (maxDevValue > exports.maxTableCell) { maxDevValue = exports.maxTableCell; } if (maxLiveValue > exports.maxTableCell) { maxLiveValue = exports.maxTableCell; } var tableHeaders = ['Guid', 'Modified', 'Name']; var tableColWidths = [maxId + 2, maxTS + 2, maxName + 2]; if (!envValue) { tableHeaders.push("Dev Value"); tableHeaders.push("Live Value"); tableColWidths.push(maxDevValue + 2); tableColWidths.push(maxLiveValue + 2); } else if ("dev" === envValue) { tableHeaders.push("Dev Value"); tableColWidths.push(maxDevValue + 2); } else { tableHeaders.push("Live Value"); tableColWidths.push(maxLiveValue + 2); } var table = new Table({ head: tableHeaders, colWidths: tableColWidths, style: exports.style() }); for (var p = 0; p < appEnvVars.length; p++) { var appVar = appEnvVars[p].fields; var dataRow = [appVar.guid, moment(appVar.sysCreated, 'YYYY-MM-DD h:mm:ss:SSS').fromNow(), appVar.name]; if (appVar.devValue) { dataRow.push(appVar.devValue); } if (appVar.liveValue) { dataRow.push(appVar.liveValue); } table.push(dataRow); } return table; };
_.each((logSearchResults.hits || {}).hits || [], function(logEntry) { var messages = _.pick(logEntry._source, 'msg', 'error', 'err', 'message'); messages = _.map(_.compact(messages), function(message) { return message.replace(/\r?\n|\r/g,''); }); table.push([logEntry._source.time, messages.join(' '), logEntry._source.level]); }, this);
logPromptResults: function() { var table = new Table(); table.push({ 'Course Name': this.settings.courseName }, { 'Course Directory': this.settings.courseDirectory }); this.log(table.toString()); },
_.each(result.diagnostics, function (diagnostic) { table.push([ diagnostic.storeId, diagnostic.fetchId, diagnostic.status, diagnostic.time, JSON.stringify(diagnostic.result || diagnostic.error || {}, null, 2) ]); });
_.each(assets, function(x){ t.push([x.symbol , ac.c(x.cost_basis) //, x.equity ? ac.c(x.cost_basis/net_equity*100) : '-' , ac.c(x.current * x.quantity) , ac.c(x.cost_basis/net_worth*100) , ac.c(x.current*x.quantity/total_worth*100) ]) })
connection.query(query, function(err, res) { console.log(res.length + " matches found!"); for (var i = 0; i < res.length; i++) { newtable.push( [res[i].DepartmentID, res[i].DepartmentName, res[i].OverHeadCosts, res[i].TotalSales, res[i].TotalSales - res[i].OverHeadCosts] ); } console.log(newtable.toString()); });