How to use the term-size.columns function in term-size

To help you get started, we’ve selected a few term-size examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kevva / obj-to-table / index.js View on Github external
input = arrify(input);

	const keys = [];
	const vals = [];

	for (const x of input) {
		vals.push(objectValues(x));

		for (const y of Object.keys(x)) {
			if (keys.indexOf(y) === -1) {
				keys.push(y);
			}
		}
	}

	const width = Math.floor(termSize.columns / (keys.length + 1));
	const table = new CliTable(Object.assign({
		head: keys,
		colWidths: fillArray([width], keys.length)
	}, opts));

	for (const x of vals) {
		table.push(x);
	}

	return table;
};

term-size

Reliably get the terminal window size (columns & rows)

MIT
Latest version published 1 year ago

Package Health Score

61 / 100
Full package analysis

Popular term-size functions