Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
LICENSE | D | 12-May-2024 | 1.1 KiB | 21 | 16 | |
README.md | D | 12-May-2024 | 2.6 KiB | 70 | 48 | |
color.js | D | 12-May-2024 | 384 | 16 | 13 | |
index.js | D | 12-May-2024 | 1.6 KiB | 84 | 63 | |
package.json | D | 12-May-2024 | 1.8 KiB | 85 | 84 | |
test.js | D | 12-May-2024 | 1.7 KiB | 79 | 66 |
README.md
1# `cli-columns` 2 3[![NPM version][npm-img]][npm-url] [![Downloads][downloads-img]][npm-url] [![Build Status][travis-img]][travis-url] [![Coverage Status][coveralls-img]][coveralls-url] [![Chat][gitter-img]][gitter-url] [![Tip][amazon-img]][amazon-url] 4 5Columnated lists for the CLI. Unicode and ANSI safe. 6 7## Install 8 9 $ npm install --save cli-columns 10 11## Usage 12 13```js 14const chalk = require('chalk'); 15const columns = require('.'); 16 17const values = [ 18 'blue' + chalk.bgBlue('berry'), 19 '笔菠萝' + chalk.yellow('苹果笔'), 20 chalk.red('apple'), 'pomegranate', 21 'durian', chalk.green('star fruit'), 22 'パイナップル', 'apricot', 'banana', 23 'pineapple', chalk.bgRed.yellow('orange') 24]; 25 26console.log(columns(values)); 27``` 28 29<img alt="screenshot" src="https://user-images.githubusercontent.com/155164/28672800-bd415c86-72ae-11e7-855c-6f6aa108921b.png"> 30 31## API 32 33### columns(values [, options]): String 34 35- `values` `{Array<String>}` Array of strings to display. 36- `options` `{Object}` 37 - `character` `{String}` (default: `' '`) Padding character. 38 - `newline` `{String}` (default: `'\n'`) Newline character. 39 - `padding` `{Number}` (default: `2`) Space between columns. 40 - `sort` `{Boolean}` (default: `true`) Whether to sort results. 41 - `width` `{Number}` (default: `process.stdout.columns`) Max width of list. 42 43Sorts and formats a list of values into columns suitable to display in a given width. 44 45## Contribute 46 47Standards for this project, including tests, code coverage, and semantics are enforced with a build tool. Pull requests must include passing tests with 100% code coverage and no linting errors. 48 49### Test 50 51 $ npm test 52 53---- 54 55© Shannon Moeller <me@shannonmoeller.com> (shannonmoeller.com) 56 57Licensed under [MIT](http://shannonmoeller.com/mit.txt) 58 59[amazon-img]: https://img.shields.io/badge/amazon-tip_jar-yellow.svg?style=flat-square 60[amazon-url]: https://www.amazon.com/gp/registry/wishlist/1VQM9ID04YPC5?sort=universal-price 61[coveralls-img]: http://img.shields.io/coveralls/shannonmoeller/cli-columns/master.svg?style=flat-square 62[coveralls-url]: https://coveralls.io/r/shannonmoeller/cli-columns 63[downloads-img]: http://img.shields.io/npm/dm/cli-columns.svg?style=flat-square 64[gitter-img]: http://img.shields.io/badge/gitter-join_chat-1dce73.svg?style=flat-square 65[gitter-url]: https://gitter.im/shannonmoeller/shannonmoeller 66[npm-img]: http://img.shields.io/npm/v/cli-columns.svg?style=flat-square 67[npm-url]: https://npmjs.org/package/cli-columns 68[travis-img]: http://img.shields.io/travis/shannonmoeller/cli-columns.svg?style=flat-square 69[travis-url]: https://travis-ci.org/shannonmoeller/cli-columns 70