Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.pipe(collectJson(function (json) {
let clOptions = {
maxWidth: process.stdout.columns,
padding: {}
}
if (t.isDefined(options['padding-left'])) clOptions.padding.left = options['padding-left']
if (t.isDefined(options['padding-right'])) clOptions.padding.right = options['padding-right']
/* split input into data and options */
if (!Array.isArray(json)) {
if (json.options && json.data) {
clOptions = extend(clOptions, json.options)
json = json.data
} else {
throw new Error('Invalid input data')
}
}
if (columns.length) clOptions.columns = columns
const table = new tableLayout.Table(json, clOptions)
return options.lines
? JSON.stringify(table.renderLines(), null, ' ') + '\n'
event (category, action, options) {
if (this._disabled) return this
if (!(category && action)) throw new Error('category and action required')
options = options || {}
if (options.hitParams && t.isPlainObject(options.hitParams)) {
options.hitParams = objToMap(options.hitParams)
}
let hit = this._createHit(new Map([
[ 't', 'event' ],
[ 'ec', category ],
[ 'ea', action ]
]), options)
if (t.isDefined(options.el)) hit.set('el', options.el)
if (t.isDefined(options.ev)) hit.set('ev', options.ev)
this._hits.push(hit)
return hit
}
create (options) {
const t = require('typical')
const serverOptions = {}
const server = require('http').createServer()
if (t.isDefined(options.maxConnections)) {
server.maxConnections = serverOptions.maxConnections = options.maxConnections
}
if (t.isDefined(options.keepAliveTimeout)) {
server.keepAliveTimeout = serverOptions.keepAliveTimeout = options.keepAliveTimeout
}
if (Object.keys(serverOptions).length) {
this.emit('verbose', 'server.config', serverOptions)
}
return server
}
}
constructor (column) {
/**
* @type {string}
*/
if (t.isDefined(column.name)) this.name = column.name
/**
* @type {number}
*/
if (t.isDefined(column.width)) this.width = column.width
if (t.isDefined(column.maxWidth)) this.maxWidth = column.maxWidth
if (t.isDefined(column.minWidth)) this.minWidth = column.minWidth
if (t.isDefined(column.noWrap)) this.noWrap = column.noWrap
if (t.isDefined(column.break)) this.break = column.break
if (t.isDefined(column.contentWrappable)) this.contentWrappable = column.contentWrappable
if (t.isDefined(column.contentWidth)) this.contentWidth = column.contentWidth
if (t.isDefined(column.minContentWidth)) this.minContentWidth = column.minContentWidth
this.padding = column.padding || { left: ' ', right: ' ' }
this.generatedWidth = null
}
constructor (column) {
/**
* @type {string}
*/
if (t.isDefined(column.name)) this.name = column.name
/**
* @type {number}
*/
if (t.isDefined(column.width)) this.width = column.width
if (t.isDefined(column.maxWidth)) this.maxWidth = column.maxWidth
if (t.isDefined(column.minWidth)) this.minWidth = column.minWidth
if (t.isDefined(column.noWrap)) this.noWrap = column.noWrap
if (t.isDefined(column.break)) this.break = column.break
if (t.isDefined(column.contentWrappable)) this.contentWrappable = column.contentWrappable
if (t.isDefined(column.contentWidth)) this.contentWidth = column.contentWidth
if (t.isDefined(column.minContentWidth)) this.minContentWidth = column.minContentWidth
this.padding = column.padding || { left: ' ', right: ' ' }
this.generatedWidth = null
}
function Column(column) {
_classCallCheck(this, Column);
if (t.isDefined(column.name)) this.name = column.name;
if (t.isDefined(column.width)) this.width = column.width;
if (t.isDefined(column.maxWidth)) this.maxWidth = column.maxWidth;
if (t.isDefined(column.minWidth)) this.minWidth = column.minWidth;
if (t.isDefined(column.noWrap)) this.noWrap = column.noWrap;
if (t.isDefined(column.break)) this.break = column.break;
if (t.isDefined(column.contentWrappable)) this.contentWrappable = column.contentWrappable;
if (t.isDefined(column.contentWidth)) this.contentWidth = column.contentWidth;
if (t.isDefined(column.minContentWidth)) this.minContentWidth = column.minContentWidth;
this.padding = column.padding || { left: ' ', right: ' ' };
this.generatedWidth = null;
}
static isWrappable (text) {
if (t.isDefined(text)) {
text = String(text)
var matches = text.match(re.chunk)
return matches ? matches.length > 1 : false
}
}
function getTable(json) {
var clOptions = {
maxWidth: process.stdout.columns,
padding: {}
};
if (t.isDefined(options['padding-left'])) clOptions.padding.left = options['padding-left'];
if (t.isDefined(options['padding-right'])) clOptions.padding.right = options['padding-right'];
if (!Array.isArray(json)) {
if (json.options && json.data) {
clOptions = extend(clOptions, json.options);
json = json.data;
} else {
throw new Error('Invalid input data');
}
}
if (columns.length) clOptions.columns = columns;
var table = new Table(json, clOptions);
return table.toString();
}
constructor (column) {
/**
* @type {string}
*/
if (t.isDefined(column.name)) this.name = column.name
/**
* @type {number}
*/
if (t.isDefined(column.width)) this.width = column.width
if (t.isDefined(column.maxWidth)) this.maxWidth = column.maxWidth
if (t.isDefined(column.minWidth)) this.minWidth = column.minWidth
if (t.isDefined(column.noWrap)) this.noWrap = column.noWrap
if (t.isDefined(column.break)) this.break = column.break
if (t.isDefined(column.contentWrappable)) this.contentWrappable = column.contentWrappable
if (t.isDefined(column.contentWidth)) this.contentWidth = column.contentWidth
if (t.isDefined(column.minContentWidth)) this.minContentWidth = column.minContentWidth
this.padding = column.padding || { left: ' ', right: ' ' }
this.generatedWidth = null
}
function Column(column) {
_classCallCheck(this, Column);
if (t.isDefined(column.name)) this.name = column.name;
if (t.isDefined(column.width)) this.width = column.width;
if (t.isDefined(column.maxWidth)) this.maxWidth = column.maxWidth;
if (t.isDefined(column.minWidth)) this.minWidth = column.minWidth;
if (t.isDefined(column.noWrap)) this.noWrap = column.noWrap;
if (t.isDefined(column.break)) this.break = column.break;
if (t.isDefined(column.contentWrappable)) this.contentWrappable = column.contentWrappable;
if (t.isDefined(column.contentWidth)) this.contentWidth = column.contentWidth;
if (t.isDefined(column.minContentWidth)) this.minContentWidth = column.minContentWidth;
this.padding = column.padding || { left: ' ', right: ' ' };
this.generatedWidth = null;
}