forked from enviPath/enviPy
Current Dev State
This commit is contained in:
69
static/js/ketcher2/node_modules/cli-columns/README.md
generated
vendored
Normal file
69
static/js/ketcher2/node_modules/cli-columns/README.md
generated
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
# `cli-columns`
|
||||
|
||||
[![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]
|
||||
|
||||
Columnated lists for the CLI. Unicode and ANSI safe.
|
||||
|
||||
## Install
|
||||
|
||||
$ npm install --save cli-columns
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var chalk = require('chalk');
|
||||
var columns = require('cli-columns');
|
||||
|
||||
var values = [
|
||||
'foo', 'bar', 'baz',
|
||||
chalk.cyan('嶜憃撊') + ' 噾噿嚁',
|
||||
'blue' + chalk.bgBlue('berry'),
|
||||
chalk.red('apple'), 'pomegranate',
|
||||
'durian', chalk.green('star fruit'),
|
||||
'apricot', 'banana pineapple'
|
||||
];
|
||||
|
||||
console.log(columns(values));
|
||||
```
|
||||
|
||||
<img width="600" alt="screenshot" src="https://cloud.githubusercontent.com/assets/155164/13035288/256c6afc-d31a-11e5-9071-57a5fc753a79.png" />
|
||||
|
||||
## API
|
||||
|
||||
### columns(values [, options]): String
|
||||
|
||||
- `values` `{Array<String>}` Array of strings to display.
|
||||
- `options` `{Object}`
|
||||
- `character` `{String}` (default: `' '`) Padding character.
|
||||
- `newline` `{String}` (default: `'\n'`) Newline character.
|
||||
- `padding` `{Number}` (default: `2`) Space between columns.
|
||||
- `width` `{Number}` (default: `process.stdout.columns`) Max width of list.
|
||||
- `noSort` `{Boolean}` (default: `false`) No use sorting.
|
||||
|
||||
Sorts and formats a list of values into columns suitable to display in a given width.
|
||||
|
||||
## Contribute
|
||||
|
||||
Standards 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.
|
||||
|
||||
### Test
|
||||
|
||||
$ npm test
|
||||
|
||||
----
|
||||
|
||||
© Shannon Moeller <me@shannonmoeller.com> (shannonmoeller.com)
|
||||
|
||||
Licensed under [MIT](http://shannonmoeller.com/mit.txt)
|
||||
|
||||
[amazon-img]: https://img.shields.io/badge/amazon-tip_jar-yellow.svg?style=flat-square
|
||||
[amazon-url]: https://www.amazon.com/gp/registry/wishlist/1VQM9ID04YPC5?sort=universal-price
|
||||
[coveralls-img]: http://img.shields.io/coveralls/shannonmoeller/cli-columns/master.svg?style=flat-square
|
||||
[coveralls-url]: https://coveralls.io/r/shannonmoeller/cli-columns
|
||||
[downloads-img]: http://img.shields.io/npm/dm/cli-columns.svg?style=flat-square
|
||||
[gitter-img]: http://img.shields.io/badge/gitter-join_chat-1dce73.svg?style=flat-square
|
||||
[gitter-url]: https://gitter.im/shannonmoeller/shannonmoeller
|
||||
[npm-img]: http://img.shields.io/npm/v/cli-columns.svg?style=flat-square
|
||||
[npm-url]: https://npmjs.org/package/cli-columns
|
||||
[travis-img]: http://img.shields.io/travis/shannonmoeller/cli-columns.svg?style=flat-square
|
||||
[travis-url]: https://travis-ci.org/shannonmoeller/cli-columns
|
||||
79
static/js/ketcher2/node_modules/cli-columns/package.json
generated
vendored
Normal file
79
static/js/ketcher2/node_modules/cli-columns/package.json
generated
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
{
|
||||
"_from": "cli-columns@^1.0.6",
|
||||
"_id": "cli-columns@1.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-PHs0wF5sN02TsYskzWdOuDN2qZQ=",
|
||||
"_location": "/cli-columns",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "cli-columns@^1.0.6",
|
||||
"name": "cli-columns",
|
||||
"escapedName": "cli-columns",
|
||||
"rawSpec": "^1.0.6",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.6"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/gulp-hb"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/cli-columns/-/cli-columns-1.1.0.tgz",
|
||||
"_shasum": "3c7b34c05e6c374d93b18b24cd674eb83376a994",
|
||||
"_spec": "cli-columns@^1.0.6",
|
||||
"_where": "/home/manfred/enviPath/ketcher2/ketcher/node_modules/gulp-hb",
|
||||
"author": {
|
||||
"name": "Shannon Moeller",
|
||||
"email": "me@shannonmoeller",
|
||||
"url": "http://shannonmoeller.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/shannonmoeller/cli-columns/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"object-assign": "^4.1.1",
|
||||
"string-width": "^1.0.2",
|
||||
"strip-ansi": "^3.0.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Columnated lists for the CLI.",
|
||||
"devDependencies": {
|
||||
"ava": "^0.18.1",
|
||||
"chalk": "^1.1.3",
|
||||
"chokidar-cli": "^1.2.0",
|
||||
"coveralls": "^2.11.16",
|
||||
"nyc": "^10.1.2",
|
||||
"strip-ansi": "^3.0.1",
|
||||
"xo": "^0.17.1"
|
||||
},
|
||||
"homepage": "https://github.com/shannonmoeller/cli-columns",
|
||||
"keywords": [
|
||||
"ansi",
|
||||
"cli",
|
||||
"column",
|
||||
"columnate",
|
||||
"columns",
|
||||
"grid",
|
||||
"list",
|
||||
"log",
|
||||
"ls",
|
||||
"row",
|
||||
"rows",
|
||||
"unicode",
|
||||
"unix"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "src/cli-columns.js",
|
||||
"name": "cli-columns",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/shannonmoeller/cli-columns.git"
|
||||
},
|
||||
"scripts": {
|
||||
"coveralls": "nyc report -r text-lcov | coveralls",
|
||||
"test": "xo && nyc ava",
|
||||
"watch": "chokidar '{src,test}/*.js' -c 'npm test'"
|
||||
},
|
||||
"version": "1.1.0"
|
||||
}
|
||||
71
static/js/ketcher2/node_modules/cli-columns/src/cli-columns.js
generated
vendored
Normal file
71
static/js/ketcher2/node_modules/cli-columns/src/cli-columns.js
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
var assign = require('object-assign');
|
||||
var stringWidth = require('string-width');
|
||||
var stripAnsi = require('strip-ansi');
|
||||
|
||||
var concat = Array.prototype.concat;
|
||||
var defaults = {
|
||||
character: ' ',
|
||||
newline: '\n',
|
||||
padding: 2,
|
||||
sort: true,
|
||||
width: 0
|
||||
};
|
||||
|
||||
function byPlainText(a, b) {
|
||||
return stripAnsi(a) > stripAnsi(b) ? 1 : -1;
|
||||
}
|
||||
|
||||
function makeArray() {
|
||||
return [];
|
||||
}
|
||||
|
||||
function makeList(count) {
|
||||
return Array.apply(null, Array(count));
|
||||
}
|
||||
|
||||
function padCell(fullWidth, character, value) {
|
||||
var valueWidth = stringWidth(value);
|
||||
var 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 = assign({}, defaults, options);
|
||||
|
||||
var cells = values
|
||||
.filter(Boolean)
|
||||
.map(String);
|
||||
|
||||
if (options.sort !== false) {
|
||||
cells = cells.sort(byPlainText);
|
||||
}
|
||||
|
||||
var termWidth = options.width || process.stdout.columns;
|
||||
var cellWidth = Math.max.apply(null, cells.map(stringWidth)) + options.padding;
|
||||
var columnCount = Math.floor(termWidth / cellWidth) || 1;
|
||||
var 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;
|
||||
19
static/js/ketcher2/node_modules/cli-columns/test/_color.js
generated
vendored
Normal file
19
static/js/ketcher2/node_modules/cli-columns/test/_color.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
var chalk = require('chalk');
|
||||
var columns = require('../src/cli-columns.js');
|
||||
|
||||
var cols = columns(
|
||||
[
|
||||
'foo', 'bar', 'baz',
|
||||
chalk.cyan('嶜憃撊') + ' 噾噿嚁',
|
||||
'blue' + chalk.bgBlue('berry'),
|
||||
chalk.red('apple'), 'pomegranate',
|
||||
'durian', chalk.green('star fruit'),
|
||||
'apricot', 'banana pineapple'
|
||||
],
|
||||
{
|
||||
width: 80
|
||||
}
|
||||
);
|
||||
|
||||
// Visual test
|
||||
console.log(chalk.yellow(cols) + '\n');
|
||||
78
static/js/ketcher2/node_modules/cli-columns/test/cli-columns.js
generated
vendored
Normal file
78
static/js/ketcher2/node_modules/cli-columns/test/cli-columns.js
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
import test from 'ava';
|
||||
import chalk from 'chalk';
|
||||
import stripAnsi from 'strip-ansi';
|
||||
import columns from '../src/cli-columns';
|
||||
|
||||
test('should print one column list', async t => {
|
||||
var cols = columns(['foo', ['bar', 'baz'], ['bat', 'qux']], {
|
||||
width: 1
|
||||
});
|
||||
|
||||
var expected =
|
||||
'bar\n' +
|
||||
'bat\n' +
|
||||
'baz\n' +
|
||||
'foo\n' +
|
||||
'qux';
|
||||
|
||||
t.is(cols, expected);
|
||||
});
|
||||
|
||||
test('should print three column list', async t => {
|
||||
var cols = columns(['foo', ['bar', 'baz'], ['bat', 'qux']], {
|
||||
width: 16
|
||||
});
|
||||
|
||||
var expected =
|
||||
'bar baz qux \n' +
|
||||
'bat foo ';
|
||||
|
||||
t.is(cols, expected);
|
||||
});
|
||||
|
||||
test('should print complex list', async t => {
|
||||
var cols = columns(
|
||||
[
|
||||
'foo', 'bar', 'baz',
|
||||
chalk.cyan('嶜憃撊') + ' 噾噿嚁',
|
||||
'blue' + chalk.bgBlue('berry'),
|
||||
chalk.red('apple'), 'pomegranate',
|
||||
'durian', chalk.green('star fruit'),
|
||||
'apricot', 'banana pineapple'
|
||||
],
|
||||
{
|
||||
width: 80
|
||||
}
|
||||
);
|
||||
|
||||
var expected =
|
||||
'apple bar durian star fruit \n' +
|
||||
'apricot baz foo 嶜憃撊 噾噿嚁 \n' +
|
||||
'banana pineapple blueberry pomegranate ';
|
||||
|
||||
t.is(stripAnsi(cols), expected);
|
||||
});
|
||||
|
||||
test('should optionally not sort', async t => {
|
||||
var cols = columns(
|
||||
[
|
||||
'foo', 'bar', 'baz',
|
||||
chalk.cyan('嶜憃撊') + ' 噾噿嚁',
|
||||
'blue' + chalk.bgBlue('berry'),
|
||||
chalk.red('apple'), 'pomegranate',
|
||||
'durian', chalk.green('star fruit'),
|
||||
'apricot', 'banana pineapple'
|
||||
],
|
||||
{
|
||||
sort: false,
|
||||
width: 80
|
||||
}
|
||||
);
|
||||
|
||||
var expected =
|
||||
'foo 嶜憃撊 噾噿嚁 pomegranate apricot \n' +
|
||||
'bar blueberry durian banana pineapple \n' +
|
||||
'baz apple star fruit ';
|
||||
|
||||
t.is(stripAnsi(cols), expected);
|
||||
});
|
||||
Reference in New Issue
Block a user