columnify
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
strip-ansi | 3.0.1 | 1.69 kB | MIT | prod | |
wcwidth | 1.0.1 | 5.68 kB | MIT | prod |
Columnify is an open-source npm package that transforms data into text columns suitable for console output. It auto-scales columns to the largest cell content, filling the remaining space to ensure left-aligned content. Original use-case was to provide meaningful wrapping in npm search results.
To use Columnify, first install it using npm with the command npm install columnify
. After installing, you can require it in your JavaScript file and use it to format arrays of objects, plain objects, and even customize column names, among other things.
For instance, you can do something like this:
var columnify = require('columnify')
var data = {
"commander@0.6.1": 1,
"minimatch@0.2.14": 3,
"mkdirp@0.3.5": 2,
"sigmund@1.0.0": 3
}
console.log(columnify(data))
This will render your data in a columnized fashion in the console.
To customize column names, you can do:
var data = {
"commander@0.6.1": 1,
"minimatch@0.2.14": 3,
"mkdirp@0.3.5": 2,
"sigmund@1.0.0": 3
}
console.log(columnify(data, {columns: ['MODULE', 'COUNT']}))
There are various other options and configurations you can apply when using Columnify. You can set maximum and minimum widths, truncate long text, control alignment, etc.
The Columnify documentation can be found on the GitHub repository of the package, which is https://github.com/timoxley/columnify. The readme file of the repository contains comprehensive usage examples and API documentation for Columnify.