summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/text-table
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/text-table')
-rw-r--r--tools/node_modules/eslint/node_modules/text-table/LICENSE18
-rw-r--r--tools/node_modules/eslint/node_modules/text-table/index.js86
-rw-r--r--tools/node_modules/eslint/node_modules/text-table/package.json73
-rw-r--r--tools/node_modules/eslint/node_modules/text-table/readme.markdown134
4 files changed, 311 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/text-table/LICENSE b/tools/node_modules/eslint/node_modules/text-table/LICENSE
new file mode 100644
index 0000000000..ee27ba4b44
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/text-table/LICENSE
@@ -0,0 +1,18 @@
+This software is released under the MIT license:
+
+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.
diff --git a/tools/node_modules/eslint/node_modules/text-table/index.js b/tools/node_modules/eslint/node_modules/text-table/index.js
new file mode 100644
index 0000000000..5c0ba9876a
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/text-table/index.js
@@ -0,0 +1,86 @@
+module.exports = function (rows_, opts) {
+ if (!opts) opts = {};
+ var hsep = opts.hsep === undefined ? ' ' : opts.hsep;
+ var align = opts.align || [];
+ var stringLength = opts.stringLength
+ || function (s) { return String(s).length; }
+ ;
+
+ var dotsizes = reduce(rows_, function (acc, row) {
+ forEach(row, function (c, ix) {
+ var n = dotindex(c);
+ if (!acc[ix] || n > acc[ix]) acc[ix] = n;
+ });
+ return acc;
+ }, []);
+
+ var rows = map(rows_, function (row) {
+ return map(row, function (c_, ix) {
+ var c = String(c_);
+ if (align[ix] === '.') {
+ var index = dotindex(c);
+ var size = dotsizes[ix] + (/\./.test(c) ? 1 : 2)
+ - (stringLength(c) - index)
+ ;
+ return c + Array(size).join(' ');
+ }
+ else return c;
+ });
+ });
+
+ var sizes = reduce(rows, function (acc, row) {
+ forEach(row, function (c, ix) {
+ var n = stringLength(c);
+ if (!acc[ix] || n > acc[ix]) acc[ix] = n;
+ });
+ return acc;
+ }, []);
+
+ return map(rows, function (row) {
+ return map(row, function (c, ix) {
+ var n = (sizes[ix] - stringLength(c)) || 0;
+ var s = Array(Math.max(n + 1, 1)).join(' ');
+ if (align[ix] === 'r' || align[ix] === '.') {
+ return s + c;
+ }
+ if (align[ix] === 'c') {
+ return Array(Math.ceil(n / 2 + 1)).join(' ')
+ + c + Array(Math.floor(n / 2 + 1)).join(' ')
+ ;
+ }
+
+ return c + s;
+ }).join(hsep).replace(/\s+$/, '');
+ }).join('\n');
+};
+
+function dotindex (c) {
+ var m = /\.[^.]*$/.exec(c);
+ return m ? m.index + 1 : c.length;
+}
+
+function reduce (xs, f, init) {
+ if (xs.reduce) return xs.reduce(f, init);
+ var i = 0;
+ var acc = arguments.length >= 3 ? init : xs[i++];
+ for (; i < xs.length; i++) {
+ f(acc, xs[i], i);
+ }
+ return acc;
+}
+
+function forEach (xs, f) {
+ if (xs.forEach) return xs.forEach(f);
+ for (var i = 0; i < xs.length; i++) {
+ f.call(xs, xs[i], i);
+ }
+}
+
+function map (xs, f) {
+ if (xs.map) return xs.map(f);
+ var res = [];
+ for (var i = 0; i < xs.length; i++) {
+ res.push(f.call(xs, xs[i], i));
+ }
+ return res;
+}
diff --git a/tools/node_modules/eslint/node_modules/text-table/package.json b/tools/node_modules/eslint/node_modules/text-table/package.json
new file mode 100644
index 0000000000..e374725dec
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/text-table/package.json
@@ -0,0 +1,73 @@
+{
+ "_from": "text-table@~0.2.0",
+ "_id": "text-table@0.2.0",
+ "_inBundle": false,
+ "_integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=",
+ "_location": "/eslint/text-table",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "text-table@~0.2.0",
+ "name": "text-table",
+ "escapedName": "text-table",
+ "rawSpec": "~0.2.0",
+ "saveSpec": null,
+ "fetchSpec": "~0.2.0"
+ },
+ "_requiredBy": [
+ "/eslint"
+ ],
+ "_resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
+ "_shasum": "7f5ee823ae805207c00af2df4a84ec3fcfa570b4",
+ "_spec": "text-table@~0.2.0",
+ "_where": "/Users/cjihrig/iojs/node/tools/eslint-tmp/node_modules/eslint",
+ "author": {
+ "name": "James Halliday",
+ "email": "mail@substack.net",
+ "url": "http://substack.net"
+ },
+ "bugs": {
+ "url": "https://github.com/substack/text-table/issues"
+ },
+ "bundleDependencies": false,
+ "deprecated": false,
+ "description": "borderless text tables with alignment",
+ "devDependencies": {
+ "cli-color": "~0.2.3",
+ "tap": "~0.4.0",
+ "tape": "~1.0.2"
+ },
+ "homepage": "https://github.com/substack/text-table",
+ "keywords": [
+ "text",
+ "table",
+ "align",
+ "ascii",
+ "rows",
+ "tabular"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "name": "text-table",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/substack/text-table.git"
+ },
+ "scripts": {
+ "test": "tap test/*.js"
+ },
+ "testling": {
+ "files": "test/*.js",
+ "browsers": [
+ "ie/6..latest",
+ "chrome/20..latest",
+ "firefox/10..latest",
+ "safari/latest",
+ "opera/11.0..latest",
+ "iphone/6",
+ "ipad/6"
+ ]
+ },
+ "version": "0.2.0"
+}
diff --git a/tools/node_modules/eslint/node_modules/text-table/readme.markdown b/tools/node_modules/eslint/node_modules/text-table/readme.markdown
new file mode 100644
index 0000000000..18806acd9e
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/text-table/readme.markdown
@@ -0,0 +1,134 @@
+# text-table
+
+generate borderless text table strings suitable for printing to stdout
+
+[![build status](https://secure.travis-ci.org/substack/text-table.png)](http://travis-ci.org/substack/text-table)
+
+[![browser support](https://ci.testling.com/substack/text-table.png)](http://ci.testling.com/substack/text-table)
+
+# example
+
+## default align
+
+``` js
+var table = require('text-table');
+var t = table([
+ [ 'master', '0123456789abcdef' ],
+ [ 'staging', 'fedcba9876543210' ]
+]);
+console.log(t);
+```
+
+```
+master 0123456789abcdef
+staging fedcba9876543210
+```
+
+## left-right align
+
+``` js
+var table = require('text-table');
+var t = table([
+ [ 'beep', '1024' ],
+ [ 'boop', '33450' ],
+ [ 'foo', '1006' ],
+ [ 'bar', '45' ]
+], { align: [ 'l', 'r' ] });
+console.log(t);
+```
+
+```
+beep 1024
+boop 33450
+foo 1006
+bar 45
+```
+
+## dotted align
+
+``` js
+var table = require('text-table');
+var t = table([
+ [ 'beep', '1024' ],
+ [ 'boop', '334.212' ],
+ [ 'foo', '1006' ],
+ [ 'bar', '45.6' ],
+ [ 'baz', '123.' ]
+], { align: [ 'l', '.' ] });
+console.log(t);
+```
+
+```
+beep 1024
+boop 334.212
+foo 1006
+bar 45.6
+baz 123.
+```
+
+## centered
+
+``` js
+var table = require('text-table');
+var t = table([
+ [ 'beep', '1024', 'xyz' ],
+ [ 'boop', '3388450', 'tuv' ],
+ [ 'foo', '10106', 'qrstuv' ],
+ [ 'bar', '45', 'lmno' ]
+], { align: [ 'l', 'c', 'l' ] });
+console.log(t);
+```
+
+```
+beep 1024 xyz
+boop 3388450 tuv
+foo 10106 qrstuv
+bar 45 lmno
+```
+
+# methods
+
+``` js
+var table = require('text-table')
+```
+
+## var s = table(rows, opts={})
+
+Return a formatted table string `s` from an array of `rows` and some options
+`opts`.
+
+`rows` should be an array of arrays containing strings, numbers, or other
+printable values.
+
+options can be:
+
+* `opts.hsep` - separator to use between columns, default `' '`
+* `opts.align` - array of alignment types for each column, default `['l','l',...]`
+* `opts.stringLength` - callback function to use when calculating the string length
+
+alignment types are:
+
+* `'l'` - left
+* `'r'` - right
+* `'c'` - center
+* `'.'` - decimal
+
+# install
+
+With [npm](https://npmjs.org) do:
+
+```
+npm install text-table
+```
+
+# Use with ANSI-colors
+
+Since the string length of ANSI color schemes does not equal the length
+JavaScript sees internally it is necessary to pass the a custom string length
+calculator during the main function call.
+
+See the `test/ansi-colors.js` file for an example.
+
+# license
+
+MIT