????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.191 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/lib/node_modules/npm/node_modules/cli-columns/ |
Upload File : |
'use strict';
const stringWidth = require('string-width');
const stripAnsi = require('strip-ansi');
const concat = Array.prototype.concat;
const defaults = {
character: ' ',
newline: '\n',
padding: 2,
sort: true,
width: 0
};
function byPlainText(a, b) {
const plainA = stripAnsi(a);
const plainB = stripAnsi(b);
if (plainA === plainB) {
return 0;
}
if (plainA > plainB) {
return 1;
}
return -1;
}
function makeArray() {
return [];
}
function makeList(count) {
return Array.apply(null, Array(count));
}
function padCell(fullWidth, character, value) {
const valueWidth = stringWidth(value);
const filler = makeList(fullWidth - valueWidth + 1);
return value + filler.join(character);
}
function toRows(rows, cell, i) {
rows[i % rows.length].push(cell);
return rows;
}
function toString(arr) {
return arr.join('');
}
function columns(values, options) {
values = concat.apply([], values);
options = Object.assign({}, defaults, options);
let cells = values
.filter(Boolean)
.map(String);
if (options.sort !== false) {
cells = cells.sort(byPlainText);
}
const termWidth = options.width || process.stdout.columns;
const cellWidth = Math.max.apply(null, cells.map(stringWidth)) + options.padding;
const columnCount = Math.floor(termWidth / cellWidth) || 1;
const rowCount = Math.ceil(cells.length / columnCount) || 1;
if (columnCount === 1) {
return cells.join(options.newline);
}
return cells
.map(padCell.bind(null, cellWidth, options.character))
.reduce(toRows, makeList(rowCount).map(makeArray))
.map(toString)
.join(options.newline);
}
module.exports = columns;