mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-12 21:03:32 -06:00
Initial commit
This commit is contained in:
24
node_modules/table/LICENSE
generated
vendored
Normal file
24
node_modules/table/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
Copyright (c) 2016, Gajus Kuizinas (http://gajus.com/)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Gajus Kuizinas (http://gajus.com/) nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL ANUARY BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
671
node_modules/table/README.md
generated
vendored
Normal file
671
node_modules/table/README.md
generated
vendored
Normal file
@@ -0,0 +1,671 @@
|
||||
<a name="table"></a>
|
||||
# Table
|
||||
|
||||
[](https://travis-ci.org/gajus/table)
|
||||
[](https://www.npmjs.com/package/table)
|
||||
[](https://github.com/gajus/canonical)
|
||||
|
||||
* [Table](#table)
|
||||
* [Features](#table-features)
|
||||
* [Usage](#table-usage)
|
||||
* [Cell Content Alignment](#table-usage-cell-content-alignment)
|
||||
* [Column Width](#table-usage-column-width)
|
||||
* [Custom Border](#table-usage-custom-border)
|
||||
* [Draw Horizontal Line](#table-usage-draw-horizontal-line)
|
||||
* [Padding Cell Content](#table-usage-padding-cell-content)
|
||||
* [Predefined Border Templates](#table-usage-predefined-border-templates)
|
||||
* [Streaming](#table-usage-streaming)
|
||||
* [Text Truncation](#table-usage-text-truncation)
|
||||
* [Text Wrapping](#table-usage-text-wrapping)
|
||||
|
||||
|
||||
Produces a string that represents array data in a text table.
|
||||
|
||||

|
||||
|
||||
<a name="table-features"></a>
|
||||
## Features
|
||||
|
||||
* Works with strings containing [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) characters.
|
||||
* Works with strings containing [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code).
|
||||
* Configurable border characters.
|
||||
* Configurable content alignment per column.
|
||||
* Configurable content padding per column.
|
||||
* Configurable column width.
|
||||
* Text wrapping.
|
||||
|
||||
<a name="table-usage"></a>
|
||||
## Usage
|
||||
|
||||
Table data is described using an array (rows) of array (cells).
|
||||
|
||||
```js
|
||||
import {
|
||||
table
|
||||
} from 'table';
|
||||
|
||||
// Using commonjs?
|
||||
// const {table} = require('table');
|
||||
|
||||
let data,
|
||||
output;
|
||||
|
||||
data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
|
||||
/**
|
||||
* @typedef {string} table~cell
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {table~cell[]} table~row
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} table~columns
|
||||
* @property {string} alignment Cell content alignment (enum: left, center, right) (default: left).
|
||||
* @property {number} width Column width (default: auto).
|
||||
* @property {number} truncate Number of characters are which the content will be truncated (default: Infinity).
|
||||
* @property {number} paddingLeft Cell content padding width left (default: 1).
|
||||
* @property {number} paddingRight Cell content padding width right (default: 1).
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} table~border
|
||||
* @property {string} topBody
|
||||
* @property {string} topJoin
|
||||
* @property {string} topLeft
|
||||
* @property {string} topRight
|
||||
* @property {string} bottomBody
|
||||
* @property {string} bottomJoin
|
||||
* @property {string} bottomLeft
|
||||
* @property {string} bottomRight
|
||||
* @property {string} bodyLeft
|
||||
* @property {string} bodyRight
|
||||
* @property {string} bodyJoin
|
||||
* @property {string} joinBody
|
||||
* @property {string} joinLeft
|
||||
* @property {string} joinRight
|
||||
* @property {string} joinJoin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Used to dynamically tell table whether to draw a line separating rows or not.
|
||||
* The default behavior is to always return true.
|
||||
*
|
||||
* @typedef {function} drawJoin
|
||||
* @param {number} index
|
||||
* @param {number} size
|
||||
* @return {boolean}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} table~config
|
||||
* @property {table~border} border
|
||||
* @property {table~columns[]} columns Column specific configuration.
|
||||
* @property {table~columns} columnDefault Default values for all columns. Column specific settings overwrite the default values.
|
||||
* @property {table~drawJoin} drawHorizontalLine
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generates a text table.
|
||||
*
|
||||
* @param {table~row[]} rows
|
||||
* @param {table~config} config
|
||||
* @return {String}
|
||||
*/
|
||||
output = table(data);
|
||||
|
||||
console.log(output);
|
||||
```
|
||||
|
||||
```
|
||||
╔════╤════╤════╗
|
||||
║ 0A │ 0B │ 0C ║
|
||||
╟────┼────┼────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
╟────┼────┼────╢
|
||||
║ 2A │ 2B │ 2C ║
|
||||
╚════╧════╧════╝
|
||||
```
|
||||
|
||||
|
||||
<a name="table-usage-cell-content-alignment"></a>
|
||||
### Cell Content Alignment
|
||||
|
||||
`{string} config.columns[{number}].alignment` property controls content horizontal alignment within a cell.
|
||||
|
||||
Valid values are: "left", "right" and "center".
|
||||
|
||||
```js
|
||||
let config,
|
||||
data,
|
||||
output;
|
||||
|
||||
data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
|
||||
config = {
|
||||
columns: {
|
||||
0: {
|
||||
alignment: 'left',
|
||||
minWidth: 10
|
||||
},
|
||||
1: {
|
||||
alignment: 'center',
|
||||
minWidth: 10
|
||||
},
|
||||
2: {
|
||||
alignment: 'right',
|
||||
minWidth: 10
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
output = table(data, config);
|
||||
|
||||
console.log(output);
|
||||
```
|
||||
|
||||
```
|
||||
╔════════════╤════════════╤════════════╗
|
||||
║ 0A │ 0B │ 0C ║
|
||||
╟────────────┼────────────┼────────────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
╟────────────┼────────────┼────────────╢
|
||||
║ 2A │ 2B │ 2C ║
|
||||
╚════════════╧════════════╧════════════╝
|
||||
```
|
||||
|
||||
<a name="table-usage-column-width"></a>
|
||||
### Column Width
|
||||
|
||||
`{number} config.columns[{number}].width` property restricts column width to a fixed width.
|
||||
|
||||
```js
|
||||
let data,
|
||||
output,
|
||||
options;
|
||||
|
||||
data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
|
||||
options = {
|
||||
columns: {
|
||||
1: {
|
||||
width: 10
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
output = table(data, options);
|
||||
|
||||
console.log(output);
|
||||
```
|
||||
|
||||
```
|
||||
╔════╤════════════╤════╗
|
||||
║ 0A │ 0B │ 0C ║
|
||||
╟────┼────────────┼────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
╟────┼────────────┼────╢
|
||||
║ 2A │ 2B │ 2C ║
|
||||
╚════╧════════════╧════╝
|
||||
```
|
||||
|
||||
<a name="table-usage-custom-border"></a>
|
||||
### Custom Border
|
||||
|
||||
`{object} config.border` property describes characters used to draw the table border.
|
||||
|
||||
```js
|
||||
let config,
|
||||
data,
|
||||
output;
|
||||
|
||||
data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
|
||||
config = {
|
||||
border: {
|
||||
topBody: `─`,
|
||||
topJoin: `┬`,
|
||||
topLeft: `┌`,
|
||||
topRight: `┐`,
|
||||
|
||||
bottomBody: `─`,
|
||||
bottomJoin: `┴`,
|
||||
bottomLeft: `└`,
|
||||
bottomRight: `┘`,
|
||||
|
||||
bodyLeft: `│`,
|
||||
bodyRight: `│`,
|
||||
bodyJoin: `│`,
|
||||
|
||||
joinBody: `─`,
|
||||
joinLeft: `├`,
|
||||
joinRight: `┤`,
|
||||
joinJoin: `┼`
|
||||
}
|
||||
};
|
||||
|
||||
output = table(data, config);
|
||||
|
||||
console.log(output);
|
||||
```
|
||||
|
||||
```
|
||||
┌────┬────┬────┐
|
||||
│ 0A │ 0B │ 0C │
|
||||
├────┼────┼────┤
|
||||
│ 1A │ 1B │ 1C │
|
||||
├────┼────┼────┤
|
||||
│ 2A │ 2B │ 2C │
|
||||
└────┴────┴────┘
|
||||
```
|
||||
|
||||
<a name="table-usage-draw-horizontal-line"></a>
|
||||
### Draw Horizontal Line
|
||||
|
||||
`{function} config.drawHorizontalLine` property is a function that is called for every non-content row in the table. The result of the function `{boolean}` determines whether a row is drawn.
|
||||
|
||||
```js
|
||||
let data,
|
||||
output,
|
||||
options;
|
||||
|
||||
data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C'],
|
||||
['3A', '3B', '3C'],
|
||||
['4A', '4B', '4C']
|
||||
];
|
||||
|
||||
options = {
|
||||
/**
|
||||
* @typedef {function} drawJoin
|
||||
* @param {number} index
|
||||
* @param {number} size
|
||||
* @return {boolean}
|
||||
*/
|
||||
drawHorizontalLine: (index, size) => {
|
||||
return index === 0 || index === 1 || index === size - 1 || index === size;
|
||||
}
|
||||
};
|
||||
|
||||
output = table(data, options);
|
||||
|
||||
console.log(output);
|
||||
```
|
||||
|
||||
```
|
||||
╔════╤════╤════╗
|
||||
║ 0A │ 0B │ 0C ║
|
||||
╟────┼────┼────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
║ 2A │ 2B │ 2C ║
|
||||
║ 3A │ 3B │ 3C ║
|
||||
╟────┼────┼────╢
|
||||
║ 4A │ 4B │ 4C ║
|
||||
╚════╧════╧════╝
|
||||
```
|
||||
|
||||
<a name="table-usage-padding-cell-content"></a>
|
||||
### Padding Cell Content
|
||||
|
||||
`{number} config.columns[{number}].paddingLeft` and `{number} config.columns[{number}].paddingRight` properties control content padding within a cell. Property value represents a number of whitespaces used to pad the content.
|
||||
|
||||
```js
|
||||
let config,
|
||||
data,
|
||||
output;
|
||||
|
||||
data = [
|
||||
['0A', 'AABBCC', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
|
||||
config = {
|
||||
columns: {
|
||||
0: {
|
||||
paddingLeft: 3
|
||||
},
|
||||
1: {
|
||||
width: 2,
|
||||
paddingRight: 3
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
output = table(data, config);
|
||||
|
||||
console.log(output);
|
||||
```
|
||||
|
||||
```
|
||||
╔══════╤══════╤════╗
|
||||
║ 0A │ AA │ 0C ║
|
||||
║ │ BB │ ║
|
||||
║ │ CC │ ║
|
||||
╟──────┼──────┼────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
╟──────┼──────┼────╢
|
||||
║ 2A │ 2B │ 2C ║
|
||||
╚══════╧══════╧════╝
|
||||
```
|
||||
|
||||
<a name="table-usage-predefined-border-templates"></a>
|
||||
### Predefined Border Templates
|
||||
|
||||
You can load one of the predefined border templates using `getBorderCharacters` function.
|
||||
|
||||
```js
|
||||
import {
|
||||
table,
|
||||
getBorderCharacters
|
||||
} from 'table';
|
||||
|
||||
let config,
|
||||
data;
|
||||
|
||||
data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
|
||||
config = {
|
||||
border: getBorderCharacters(`name of the template`)
|
||||
};
|
||||
|
||||
table(data, config);
|
||||
```
|
||||
|
||||
```
|
||||
# honeywell
|
||||
|
||||
╔════╤════╤════╗
|
||||
║ 0A │ 0B │ 0C ║
|
||||
╟────┼────┼────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
╟────┼────┼────╢
|
||||
║ 2A │ 2B │ 2C ║
|
||||
╚════╧════╧════╝
|
||||
|
||||
# norc
|
||||
|
||||
┌────┬────┬────┐
|
||||
│ 0A │ 0B │ 0C │
|
||||
├────┼────┼────┤
|
||||
│ 1A │ 1B │ 1C │
|
||||
├────┼────┼────┤
|
||||
│ 2A │ 2B │ 2C │
|
||||
└────┴────┴────┘
|
||||
|
||||
# ramac (ASCII; for use in terminals that do not support Unicode characters)
|
||||
|
||||
+----+----+----+
|
||||
| 0A | 0B | 0C |
|
||||
|----|----|----|
|
||||
| 1A | 1B | 1C |
|
||||
|----|----|----|
|
||||
| 2A | 2B | 2C |
|
||||
+----+----+----+
|
||||
|
||||
# void (no borders; see "bordless table" section of the documentation)
|
||||
|
||||
0A 0B 0C
|
||||
|
||||
1A 1B 1C
|
||||
|
||||
2A 2B 2C
|
||||
|
||||
```
|
||||
|
||||
Raise [an issue](https://github.com/gajus/table/issues) if you'd like to contribute a new border template.
|
||||
|
||||
<a name="table-usage-predefined-border-templates-borderless-table"></a>
|
||||
#### Borderless Table
|
||||
|
||||
Simply using "void" border character template creates a table with a lot of unnecessary spacing.
|
||||
|
||||
To create a more plesant to the eye table, reset the padding and remove the joining rows, e.g.
|
||||
|
||||
```js
|
||||
let output;
|
||||
|
||||
output = table(data, {
|
||||
border: getBorderCharacters(`void`),
|
||||
columnDefault: {
|
||||
paddingLeft: 0,
|
||||
paddingRight: 1
|
||||
},
|
||||
drawJoin: () => {
|
||||
return false
|
||||
}
|
||||
});
|
||||
|
||||
console.log(output);
|
||||
```
|
||||
|
||||
```
|
||||
0A 0B 0C
|
||||
1A 1B 1C
|
||||
2A 2B 2C
|
||||
```
|
||||
|
||||
<a name="table-usage-streaming"></a>
|
||||
### Streaming
|
||||
|
||||
`table` package exports `createStream` function used to draw a table and append rows.
|
||||
|
||||
`createStream` requires `{number} columnDefault.width` and `{number} columnCount` configuration properties.
|
||||
|
||||
```js
|
||||
import {
|
||||
createStream
|
||||
} from 'table';
|
||||
|
||||
let config,
|
||||
stream;
|
||||
|
||||
config = {
|
||||
columnDefault: {
|
||||
width: 50
|
||||
},
|
||||
columnCount: 1
|
||||
};
|
||||
|
||||
stream = createStream(config);
|
||||
|
||||
setInterval(() => {
|
||||
stream.write([new Date()]);
|
||||
}, 500);
|
||||
```
|
||||
|
||||

|
||||
|
||||
`table` package uses ANSI escape codes to overwrite the output of the last line when a new row is printed.
|
||||
|
||||
The underlying implementation is explained in this [Stack Overflow answer](http://stackoverflow.com/a/32938658/368691).
|
||||
|
||||
Streaming supports all of the configuration properties and functionality of a static table (such as auto text wrapping, alignment and padding), e.g.
|
||||
|
||||
```js
|
||||
import {
|
||||
createStream
|
||||
} from 'table';
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
let config,
|
||||
stream,
|
||||
i;
|
||||
|
||||
config = {
|
||||
columnDefault: {
|
||||
width: 50
|
||||
},
|
||||
columnCount: 3,
|
||||
columns: {
|
||||
0: {
|
||||
width: 10,
|
||||
alignment: 'right'
|
||||
},
|
||||
1: {
|
||||
alignment: 'center',
|
||||
},
|
||||
2: {
|
||||
width: 10
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
stream = createStream(config);
|
||||
|
||||
i = 0;
|
||||
|
||||
setInterval(() => {
|
||||
let random;
|
||||
|
||||
random = _.sample('abcdefghijklmnopqrstuvwxyz', _.random(1, 30)).join('');
|
||||
|
||||
stream.write([i++, new Date(), random]);
|
||||
}, 500);
|
||||
```
|
||||
|
||||

|
||||
<a name="table-usage-text-truncation"></a>
|
||||
### Text Truncation
|
||||
|
||||
To handle a content that overflows the container width, `table` package implements [text wrapping](#table-usage-text-wrapping). However, sometimes you may want to truncate content that is too long to be displayed in the table.
|
||||
|
||||
`{number} config.columns[{number}].truncate` property (default: `Infinity`) truncates the text at the specified length.
|
||||
|
||||
```js
|
||||
let config,
|
||||
data,
|
||||
output;
|
||||
|
||||
data = [
|
||||
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
|
||||
];
|
||||
|
||||
config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 20,
|
||||
truncate: 100
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
output = table(data, config);
|
||||
|
||||
console.log(output);
|
||||
```
|
||||
|
||||
```
|
||||
╔══════════════════════╗
|
||||
║ Lorem ipsum dolor si ║
|
||||
║ t amet, consectetur ║
|
||||
║ adipiscing elit. Pha ║
|
||||
║ sellus pulvinar nibh ║
|
||||
║ sed mauris conva... ║
|
||||
╚══════════════════════╝
|
||||
```
|
||||
|
||||
<a name="table-usage-text-wrapping"></a>
|
||||
### Text Wrapping
|
||||
|
||||
`table` package implements auto text wrapping, i.e. text that has width greater than the container width will be separated into multiple lines, e.g.
|
||||
|
||||
```js
|
||||
let config,
|
||||
data,
|
||||
output;
|
||||
|
||||
data = [
|
||||
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
|
||||
];
|
||||
|
||||
config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 20
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
output = table(data, config);
|
||||
|
||||
console.log(output);
|
||||
```
|
||||
|
||||
```
|
||||
╔══════════════════════╗
|
||||
║ Lorem ipsum dolor si ║
|
||||
║ t amet, consectetur ║
|
||||
║ adipiscing elit. Pha ║
|
||||
║ sellus pulvinar nibh ║
|
||||
║ sed mauris convallis ║
|
||||
║ dapibus. Nunc venena ║
|
||||
║ tis tempus nulla sit ║
|
||||
║ amet viverra. ║
|
||||
╚══════════════════════╝
|
||||
```
|
||||
|
||||
When `wrapWord` is `true` the text is broken at the nearest space or one of the special characters ("-", "_", "\", "/", ".", ",", ";"), e.g.
|
||||
|
||||
```js
|
||||
let config,
|
||||
data,
|
||||
output;
|
||||
|
||||
data = [
|
||||
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
|
||||
];
|
||||
|
||||
config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 20,
|
||||
wrapWord: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
output = table(data, config);
|
||||
|
||||
console.log(output);
|
||||
```
|
||||
|
||||
```
|
||||
╔══════════════════════╗
|
||||
║ Lorem ipsum dolor ║
|
||||
║ sit amet, ║
|
||||
║ consectetur ║
|
||||
║ adipiscing elit. ║
|
||||
║ Phasellus pulvinar ║
|
||||
║ nibh sed mauris ║
|
||||
║ convallis dapibus. ║
|
||||
║ Nunc venenatis ║
|
||||
║ tempus nulla sit ║
|
||||
║ amet viverra. ║
|
||||
╚══════════════════════╝
|
||||
```
|
||||
|
106
node_modules/table/dist/alignString.js
generated
vendored
Normal file
106
node_modules/table/dist/alignString.js
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
var _stringWidth = require('string-width');
|
||||
|
||||
var _stringWidth2 = _interopRequireDefault(_stringWidth);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
const alignments = ['left', 'right', 'center'];
|
||||
|
||||
/**
|
||||
* @param {string} subject
|
||||
* @param {number} width
|
||||
* @returns {string}
|
||||
*/
|
||||
const alignLeft = (subject, width) => {
|
||||
return subject + _lodash2.default.repeat(' ', width);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} subject
|
||||
* @param {number} width
|
||||
* @returns {string}
|
||||
*/
|
||||
const alignRight = (subject, width) => {
|
||||
return _lodash2.default.repeat(' ', width) + subject;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} subject
|
||||
* @param {number} width
|
||||
* @returns {string}
|
||||
*/
|
||||
const alignCenter = (subject, width) => {
|
||||
let halfWidth;
|
||||
|
||||
halfWidth = width / 2;
|
||||
|
||||
if (halfWidth % 2 === 0) {
|
||||
return _lodash2.default.repeat(' ', halfWidth) + subject + _lodash2.default.repeat(' ', halfWidth);
|
||||
} else {
|
||||
halfWidth = _lodash2.default.floor(halfWidth);
|
||||
|
||||
return _lodash2.default.repeat(' ', halfWidth) + subject + _lodash2.default.repeat(' ', halfWidth + 1);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Pads a string to the left and/or right to position the subject
|
||||
* text in a desired alignment within a container.
|
||||
*
|
||||
* @param {string} subject
|
||||
* @param {number} containerWidth
|
||||
* @param {string} alignment One of the valid options (left, right, center).
|
||||
* @returns {string}
|
||||
*/
|
||||
|
||||
exports.default = (subject, containerWidth, alignment) => {
|
||||
if (!_lodash2.default.isString(subject)) {
|
||||
throw new Error('Subject parameter value must be a string.');
|
||||
}
|
||||
|
||||
if (!_lodash2.default.isNumber(containerWidth)) {
|
||||
throw new Error('Container width parameter value must be a number.');
|
||||
}
|
||||
|
||||
const subjectWidth = (0, _stringWidth2.default)(subject);
|
||||
|
||||
if (subjectWidth > containerWidth) {
|
||||
// console.log('subjectWidth', subjectWidth, 'containerWidth', containerWidth, 'subject', subject);
|
||||
|
||||
throw new Error('Subject parameter value width cannot be greater than the container width.');
|
||||
}
|
||||
|
||||
if (!_lodash2.default.isString(alignment)) {
|
||||
throw new Error('Alignment parameter value must be a string.');
|
||||
}
|
||||
|
||||
if (alignments.indexOf(alignment) === -1) {
|
||||
throw new Error('Alignment parameter value must be a known alignment parameter value (left, right, center).');
|
||||
}
|
||||
|
||||
if (subjectWidth === 0) {
|
||||
return _lodash2.default.repeat(' ', containerWidth);
|
||||
}
|
||||
|
||||
const availableWidth = containerWidth - subjectWidth;
|
||||
|
||||
if (alignment === 'left') {
|
||||
return alignLeft(subject, availableWidth);
|
||||
}
|
||||
|
||||
if (alignment === 'right') {
|
||||
return alignRight(subject, availableWidth);
|
||||
}
|
||||
|
||||
return alignCenter(subject, availableWidth);
|
||||
};
|
38
node_modules/table/dist/alignTableData.js
generated
vendored
Normal file
38
node_modules/table/dist/alignTableData.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
var _stringWidth = require('string-width');
|
||||
|
||||
var _stringWidth2 = _interopRequireDefault(_stringWidth);
|
||||
|
||||
var _alignString = require('./alignString');
|
||||
|
||||
var _alignString2 = _interopRequireDefault(_alignString);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* @param {table~row[]} rows
|
||||
* @param {Object} config
|
||||
* @returns {table~row[]}
|
||||
*/
|
||||
exports.default = (rows, config) => {
|
||||
return _lodash2.default.map(rows, cells => {
|
||||
return _lodash2.default.map(cells, (value, index1) => {
|
||||
const column = config.columns[index1];
|
||||
|
||||
if ((0, _stringWidth2.default)(value) === column.width) {
|
||||
return value;
|
||||
} else {
|
||||
return (0, _alignString2.default)(value, column.width, column.alignment);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
47
node_modules/table/dist/calculateCellHeight.js
generated
vendored
Normal file
47
node_modules/table/dist/calculateCellHeight.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
var _stringWidth = require('string-width');
|
||||
|
||||
var _stringWidth2 = _interopRequireDefault(_stringWidth);
|
||||
|
||||
var _wrapWord = require('./wrapWord');
|
||||
|
||||
var _wrapWord2 = _interopRequireDefault(_wrapWord);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @param {number} columnWidth
|
||||
* @param {boolean} useWrapWord
|
||||
* @returns {number}
|
||||
*/
|
||||
exports.default = function (value, columnWidth) {
|
||||
let useWrapWord = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
||||
|
||||
if (!_lodash2.default.isString(value)) {
|
||||
throw new Error('Value must be a string.');
|
||||
}
|
||||
|
||||
if (!_lodash2.default.isInteger(columnWidth)) {
|
||||
throw new Error('Column width must be an integer.');
|
||||
}
|
||||
|
||||
if (columnWidth < 1) {
|
||||
throw new Error('Column width must be greater than 0.');
|
||||
}
|
||||
|
||||
if (useWrapWord) {
|
||||
return (0, _wrapWord2.default)(value, columnWidth).length;
|
||||
}
|
||||
|
||||
return _lodash2.default.ceil((0, _stringWidth2.default)(value) / columnWidth);
|
||||
};
|
27
node_modules/table/dist/calculateCellWidthIndex.js
generated
vendored
Normal file
27
node_modules/table/dist/calculateCellWidthIndex.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
var _stringWidth = require('string-width');
|
||||
|
||||
var _stringWidth2 = _interopRequireDefault(_stringWidth);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Calculates width of each cell contents.
|
||||
*
|
||||
* @param {string[]} cells
|
||||
* @returns {number[]}
|
||||
*/
|
||||
exports.default = cells => {
|
||||
return _lodash2.default.map(cells, value => {
|
||||
return (0, _stringWidth2.default)(value);
|
||||
});
|
||||
};
|
41
node_modules/table/dist/calculateMaximumColumnWidthIndex.js
generated
vendored
Normal file
41
node_modules/table/dist/calculateMaximumColumnWidthIndex.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
var _calculateCellWidthIndex = require('./calculateCellWidthIndex');
|
||||
|
||||
var _calculateCellWidthIndex2 = _interopRequireDefault(_calculateCellWidthIndex);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Produces an array of values that describe the largest value length (width) in every column.
|
||||
*
|
||||
* @param {Array[]} rows
|
||||
* @returns {number[]}
|
||||
*/
|
||||
exports.default = rows => {
|
||||
if (!rows[0]) {
|
||||
throw new Error('Dataset must have at least one row.');
|
||||
}
|
||||
|
||||
const columns = _lodash2.default.fill(Array(rows[0].length), 0);
|
||||
|
||||
_lodash2.default.forEach(rows, row => {
|
||||
const columnWidthIndex = (0, _calculateCellWidthIndex2.default)(row);
|
||||
|
||||
_lodash2.default.forEach(columnWidthIndex, (valueWidth, index0) => {
|
||||
if (columns[index0] < valueWidth) {
|
||||
columns[index0] = valueWidth;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return columns;
|
||||
};
|
48
node_modules/table/dist/calculateRowHeightIndex.js
generated
vendored
Normal file
48
node_modules/table/dist/calculateRowHeightIndex.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
var _calculateCellHeight = require('./calculateCellHeight');
|
||||
|
||||
var _calculateCellHeight2 = _interopRequireDefault(_calculateCellHeight);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Calculates the vertical row span index.
|
||||
*
|
||||
* @param {Array[]} rows
|
||||
* @param {Object} config
|
||||
* @returns {number[]}
|
||||
*/
|
||||
exports.default = (rows, config) => {
|
||||
const tableWidth = rows[0].length;
|
||||
|
||||
const rowSpanIndex = [];
|
||||
|
||||
_lodash2.default.forEach(rows, cells => {
|
||||
const cellHeightIndex = _lodash2.default.fill(Array(tableWidth), 1);
|
||||
|
||||
_lodash2.default.forEach(cells, (value, index1) => {
|
||||
if (!_lodash2.default.isNumber(config.columns[index1].width)) {
|
||||
throw new Error('column[index].width must be a number.');
|
||||
}
|
||||
|
||||
if (!_lodash2.default.isBoolean(config.columns[index1].wrapWord)) {
|
||||
throw new Error('column[index].wrapWord must be a boolean.');
|
||||
}
|
||||
|
||||
cellHeightIndex[index1] = (0, _calculateCellHeight2.default)(value, config.columns[index1].width, config.columns[index1].wrapWord);
|
||||
});
|
||||
|
||||
rowSpanIndex.push(_lodash2.default.max(cellHeightIndex));
|
||||
});
|
||||
|
||||
return rowSpanIndex;
|
||||
};
|
157
node_modules/table/dist/createStream.js
generated
vendored
Normal file
157
node_modules/table/dist/createStream.js
generated
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
var _makeStreamConfig = require('./makeStreamConfig');
|
||||
|
||||
var _makeStreamConfig2 = _interopRequireDefault(_makeStreamConfig);
|
||||
|
||||
var _drawRow = require('./drawRow');
|
||||
|
||||
var _drawRow2 = _interopRequireDefault(_drawRow);
|
||||
|
||||
var _drawBorder = require('./drawBorder');
|
||||
|
||||
var _stringifyTableData = require('./stringifyTableData');
|
||||
|
||||
var _stringifyTableData2 = _interopRequireDefault(_stringifyTableData);
|
||||
|
||||
var _truncateTableData = require('./truncateTableData');
|
||||
|
||||
var _truncateTableData2 = _interopRequireDefault(_truncateTableData);
|
||||
|
||||
var _mapDataUsingRowHeightIndex = require('./mapDataUsingRowHeightIndex');
|
||||
|
||||
var _mapDataUsingRowHeightIndex2 = _interopRequireDefault(_mapDataUsingRowHeightIndex);
|
||||
|
||||
var _alignTableData = require('./alignTableData');
|
||||
|
||||
var _alignTableData2 = _interopRequireDefault(_alignTableData);
|
||||
|
||||
var _padTableData = require('./padTableData');
|
||||
|
||||
var _padTableData2 = _interopRequireDefault(_padTableData);
|
||||
|
||||
var _calculateRowHeightIndex = require('./calculateRowHeightIndex');
|
||||
|
||||
var _calculateRowHeightIndex2 = _interopRequireDefault(_calculateRowHeightIndex);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* @param {Array} data
|
||||
* @param {Object} config
|
||||
* @returns {Array}
|
||||
*/
|
||||
const prepareData = (data, config) => {
|
||||
let rows;
|
||||
|
||||
rows = (0, _stringifyTableData2.default)(data);
|
||||
|
||||
rows = (0, _truncateTableData2.default)(data, config);
|
||||
|
||||
const rowHeightIndex = (0, _calculateRowHeightIndex2.default)(rows, config);
|
||||
|
||||
rows = (0, _mapDataUsingRowHeightIndex2.default)(rows, rowHeightIndex, config);
|
||||
rows = (0, _alignTableData2.default)(rows, config);
|
||||
rows = (0, _padTableData2.default)(rows, config);
|
||||
|
||||
return rows;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string[]} row
|
||||
* @param {number[]} columnWidthIndex
|
||||
* @param {Object} config
|
||||
* @returns {undefined}
|
||||
*/
|
||||
const create = (row, columnWidthIndex, config) => {
|
||||
const rows = prepareData([row], config);
|
||||
|
||||
const body = _lodash2.default.map(rows, literalRow => {
|
||||
return (0, _drawRow2.default)(literalRow, config.border);
|
||||
}).join('');
|
||||
|
||||
let output;
|
||||
|
||||
output = '';
|
||||
|
||||
output += (0, _drawBorder.drawBorderTop)(columnWidthIndex, config.border);
|
||||
output += body;
|
||||
output += (0, _drawBorder.drawBorderBottom)(columnWidthIndex, config.border);
|
||||
|
||||
output = _lodash2.default.trimEnd(output);
|
||||
|
||||
process.stdout.write(output);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string[]} row
|
||||
* @param {number[]} columnWidthIndex
|
||||
* @param {Object} config
|
||||
* @returns {undefined}
|
||||
*/
|
||||
const append = (row, columnWidthIndex, config) => {
|
||||
const rows = prepareData([row], config);
|
||||
|
||||
const body = _lodash2.default.map(rows, literalRow => {
|
||||
return (0, _drawRow2.default)(literalRow, config.border);
|
||||
}).join('');
|
||||
|
||||
let output;
|
||||
|
||||
output = '\r\x1b[K';
|
||||
|
||||
output += (0, _drawBorder.drawBorderJoin)(columnWidthIndex, config.border);
|
||||
output += body;
|
||||
output += (0, _drawBorder.drawBorderBottom)(columnWidthIndex, config.border);
|
||||
|
||||
output = _lodash2.default.trimEnd(output);
|
||||
|
||||
process.stdout.write(output);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} userConfig
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
exports.default = function () {
|
||||
let userConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
|
||||
const config = (0, _makeStreamConfig2.default)(userConfig);
|
||||
|
||||
const columnWidthIndex = _lodash2.default.mapValues(config.columns, column => {
|
||||
return column.width + column.paddingLeft + column.paddingRight;
|
||||
});
|
||||
|
||||
let empty;
|
||||
|
||||
empty = true;
|
||||
|
||||
return {
|
||||
/**
|
||||
* @param {string[]} row
|
||||
* @returns {undefined}
|
||||
*/
|
||||
write: row => {
|
||||
if (row.length !== config.columnCount) {
|
||||
throw new Error('Row cell count does not match the config.columnCount.');
|
||||
}
|
||||
|
||||
if (empty) {
|
||||
empty = false;
|
||||
|
||||
return create(row, columnWidthIndex, config);
|
||||
} else {
|
||||
return append(row, columnWidthIndex, config);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
104
node_modules/table/dist/drawBorder.js
generated
vendored
Normal file
104
node_modules/table/dist/drawBorder.js
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.drawBorderTop = exports.drawBorderJoin = exports.drawBorderBottom = exports.drawBorder = undefined;
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* @typedef drawBorder~parts
|
||||
* @property {string} left
|
||||
* @property {string} right
|
||||
* @property {string} body
|
||||
* @property {string} join
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {number[]} columnSizeIndex
|
||||
* @param {drawBorder~parts} parts
|
||||
* @returns {string}
|
||||
*/
|
||||
const drawBorder = (columnSizeIndex, parts) => {
|
||||
const columns = _lodash2.default.map(columnSizeIndex, size => {
|
||||
return _lodash2.default.repeat(parts.body, size);
|
||||
}).join(parts.join);
|
||||
|
||||
return parts.left + columns + parts.right + '\n';
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef drawBorderTop~parts
|
||||
* @property {string} topLeft
|
||||
* @property {string} topRight
|
||||
* @property {string} topBody
|
||||
* @property {string} topJoin
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {number[]} columnSizeIndex
|
||||
* @param {drawBorderTop~parts} parts
|
||||
* @returns {string}
|
||||
*/
|
||||
const drawBorderTop = (columnSizeIndex, parts) => {
|
||||
return drawBorder(columnSizeIndex, {
|
||||
body: parts.topBody,
|
||||
join: parts.topJoin,
|
||||
left: parts.topLeft,
|
||||
right: parts.topRight
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef drawBorderJoin~parts
|
||||
* @property {string} joinLeft
|
||||
* @property {string} joinRight
|
||||
* @property {string} joinBody
|
||||
* @property {string} joinJoin
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {number[]} columnSizeIndex
|
||||
* @param {drawBorderJoin~parts} parts
|
||||
* @returns {string}
|
||||
*/
|
||||
const drawBorderJoin = (columnSizeIndex, parts) => {
|
||||
return drawBorder(columnSizeIndex, {
|
||||
body: parts.joinBody,
|
||||
join: parts.joinJoin,
|
||||
left: parts.joinLeft,
|
||||
right: parts.joinRight
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef drawBorderBottom~parts
|
||||
* @property {string} topLeft
|
||||
* @property {string} topRight
|
||||
* @property {string} topBody
|
||||
* @property {string} topJoin
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {number[]} columnSizeIndex
|
||||
* @param {drawBorderBottom~parts} parts
|
||||
* @returns {string}
|
||||
*/
|
||||
const drawBorderBottom = (columnSizeIndex, parts) => {
|
||||
return drawBorder(columnSizeIndex, {
|
||||
body: parts.bottomBody,
|
||||
join: parts.bottomJoin,
|
||||
left: parts.bottomLeft,
|
||||
right: parts.bottomRight
|
||||
});
|
||||
};
|
||||
|
||||
exports.drawBorder = drawBorder;
|
||||
exports.drawBorderBottom = drawBorderBottom;
|
||||
exports.drawBorderJoin = drawBorderJoin;
|
||||
exports.drawBorderTop = drawBorderTop;
|
21
node_modules/table/dist/drawRow.js
generated
vendored
Normal file
21
node_modules/table/dist/drawRow.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
/**
|
||||
* @typedef {Object} drawRow~border
|
||||
* @property {string} bodyLeft
|
||||
* @property {string} bodyRight
|
||||
* @property {string} bodyJoin
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {number[]} columns
|
||||
* @param {drawRow~border} border
|
||||
* @returns {string}
|
||||
*/
|
||||
exports.default = (columns, border) => {
|
||||
return border.bodyLeft + columns.join(border.bodyJoin) + border.bodyRight + '\n';
|
||||
};
|
61
node_modules/table/dist/drawTable.js
generated
vendored
Normal file
61
node_modules/table/dist/drawTable.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
var _drawBorder = require('./drawBorder');
|
||||
|
||||
var _drawRow = require('./drawRow');
|
||||
|
||||
var _drawRow2 = _interopRequireDefault(_drawRow);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* @param {Array} rows
|
||||
* @param {Object} border
|
||||
* @param {Array} columnSizeIndex
|
||||
* @param {Array} rowSpanIndex
|
||||
* @param {Function} drawHorizontalLine
|
||||
* @returns {string}
|
||||
*/
|
||||
exports.default = (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine) => {
|
||||
let output, realRowIndex, rowHeight;
|
||||
|
||||
const rowCount = rows.length;
|
||||
|
||||
realRowIndex = 0;
|
||||
|
||||
output = '';
|
||||
|
||||
if (drawHorizontalLine(realRowIndex, rowCount)) {
|
||||
output += (0, _drawBorder.drawBorderTop)(columnSizeIndex, border);
|
||||
}
|
||||
|
||||
_lodash2.default.forEach(rows, (row, index0) => {
|
||||
output += (0, _drawRow2.default)(row, border);
|
||||
|
||||
if (!rowHeight) {
|
||||
rowHeight = rowSpanIndex[realRowIndex];
|
||||
|
||||
realRowIndex++;
|
||||
}
|
||||
|
||||
rowHeight--;
|
||||
|
||||
if (rowHeight === 0 && index0 !== rowCount - 1 && drawHorizontalLine(realRowIndex, rowCount)) {
|
||||
output += (0, _drawBorder.drawBorderJoin)(columnSizeIndex, border);
|
||||
}
|
||||
});
|
||||
|
||||
if (drawHorizontalLine(realRowIndex, rowCount)) {
|
||||
output += (0, _drawBorder.drawBorderBottom)(columnSizeIndex, border);
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
126
node_modules/table/dist/getBorderCharacters.js
generated
vendored
Normal file
126
node_modules/table/dist/getBorderCharacters.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
/**
|
||||
* @typedef border
|
||||
* @property {string} topBody
|
||||
* @property {string} topJoin
|
||||
* @property {string} topLeft
|
||||
* @property {string} topRight
|
||||
* @property {string} bottomBody
|
||||
* @property {string} bottomJoin
|
||||
* @property {string} bottomLeft
|
||||
* @property {string} bottomRight
|
||||
* @property {string} bodyLeft
|
||||
* @property {string} bodyRight
|
||||
* @property {string} bodyJoin
|
||||
* @property {string} joinBody
|
||||
* @property {string} joinLeft
|
||||
* @property {string} joinRight
|
||||
* @property {string} joinJoin
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @returns {border}
|
||||
*/
|
||||
exports.default = name => {
|
||||
if (name === 'honeywell') {
|
||||
return {
|
||||
topBody: '═',
|
||||
topJoin: '╤',
|
||||
topLeft: '╔',
|
||||
topRight: '╗',
|
||||
|
||||
bottomBody: '═',
|
||||
bottomJoin: '╧',
|
||||
bottomLeft: '╚',
|
||||
bottomRight: '╝',
|
||||
|
||||
bodyLeft: '║',
|
||||
bodyRight: '║',
|
||||
bodyJoin: '│',
|
||||
|
||||
joinBody: '─',
|
||||
joinLeft: '╟',
|
||||
joinRight: '╢',
|
||||
joinJoin: '┼'
|
||||
};
|
||||
}
|
||||
|
||||
if (name === 'norc') {
|
||||
return {
|
||||
topBody: '─',
|
||||
topJoin: '┬',
|
||||
topLeft: '┌',
|
||||
topRight: '┐',
|
||||
|
||||
bottomBody: '─',
|
||||
bottomJoin: '┴',
|
||||
bottomLeft: '└',
|
||||
bottomRight: '┘',
|
||||
|
||||
bodyLeft: '│',
|
||||
bodyRight: '│',
|
||||
bodyJoin: '│',
|
||||
|
||||
joinBody: '─',
|
||||
joinLeft: '├',
|
||||
joinRight: '┤',
|
||||
joinJoin: '┼'
|
||||
};
|
||||
}
|
||||
|
||||
if (name === 'ramac') {
|
||||
return {
|
||||
topBody: '-',
|
||||
topJoin: '+',
|
||||
topLeft: '+',
|
||||
topRight: '+',
|
||||
|
||||
bottomBody: '-',
|
||||
bottomJoin: '+',
|
||||
bottomLeft: '+',
|
||||
bottomRight: '+',
|
||||
|
||||
bodyLeft: '|',
|
||||
bodyRight: '|',
|
||||
bodyJoin: '|',
|
||||
|
||||
joinBody: '-',
|
||||
joinLeft: '|',
|
||||
joinRight: '|',
|
||||
joinJoin: '|'
|
||||
};
|
||||
}
|
||||
|
||||
if (name === 'void') {
|
||||
return {
|
||||
topBody: '',
|
||||
topJoin: '',
|
||||
topLeft: '',
|
||||
topRight: '',
|
||||
|
||||
bottomBody: '',
|
||||
bottomJoin: '',
|
||||
bottomLeft: '',
|
||||
bottomRight: '',
|
||||
|
||||
bodyLeft: '',
|
||||
bodyRight: '',
|
||||
bodyJoin: '',
|
||||
|
||||
joinBody: '',
|
||||
joinLeft: '',
|
||||
joinRight: '',
|
||||
joinJoin: ''
|
||||
};
|
||||
}
|
||||
|
||||
throw new Error('Unknown border template "' + name + '".');
|
||||
};
|
24
node_modules/table/dist/index.js
generated
vendored
Normal file
24
node_modules/table/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getBorderCharacters = exports.createStream = exports.table = undefined;
|
||||
|
||||
var _table = require('./table');
|
||||
|
||||
var _table2 = _interopRequireDefault(_table);
|
||||
|
||||
var _createStream = require('./createStream');
|
||||
|
||||
var _createStream2 = _interopRequireDefault(_createStream);
|
||||
|
||||
var _getBorderCharacters = require('./getBorderCharacters');
|
||||
|
||||
var _getBorderCharacters2 = _interopRequireDefault(_getBorderCharacters);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.table = _table2.default;
|
||||
exports.createStream = _createStream2.default;
|
||||
exports.getBorderCharacters = _getBorderCharacters2.default;
|
99
node_modules/table/dist/makeConfig.js
generated
vendored
Normal file
99
node_modules/table/dist/makeConfig.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
var _getBorderCharacters = require('./getBorderCharacters');
|
||||
|
||||
var _getBorderCharacters2 = _interopRequireDefault(_getBorderCharacters);
|
||||
|
||||
var _validateConfig = require('./validateConfig');
|
||||
|
||||
var _validateConfig2 = _interopRequireDefault(_validateConfig);
|
||||
|
||||
var _calculateMaximumColumnWidthIndex = require('./calculateMaximumColumnWidthIndex');
|
||||
|
||||
var _calculateMaximumColumnWidthIndex2 = _interopRequireDefault(_calculateMaximumColumnWidthIndex);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Merges user provided border characters with the default border ("honeywell") characters.
|
||||
*
|
||||
* @param {Object} border
|
||||
* @returns {Object}
|
||||
*/
|
||||
const makeBorder = function makeBorder() {
|
||||
let border = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
|
||||
return _lodash2.default.assign({}, (0, _getBorderCharacters2.default)('honeywell'), border);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a configuration for every column using default
|
||||
* values for the missing configuration properties.
|
||||
*
|
||||
* @param {Array[]} rows
|
||||
* @param {Object} columns
|
||||
* @param {Object} columnDefault
|
||||
* @returns {Object}
|
||||
*/
|
||||
const makeColumns = function makeColumns(rows) {
|
||||
let columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
let columnDefault = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
|
||||
const maximumColumnWidthIndex = (0, _calculateMaximumColumnWidthIndex2.default)(rows);
|
||||
|
||||
_lodash2.default.times(rows[0].length, index => {
|
||||
if (_lodash2.default.isUndefined(columns[index])) {
|
||||
columns[index] = {};
|
||||
}
|
||||
|
||||
columns[index] = _lodash2.default.assign({
|
||||
alignment: 'left',
|
||||
paddingLeft: 1,
|
||||
paddingRight: 1,
|
||||
truncate: Infinity,
|
||||
width: maximumColumnWidthIndex[index],
|
||||
wrapWord: false
|
||||
}, columnDefault, columns[index]);
|
||||
});
|
||||
|
||||
return columns;
|
||||
};
|
||||
|
||||
/**
|
||||
* Makes a new configuration object out of the userConfig object
|
||||
* using default values for the missing configuration properties.
|
||||
*
|
||||
* @param {Array[]} rows
|
||||
* @param {Object} userConfig
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
exports.default = function (rows) {
|
||||
let userConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
(0, _validateConfig2.default)('config.json', userConfig);
|
||||
|
||||
const config = _lodash2.default.cloneDeep(userConfig);
|
||||
|
||||
config.border = makeBorder(config.border);
|
||||
config.columns = makeColumns(rows, config.columns, config.columnDefault);
|
||||
|
||||
if (!config.drawHorizontalLine) {
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
config.drawHorizontalLine = () => {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
return config;
|
||||
};
|
107
node_modules/table/dist/makeStreamConfig.js
generated
vendored
Normal file
107
node_modules/table/dist/makeStreamConfig.js
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
var _getBorderCharacters = require('./getBorderCharacters');
|
||||
|
||||
var _getBorderCharacters2 = _interopRequireDefault(_getBorderCharacters);
|
||||
|
||||
var _validateConfig = require('./validateConfig');
|
||||
|
||||
var _validateConfig2 = _interopRequireDefault(_validateConfig);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Merges user provided border characters with the default border ("honeywell") characters.
|
||||
*
|
||||
* @param {Object} border
|
||||
* @returns {Object}
|
||||
*/
|
||||
const makeBorder = function makeBorder() {
|
||||
let border = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
|
||||
return _lodash2.default.assign({}, (0, _getBorderCharacters2.default)('honeywell'), border);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a configuration for every column using default
|
||||
* values for the missing configuration properties.
|
||||
*
|
||||
* @param {number} columnCount
|
||||
* @param {Object} columns
|
||||
* @param {Object} columnDefault
|
||||
* @returns {Object}
|
||||
*/
|
||||
const makeColumns = function makeColumns(columnCount) {
|
||||
let columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
let columnDefault = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
|
||||
_lodash2.default.times(columnCount, index => {
|
||||
if (_lodash2.default.isUndefined(columns[index])) {
|
||||
columns[index] = {};
|
||||
}
|
||||
|
||||
columns[index] = _lodash2.default.assign({
|
||||
alignment: 'left',
|
||||
paddingLeft: 1,
|
||||
paddingRight: 1,
|
||||
truncate: Infinity,
|
||||
wrapWord: false
|
||||
}, columnDefault, columns[index]);
|
||||
});
|
||||
|
||||
return columns;
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {Object} columnConfig
|
||||
* @property {string} alignment
|
||||
* @property {number} width
|
||||
* @property {number} truncate
|
||||
* @property {number} paddingLeft
|
||||
* @property {number} paddingRight
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} streamConfig
|
||||
* @property {columnConfig} columnDefault
|
||||
* @property {Object} border
|
||||
* @property {columnConfig[]}
|
||||
* @property {number} columnCount Number of columns in the table (required).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Makes a new configuration object out of the userConfig object
|
||||
* using default values for the missing configuration properties.
|
||||
*
|
||||
* @param {streamConfig} userConfig
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
exports.default = function () {
|
||||
let userConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
|
||||
(0, _validateConfig2.default)('streamConfig.json', userConfig);
|
||||
|
||||
const config = _lodash2.default.cloneDeep(userConfig);
|
||||
|
||||
if (!config.columnDefault || !config.columnDefault.width) {
|
||||
throw new Error('Must provide config.columnDefault.width when creating a stream.');
|
||||
}
|
||||
|
||||
if (!config.columnCount) {
|
||||
throw new Error('Must provide config.columnCount.');
|
||||
}
|
||||
|
||||
config.border = makeBorder(config.border);
|
||||
config.columns = makeColumns(config.columnCount, config.columns, config.columnDefault);
|
||||
|
||||
return config;
|
||||
};
|
57
node_modules/table/dist/mapDataUsingRowHeightIndex.js
generated
vendored
Normal file
57
node_modules/table/dist/mapDataUsingRowHeightIndex.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
var _wrapString = require('./wrapString');
|
||||
|
||||
var _wrapString2 = _interopRequireDefault(_wrapString);
|
||||
|
||||
var _wrapWord = require('./wrapWord');
|
||||
|
||||
var _wrapWord2 = _interopRequireDefault(_wrapWord);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* @param {Array} unmappedRows
|
||||
* @param {number[]} rowHeightIndex
|
||||
* @param {Object} config
|
||||
* @returns {Array}
|
||||
*/
|
||||
exports.default = (unmappedRows, rowHeightIndex, config) => {
|
||||
const tableWidth = unmappedRows[0].length;
|
||||
|
||||
const mappedRows = _lodash2.default.map(unmappedRows, (cells, index0) => {
|
||||
const rowHeight = _lodash2.default.times(rowHeightIndex[index0], () => {
|
||||
return _lodash2.default.fill(Array(tableWidth), '');
|
||||
});
|
||||
|
||||
// rowHeight
|
||||
// [{row index within rowSaw; index2}]
|
||||
// [{cell index within a virtual row; index1}]
|
||||
|
||||
_lodash2.default.forEach(cells, (value, index1) => {
|
||||
let chunkedValue;
|
||||
|
||||
if (config.columns[index1].wrapWord) {
|
||||
chunkedValue = (0, _wrapWord2.default)(value, config.columns[index1].width);
|
||||
} else {
|
||||
chunkedValue = (0, _wrapString2.default)(value, config.columns[index1].width);
|
||||
}
|
||||
|
||||
_lodash2.default.forEach(chunkedValue, (part, index2) => {
|
||||
rowHeight[index2][index1] = part;
|
||||
});
|
||||
});
|
||||
|
||||
return rowHeight;
|
||||
});
|
||||
|
||||
return _lodash2.default.flatten(mappedRows);
|
||||
};
|
26
node_modules/table/dist/padTableData.js
generated
vendored
Normal file
26
node_modules/table/dist/padTableData.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* @param {table~row[]} rows
|
||||
* @param {Object} config
|
||||
* @returns {table~row[]}
|
||||
*/
|
||||
exports.default = (rows, config) => {
|
||||
return _lodash2.default.map(rows, cells => {
|
||||
return _lodash2.default.map(cells, (value, index1) => {
|
||||
const column = config.columns[index1];
|
||||
|
||||
return _lodash2.default.repeat(' ', column.paddingLeft) + value + _lodash2.default.repeat(' ', column.paddingRight);
|
||||
});
|
||||
});
|
||||
};
|
114
node_modules/table/dist/schemas/config.json
generated
vendored
Normal file
114
node_modules/table/dist/schemas/config.json
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
{
|
||||
"id": "config.json",
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"border": {
|
||||
"$ref": "#/definitions/borders"
|
||||
},
|
||||
"columns": {
|
||||
"$ref": "#/definitions/columns"
|
||||
},
|
||||
"columnDefault": {
|
||||
"$ref": "#/definitions/column"
|
||||
},
|
||||
"drawHorizontalLine": {
|
||||
"typeof": "function"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"definitions": {
|
||||
"columns": {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^[0-9]+$": {
|
||||
"$ref": "#/definitions/column"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"column": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"alignment": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"right",
|
||||
"center"
|
||||
]
|
||||
},
|
||||
"width": {
|
||||
"type": "number"
|
||||
},
|
||||
"wrapWord": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"truncate": {
|
||||
"type": "number"
|
||||
},
|
||||
"paddingLeft": {
|
||||
"type": "number"
|
||||
},
|
||||
"paddingRight": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"borders": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"topBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"border": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
114
node_modules/table/dist/schemas/streamConfig.json
generated
vendored
Normal file
114
node_modules/table/dist/schemas/streamConfig.json
generated
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
{
|
||||
"id": "streamConfig.json",
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"border": {
|
||||
"$ref": "#/definitions/borders"
|
||||
},
|
||||
"columns": {
|
||||
"$ref": "#/definitions/columns"
|
||||
},
|
||||
"columnDefault": {
|
||||
"$ref": "#/definitions/column"
|
||||
},
|
||||
"columnCount": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"definitions": {
|
||||
"columns": {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^[0-9]+$": {
|
||||
"$ref": "#/definitions/column"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"column": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"alignment": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"left",
|
||||
"right",
|
||||
"center"
|
||||
]
|
||||
},
|
||||
"width": {
|
||||
"type": "number"
|
||||
},
|
||||
"wrapWord": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"truncate": {
|
||||
"type": "number"
|
||||
},
|
||||
"paddingLeft": {
|
||||
"type": "number"
|
||||
},
|
||||
"paddingRight": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"borders": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"topBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"border": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
23
node_modules/table/dist/stringifyTableData.js
generated
vendored
Normal file
23
node_modules/table/dist/stringifyTableData.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Casts all cell values to a string.
|
||||
*
|
||||
* @param {table~row[]} rows
|
||||
* @returns {table~row[]}
|
||||
*/
|
||||
exports.default = rows => {
|
||||
return _lodash2.default.map(rows, cells => {
|
||||
return _lodash2.default.map(cells, String);
|
||||
});
|
||||
};
|
133
node_modules/table/dist/table.js
generated
vendored
Normal file
133
node_modules/table/dist/table.js
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _drawTable = require('./drawTable');
|
||||
|
||||
var _drawTable2 = _interopRequireDefault(_drawTable);
|
||||
|
||||
var _calculateCellWidthIndex = require('./calculateCellWidthIndex');
|
||||
|
||||
var _calculateCellWidthIndex2 = _interopRequireDefault(_calculateCellWidthIndex);
|
||||
|
||||
var _makeConfig = require('./makeConfig');
|
||||
|
||||
var _makeConfig2 = _interopRequireDefault(_makeConfig);
|
||||
|
||||
var _calculateRowHeightIndex = require('./calculateRowHeightIndex');
|
||||
|
||||
var _calculateRowHeightIndex2 = _interopRequireDefault(_calculateRowHeightIndex);
|
||||
|
||||
var _mapDataUsingRowHeightIndex = require('./mapDataUsingRowHeightIndex');
|
||||
|
||||
var _mapDataUsingRowHeightIndex2 = _interopRequireDefault(_mapDataUsingRowHeightIndex);
|
||||
|
||||
var _alignTableData = require('./alignTableData');
|
||||
|
||||
var _alignTableData2 = _interopRequireDefault(_alignTableData);
|
||||
|
||||
var _padTableData = require('./padTableData');
|
||||
|
||||
var _padTableData2 = _interopRequireDefault(_padTableData);
|
||||
|
||||
var _validateTableData = require('./validateTableData');
|
||||
|
||||
var _validateTableData2 = _interopRequireDefault(_validateTableData);
|
||||
|
||||
var _stringifyTableData = require('./stringifyTableData');
|
||||
|
||||
var _stringifyTableData2 = _interopRequireDefault(_stringifyTableData);
|
||||
|
||||
var _truncateTableData = require('./truncateTableData');
|
||||
|
||||
var _truncateTableData2 = _interopRequireDefault(_truncateTableData);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* @typedef {string} table~cell
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {table~cell[]} table~row
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} table~columns
|
||||
* @property {string} alignment Cell content alignment (enum: left, center, right) (default: left).
|
||||
* @property {number} width Column width (default: auto).
|
||||
* @property {number} truncate Number of characters are which the content will be truncated (default: Infinity).
|
||||
* @property {number} paddingLeft Cell content padding width left (default: 1).
|
||||
* @property {number} paddingRight Cell content padding width right (default: 1).
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} table~border
|
||||
* @property {string} topBody
|
||||
* @property {string} topJoin
|
||||
* @property {string} topLeft
|
||||
* @property {string} topRight
|
||||
* @property {string} bottomBody
|
||||
* @property {string} bottomJoin
|
||||
* @property {string} bottomLeft
|
||||
* @property {string} bottomRight
|
||||
* @property {string} bodyLeft
|
||||
* @property {string} bodyRight
|
||||
* @property {string} bodyJoin
|
||||
* @property {string} joinBody
|
||||
* @property {string} joinLeft
|
||||
* @property {string} joinRight
|
||||
* @property {string} joinJoin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Used to tell whether to draw a horizontal line.
|
||||
* This callback is called for each non-content line of the table.
|
||||
* The default behavior is to always return true.
|
||||
*
|
||||
* @typedef {Function} drawHorizontalLine
|
||||
* @param {number} index
|
||||
* @param {number} size
|
||||
* @returns {boolean}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} table~config
|
||||
* @property {table~border} border
|
||||
* @property {table~columns[]} columns Column specific configuration.
|
||||
* @property {table~columns} columnDefault Default values for all columns. Column specific settings overwrite the default values.
|
||||
* @property {table~drawHorizontalLine} drawHorizontalLine
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generates a text table.
|
||||
*
|
||||
* @param {table~row[]} data
|
||||
* @param {table~config} userConfig
|
||||
* @returns {string}
|
||||
*/
|
||||
exports.default = function (data) {
|
||||
let userConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
|
||||
let rows;
|
||||
|
||||
(0, _validateTableData2.default)(data);
|
||||
|
||||
rows = (0, _stringifyTableData2.default)(data);
|
||||
|
||||
const config = (0, _makeConfig2.default)(rows, userConfig);
|
||||
|
||||
rows = (0, _truncateTableData2.default)(data, config);
|
||||
|
||||
const rowHeightIndex = (0, _calculateRowHeightIndex2.default)(rows, config);
|
||||
|
||||
rows = (0, _mapDataUsingRowHeightIndex2.default)(rows, rowHeightIndex, config);
|
||||
rows = (0, _alignTableData2.default)(rows, config);
|
||||
rows = (0, _padTableData2.default)(rows, config);
|
||||
|
||||
const cellWidthIndex = (0, _calculateCellWidthIndex2.default)(rows[0]);
|
||||
|
||||
return (0, _drawTable2.default)(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawHorizontalLine);
|
||||
};
|
27
node_modules/table/dist/truncateTableData.js
generated
vendored
Normal file
27
node_modules/table/dist/truncateTableData.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* @todo Make it work with ASCII content.
|
||||
* @param {table~row[]} rows
|
||||
* @param {Object} config
|
||||
* @returns {table~row[]}
|
||||
*/
|
||||
exports.default = (rows, config) => {
|
||||
return _lodash2.default.map(rows, cells => {
|
||||
return _lodash2.default.map(cells, (content, index) => {
|
||||
return _lodash2.default.truncate(content, {
|
||||
length: config.columns[index].truncate
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
756
node_modules/table/dist/validateConfig.js
generated
vendored
Normal file
756
node_modules/table/dist/validateConfig.js
generated
vendored
Normal file
@@ -0,0 +1,756 @@
|
||||
'use strict';
|
||||
var equal = require('ajv/lib/compile/equal');
|
||||
var validate = (function() {
|
||||
var pattern0 = new RegExp('^[0-9]+$');
|
||||
var refVal = [];
|
||||
var refVal1 = (function() {
|
||||
var pattern0 = new RegExp('^[0-9]+$');
|
||||
return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
|
||||
'use strict';
|
||||
var vErrors = null;
|
||||
var errors = 0;
|
||||
if (rootData === undefined) rootData = data;
|
||||
if ((data && typeof data === "object" && !Array.isArray(data))) {
|
||||
var errs__0 = errors;
|
||||
var valid1 = true;
|
||||
for (var key0 in data) {
|
||||
var isAdditional0 = !(false || validate.schema.properties[key0]);
|
||||
if (isAdditional0) {
|
||||
valid1 = false;
|
||||
var err = {
|
||||
keyword: 'additionalProperties',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/additionalProperties',
|
||||
params: {
|
||||
additionalProperty: '' + key0 + ''
|
||||
},
|
||||
message: 'should NOT have additional properties'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
if (data.topBody !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal2(data.topBody, (dataPath || '') + '.topBody', data, 'topBody', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal2.errors;
|
||||
else vErrors = vErrors.concat(refVal2.errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.topJoin !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.topJoin, (dataPath || '') + '.topJoin', data, 'topJoin', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.topLeft !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.topLeft, (dataPath || '') + '.topLeft', data, 'topLeft', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.topRight !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.topRight, (dataPath || '') + '.topRight', data, 'topRight', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.bottomBody !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.bottomBody, (dataPath || '') + '.bottomBody', data, 'bottomBody', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.bottomJoin !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.bottomJoin, (dataPath || '') + '.bottomJoin', data, 'bottomJoin', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.bottomLeft !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.bottomLeft, (dataPath || '') + '.bottomLeft', data, 'bottomLeft', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.bottomRight !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.bottomRight, (dataPath || '') + '.bottomRight', data, 'bottomRight', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.bodyLeft !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.bodyLeft, (dataPath || '') + '.bodyLeft', data, 'bodyLeft', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.bodyRight !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.bodyRight, (dataPath || '') + '.bodyRight', data, 'bodyRight', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.bodyJoin !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.bodyJoin, (dataPath || '') + '.bodyJoin', data, 'bodyJoin', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.joinBody !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.joinBody, (dataPath || '') + '.joinBody', data, 'joinBody', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.joinLeft !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.joinLeft, (dataPath || '') + '.joinLeft', data, 'joinLeft', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.joinRight !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.joinRight, (dataPath || '') + '.joinRight', data, 'joinRight', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.joinJoin !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.joinJoin, (dataPath || '') + '.joinJoin', data, 'joinJoin', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
} else {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/type',
|
||||
params: {
|
||||
type: 'object'
|
||||
},
|
||||
message: 'should be object'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
validate.errors = vErrors;
|
||||
return errors === 0;
|
||||
};
|
||||
})();
|
||||
refVal1.schema = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"topBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
};
|
||||
refVal1.errors = null;
|
||||
refVal[1] = refVal1;
|
||||
var refVal2 = (function() {
|
||||
var pattern0 = new RegExp('^[0-9]+$');
|
||||
return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
|
||||
'use strict';
|
||||
var vErrors = null;
|
||||
var errors = 0;
|
||||
if (rootData === undefined) rootData = data;
|
||||
if (typeof data !== "string") {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/type',
|
||||
params: {
|
||||
type: 'string'
|
||||
},
|
||||
message: 'should be string'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
validate.errors = vErrors;
|
||||
return errors === 0;
|
||||
};
|
||||
})();
|
||||
refVal2.schema = {
|
||||
"type": "string"
|
||||
};
|
||||
refVal2.errors = null;
|
||||
refVal[2] = refVal2;
|
||||
var refVal3 = (function() {
|
||||
var pattern0 = new RegExp('^[0-9]+$');
|
||||
return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
|
||||
'use strict';
|
||||
var vErrors = null;
|
||||
var errors = 0;
|
||||
if (rootData === undefined) rootData = data;
|
||||
if ((data && typeof data === "object" && !Array.isArray(data))) {
|
||||
var errs__0 = errors;
|
||||
var valid1 = true;
|
||||
for (var key0 in data) {
|
||||
var isAdditional0 = !(false || pattern0.test(key0));
|
||||
if (isAdditional0) {
|
||||
valid1 = false;
|
||||
var err = {
|
||||
keyword: 'additionalProperties',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/additionalProperties',
|
||||
params: {
|
||||
additionalProperty: '' + key0 + ''
|
||||
},
|
||||
message: 'should NOT have additional properties'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
for (var key0 in data) {
|
||||
if (pattern0.test(key0)) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal4(data[key0], (dataPath || '') + '[\'' + key0 + '\']', data, key0, rootData)) {
|
||||
if (vErrors === null) vErrors = refVal4.errors;
|
||||
else vErrors = vErrors.concat(refVal4.errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/type',
|
||||
params: {
|
||||
type: 'object'
|
||||
},
|
||||
message: 'should be object'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
validate.errors = vErrors;
|
||||
return errors === 0;
|
||||
};
|
||||
})();
|
||||
refVal3.schema = {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^[0-9]+$": {
|
||||
"$ref": "#/definitions/column"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
};
|
||||
refVal3.errors = null;
|
||||
refVal[3] = refVal3;
|
||||
var refVal4 = (function() {
|
||||
var pattern0 = new RegExp('^[0-9]+$');
|
||||
return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
|
||||
'use strict';
|
||||
var vErrors = null;
|
||||
var errors = 0;
|
||||
if (rootData === undefined) rootData = data;
|
||||
if ((data && typeof data === "object" && !Array.isArray(data))) {
|
||||
var errs__0 = errors;
|
||||
var valid1 = true;
|
||||
for (var key0 in data) {
|
||||
var isAdditional0 = !(false || validate.schema.properties[key0]);
|
||||
if (isAdditional0) {
|
||||
valid1 = false;
|
||||
var err = {
|
||||
keyword: 'additionalProperties',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/additionalProperties',
|
||||
params: {
|
||||
additionalProperty: '' + key0 + ''
|
||||
},
|
||||
message: 'should NOT have additional properties'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
var data1 = data.alignment;
|
||||
if (data1 !== undefined) {
|
||||
var errs_1 = errors;
|
||||
var schema1 = validate.schema.properties.alignment.enum;
|
||||
var valid1;
|
||||
valid1 = false;
|
||||
for (var i1 = 0; i1 < schema1.length; i1++)
|
||||
if (equal(data1, schema1[i1])) {
|
||||
valid1 = true;
|
||||
break;
|
||||
}
|
||||
if (!valid1) {
|
||||
var err = {
|
||||
keyword: 'enum',
|
||||
dataPath: (dataPath || '') + '.alignment',
|
||||
schemaPath: '#/properties/alignment/enum',
|
||||
params: {
|
||||
allowedValues: schema1
|
||||
},
|
||||
message: 'should be equal to one of the allowed values'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
if (typeof data1 !== "string") {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + '.alignment',
|
||||
schemaPath: '#/properties/alignment/type',
|
||||
params: {
|
||||
type: 'string'
|
||||
},
|
||||
message: 'should be string'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.width !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (typeof data.width !== "number") {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + '.width',
|
||||
schemaPath: '#/properties/width/type',
|
||||
params: {
|
||||
type: 'number'
|
||||
},
|
||||
message: 'should be number'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.wrapWord !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (typeof data.wrapWord !== "boolean") {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + '.wrapWord',
|
||||
schemaPath: '#/properties/wrapWord/type',
|
||||
params: {
|
||||
type: 'boolean'
|
||||
},
|
||||
message: 'should be boolean'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.truncate !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (typeof data.truncate !== "number") {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + '.truncate',
|
||||
schemaPath: '#/properties/truncate/type',
|
||||
params: {
|
||||
type: 'number'
|
||||
},
|
||||
message: 'should be number'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.paddingLeft !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (typeof data.paddingLeft !== "number") {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + '.paddingLeft',
|
||||
schemaPath: '#/properties/paddingLeft/type',
|
||||
params: {
|
||||
type: 'number'
|
||||
},
|
||||
message: 'should be number'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.paddingRight !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (typeof data.paddingRight !== "number") {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + '.paddingRight',
|
||||
schemaPath: '#/properties/paddingRight/type',
|
||||
params: {
|
||||
type: 'number'
|
||||
},
|
||||
message: 'should be number'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
} else {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/type',
|
||||
params: {
|
||||
type: 'object'
|
||||
},
|
||||
message: 'should be object'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
validate.errors = vErrors;
|
||||
return errors === 0;
|
||||
};
|
||||
})();
|
||||
refVal4.schema = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"alignment": {
|
||||
"type": "string",
|
||||
"enum": ["left", "right", "center"]
|
||||
},
|
||||
"width": {
|
||||
"type": "number"
|
||||
},
|
||||
"wrapWord": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"truncate": {
|
||||
"type": "number"
|
||||
},
|
||||
"paddingLeft": {
|
||||
"type": "number"
|
||||
},
|
||||
"paddingRight": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
};
|
||||
refVal4.errors = null;
|
||||
refVal[4] = refVal4;
|
||||
return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
|
||||
'use strict';
|
||||
var vErrors = null;
|
||||
var errors = 0;
|
||||
if (rootData === undefined) rootData = data;
|
||||
if ((data && typeof data === "object" && !Array.isArray(data))) {
|
||||
var errs__0 = errors;
|
||||
var valid1 = true;
|
||||
for (var key0 in data) {
|
||||
var isAdditional0 = !(false || key0 == 'border' || key0 == 'columns' || key0 == 'columnDefault' || key0 == 'drawHorizontalLine');
|
||||
if (isAdditional0) {
|
||||
valid1 = false;
|
||||
var err = {
|
||||
keyword: 'additionalProperties',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/additionalProperties',
|
||||
params: {
|
||||
additionalProperty: '' + key0 + ''
|
||||
},
|
||||
message: 'should NOT have additional properties'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
if (data.border !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal1(data.border, (dataPath || '') + '.border', data, 'border', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal1.errors;
|
||||
else vErrors = vErrors.concat(refVal1.errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.columns !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal3(data.columns, (dataPath || '') + '.columns', data, 'columns', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal3.errors;
|
||||
else vErrors = vErrors.concat(refVal3.errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.columnDefault !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[4](data.columnDefault, (dataPath || '') + '.columnDefault', data, 'columnDefault', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[4].errors;
|
||||
else vErrors = vErrors.concat(refVal[4].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.drawHorizontalLine !== undefined) {
|
||||
var errs_1 = errors;
|
||||
var errs__1 = errors;
|
||||
var valid1;
|
||||
if (!(typeof data.drawHorizontalLine == "function")) {
|
||||
if (errs__1 == errors) {
|
||||
var err = {
|
||||
keyword: 'typeof',
|
||||
dataPath: (dataPath || '') + '.drawHorizontalLine',
|
||||
schemaPath: '#/properties/drawHorizontalLine/typeof',
|
||||
params: {
|
||||
keyword: 'typeof'
|
||||
},
|
||||
message: 'should pass "typeof" keyword validation'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
} else {
|
||||
for (var i1 = errs__1; i1 < errors; i1++) {
|
||||
var ruleErr1 = vErrors[i1];
|
||||
if (ruleErr1.dataPath === undefined) {
|
||||
ruleErr1.dataPath = (dataPath || '') + '.drawHorizontalLine';
|
||||
}
|
||||
if (ruleErr1.schemaPath === undefined) {
|
||||
ruleErr1.schemaPath = "#/properties/drawHorizontalLine/typeof";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
} else {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/type',
|
||||
params: {
|
||||
type: 'object'
|
||||
},
|
||||
message: 'should be object'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
validate.errors = vErrors;
|
||||
return errors === 0;
|
||||
};
|
||||
})();
|
||||
validate.schema = {
|
||||
"id": "config.json",
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"border": {
|
||||
"$ref": "#/definitions/borders"
|
||||
},
|
||||
"columns": {
|
||||
"$ref": "#/definitions/columns"
|
||||
},
|
||||
"columnDefault": {
|
||||
"$ref": "#/definitions/column"
|
||||
},
|
||||
"drawHorizontalLine": {
|
||||
"typeof": "function"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"definitions": {
|
||||
"columns": {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^[0-9]+$": {
|
||||
"$ref": "#/definitions/column"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"column": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"alignment": {
|
||||
"type": "string",
|
||||
"enum": ["left", "right", "center"]
|
||||
},
|
||||
"width": {
|
||||
"type": "number"
|
||||
},
|
||||
"wrapWord": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"truncate": {
|
||||
"type": "number"
|
||||
},
|
||||
"paddingLeft": {
|
||||
"type": "number"
|
||||
},
|
||||
"paddingRight": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"borders": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"topBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"border": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
};
|
||||
validate.errors = null;
|
||||
module.exports = validate;
|
742
node_modules/table/dist/validateStreamConfig.js
generated
vendored
Normal file
742
node_modules/table/dist/validateStreamConfig.js
generated
vendored
Normal file
@@ -0,0 +1,742 @@
|
||||
'use strict';
|
||||
var equal = require('ajv/lib/compile/equal');
|
||||
var validate = (function() {
|
||||
var pattern0 = new RegExp('^[0-9]+$');
|
||||
var refVal = [];
|
||||
var refVal1 = (function() {
|
||||
var pattern0 = new RegExp('^[0-9]+$');
|
||||
return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
|
||||
'use strict';
|
||||
var vErrors = null;
|
||||
var errors = 0;
|
||||
if (rootData === undefined) rootData = data;
|
||||
if ((data && typeof data === "object" && !Array.isArray(data))) {
|
||||
var errs__0 = errors;
|
||||
var valid1 = true;
|
||||
for (var key0 in data) {
|
||||
var isAdditional0 = !(false || validate.schema.properties[key0]);
|
||||
if (isAdditional0) {
|
||||
valid1 = false;
|
||||
var err = {
|
||||
keyword: 'additionalProperties',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/additionalProperties',
|
||||
params: {
|
||||
additionalProperty: '' + key0 + ''
|
||||
},
|
||||
message: 'should NOT have additional properties'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
if (data.topBody !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal2(data.topBody, (dataPath || '') + '.topBody', data, 'topBody', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal2.errors;
|
||||
else vErrors = vErrors.concat(refVal2.errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.topJoin !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.topJoin, (dataPath || '') + '.topJoin', data, 'topJoin', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.topLeft !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.topLeft, (dataPath || '') + '.topLeft', data, 'topLeft', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.topRight !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.topRight, (dataPath || '') + '.topRight', data, 'topRight', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.bottomBody !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.bottomBody, (dataPath || '') + '.bottomBody', data, 'bottomBody', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.bottomJoin !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.bottomJoin, (dataPath || '') + '.bottomJoin', data, 'bottomJoin', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.bottomLeft !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.bottomLeft, (dataPath || '') + '.bottomLeft', data, 'bottomLeft', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.bottomRight !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.bottomRight, (dataPath || '') + '.bottomRight', data, 'bottomRight', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.bodyLeft !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.bodyLeft, (dataPath || '') + '.bodyLeft', data, 'bodyLeft', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.bodyRight !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.bodyRight, (dataPath || '') + '.bodyRight', data, 'bodyRight', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.bodyJoin !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.bodyJoin, (dataPath || '') + '.bodyJoin', data, 'bodyJoin', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.joinBody !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.joinBody, (dataPath || '') + '.joinBody', data, 'joinBody', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.joinLeft !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.joinLeft, (dataPath || '') + '.joinLeft', data, 'joinLeft', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.joinRight !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.joinRight, (dataPath || '') + '.joinRight', data, 'joinRight', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.joinJoin !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[2](data.joinJoin, (dataPath || '') + '.joinJoin', data, 'joinJoin', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[2].errors;
|
||||
else vErrors = vErrors.concat(refVal[2].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
} else {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/type',
|
||||
params: {
|
||||
type: 'object'
|
||||
},
|
||||
message: 'should be object'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
validate.errors = vErrors;
|
||||
return errors === 0;
|
||||
};
|
||||
})();
|
||||
refVal1.schema = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"topBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
};
|
||||
refVal1.errors = null;
|
||||
refVal[1] = refVal1;
|
||||
var refVal2 = (function() {
|
||||
var pattern0 = new RegExp('^[0-9]+$');
|
||||
return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
|
||||
'use strict';
|
||||
var vErrors = null;
|
||||
var errors = 0;
|
||||
if (rootData === undefined) rootData = data;
|
||||
if (typeof data !== "string") {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/type',
|
||||
params: {
|
||||
type: 'string'
|
||||
},
|
||||
message: 'should be string'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
validate.errors = vErrors;
|
||||
return errors === 0;
|
||||
};
|
||||
})();
|
||||
refVal2.schema = {
|
||||
"type": "string"
|
||||
};
|
||||
refVal2.errors = null;
|
||||
refVal[2] = refVal2;
|
||||
var refVal3 = (function() {
|
||||
var pattern0 = new RegExp('^[0-9]+$');
|
||||
return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
|
||||
'use strict';
|
||||
var vErrors = null;
|
||||
var errors = 0;
|
||||
if (rootData === undefined) rootData = data;
|
||||
if ((data && typeof data === "object" && !Array.isArray(data))) {
|
||||
var errs__0 = errors;
|
||||
var valid1 = true;
|
||||
for (var key0 in data) {
|
||||
var isAdditional0 = !(false || pattern0.test(key0));
|
||||
if (isAdditional0) {
|
||||
valid1 = false;
|
||||
var err = {
|
||||
keyword: 'additionalProperties',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/additionalProperties',
|
||||
params: {
|
||||
additionalProperty: '' + key0 + ''
|
||||
},
|
||||
message: 'should NOT have additional properties'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
for (var key0 in data) {
|
||||
if (pattern0.test(key0)) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal4(data[key0], (dataPath || '') + '[\'' + key0 + '\']', data, key0, rootData)) {
|
||||
if (vErrors === null) vErrors = refVal4.errors;
|
||||
else vErrors = vErrors.concat(refVal4.errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/type',
|
||||
params: {
|
||||
type: 'object'
|
||||
},
|
||||
message: 'should be object'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
validate.errors = vErrors;
|
||||
return errors === 0;
|
||||
};
|
||||
})();
|
||||
refVal3.schema = {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^[0-9]+$": {
|
||||
"$ref": "#/definitions/column"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
};
|
||||
refVal3.errors = null;
|
||||
refVal[3] = refVal3;
|
||||
var refVal4 = (function() {
|
||||
var pattern0 = new RegExp('^[0-9]+$');
|
||||
return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
|
||||
'use strict';
|
||||
var vErrors = null;
|
||||
var errors = 0;
|
||||
if (rootData === undefined) rootData = data;
|
||||
if ((data && typeof data === "object" && !Array.isArray(data))) {
|
||||
var errs__0 = errors;
|
||||
var valid1 = true;
|
||||
for (var key0 in data) {
|
||||
var isAdditional0 = !(false || validate.schema.properties[key0]);
|
||||
if (isAdditional0) {
|
||||
valid1 = false;
|
||||
var err = {
|
||||
keyword: 'additionalProperties',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/additionalProperties',
|
||||
params: {
|
||||
additionalProperty: '' + key0 + ''
|
||||
},
|
||||
message: 'should NOT have additional properties'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
var data1 = data.alignment;
|
||||
if (data1 !== undefined) {
|
||||
var errs_1 = errors;
|
||||
var schema1 = validate.schema.properties.alignment.enum;
|
||||
var valid1;
|
||||
valid1 = false;
|
||||
for (var i1 = 0; i1 < schema1.length; i1++)
|
||||
if (equal(data1, schema1[i1])) {
|
||||
valid1 = true;
|
||||
break;
|
||||
}
|
||||
if (!valid1) {
|
||||
var err = {
|
||||
keyword: 'enum',
|
||||
dataPath: (dataPath || '') + '.alignment',
|
||||
schemaPath: '#/properties/alignment/enum',
|
||||
params: {
|
||||
allowedValues: schema1
|
||||
},
|
||||
message: 'should be equal to one of the allowed values'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
if (typeof data1 !== "string") {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + '.alignment',
|
||||
schemaPath: '#/properties/alignment/type',
|
||||
params: {
|
||||
type: 'string'
|
||||
},
|
||||
message: 'should be string'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.width !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (typeof data.width !== "number") {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + '.width',
|
||||
schemaPath: '#/properties/width/type',
|
||||
params: {
|
||||
type: 'number'
|
||||
},
|
||||
message: 'should be number'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.wrapWord !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (typeof data.wrapWord !== "boolean") {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + '.wrapWord',
|
||||
schemaPath: '#/properties/wrapWord/type',
|
||||
params: {
|
||||
type: 'boolean'
|
||||
},
|
||||
message: 'should be boolean'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.truncate !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (typeof data.truncate !== "number") {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + '.truncate',
|
||||
schemaPath: '#/properties/truncate/type',
|
||||
params: {
|
||||
type: 'number'
|
||||
},
|
||||
message: 'should be number'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.paddingLeft !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (typeof data.paddingLeft !== "number") {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + '.paddingLeft',
|
||||
schemaPath: '#/properties/paddingLeft/type',
|
||||
params: {
|
||||
type: 'number'
|
||||
},
|
||||
message: 'should be number'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.paddingRight !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (typeof data.paddingRight !== "number") {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + '.paddingRight',
|
||||
schemaPath: '#/properties/paddingRight/type',
|
||||
params: {
|
||||
type: 'number'
|
||||
},
|
||||
message: 'should be number'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
} else {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/type',
|
||||
params: {
|
||||
type: 'object'
|
||||
},
|
||||
message: 'should be object'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
validate.errors = vErrors;
|
||||
return errors === 0;
|
||||
};
|
||||
})();
|
||||
refVal4.schema = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"alignment": {
|
||||
"type": "string",
|
||||
"enum": ["left", "right", "center"]
|
||||
},
|
||||
"width": {
|
||||
"type": "number"
|
||||
},
|
||||
"wrapWord": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"truncate": {
|
||||
"type": "number"
|
||||
},
|
||||
"paddingLeft": {
|
||||
"type": "number"
|
||||
},
|
||||
"paddingRight": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
};
|
||||
refVal4.errors = null;
|
||||
refVal[4] = refVal4;
|
||||
return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
|
||||
'use strict';
|
||||
var vErrors = null;
|
||||
var errors = 0;
|
||||
if (rootData === undefined) rootData = data;
|
||||
if ((data && typeof data === "object" && !Array.isArray(data))) {
|
||||
var errs__0 = errors;
|
||||
var valid1 = true;
|
||||
for (var key0 in data) {
|
||||
var isAdditional0 = !(false || key0 == 'border' || key0 == 'columns' || key0 == 'columnDefault' || key0 == 'columnCount');
|
||||
if (isAdditional0) {
|
||||
valid1 = false;
|
||||
var err = {
|
||||
keyword: 'additionalProperties',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/additionalProperties',
|
||||
params: {
|
||||
additionalProperty: '' + key0 + ''
|
||||
},
|
||||
message: 'should NOT have additional properties'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
if (data.border !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal1(data.border, (dataPath || '') + '.border', data, 'border', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal1.errors;
|
||||
else vErrors = vErrors.concat(refVal1.errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.columns !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal3(data.columns, (dataPath || '') + '.columns', data, 'columns', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal3.errors;
|
||||
else vErrors = vErrors.concat(refVal3.errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.columnDefault !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (!refVal[4](data.columnDefault, (dataPath || '') + '.columnDefault', data, 'columnDefault', rootData)) {
|
||||
if (vErrors === null) vErrors = refVal[4].errors;
|
||||
else vErrors = vErrors.concat(refVal[4].errors);
|
||||
errors = vErrors.length;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
if (data.columnCount !== undefined) {
|
||||
var errs_1 = errors;
|
||||
if (typeof data.columnCount !== "number") {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + '.columnCount',
|
||||
schemaPath: '#/properties/columnCount/type',
|
||||
params: {
|
||||
type: 'number'
|
||||
},
|
||||
message: 'should be number'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
var valid1 = errors === errs_1;
|
||||
}
|
||||
} else {
|
||||
var err = {
|
||||
keyword: 'type',
|
||||
dataPath: (dataPath || '') + "",
|
||||
schemaPath: '#/type',
|
||||
params: {
|
||||
type: 'object'
|
||||
},
|
||||
message: 'should be object'
|
||||
};
|
||||
if (vErrors === null) vErrors = [err];
|
||||
else vErrors.push(err);
|
||||
errors++;
|
||||
}
|
||||
validate.errors = vErrors;
|
||||
return errors === 0;
|
||||
};
|
||||
})();
|
||||
validate.schema = {
|
||||
"id": "streamConfig.json",
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"border": {
|
||||
"$ref": "#/definitions/borders"
|
||||
},
|
||||
"columns": {
|
||||
"$ref": "#/definitions/columns"
|
||||
},
|
||||
"columnDefault": {
|
||||
"$ref": "#/definitions/column"
|
||||
},
|
||||
"columnCount": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"definitions": {
|
||||
"columns": {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^[0-9]+$": {
|
||||
"$ref": "#/definitions/column"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"column": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"alignment": {
|
||||
"type": "string",
|
||||
"enum": ["left", "right", "center"]
|
||||
},
|
||||
"width": {
|
||||
"type": "number"
|
||||
},
|
||||
"wrapWord": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"truncate": {
|
||||
"type": "number"
|
||||
},
|
||||
"paddingLeft": {
|
||||
"type": "number"
|
||||
},
|
||||
"paddingRight": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"borders": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"topBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"topRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bottomRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"bodyJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinBody": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinLeft": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinRight": {
|
||||
"$ref": "#/definitions/border"
|
||||
},
|
||||
"joinJoin": {
|
||||
"$ref": "#/definitions/border"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"border": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
};
|
||||
validate.errors = null;
|
||||
module.exports = validate;
|
57
node_modules/table/dist/validateTableData.js
generated
vendored
Normal file
57
node_modules/table/dist/validateTableData.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* @typedef {string} cell
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {cell[]} validateData~column
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {column[]} rows
|
||||
* @returns {undefined}
|
||||
*/
|
||||
exports.default = rows => {
|
||||
if (!_lodash2.default.isArray(rows)) {
|
||||
throw new Error('Table data must be an array.');
|
||||
}
|
||||
|
||||
if (rows.length === 0) {
|
||||
throw new Error('Table must define at least one row.');
|
||||
}
|
||||
|
||||
if (rows[0].length === 0) {
|
||||
throw new Error('Table must define at least one column.');
|
||||
}
|
||||
|
||||
const columnNumber = rows[0].length;
|
||||
|
||||
_lodash2.default.forEach(rows, cells => {
|
||||
if (!_lodash2.default.isArray(cells)) {
|
||||
throw new Error('Table row data must be an array.');
|
||||
}
|
||||
|
||||
if (cells.length !== columnNumber) {
|
||||
throw new Error('Table must have a consistent number of cells.');
|
||||
}
|
||||
|
||||
// @todo Make an exception for newline characters.
|
||||
// @see https://github.com/gajus/table/issues/9
|
||||
_lodash2.default.forEach(cells, cell => {
|
||||
if (/[\x01-\x1A]/.test(cell)) {
|
||||
throw new Error('Table data must not contain control characters.');
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
46
node_modules/table/dist/wrapString.js
generated
vendored
Normal file
46
node_modules/table/dist/wrapString.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
var _sliceAnsi = require('slice-ansi');
|
||||
|
||||
var _sliceAnsi2 = _interopRequireDefault(_sliceAnsi);
|
||||
|
||||
var _stringWidth = require('string-width');
|
||||
|
||||
var _stringWidth2 = _interopRequireDefault(_stringWidth);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Creates an array of strings split into groups the length of size.
|
||||
* This function works with strings that contain ASCII characters.
|
||||
*
|
||||
* wrapText is different from would-be "chunk" implementation
|
||||
* in that whitespace characters that occur on a chunk size limit are trimmed.
|
||||
*
|
||||
* @param {string} subject
|
||||
* @param {number} size
|
||||
* @returns {Array}
|
||||
*/
|
||||
exports.default = (subject, size) => {
|
||||
let subjectSlice;
|
||||
|
||||
subjectSlice = subject;
|
||||
|
||||
const chunks = [];
|
||||
|
||||
do {
|
||||
chunks.push((0, _sliceAnsi2.default)(subjectSlice, 0, size));
|
||||
|
||||
subjectSlice = _lodash2.default.trim((0, _sliceAnsi2.default)(subjectSlice, size));
|
||||
} while ((0, _stringWidth2.default)(subjectSlice));
|
||||
|
||||
return chunks;
|
||||
};
|
56
node_modules/table/dist/wrapWord.js
generated
vendored
Normal file
56
node_modules/table/dist/wrapWord.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
var _sliceAnsi = require('slice-ansi');
|
||||
|
||||
var _sliceAnsi2 = _interopRequireDefault(_sliceAnsi);
|
||||
|
||||
var _stringWidth = require('string-width');
|
||||
|
||||
var _stringWidth2 = _interopRequireDefault(_stringWidth);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {number} size
|
||||
* @returns {Array}
|
||||
*/
|
||||
exports.default = (input, size) => {
|
||||
let subject;
|
||||
|
||||
subject = input;
|
||||
|
||||
const chunks = [];
|
||||
|
||||
// https://regex101.com/r/gY5kZ1/1
|
||||
const re = new RegExp('(^.{1,' + size + '}(\\s+|$))|(^.{1,' + (size - 1) + '}(\\\\|/|_|\\.|,|;|-))');
|
||||
|
||||
do {
|
||||
let chunk;
|
||||
|
||||
chunk = subject.match(re);
|
||||
|
||||
if (chunk) {
|
||||
chunk = chunk[0];
|
||||
|
||||
subject = (0, _sliceAnsi2.default)(subject, (0, _stringWidth2.default)(chunk));
|
||||
|
||||
chunk = _lodash2.default.trim(chunk);
|
||||
} else {
|
||||
chunk = (0, _sliceAnsi2.default)(subject, 0, size);
|
||||
subject = (0, _sliceAnsi2.default)(subject, size);
|
||||
}
|
||||
|
||||
chunks.push(chunk);
|
||||
} while ((0, _stringWidth2.default)(subject));
|
||||
|
||||
return chunks;
|
||||
};
|
124
node_modules/table/package.json
generated
vendored
Normal file
124
node_modules/table/package.json
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"table@^4.0.1",
|
||||
"/Users/pmarsceill/_projects/just-the-docs/node_modules/stylelint"
|
||||
]
|
||||
],
|
||||
"_from": "table@>=4.0.1 <5.0.0",
|
||||
"_id": "table@4.0.1",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/table",
|
||||
"_nodeVersion": "7.1.0",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-18-east.internal.npmjs.com",
|
||||
"tmp": "tmp/table-4.0.1.tgz_1479830119997_0.18416268657892942"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "gajus@gajus.com",
|
||||
"name": "gajus"
|
||||
},
|
||||
"_npmVersion": "4.0.2",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "table",
|
||||
"raw": "table@^4.0.1",
|
||||
"rawSpec": "^4.0.1",
|
||||
"scope": null,
|
||||
"spec": ">=4.0.1 <5.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/stylelint"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/table/-/table-4.0.1.tgz",
|
||||
"_shasum": "a8116c133fac2c61f4a420ab6cdf5c4d61f0e435",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "table@^4.0.1",
|
||||
"_where": "/Users/pmarsceill/_projects/just-the-docs/node_modules/stylelint",
|
||||
"author": {
|
||||
"email": "gajus@gajus.com",
|
||||
"name": "Gajus Kuizinas",
|
||||
"url": "http://gajus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/gajus/table/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"ajv": "^4.7.0",
|
||||
"ajv-keywords": "^1.0.0",
|
||||
"chalk": "^1.1.1",
|
||||
"lodash": "^4.0.0",
|
||||
"slice-ansi": "0.0.4",
|
||||
"string-width": "^2.0.0"
|
||||
},
|
||||
"description": "Formats data into a string table.",
|
||||
"devDependencies": {
|
||||
"ajv-cli": "^1.1.0",
|
||||
"babel": "^6.5.2",
|
||||
"babel-cli": "^6.14.0",
|
||||
"babel-core": "^6.14.0",
|
||||
"babel-plugin-istanbul": "^2.0.3",
|
||||
"babel-preset-es2015-node4": "^2.1.0",
|
||||
"babel-register": "^6.14.0",
|
||||
"chai": "^3.4.1",
|
||||
"eslint": "^3.5.0",
|
||||
"eslint-config-canonical": "^1.8.6",
|
||||
"gitdown": "^2.4.0",
|
||||
"husky": "^0.11.7",
|
||||
"mocha": "^3.0.2",
|
||||
"nyc": "^8.3.1",
|
||||
"sinon": "^1.17.2"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "a8116c133fac2c61f4a420ab6cdf5c4d61f0e435",
|
||||
"tarball": "https://registry.npmjs.org/table/-/table-4.0.1.tgz"
|
||||
},
|
||||
"gitHead": "e55ef35ac3afbe42f789f666bc98cf05a97ae941",
|
||||
"homepage": "https://github.com/gajus/table#readme",
|
||||
"keywords": [
|
||||
"align",
|
||||
"ansi",
|
||||
"ascii",
|
||||
"table",
|
||||
"text"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "./dist/index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "gajus",
|
||||
"email": "gk@anuary.com"
|
||||
}
|
||||
],
|
||||
"name": "table",
|
||||
"nyc": {
|
||||
"include": [
|
||||
"src/*.js"
|
||||
],
|
||||
"instrument": false,
|
||||
"lines": 70,
|
||||
"require": [
|
||||
"babel-register"
|
||||
],
|
||||
"sourceMap": false
|
||||
},
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/gajus/table.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rm -fr ./dist && NODE_ENV=production babel --copy-files ./src --out-dir ./dist && npm run make-validators",
|
||||
"lint": "npm run build && eslint ./src ./tests",
|
||||
"make-readme": "gitdown ./.README/README.md --output-file ./README.md",
|
||||
"make-validators": "ajv compile --all-errors --inline-refs=false -s src/schemas/config -c ajv-keywords/keywords/typeof -o dist/validateConfig.js && ajv compile --all-errors --inline-refs=false -s src/schemas/streamConfig -c ajv-keywords/keywords/typeof -o dist/validateStreamConfig.js",
|
||||
"precommit": "npm run lint && npm run test",
|
||||
"prepublish": "NODE_ENV=production npm run build",
|
||||
"test": "npm run build && nyc --check-coverage mocha"
|
||||
},
|
||||
"version": "4.0.1"
|
||||
}
|
27
node_modules/table/test/README/usage/basic.js
generated
vendored
Normal file
27
node_modules/table/test/README/usage/basic.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import {
|
||||
table
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('basic', () => {
|
||||
const data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
|
||||
const output = table(data);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
╔════╤════╤════╗
|
||||
║ 0A │ 0B │ 0C ║
|
||||
╟────┼────┼────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
╟────┼────┼────╢
|
||||
║ 2A │ 2B │ 2C ║
|
||||
╚════╧════╧════╝
|
||||
`);
|
||||
});
|
||||
});
|
47
node_modules/table/test/README/usage/cell_content_alignment.js
generated
vendored
Normal file
47
node_modules/table/test/README/usage/cell_content_alignment.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
table
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('cell_content_alignment', () => {
|
||||
const data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
alignment: 'left',
|
||||
width: 10
|
||||
},
|
||||
1: {
|
||||
alignment: 'center',
|
||||
width: 10
|
||||
},
|
||||
2: {
|
||||
alignment: 'right',
|
||||
width: 10
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const output = table(data, config);
|
||||
|
||||
// console.log(output);
|
||||
|
||||
/* eslint-disable no-restricted-syntax */
|
||||
expectTable(output, `
|
||||
╔════════════╤════════════╤════════════╗
|
||||
║ 0A │ 0B │ 0C ║
|
||||
╟────────────┼────────────┼────────────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
╟────────────┼────────────┼────────────╢
|
||||
║ 2A │ 2B │ 2C ║
|
||||
╚════════════╧════════════╧════════════╝
|
||||
`);
|
||||
/* eslint-enable no-restricted-syntax */
|
||||
});
|
||||
});
|
35
node_modules/table/test/README/usage/column_width.js
generated
vendored
Normal file
35
node_modules/table/test/README/usage/column_width.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
table
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('column_width', () => {
|
||||
const data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
1: {
|
||||
width: 10
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const output = table(data, config);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
╔════╤════════════╤════╗
|
||||
║ 0A │ 0B │ 0C ║
|
||||
╟────┼────────────┼────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
╟────┼────────────┼────╢
|
||||
║ 2A │ 2B │ 2C ║
|
||||
╚════╧════════════╧════╝
|
||||
`);
|
||||
});
|
||||
});
|
52
node_modules/table/test/README/usage/custom_border.js
generated
vendored
Normal file
52
node_modules/table/test/README/usage/custom_border.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import {
|
||||
table
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('usage/custom_border', () => {
|
||||
const data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
|
||||
/* eslint-disable sort-keys */
|
||||
const config = {
|
||||
border: {
|
||||
topBody: '─',
|
||||
topJoin: '┬',
|
||||
topLeft: '┌',
|
||||
topRight: '┐',
|
||||
|
||||
bottomBody: '─',
|
||||
bottomJoin: '┴',
|
||||
bottomLeft: '└',
|
||||
bottomRight: '┘',
|
||||
|
||||
bodyLeft: '│',
|
||||
bodyRight: '│',
|
||||
bodyJoin: '│',
|
||||
|
||||
joinBody: '─',
|
||||
joinLeft: '├',
|
||||
joinRight: '┤',
|
||||
joinJoin: '┼'
|
||||
}
|
||||
};
|
||||
/* eslint-enable */
|
||||
|
||||
const output = table(data, config);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
┌────┬────┬────┐
|
||||
│ 0A │ 0B │ 0C │
|
||||
├────┼────┼────┤
|
||||
│ 1A │ 1B │ 1C │
|
||||
├────┼────┼────┤
|
||||
│ 2A │ 2B │ 2C │
|
||||
└────┴────┴────┘
|
||||
`);
|
||||
});
|
||||
});
|
43
node_modules/table/test/README/usage/draw_horizontal_line.js
generated
vendored
Normal file
43
node_modules/table/test/README/usage/draw_horizontal_line.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import {
|
||||
table
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('usage/draw_horizontal_line', () => {
|
||||
const data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C'],
|
||||
['3A', '3B', '3C'],
|
||||
['4A', '4B', '4C']
|
||||
];
|
||||
|
||||
const options = {
|
||||
/**
|
||||
* @typedef {Function} drawJoin
|
||||
* @param {number} index
|
||||
* @param {number} size
|
||||
* @returns {boolean}
|
||||
*/
|
||||
drawHorizontalLine: (index, size) => {
|
||||
return index === 0 || index === 1 || index === size - 1 || index === size;
|
||||
}
|
||||
};
|
||||
|
||||
const output = table(data, options);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
╔════╤════╤════╗
|
||||
║ 0A │ 0B │ 0C ║
|
||||
╟────┼────┼────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
║ 2A │ 2B │ 2C ║
|
||||
║ 3A │ 3B │ 3C ║
|
||||
╟────┼────┼────╢
|
||||
║ 4A │ 4B │ 4C ║
|
||||
╚════╧════╧════╝
|
||||
`);
|
||||
});
|
||||
});
|
13
node_modules/table/test/README/usage/expectTable.js
generated
vendored
Normal file
13
node_modules/table/test/README/usage/expectTable.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import _ from 'lodash';
|
||||
|
||||
/**
|
||||
* @param {string} result
|
||||
* @param {string} expectedResult
|
||||
* @returns {undefined}
|
||||
*/
|
||||
export default (result, expectedResult) => {
|
||||
expect(result).to.equal(_.trim(expectedResult) + '\n');
|
||||
};
|
68
node_modules/table/test/README/usage/moon_mission.js
generated
vendored
Normal file
68
node_modules/table/test/README/usage/moon_mission.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
import _ from 'lodash';
|
||||
import chalk from 'chalk';
|
||||
import {
|
||||
table,
|
||||
getBorderCharacters
|
||||
} from './../../../src';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('moon_mission', () => {
|
||||
const data = [
|
||||
[
|
||||
chalk.bold('Spacecraft'),
|
||||
chalk.bold('Launch Date'),
|
||||
chalk.bold('Operator'),
|
||||
chalk.bold('Outcome'),
|
||||
chalk.bold('Remarks')
|
||||
],
|
||||
[
|
||||
'Able I',
|
||||
'17 August 1958',
|
||||
'USAF',
|
||||
chalk.white.bold.bgRed('Launch failure'),
|
||||
'First attempted launch beyond Earth orbit; failed to orbit due to turbopump gearbox malfunction resulting in first stage explosion.[3] Reached apogee of 16 kilometres (9.9 mi)'
|
||||
],
|
||||
[
|
||||
'Luna 2',
|
||||
'12 September 1959',
|
||||
'OKB-1',
|
||||
chalk.black.bgGreen('Successful'),
|
||||
'Successful impact at 21:02 on 14 September 1959. First spacecraft to reach lunar surface'
|
||||
],
|
||||
[
|
||||
'Lunar Orbiter 1',
|
||||
'10 August 1966',
|
||||
'NASA',
|
||||
chalk.black.bgYellow('Partial failure'),
|
||||
'Orbital insertion at around 15:36 UTC on 14 August. Deorbited early due to lack of fuel and to avoid communications interference with the next mission, impacted the Moon at 13:30 UTC on 29 October 1966.'
|
||||
],
|
||||
[
|
||||
'Apollo 8',
|
||||
'21 December 1968',
|
||||
'NASA',
|
||||
chalk.black.bgGreen('Successful'),
|
||||
'First manned mission to the Moon; entered orbit around the Moon with four-minute burn beginning at 09:59:52 UTC on 24 December. Completed ten orbits of the Moon before returning to Earth with an engine burn at 06:10:16 UTC on 25 December. Landed in the Pacific Ocean at 15:51 UTC on 27 December.'
|
||||
],
|
||||
[
|
||||
'Apollo 11',
|
||||
'16 July 1969',
|
||||
'NASA',
|
||||
chalk.black.bgGreen('Successful'),
|
||||
'First manned landing on the Moon. LM landed at 20:17 UTC on 20 July 1969'
|
||||
]
|
||||
];
|
||||
|
||||
const tableBorder = _.mapValues(getBorderCharacters('honeywell'), (char) => {
|
||||
return chalk.gray(char);
|
||||
});
|
||||
|
||||
table(data, {
|
||||
border: tableBorder,
|
||||
columns: {
|
||||
4: {
|
||||
width: 50
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
41
node_modules/table/test/README/usage/padding_cell_content.js
generated
vendored
Normal file
41
node_modules/table/test/README/usage/padding_cell_content.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
import {
|
||||
table
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('usage/padding_cell_content', () => {
|
||||
const data = [
|
||||
['0A', 'AABBCC', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
paddingLeft: 3
|
||||
},
|
||||
1: {
|
||||
paddingRight: 3,
|
||||
width: 2
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const output = table(data, config);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
╔══════╤══════╤════╗
|
||||
║ 0A │ AA │ 0C ║
|
||||
║ │ BB │ ║
|
||||
║ │ CC │ ║
|
||||
╟──────┼──────┼────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
╟──────┼──────┼────╢
|
||||
║ 2A │ 2B │ 2C ║
|
||||
╚══════╧══════╧════╝
|
||||
`);
|
||||
});
|
||||
});
|
92
node_modules/table/test/README/usage/predefined_border_templates.js
generated
vendored
Normal file
92
node_modules/table/test/README/usage/predefined_border_templates.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
import _ from 'lodash';
|
||||
import {
|
||||
table,
|
||||
getBorderCharacters
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/predefined_border_templates', () => {
|
||||
let data;
|
||||
|
||||
before(() => {
|
||||
data = [
|
||||
['0A', '0B', '0C'],
|
||||
['1A', '1B', '1C'],
|
||||
['2A', '2B', '2C']
|
||||
];
|
||||
});
|
||||
|
||||
it('honeywell', () => {
|
||||
const output = table(data, {
|
||||
border: getBorderCharacters('honeywell')
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
╔════╤════╤════╗
|
||||
║ 0A │ 0B │ 0C ║
|
||||
╟────┼────┼────╢
|
||||
║ 1A │ 1B │ 1C ║
|
||||
╟────┼────┼────╢
|
||||
║ 2A │ 2B │ 2C ║
|
||||
╚════╧════╧════╝
|
||||
`);
|
||||
});
|
||||
|
||||
it('norc', () => {
|
||||
const output = table(data, {
|
||||
border: getBorderCharacters('norc')
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
┌────┬────┬────┐
|
||||
│ 0A │ 0B │ 0C │
|
||||
├────┼────┼────┤
|
||||
│ 1A │ 1B │ 1C │
|
||||
├────┼────┼────┤
|
||||
│ 2A │ 2B │ 2C │
|
||||
└────┴────┴────┘
|
||||
`);
|
||||
});
|
||||
|
||||
it('ramac', () => {
|
||||
const output = table(data, {
|
||||
border: getBorderCharacters('ramac')
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
+----+----+----+
|
||||
| 0A | 0B | 0C |
|
||||
|----|----|----|
|
||||
| 1A | 1B | 1C |
|
||||
|----|----|----|
|
||||
| 2A | 2B | 2C |
|
||||
+----+----+----+
|
||||
`);
|
||||
});
|
||||
|
||||
it('void', () => {
|
||||
const output = table(data, {
|
||||
border: getBorderCharacters('void')
|
||||
});
|
||||
|
||||
expectTable(_.trim(output) + '\n', '0A 0B 0C \n\n 1A 1B 1C \n\n 2A 2B 2C');
|
||||
});
|
||||
|
||||
it('borderless', () => {
|
||||
const output = table(data, {
|
||||
border: getBorderCharacters('void'),
|
||||
columnDefault: {
|
||||
paddingLeft: 0,
|
||||
paddingRight: 1
|
||||
},
|
||||
drawHorizontalLine: () => {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
expectTable(_.trim(output) + '\n', '0A 0B 0C \n1A 1B 1C \n2A 2B 2C');
|
||||
});
|
||||
});
|
56
node_modules/table/test/README/usage/streaming.js
generated
vendored
Normal file
56
node_modules/table/test/README/usage/streaming.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
import {
|
||||
createStream
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
describe('process.stdout.write', () => {
|
||||
let processStdoutWriteBuffer;
|
||||
|
||||
/**
|
||||
* @var {Function} Reference to the original process.stdout.write function.
|
||||
*/
|
||||
const processStdoutWrite = process.stdout.write;
|
||||
|
||||
/**
|
||||
* @returns {undefined}
|
||||
*/
|
||||
const overwriteProcessStdoutWrite = () => {
|
||||
processStdoutWriteBuffer = '';
|
||||
|
||||
process.stdout.write = (text) => {
|
||||
processStdoutWriteBuffer += text;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
const resetProcessStdoudWrite = () => {
|
||||
process.stdout.write = processStdoutWrite;
|
||||
|
||||
return processStdoutWriteBuffer;
|
||||
};
|
||||
|
||||
it('streaming', () => {
|
||||
const config = {
|
||||
columnCount: 3,
|
||||
columnDefault: {
|
||||
width: 2
|
||||
}
|
||||
};
|
||||
|
||||
const stream = createStream(config);
|
||||
|
||||
overwriteProcessStdoutWrite();
|
||||
|
||||
stream.write(['0A', '0B', '0C']);
|
||||
stream.write(['1A', '1B', '1C']);
|
||||
stream.write(['2A', '2B', '2C']);
|
||||
|
||||
const output = resetProcessStdoudWrite();
|
||||
|
||||
expectTable(output + '\n', '╔════╤════╤════╗\n║ 0A │ 0B │ 0C ║\n╚════╧════╧════╝\r\u001b[K╟────┼────┼────╢\n║ 1A │ 1B │ 1C ║\n╚════╧════╧════╝\r\u001b[K╟────┼────┼────╢\n║ 2A │ 2B │ 2C ║\n╚════╧════╧════╝');
|
||||
});
|
||||
});
|
||||
});
|
34
node_modules/table/test/README/usage/text_truncating.js
generated
vendored
Normal file
34
node_modules/table/test/README/usage/text_truncating.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import {
|
||||
table
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('text_truncating', () => {
|
||||
const data = [
|
||||
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
truncate: 100,
|
||||
width: 20
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const output = table(data, config);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
╔══════════════════════╗
|
||||
║ Lorem ipsum dolor si ║
|
||||
║ t amet, consectetur ║
|
||||
║ adipiscing elit. Pha ║
|
||||
║ sellus pulvinar nibh ║
|
||||
║ sed mauris conva... ║
|
||||
╚══════════════════════╝
|
||||
`);
|
||||
});
|
||||
});
|
69
node_modules/table/test/README/usage/text_wrapping.js
generated
vendored
Normal file
69
node_modules/table/test/README/usage/text_wrapping.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
import {
|
||||
table
|
||||
} from './../../../src';
|
||||
import expectTable from './expectTable';
|
||||
|
||||
describe('README.md usage/', () => {
|
||||
it('text_wrapping (no wrap word)', () => {
|
||||
const data = [
|
||||
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 20
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const output = table(data, config);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
╔══════════════════════╗
|
||||
║ Lorem ipsum dolor si ║
|
||||
║ t amet, consectetur ║
|
||||
║ adipiscing elit. Pha ║
|
||||
║ sellus pulvinar nibh ║
|
||||
║ sed mauris convallis ║
|
||||
║ dapibus. Nunc venena ║
|
||||
║ tis tempus nulla sit ║
|
||||
║ amet viverra. ║
|
||||
╚══════════════════════╝
|
||||
`);
|
||||
});
|
||||
|
||||
it('text_wrapping (wrap word)', () => {
|
||||
const data = [
|
||||
['Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pulvinar nibh sed mauris convallis dapibus. Nunc venenatis tempus nulla sit amet viverra.']
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 20,
|
||||
wrapWord: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const output = table(data, config);
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
expectTable(output, `
|
||||
╔══════════════════════╗
|
||||
║ Lorem ipsum dolor ║
|
||||
║ sit amet, ║
|
||||
║ consectetur ║
|
||||
║ adipiscing elit. ║
|
||||
║ Phasellus pulvinar ║
|
||||
║ nibh sed mauris ║
|
||||
║ convallis dapibus. ║
|
||||
║ Nunc venenatis ║
|
||||
║ tempus nulla sit ║
|
||||
║ amet viverra. ║
|
||||
╚══════════════════════╝
|
||||
`);
|
||||
});
|
||||
});
|
102
node_modules/table/test/alignString.js
generated
vendored
Normal file
102
node_modules/table/test/alignString.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/* eslint-disable max-nested-callbacks */
|
||||
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import chalk from 'chalk';
|
||||
import alignString from './../src/alignString';
|
||||
|
||||
describe('alignString', () => {
|
||||
context('subject parameter value is not a string', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
alignString();
|
||||
}).to.throw(Error, 'Subject parameter value must be a string.');
|
||||
});
|
||||
});
|
||||
context('container width parameter value is not a string', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
alignString('');
|
||||
}).to.throw(Error, 'Container width parameter value must be a number.');
|
||||
});
|
||||
});
|
||||
context('subject parameter value width is greater than the container width', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
alignString('aa', 1, 'left');
|
||||
}).to.throw(Error, 'Subject parameter value width cannot be greater than the container width.');
|
||||
});
|
||||
});
|
||||
context('container alignment parameter value is not a string', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
alignString('', 1);
|
||||
}).to.throw(Error, 'Alignment parameter value must be a string.');
|
||||
});
|
||||
});
|
||||
context('container alignment parameter value is not a known alignment parameter value', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
alignString('', 1, 'foo');
|
||||
}).to.throw(Error, 'Alignment parameter value must be a known alignment parameter value (left, right, center).');
|
||||
});
|
||||
});
|
||||
context('subject parameter value', () => {
|
||||
context('0 width', () => {
|
||||
it('produces a string consisting of container width number of whitespace characters', () => {
|
||||
expect(alignString('', 5, 'left')).to.equal(' ', 'left');
|
||||
expect(alignString('', 5, 'center')).to.equal(' ', 'center');
|
||||
expect(alignString('', 5, 'right')).to.equal(' ', 'right');
|
||||
});
|
||||
});
|
||||
context('plain text', () => {
|
||||
context('alignment', () => {
|
||||
context('left', () => {
|
||||
it('pads the string on the right side using a whitespace character', () => {
|
||||
expect(alignString('aa', 6, 'left')).to.equal('aa ');
|
||||
});
|
||||
});
|
||||
context('right', () => {
|
||||
it('pads the string on the left side using a whitespace character', () => {
|
||||
expect(alignString('aa', 6, 'right')).to.equal(' aa');
|
||||
});
|
||||
});
|
||||
context('center', () => {
|
||||
it('pads the string on both sides using a whitespace character', () => {
|
||||
expect(alignString('aa', 6, 'center')).to.equal(' aa ');
|
||||
});
|
||||
context('uneven number of available with', () => {
|
||||
it('floors the available width; adds extra space to the end of the string', () => {
|
||||
expect(alignString('aa', 7, 'center')).to.equal(' aa ');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
context('text containing ANSI escape codes', () => {
|
||||
context('alignment', () => {
|
||||
context('left', () => {
|
||||
it('pads the string on the right side using a whitespace character', () => {
|
||||
expect(alignString(chalk.red('aa'), 6, 'left')).to.equal(chalk.red('aa') + ' ');
|
||||
});
|
||||
});
|
||||
context('right', () => {
|
||||
it('pads the string on the left side using a whitespace character', () => {
|
||||
expect(alignString(chalk.red('aa'), 6, 'right')).to.equal(' ' + chalk.red('aa'));
|
||||
});
|
||||
});
|
||||
context('center', () => {
|
||||
it('pads the string on both sides using a whitespace character', () => {
|
||||
expect(alignString(chalk.red('aa'), 6, 'center')).to.equal(' ' + chalk.red('aa') + ' ');
|
||||
});
|
||||
context('uneven number of available with', () => {
|
||||
it('floors the available width; adds extra space to the end of the string', () => {
|
||||
expect(alignString(chalk.red('aa'), 7, 'center')).to.equal(' ' + chalk.red('aa') + ' ');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
44
node_modules/table/test/calculateCellHeight.js
generated
vendored
Normal file
44
node_modules/table/test/calculateCellHeight.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/* eslint-disable max-nested-callbacks */
|
||||
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import calculateCellHeight from './../src/calculateCellHeight';
|
||||
|
||||
describe('calculateCellHeight', () => {
|
||||
describe('value', () => {
|
||||
context('is not a string', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
calculateCellHeight(null);
|
||||
}).to.throw(Error, 'Value must be a string.');
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('context width', () => {
|
||||
context('is not an integer', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
calculateCellHeight('foo', null);
|
||||
}).to.throw(Error, 'Column width must be an integer.');
|
||||
});
|
||||
});
|
||||
context('is 0', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
calculateCellHeight('foo', 0);
|
||||
}).to.throw(Error, 'Column width must be greater than 0.');
|
||||
});
|
||||
});
|
||||
context('is lesser than the column width', () => {
|
||||
it('has height 1', () => {
|
||||
expect(calculateCellHeight('foo', 10)).to.equal(1);
|
||||
});
|
||||
});
|
||||
context('is 2 and half times greater than the column width', () => {
|
||||
it('has height 3', () => {
|
||||
expect(calculateCellHeight('aabbc', 2)).to.equal(3);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
20
node_modules/table/test/calculateCellWidthIndex.js
generated
vendored
Normal file
20
node_modules/table/test/calculateCellWidthIndex.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import calculateCellWidthIndex from './../src/calculateCellWidthIndex';
|
||||
|
||||
describe('calculateCellWidthIndex', () => {
|
||||
context('all cells have different width', () => {
|
||||
it('describes each cell contents width', () => {
|
||||
const cellWidthIndex = calculateCellWidthIndex([
|
||||
'a',
|
||||
'aaa',
|
||||
'aaaaaa'
|
||||
]);
|
||||
|
||||
expect(cellWidthIndex[0]).to.equal(1, 'first column');
|
||||
expect(cellWidthIndex[1]).to.equal(3, 'second column');
|
||||
expect(cellWidthIndex[2]).to.equal(6, 'third column');
|
||||
});
|
||||
});
|
||||
});
|
59
node_modules/table/test/calculateMaximumColumnWidthIndex.js
generated
vendored
Normal file
59
node_modules/table/test/calculateMaximumColumnWidthIndex.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import chalk from 'chalk';
|
||||
import calculateMaximumColumnWidthIndex from './../src/calculateMaximumColumnWidthIndex';
|
||||
|
||||
describe('calculateMaximumColumnWidthIndex', () => {
|
||||
it('throws an error when attempting to calculate maximum column value index for an empty data set', () => {
|
||||
expect(() => {
|
||||
calculateMaximumColumnWidthIndex([]);
|
||||
}).to.throw(Error, 'Dataset must have at least one row.');
|
||||
});
|
||||
it('calculates the maximum column value index', () => {
|
||||
const maximumColumnValueIndex = calculateMaximumColumnWidthIndex([
|
||||
[
|
||||
'',
|
||||
'a',
|
||||
'b',
|
||||
'c'
|
||||
],
|
||||
[
|
||||
'',
|
||||
'a',
|
||||
'bbbbbbbbbb',
|
||||
'c'
|
||||
],
|
||||
[
|
||||
'',
|
||||
'',
|
||||
'b',
|
||||
'ccccc'
|
||||
]
|
||||
]);
|
||||
|
||||
expect(maximumColumnValueIndex).to.deep.equal([0, 1, 10, 5]);
|
||||
});
|
||||
context('cell values contain ANSI codes', () => {
|
||||
it('uses visual width of the string', () => {
|
||||
const maximumColumnValueIndex = calculateMaximumColumnWidthIndex([
|
||||
[
|
||||
chalk.red('aaaaa')
|
||||
]
|
||||
]);
|
||||
|
||||
expect(maximumColumnValueIndex[0]).to.equal(5);
|
||||
});
|
||||
});
|
||||
context('cell values contain fullwidth characters', () => {
|
||||
it('uses visual width of the string', () => {
|
||||
const maximumColumnValueIndex = calculateMaximumColumnWidthIndex([
|
||||
[
|
||||
chalk.red('古')
|
||||
]
|
||||
]);
|
||||
|
||||
expect(maximumColumnValueIndex[0]).to.equal(2);
|
||||
});
|
||||
});
|
||||
});
|
78
node_modules/table/test/calculateRowHeightIndex.js
generated
vendored
Normal file
78
node_modules/table/test/calculateRowHeightIndex.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
/* eslint-disable max-nested-callbacks */
|
||||
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import calculateRowHeightIndex from './../src/calculateRowHeightIndex';
|
||||
|
||||
describe('calculateRowHeightIndex', () => {
|
||||
context('single column', () => {
|
||||
context('cell content width is lesser than column width', () => {
|
||||
it('is equal to 1', () => {
|
||||
const data = [
|
||||
[
|
||||
'aaa'
|
||||
]
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 10,
|
||||
wrapWord: false
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const rowSpanIndex = calculateRowHeightIndex(data, config);
|
||||
|
||||
expect(rowSpanIndex[0]).to.equal(1);
|
||||
});
|
||||
});
|
||||
context('cell content width is twice the size of the column width', () => {
|
||||
it('is equal to 2', () => {
|
||||
const data = [
|
||||
[
|
||||
'aaabbb'
|
||||
]
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 3,
|
||||
wrapWord: false
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const rowSpanIndex = calculateRowHeightIndex(data, config);
|
||||
|
||||
expect(rowSpanIndex[0]).to.equal(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
context('multiple columns', () => {
|
||||
context('multiple cell content width is greater than the column width', () => {
|
||||
it('uses the largest height', () => {
|
||||
const data = [
|
||||
['aaabbb'],
|
||||
['aaabbb']
|
||||
];
|
||||
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 2,
|
||||
wrapWord: false
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const rowSpanIndex = calculateRowHeightIndex(data, config);
|
||||
|
||||
expect(rowSpanIndex[0]).to.equal(3);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
43
node_modules/table/test/config.js
generated
vendored
Normal file
43
node_modules/table/test/config.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import configSamples from './configSamples';
|
||||
import validateConfig from '../dist/validateConfig';
|
||||
import configSchema from '../src/schemas/config.json';
|
||||
import Ajv from 'ajv';
|
||||
import ajvKeywords from 'ajv-keywords';
|
||||
|
||||
describe('config.json schema', () => {
|
||||
var validate;
|
||||
|
||||
before(() => {
|
||||
var ajv = new Ajv({allErrors: true});
|
||||
ajvKeywords(ajv, 'typeof');
|
||||
validate = ajv.compile(configSchema);
|
||||
});
|
||||
|
||||
it('should pass validation of valid config samples', () => {
|
||||
configSamples.valid.forEach((sample, i) => {
|
||||
testValid(sample, validate);
|
||||
testValid(sample, validateConfig);
|
||||
});
|
||||
|
||||
function testValid(sample, validate) {
|
||||
var valid = validate(sample);
|
||||
if (!valid) console.log(validate.errors);
|
||||
expect(valid).to.equal(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('should fail validation of invalid config samples', () => {
|
||||
configSamples.invalid.forEach((sample, i) => {
|
||||
testInvalid(sample, validate);
|
||||
testInvalid(sample, validateConfig);
|
||||
});
|
||||
|
||||
function testInvalid(sample, validate) {
|
||||
var valid = validate(sample);
|
||||
expect(valid).to.equal(false);
|
||||
}
|
||||
});
|
||||
});
|
153
node_modules/table/test/configSamples.js
generated
vendored
Normal file
153
node_modules/table/test/configSamples.js
generated
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
export default {
|
||||
valid: [
|
||||
{
|
||||
columns: {
|
||||
0: {
|
||||
alignment: 'left',
|
||||
// minWidth: 10,
|
||||
width: 10
|
||||
},
|
||||
1: {
|
||||
alignment: 'center',
|
||||
// minWidth: 10,
|
||||
width: 10
|
||||
},
|
||||
2: {
|
||||
alignment: 'right',
|
||||
// minWidth: 10,
|
||||
width: 10
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
border: {
|
||||
topBody: `─`,
|
||||
topJoin: `┬`,
|
||||
topLeft: `┌`,
|
||||
topRight: `┐`,
|
||||
|
||||
bottomBody: `─`,
|
||||
bottomJoin: `┴`,
|
||||
bottomLeft: `└`,
|
||||
bottomRight: `┘`,
|
||||
|
||||
bodyLeft: `│`,
|
||||
bodyRight: `│`,
|
||||
bodyJoin: `│`,
|
||||
|
||||
joinBody: `─`,
|
||||
joinLeft: `├`,
|
||||
joinRight: `┤`,
|
||||
joinJoin: `┼`
|
||||
}
|
||||
},
|
||||
{
|
||||
columns: {
|
||||
0: {
|
||||
paddingLeft: 3
|
||||
},
|
||||
1: {
|
||||
width: 2,
|
||||
paddingRight: 3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
border: {},
|
||||
columnDefault: {
|
||||
paddingLeft: 0,
|
||||
paddingRight: 1
|
||||
},
|
||||
// drawJoin: () => {
|
||||
// return false
|
||||
// }
|
||||
},
|
||||
{
|
||||
columnDefault: {
|
||||
width: 50
|
||||
},
|
||||
// columnCount: 3,
|
||||
columns: {
|
||||
0: {
|
||||
width: 10,
|
||||
alignment: 'right'
|
||||
},
|
||||
1: {
|
||||
alignment: 'center',
|
||||
},
|
||||
2: {
|
||||
width: 10
|
||||
}
|
||||
}
|
||||
},
|
||||
{ border: { topBody: '-' } },
|
||||
{ border: { topJoin: '-' } },
|
||||
{ border: { topLeft: '-' } },
|
||||
{ border: { topRight: '-' } },
|
||||
{ border: { bottomBody: '-' } },
|
||||
{ border: { bottomJoin: '-' } },
|
||||
{ border: { bottomLeft: '-' } },
|
||||
{ border: { bottomRight: '-' } },
|
||||
{ border: { bodyLeft: '-' } },
|
||||
{ border: { bodyRight: '-' } },
|
||||
{ border: { bodyJoin: '-' } },
|
||||
{ border: { joinBody: '-' } },
|
||||
{ border: { joinLeft: '-' } },
|
||||
{ border: { joinRight: '-' } },
|
||||
{ border: { joinJoin: '-' } },
|
||||
{ columns: { '1': { alignment: 'left' } } },
|
||||
{ columns: { '1': { width: 5 } } },
|
||||
{ columns: { '1': { wrapWord: true } } },
|
||||
{ columns: { '1': { truncate: 1 } } },
|
||||
{ columns: { '1': { paddingLeft: 1 } } },
|
||||
{ columns: { '1': { paddingRight: 1 } } },
|
||||
{ columnDefault: { alignment: 'left' } },
|
||||
{ columnDefault: { width: 5 } },
|
||||
{ columnDefault: { wrapWord: true } },
|
||||
{ columnDefault: { truncate: 1 } },
|
||||
{ columnDefault: { paddingLeft: 1 } },
|
||||
{ columnDefault: { paddingRight: 1 } },
|
||||
{ drawHorizontalLine: function(){} }
|
||||
],
|
||||
invalid: [
|
||||
{ border: 1 },
|
||||
{ border: { unknown: '-' } },
|
||||
{ border: { topBody: 1 } },
|
||||
{ border: { topJoin: 1 } },
|
||||
{ border: { topLeft: 1 } },
|
||||
{ border: { topRight: 1 } },
|
||||
{ border: { bottomBody: 1 } },
|
||||
{ border: { bottomJoin: 1 } },
|
||||
{ border: { bottomLeft: 1 } },
|
||||
{ border: { bottomRight: 1 } },
|
||||
{ border: { bodyLeft: 1 } },
|
||||
{ border: { bodyRight: 1 } },
|
||||
{ border: { bodyJoin: 1 } },
|
||||
{ border: { joinBody: 1 } },
|
||||
{ border: { joinLeft: 1 } },
|
||||
{ border: { joinRight: 1 } },
|
||||
{ border: { joinJoin: 1 } },
|
||||
{ columns: 1 },
|
||||
{ columns: { a: { width: 5 } } },
|
||||
{ columns: { '1': 1 } },
|
||||
{ columns: { '1': { unknown: 1 } } },
|
||||
{ columns: { '1': { alignment: 1 } } },
|
||||
{ columns: { '1': { alignment: '1' } } },
|
||||
{ columns: { '1': { width: '5' } } },
|
||||
{ columns: { '1': { wrapWord: 1 } } },
|
||||
{ columns: { '1': { truncate: '1' } } },
|
||||
{ columns: { '1': { paddingLeft: '1' } } },
|
||||
{ columns: { '1': { paddingRight: '1' } } },
|
||||
{ columnDefault: 1 },
|
||||
{ columnDefault: { unknown: 1 } },
|
||||
{ columnDefault: { alignment: 1 } },
|
||||
{ columnDefault: { alignment: '1' } },
|
||||
{ columnDefault: { width: '5' } },
|
||||
{ columnDefault: { wrapWord: 1 } },
|
||||
{ columnDefault: { truncate: '1' } },
|
||||
{ columnDefault: { paddingLeft: '1' } },
|
||||
{ columnDefault: { paddingRight: '1' } },
|
||||
{ drawHorizontalLine: 1 },
|
||||
{ unknown: 1 }
|
||||
]
|
||||
};
|
41
node_modules/table/test/createStream.js
generated
vendored
Normal file
41
node_modules/table/test/createStream.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/* eslint-disable max-nested-callbacks */
|
||||
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import createStream from './../src/createStream';
|
||||
|
||||
describe('createStream', () => {
|
||||
context('"config.columnDefault.width" property is not provided', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
createStream();
|
||||
}).to.throw(Error, 'Must provide config.columnDefault.width when creating a stream.');
|
||||
});
|
||||
});
|
||||
context('"config.columnCount" property is not provided', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
createStream({
|
||||
columnDefault: {
|
||||
width: 10
|
||||
}
|
||||
});
|
||||
}).to.throw(Error, 'Must provide config.columnCount.');
|
||||
});
|
||||
});
|
||||
context('Table data cell count does not match the columnCount.', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
const stream = createStream({
|
||||
columnCount: 10,
|
||||
columnDefault: {
|
||||
width: 10
|
||||
}
|
||||
});
|
||||
|
||||
stream.write(['foo']);
|
||||
}).to.throw(Error, 'Row cell count does not match the config.columnCount.');
|
||||
});
|
||||
});
|
||||
});
|
71
node_modules/table/test/drawBorder.js
generated
vendored
Normal file
71
node_modules/table/test/drawBorder.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import {
|
||||
drawBorder,
|
||||
drawBorderTop,
|
||||
drawBorderJoin,
|
||||
drawBorderBottom
|
||||
} from './../src/drawBorder';
|
||||
|
||||
describe('drawBorder', () => {
|
||||
it('draws a border using parts', () => {
|
||||
const parts = {
|
||||
left: '╔',
|
||||
right: '╗',
|
||||
body: '═',
|
||||
join: '╤'
|
||||
};
|
||||
|
||||
expect(drawBorder([1], parts)).to.equal('╔═╗\n');
|
||||
expect(drawBorder([1, 1], parts)).to.equal('╔═╤═╗\n');
|
||||
expect(drawBorder([5, 10], parts)).to.equal('╔═════╤══════════╗\n');
|
||||
});
|
||||
});
|
||||
|
||||
describe('drawBorderTop', () => {
|
||||
it('draws a border using parts', () => {
|
||||
const parts = {
|
||||
topLeft: '╔',
|
||||
topRight: '╗',
|
||||
topBody: '═',
|
||||
topJoin: '╤'
|
||||
};
|
||||
|
||||
expect(drawBorderTop([1], parts)).to.equal('╔═╗\n');
|
||||
expect(drawBorderTop([1, 1], parts)).to.equal('╔═╤═╗\n');
|
||||
expect(drawBorderTop([5, 10], parts)).to.equal('╔═════╤══════════╗\n');
|
||||
});
|
||||
});
|
||||
|
||||
describe('drawBorderJoin', () => {
|
||||
it('draws a border using parts', () => {
|
||||
const parts = {
|
||||
joinBody: '─',
|
||||
joinLeft: '╟',
|
||||
joinRight: '╢',
|
||||
joinJoin: '┼'
|
||||
};
|
||||
|
||||
expect(drawBorderJoin([1], parts)).to.equal('╟─╢\n');
|
||||
expect(drawBorderJoin([1, 1], parts)).to.equal('╟─┼─╢\n');
|
||||
expect(drawBorderJoin([5, 10], parts)).to.equal('╟─────┼──────────╢\n');
|
||||
});
|
||||
});
|
||||
|
||||
describe('drawBorderBottom', () => {
|
||||
it('draws a border using parts', () => {
|
||||
const parts = {
|
||||
bottomBody: '═',
|
||||
bottomJoin: '╧',
|
||||
bottomLeft: '╚',
|
||||
bottomRight: '╝'
|
||||
};
|
||||
|
||||
expect(drawBorderBottom([1], parts)).to.equal('╚═╝\n');
|
||||
expect(drawBorderBottom([1, 1], parts)).to.equal('╚═╧═╝\n');
|
||||
expect(drawBorderBottom([5, 10], parts)).to.equal('╚═════╧══════════╝\n');
|
||||
});
|
||||
});
|
75
node_modules/table/test/makeConfig.js
generated
vendored
Normal file
75
node_modules/table/test/makeConfig.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
/* eslint-disable max-nested-callbacks */
|
||||
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import makeConfig from './../src/makeConfig';
|
||||
|
||||
describe('makeConfig', () => {
|
||||
it('does not affect the parameter configuration object', () => {
|
||||
const config = {};
|
||||
|
||||
makeConfig([
|
||||
[
|
||||
'aaaaa'
|
||||
]
|
||||
], config);
|
||||
|
||||
expect(config).to.deep.equal({});
|
||||
});
|
||||
|
||||
context('column', () => {
|
||||
context('"alignment"', () => {
|
||||
context('is not provided', () => {
|
||||
it('defaults to "left"', () => {
|
||||
const config = makeConfig([
|
||||
[
|
||||
'aaaaa'
|
||||
]
|
||||
]);
|
||||
|
||||
expect(config.columns[0].alignment).to.equal('left');
|
||||
});
|
||||
});
|
||||
});
|
||||
context('"width"', () => {
|
||||
context('is not provided', () => {
|
||||
it('defaults to the maximum column width', () => {
|
||||
const config = makeConfig([
|
||||
[
|
||||
'aaaaa'
|
||||
]
|
||||
]);
|
||||
|
||||
expect(config.columns[0].width).to.equal(5);
|
||||
});
|
||||
});
|
||||
});
|
||||
context('"paddingLeft"', () => {
|
||||
context('is not provided', () => {
|
||||
it('defaults to 1', () => {
|
||||
const config = makeConfig([
|
||||
[
|
||||
'aaaaa'
|
||||
]
|
||||
]);
|
||||
|
||||
expect(config.columns[0].paddingLeft).to.equal(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
context('"paddingRight"', () => {
|
||||
context('is not provided', () => {
|
||||
it('defaults to 1', () => {
|
||||
const config = makeConfig([
|
||||
[
|
||||
'aaaaa'
|
||||
]
|
||||
]);
|
||||
|
||||
expect(config.columns[0].paddingRight).to.equal(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
119
node_modules/table/test/mapDataUsingRowHeightIndex.js
generated
vendored
Normal file
119
node_modules/table/test/mapDataUsingRowHeightIndex.js
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import mapDataUsingRowHeightIndex from './../src/mapDataUsingRowHeightIndex';
|
||||
|
||||
describe('mapDataUsingRowHeightIndex', () => {
|
||||
context('no data spans multiple rows', () => {
|
||||
it('maps data to a single cell', () => {
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 2
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const rowSpanIndex = [
|
||||
1
|
||||
];
|
||||
|
||||
const data = [
|
||||
[
|
||||
'aa'
|
||||
]
|
||||
];
|
||||
|
||||
const mappedData = mapDataUsingRowHeightIndex(data, rowSpanIndex, config);
|
||||
|
||||
expect(mappedData).to.deep.equal([
|
||||
[
|
||||
'aa'
|
||||
]
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
context('single cell spans multiple rows', () => {
|
||||
it('maps data to multiple rows', () => {
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 2
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const rowSpanIndex = [
|
||||
5
|
||||
];
|
||||
|
||||
const data = [
|
||||
[
|
||||
'aabbccddee'
|
||||
]
|
||||
];
|
||||
|
||||
const mappedData = mapDataUsingRowHeightIndex(data, rowSpanIndex, config);
|
||||
|
||||
expect(mappedData).to.deep.equal([
|
||||
['aa'],
|
||||
['bb'],
|
||||
['cc'],
|
||||
['dd'],
|
||||
['ee']
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
context('multiple cells spans multiple rows', () => {
|
||||
it('maps data to multiple rows', () => {
|
||||
const config = {
|
||||
columns: {
|
||||
0: {
|
||||
width: 2
|
||||
},
|
||||
1: {
|
||||
width: 4
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const rowSpanIndex = [
|
||||
5
|
||||
];
|
||||
|
||||
const data = [
|
||||
[
|
||||
'aabbccddee',
|
||||
'00001111'
|
||||
]
|
||||
];
|
||||
|
||||
const mappedData = mapDataUsingRowHeightIndex(data, rowSpanIndex, config);
|
||||
|
||||
expect(mappedData).to.deep.equal([
|
||||
[
|
||||
'aa',
|
||||
'0000'
|
||||
],
|
||||
[
|
||||
'bb',
|
||||
'1111'
|
||||
],
|
||||
[
|
||||
'cc',
|
||||
''
|
||||
],
|
||||
[
|
||||
'dd',
|
||||
''
|
||||
],
|
||||
[
|
||||
'ee',
|
||||
''
|
||||
]
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
43
node_modules/table/test/streamConfig.js
generated
vendored
Normal file
43
node_modules/table/test/streamConfig.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import configSamples from './streamConfigSamples';
|
||||
import validateConfig from '../dist/validateStreamConfig';
|
||||
import configSchema from '../src/schemas/streamConfig.json';
|
||||
import Ajv from 'ajv';
|
||||
import ajvKeywords from 'ajv-keywords';
|
||||
|
||||
describe('streamConfig.json schema', () => {
|
||||
var validate;
|
||||
|
||||
before(() => {
|
||||
var ajv = new Ajv({allErrors: true});
|
||||
ajvKeywords(ajv, 'typeof');
|
||||
validate = ajv.compile(configSchema);
|
||||
});
|
||||
|
||||
it('should pass validation of valid streamConfig samples', () => {
|
||||
configSamples.valid.forEach((sample, i) => {
|
||||
testValid(sample, validate);
|
||||
testValid(sample, validateConfig);
|
||||
});
|
||||
|
||||
function testValid(sample, validate) {
|
||||
var valid = validate(sample);
|
||||
if (!valid) console.log(validate.errors);
|
||||
expect(valid).to.equal(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('should fail validation of invalid streamConfig samples', () => {
|
||||
configSamples.invalid.forEach((sample, i) => {
|
||||
testInvalid(sample, validate);
|
||||
testInvalid(sample, validateConfig);
|
||||
});
|
||||
|
||||
function testInvalid(sample, validate) {
|
||||
var valid = validate(sample);
|
||||
expect(valid).to.equal(false);
|
||||
}
|
||||
});
|
||||
});
|
151
node_modules/table/test/streamConfigSamples.js
generated
vendored
Normal file
151
node_modules/table/test/streamConfigSamples.js
generated
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
export default {
|
||||
valid: [
|
||||
{
|
||||
columns: {
|
||||
0: {
|
||||
alignment: 'left',
|
||||
// minWidth: 10,
|
||||
width: 10
|
||||
},
|
||||
1: {
|
||||
alignment: 'center',
|
||||
// minWidth: 10,
|
||||
width: 10
|
||||
},
|
||||
2: {
|
||||
alignment: 'right',
|
||||
// minWidth: 10,
|
||||
width: 10
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
border: {
|
||||
topBody: `─`,
|
||||
topJoin: `┬`,
|
||||
topLeft: `┌`,
|
||||
topRight: `┐`,
|
||||
|
||||
bottomBody: `─`,
|
||||
bottomJoin: `┴`,
|
||||
bottomLeft: `└`,
|
||||
bottomRight: `┘`,
|
||||
|
||||
bodyLeft: `│`,
|
||||
bodyRight: `│`,
|
||||
bodyJoin: `│`,
|
||||
|
||||
joinBody: `─`,
|
||||
joinLeft: `├`,
|
||||
joinRight: `┤`,
|
||||
joinJoin: `┼`
|
||||
}
|
||||
},
|
||||
{
|
||||
columns: {
|
||||
0: {
|
||||
paddingLeft: 3
|
||||
},
|
||||
1: {
|
||||
width: 2,
|
||||
paddingRight: 3
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
border: {},
|
||||
columnDefault: {
|
||||
paddingLeft: 0,
|
||||
paddingRight: 1
|
||||
},
|
||||
// drawJoin: () => {
|
||||
// return false
|
||||
// }
|
||||
},
|
||||
{
|
||||
columnDefault: {
|
||||
width: 50
|
||||
},
|
||||
// columnCount: 3,
|
||||
columns: {
|
||||
0: {
|
||||
width: 10,
|
||||
alignment: 'right'
|
||||
},
|
||||
1: {
|
||||
alignment: 'center',
|
||||
},
|
||||
2: {
|
||||
width: 10
|
||||
}
|
||||
}
|
||||
},
|
||||
{ border: { topBody: '-' } },
|
||||
{ border: { topJoin: '-' } },
|
||||
{ border: { topLeft: '-' } },
|
||||
{ border: { topRight: '-' } },
|
||||
{ border: { bottomBody: '-' } },
|
||||
{ border: { bottomJoin: '-' } },
|
||||
{ border: { bottomLeft: '-' } },
|
||||
{ border: { bottomRight: '-' } },
|
||||
{ border: { bodyLeft: '-' } },
|
||||
{ border: { bodyRight: '-' } },
|
||||
{ border: { bodyJoin: '-' } },
|
||||
{ border: { joinBody: '-' } },
|
||||
{ border: { joinLeft: '-' } },
|
||||
{ border: { joinRight: '-' } },
|
||||
{ border: { joinJoin: '-' } },
|
||||
{ columns: { '1': { alignment: 'left' } } },
|
||||
{ columns: { '1': { width: 5 } } },
|
||||
{ columns: { '1': { wrapWord: true } } },
|
||||
{ columns: { '1': { truncate: 1 } } },
|
||||
{ columns: { '1': { paddingLeft: 1 } } },
|
||||
{ columns: { '1': { paddingRight: 1 } } },
|
||||
{ columnDefault: { alignment: 'left' } },
|
||||
{ columnDefault: { width: 5 } },
|
||||
{ columnDefault: { wrapWord: true } },
|
||||
{ columnDefault: { truncate: 1 } },
|
||||
{ columnDefault: { paddingLeft: 1 } },
|
||||
{ columnDefault: { paddingRight: 1 } }
|
||||
],
|
||||
invalid: [
|
||||
{ border: 1 },
|
||||
{ border: { unknown: '-' } },
|
||||
{ border: { topBody: 1 } },
|
||||
{ border: { topJoin: 1 } },
|
||||
{ border: { topLeft: 1 } },
|
||||
{ border: { topRight: 1 } },
|
||||
{ border: { bottomBody: 1 } },
|
||||
{ border: { bottomJoin: 1 } },
|
||||
{ border: { bottomLeft: 1 } },
|
||||
{ border: { bottomRight: 1 } },
|
||||
{ border: { bodyLeft: 1 } },
|
||||
{ border: { bodyRight: 1 } },
|
||||
{ border: { bodyJoin: 1 } },
|
||||
{ border: { joinBody: 1 } },
|
||||
{ border: { joinLeft: 1 } },
|
||||
{ border: { joinRight: 1 } },
|
||||
{ border: { joinJoin: 1 } },
|
||||
{ columns: 1 },
|
||||
{ columns: { a: { width: 5 } } },
|
||||
{ columns: { '1': 1 } },
|
||||
{ columns: { '1': { unknown: 1 } } },
|
||||
{ columns: { '1': { alignment: 1 } } },
|
||||
{ columns: { '1': { alignment: '1' } } },
|
||||
{ columns: { '1': { width: '5' } } },
|
||||
{ columns: { '1': { wrapWord: 1 } } },
|
||||
{ columns: { '1': { truncate: '1' } } },
|
||||
{ columns: { '1': { paddingLeft: '1' } } },
|
||||
{ columns: { '1': { paddingRight: '1' } } },
|
||||
{ columnDefault: 1 },
|
||||
{ columnDefault: { unknown: 1 } },
|
||||
{ columnDefault: { alignment: 1 } },
|
||||
{ columnDefault: { alignment: '1' } },
|
||||
{ columnDefault: { width: '5' } },
|
||||
{ columnDefault: { wrapWord: 1 } },
|
||||
{ columnDefault: { truncate: '1' } },
|
||||
{ columnDefault: { paddingLeft: '1' } },
|
||||
{ columnDefault: { paddingRight: '1' } },
|
||||
{ unknown: 1 }
|
||||
]
|
||||
};
|
65
node_modules/table/test/validateTableData.js
generated
vendored
Normal file
65
node_modules/table/test/validateTableData.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/* eslint-disable max-nested-callbacks */
|
||||
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import validateTableData from './../src/validateTableData';
|
||||
|
||||
describe('validateTableData', () => {
|
||||
context('table does not have a row', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
validateTableData([]);
|
||||
}).to.throw(Error, 'Table must define at least one row.');
|
||||
});
|
||||
});
|
||||
|
||||
context('table does not have a column', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
validateTableData([[]]);
|
||||
}).to.throw(Error, 'Table must define at least one column.');
|
||||
});
|
||||
});
|
||||
|
||||
context('row data is not an array', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
validateTableData({});
|
||||
}).to.throw(Error, 'Table data must be an array.');
|
||||
});
|
||||
});
|
||||
|
||||
context('column data is not an array', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
validateTableData([{}]);
|
||||
}).to.throw(Error, 'Table row data must be an array.');
|
||||
});
|
||||
});
|
||||
|
||||
context('cell data contains a control character', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
validateTableData([
|
||||
[
|
||||
[
|
||||
String.fromCodePoint(0x01)
|
||||
]
|
||||
]
|
||||
]);
|
||||
}).to.throw(Error, 'Table data must not contain control characters.');
|
||||
});
|
||||
});
|
||||
|
||||
context('rows have inconsistent number of cells', () => {
|
||||
it('throws an error', () => {
|
||||
expect(() => {
|
||||
validateTableData([
|
||||
['a', 'b', 'c'],
|
||||
['a', 'b']
|
||||
]);
|
||||
}).to.throw(Error, 'Table must have a consistent number of cells.');
|
||||
});
|
||||
});
|
||||
});
|
45
node_modules/table/test/wrapString.js
generated
vendored
Normal file
45
node_modules/table/test/wrapString.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/* eslint-disable max-nested-callbacks */
|
||||
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import chalk from 'chalk';
|
||||
import wrapString from './../src/wrapString';
|
||||
|
||||
describe('wrapString', () => {
|
||||
context('subject is a plain text string', () => {
|
||||
context('subject is lesser than the chunk size', () => {
|
||||
it('returns subject in a single chunk', () => {
|
||||
expect(wrapString('aaa', 3)).to.deep.equal(['aaa']);
|
||||
});
|
||||
});
|
||||
context('subject is larger than the chunk size', () => {
|
||||
it('returns subject sliced into multiple chunks', () => {
|
||||
expect(wrapString('aaabbbc', 3)).to.deep.equal(['aaa', 'bbb', 'c']);
|
||||
});
|
||||
});
|
||||
context('a chunk starts with a space', () => {
|
||||
it('adjusts chunks to offset the space', () => {
|
||||
expect(wrapString('aaa bbb ccc', 3)).to.deep.equal(['aaa', 'bbb', 'ccc']);
|
||||
});
|
||||
});
|
||||
});
|
||||
context('subject string contains ANSI escape codes', () => {
|
||||
describe('subject is lesser than the chunk size', () => {
|
||||
it.skip('returns subject in a single chunk', () => {
|
||||
expect(wrapString(chalk.red('aaa'), 3)).to.deep.equal([
|
||||
'\u001b[31m\u001b[31m\u001b[31m\u001b[31m\u001b[31maaa\u001b[39m'
|
||||
]);
|
||||
});
|
||||
});
|
||||
describe('subject is larger than the chunk size', () => {
|
||||
it.skip('returns subject sliced into multiple chunks', () => {
|
||||
expect(wrapString(chalk.red('aaabbbc'), 3)).to.deep.equal([
|
||||
'\u001b[31m\u001b[31m\u001b[31m\u001b[31m\u001b[31maaa\u001b[39m',
|
||||
'\u001b[31m\u001b[31m\u001b[31m\u001b[31m\u001b[31mbbb\u001b[39m',
|
||||
'\u001b[31m\u001b[31m\u001b[31m\u001b[31m\u001b[31mc\u001b[39m'
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
32
node_modules/table/test/wrapWord.js
generated
vendored
Normal file
32
node_modules/table/test/wrapWord.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
expect
|
||||
} from 'chai';
|
||||
import wrapWord from './../src/wrapWord';
|
||||
|
||||
describe('wrapWord', () => {
|
||||
it('wraps a string at a nearest whitespace', () => {
|
||||
expect(wrapWord('aaa bbb', 5)).to.deep.equal(['aaa', 'bbb']);
|
||||
expect(wrapWord('a a a bbb', 5)).to.deep.equal(['a a a', 'bbb']);
|
||||
});
|
||||
context('a single word is longer than chunk size', () => {
|
||||
it('cuts the word', () => {
|
||||
expect(wrapWord('aaaaa', 2)).to.deep.equal(['aa', 'aa', 'a']);
|
||||
});
|
||||
});
|
||||
context('a long word with a special character', () => {
|
||||
it('cuts the word at the special character', () => {
|
||||
expect(wrapWord('aaa\\bbb', 5)).to.deep.equal(['aaa\\', 'bbb']);
|
||||
expect(wrapWord('aaa/bbb', 5)).to.deep.equal(['aaa/', 'bbb']);
|
||||
expect(wrapWord('aaa_bbb', 5)).to.deep.equal(['aaa_', 'bbb']);
|
||||
expect(wrapWord('aaa-bbb', 5)).to.deep.equal(['aaa-', 'bbb']);
|
||||
expect(wrapWord('aaa.bbb', 5)).to.deep.equal(['aaa.', 'bbb']);
|
||||
expect(wrapWord('aaa,bbb', 5)).to.deep.equal(['aaa,', 'bbb']);
|
||||
expect(wrapWord('aaa;bbb', 5)).to.deep.equal(['aaa;', 'bbb']);
|
||||
});
|
||||
});
|
||||
context('a special character after the length of a container', () => {
|
||||
it('does not include special character', () => {
|
||||
expect(wrapWord('aa-bbbbb-cccc', 5)).to.deep.equal(['aa-', 'bbbbb', '-cccc']);
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user