push all website files

This commit is contained in:
Jacob Levine
2019-01-06 13:14:45 -06:00
parent d7301e26c3
commit d2d5d4c04e
15662 changed files with 2166516 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) Shannon Moeller <me@shannonmoeller.com> (shannonmoeller.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View 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
const chalk = require('chalk');
const columns = require('.');
const values = [
'blue' + chalk.bgBlue('berry'),
'笔菠萝' + chalk.yellow('苹果笔'),
chalk.red('apple'), 'pomegranate',
'durian', chalk.green('star fruit'),
'パイナップル', 'apricot', 'banana',
'pineapple', chalk.bgRed.yellow('orange')
];
console.log(columns(values));
```
<img alt="screenshot" src="https://user-images.githubusercontent.com/155164/28672800-bd415c86-72ae-11e7-855c-6f6aa108921b.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.
- `sort` `{Boolean}` (default: `true`) Whether to sort results.
- `width` `{Number}` (default: `process.stdout.columns`) Max width of list.
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

View File

@@ -0,0 +1,15 @@
const chalk = require('chalk');
const columns = require('.');
const values = [
'blue' + chalk.bgBlue('berry'),
'笔菠萝' + chalk.yellow('苹果笔'),
chalk.red('apple'), 'pomegranate',
'durian', chalk.green('star fruit'),
'パイナップル', 'apricot', 'banana',
'pineapple', chalk.bgRed.yellow('orange')
];
console.log('');
console.log(columns(values));
console.log('');

View File

@@ -0,0 +1,83 @@
'use strict';
const stringWidth = require('string-width');
const stripAnsi = require('strip-ansi');
const concat = Array.prototype.concat;
const defaults = {
character: ' ',
newline: '\n',
padding: 2,
sort: true,
width: 0
};
function byPlainText(a, b) {
const plainA = stripAnsi(a);
const plainB = stripAnsi(b);
if (plainA === plainB) {
return 0;
}
if (plainA > plainB) {
return 1;
}
return -1;
}
function makeArray() {
return [];
}
function makeList(count) {
return Array.apply(null, Array(count));
}
function padCell(fullWidth, character, value) {
const valueWidth = stringWidth(value);
const 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 = Object.assign({}, defaults, options);
let cells = values
.filter(Boolean)
.map(String);
if (options.sort !== false) {
cells = cells.sort(byPlainText);
}
const termWidth = options.width || process.stdout.columns;
const cellWidth = Math.max.apply(null, cells.map(stringWidth)) + options.padding;
const columnCount = Math.floor(termWidth / cellWidth) || 1;
const 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;

View File

@@ -0,0 +1,84 @@
{
"_args": [
[
"cli-columns@3.1.2",
"/Users/rebecca/code/npm"
]
],
"_from": "cli-columns@3.1.2",
"_id": "cli-columns@3.1.2",
"_inBundle": true,
"_integrity": "sha1-ZzLZcpee/CrkRKHwjgj6E5yWoY4=",
"_location": "/npm/cli-columns",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "cli-columns@3.1.2",
"name": "cli-columns",
"escapedName": "cli-columns",
"rawSpec": "3.1.2",
"saveSpec": null,
"fetchSpec": "3.1.2"
},
"_requiredBy": [
"/npm"
],
"_resolved": "https://registry.npmjs.org/cli-columns/-/cli-columns-3.1.2.tgz",
"_spec": "3.1.2",
"_where": "/Users/rebecca/code/npm",
"author": {
"name": "Shannon Moeller",
"email": "me@shannonmoeller",
"url": "http://shannonmoeller.com"
},
"bugs": {
"url": "https://github.com/shannonmoeller/cli-columns/issues"
},
"dependencies": {
"string-width": "^2.0.0",
"strip-ansi": "^3.0.1"
},
"description": "Columnated lists for the CLI.",
"devDependencies": {
"ava": "^0.19.1",
"chalk": "^1.1.3",
"coveralls": "^2.13.1",
"nyc": "^11.0.2",
"xo": "^0.18.2"
},
"engines": {
"node": ">= 4"
},
"files": [
"*.js"
],
"homepage": "https://github.com/shannonmoeller/cli-columns#readme",
"keywords": [
"ansi",
"cli",
"column",
"columnate",
"columns",
"grid",
"list",
"log",
"ls",
"row",
"rows",
"unicode",
"unix"
],
"license": "MIT",
"main": "index.js",
"name": "cli-columns",
"repository": {
"type": "git",
"url": "git+https://github.com/shannonmoeller/cli-columns.git"
},
"scripts": {
"report": "nyc report -r text-lcov | coveralls",
"test": "xo && nyc ava"
},
"version": "3.1.2"
}

View File

@@ -0,0 +1,78 @@
import test from 'ava';
import chalk from 'chalk';
import stripAnsi from 'strip-ansi';
import columns from './index';
test('should print one column list', t => {
const cols = columns(['foo', ['bar', 'baz'], ['bar', 'qux']], {
width: 1
});
const expected =
'bar\n' +
'bar\n' +
'baz\n' +
'foo\n' +
'qux';
t.is(cols, expected);
});
test('should print three column list', t => {
const cols = columns(['foo', ['bar', 'baz'], ['bat', 'qux']], {
width: 16
});
const expected =
'bar baz qux \n' +
'bat foo ';
t.is(cols, expected);
});
test('should print complex list', t => {
const 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
}
);
const 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', t => {
const 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
}
);
const expected =
'foo 嶜憃撊 噾噿嚁 pomegranate apricot \n' +
'bar blueberry durian banana pineapple \n' +
'baz apple star fruit ';
t.is(stripAnsi(cols), expected);
});