This commit is contained in:
Bxio 2025-04-27 15:36:04 +01:00
parent 08f16b0b65
commit 6e986a0586
18 changed files with 1867 additions and 4 deletions

View File

@ -0,0 +1,2 @@
undefined: undefined
undefined

5
node_modules/.package-lock.json generated vendored
View File

@ -227,6 +227,11 @@
"resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz",
"integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw=="
},
"node_modules/ascii-table": {
"version": "0.0.9",
"resolved": "https://registry.npmjs.org/ascii-table/-/ascii-table-0.0.9.tgz",
"integrity": "sha512-xpkr6sCDIYTPqzvjG8M3ncw1YOTaloWZOyrUmicoEifBEKzQzt+ooUpRpQ/AbOoJfO/p2ZKiyp79qHThzJDulQ=="
},
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",

26
node_modules/ascii-table/.jshintrc generated vendored Normal file
View File

@ -0,0 +1,26 @@
{
"node": true
, "asi": true
, "nonstandard": true
, "strict": false
, "smarttabs": true
, "maxlen": 1800
, "newcap": false
, "expr": true
, "undef": true
, "unused": false
, "onecase": true
, "laxcomma": true
, "laxbreak": true
, "white": false
, "shadow": true
, "proto": true
, "loopfunc": true
, "boss": true
, "validthis": true
, "unused": "vars"
, "globals": {
"describe": false
, "it": false
}
}

34
node_modules/ascii-table/.npmignore generated vendored Normal file
View File

@ -0,0 +1,34 @@
# Numerous always-ignore extensions
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.vi
*~
*.iml
*.ipr
*.iws
# OS or Editor folders
.DS_Store
.cache
.project
.settings
nbproject
thumbs.db
# Logs
.log
.pid
.sock
# Folders to ignore
node_modules
.hg
.svn
publish
.idea
_dev

3
node_modules/ascii-table/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,3 @@
language: node_js
node_js:
- 0.10.13

13
node_modules/ascii-table/Makefile generated vendored Normal file
View File

@ -0,0 +1,13 @@
SHELL := /bin/bash
test:
@mocha -R spec test.js
hint:
@jshint ascii-table.js test.js package.json
# UglifyJS v2
min:
@echo -n ';' > ascii-table.min.js; uglifyjs ascii-table.js -o ascii-table.min.js -c -m;
.PHONY: test hint min

649
node_modules/ascii-table/ascii-table.js generated vendored Normal file
View File

@ -0,0 +1,649 @@
/**
* (c) 2013 Beau Sorensen
* MIT Licensed
* For all details and documentation:
* https://github.com/sorensen/ascii-table
*/
;(function() {
'use strict';
/*!
* Module dependencies
*/
var slice = Array.prototype.slice
, toString = Object.prototype.toString
/**
* AsciiTable constructor
*
* @param {String|Object} title or JSON table
* @param {Object} table options
* - `prefix` - string prefix added to each line on render
* @constructor
* @api public
*/
function AsciiTable(name, options) {
this.options = options || {}
this.reset(name)
}
/*!
* Current library version, should match `package.json`
*/
AsciiTable.VERSION = '0.0.8'
/*!
* Alignment constants
*/
AsciiTable.LEFT = 0
AsciiTable.CENTER = 1
AsciiTable.RIGHT = 2
/*!
* Static methods
*/
/**
* Create a new table instance
*
* @param {String|Object} title or JSON table
* @param {Object} table options
* @api public
*/
AsciiTable.factory = function(name, options) {
return new AsciiTable(name, options)
}
/**
* Align the a string at the given length
*
* @param {Number} direction
* @param {String} string input
* @param {Number} string length
* @param {Number} padding character
* @api public
*/
AsciiTable.align = function(dir, str, len, pad) {
if (dir === AsciiTable.LEFT) return AsciiTable.alignLeft(str, len, pad)
if (dir === AsciiTable.RIGHT) return AsciiTable.alignRight(str, len, pad)
if (dir === AsciiTable.CENTER) return AsciiTable.alignCenter(str, len, pad)
return AsciiTable.alignAuto(str, len, pad)
}
/**
* Left align a string by padding it at a given length
*
* @param {String} str
* @param {Number} string length
* @param {String} padding character (optional, default '')
* @api public
*/
AsciiTable.alignLeft = function(str, len, pad) {
if (!len || len < 0) return ''
if (str === undefined || str === null) str = ''
if (typeof pad === 'undefined') pad = ' '
if (typeof str !== 'string') str = str.toString()
var alen = len + 1 - str.length
if (alen <= 0) return str
return str + Array(len + 1 - str.length).join(pad)
}
/**
* Center align a string by padding it at a given length
*
* @param {String} str
* @param {Number} string length
* @param {String} padding character (optional, default '')
* @api public
*/
AsciiTable.alignCenter = function(str, len, pad) {
if (!len || len < 0) return ''
if (str === undefined || str === null) str = ''
if (typeof pad === 'undefined') pad = ' '
if (typeof str !== 'string') str = str.toString()
var nLen = str.length
, half = Math.floor(len / 2 - nLen / 2)
, odds = Math.abs((nLen % 2) - (len % 2))
, len = str.length
return AsciiTable.alignRight('', half, pad)
+ str
+ AsciiTable.alignLeft('', half + odds, pad)
}
/**
* Right align a string by padding it at a given length
*
* @param {String} str
* @param {Number} string length
* @param {String} padding character (optional, default '')
* @api public
*/
AsciiTable.alignRight = function(str, len, pad) {
if (!len || len < 0) return ''
if (str === undefined || str === null) str = ''
if (typeof pad === 'undefined') pad = ' '
if (typeof str !== 'string') str = str.toString()
var alen = len + 1 - str.length
if (alen <= 0) return str
return Array(len + 1 - str.length).join(pad) + str
}
/**
* Auto align string value based on object type
*
* @param {Any} object to string
* @param {Number} string length
* @param {String} padding character (optional, default '')
* @api public
*/
AsciiTable.alignAuto = function(str, len, pad) {
if (str === undefined || str === null) str = ''
var type = toString.call(str)
pad || (pad = ' ')
len = +len
if (type !== '[object String]') {
str = str.toString()
}
if (str.length < len) {
switch(type) {
case '[object Number]': return AsciiTable.alignRight(str, len, pad)
default: return AsciiTable.alignLeft(str, len, pad)
}
}
return str
}
/**
* Fill an array at a given size with the given value
*
* @param {Number} array size
* @param {Any} fill value
* @return {Array} filled array
* @api public
*/
AsciiTable.arrayFill = function(len, fill) {
var arr = new Array(len)
for (var i = 0; i !== len; i++) {
arr[i] = fill;
}
return arr
}
/*!
* Instance methods
*/
/**
* Reset the table state back to defaults
*
* @param {String|Object} title or JSON table
* @api public
*/
AsciiTable.prototype.reset =
AsciiTable.prototype.clear = function(name) {
this.__name = ''
this.__nameAlign = AsciiTable.CENTER
this.__rows = []
this.__maxCells = 0
this.__aligns = []
this.__colMaxes = []
this.__spacing = 1
this.__heading = null
this.__headingAlign = AsciiTable.CENTER
this.setBorder()
if (toString.call(name) === '[object String]') {
this.__name = name
} else if (toString.call(name) === '[object Object]') {
this.fromJSON(name)
}
return this
}
/**
* Set the table border
*
* @param {String} horizontal edges (optional, default `|`)
* @param {String} vertical edges (optional, default `-`)
* @param {String} top corners (optional, default `.`)
* @param {String} bottom corners (optional, default `'`)
* @api public
*/
AsciiTable.prototype.setBorder = function(edge, fill, top, bottom) {
this.__border = true
if (arguments.length === 1) {
fill = top = bottom = edge
}
this.__edge = edge || '|'
this.__fill = fill || '-'
this.__top = top || '.'
this.__bottom = bottom || "'"
return this
}
/**
* Remove all table borders
*
* @api public
*/
AsciiTable.prototype.removeBorder = function() {
this.__border = false
this.__edge = ' '
this.__fill = ' '
return this
}
/**
* Set the column alignment at a given index
*
* @param {Number} column index
* @param {Number} alignment direction
* @api public
*/
AsciiTable.prototype.setAlign = function(idx, dir) {
this.__aligns[idx] = dir
return this
}
/**
* Set the title of the table
*
* @param {String} title
* @api public
*/
AsciiTable.prototype.setTitle = function(name) {
this.__name = name
return this
}
/**
* Get the title of the table
*
* @return {String} title
* @api public
*/
AsciiTable.prototype.getTitle = function() {
return this.__name
}
/**
* Set table title alignment
*
* @param {Number} direction
* @api public
*/
AsciiTable.prototype.setTitleAlign = function(dir) {
this.__nameAlign = dir
return this
}
/**
* AsciiTable sorting shortcut to sort rows
*
* @param {Function} sorting method
* @api public
*/
AsciiTable.prototype.sort = function(method) {
this.__rows.sort(method)
return this
}
/**
* Sort rows based on sort method for given column
*
* @param {Number} column index
* @param {Function} sorting method
* @api public
*/
AsciiTable.prototype.sortColumn = function(idx, method) {
this.__rows.sort(function(a, b) {
return method(a[idx], b[idx])
})
return this
}
/**
* Set table heading for columns
*
* @api public
*/
AsciiTable.prototype.setHeading = function(row) {
if (arguments.length > 1 || toString.call(row) !== '[object Array]') {
row = slice.call(arguments)
}
this.__heading = row
return this
}
/**
* Get table heading for columns
*
* @return {Array} copy of headings
* @api public
*/
AsciiTable.prototype.getHeading = function() {
return this.__heading.slice()
}
/**
* Set heading alignment
*
* @param {Number} direction
* @api public
*/
AsciiTable.prototype.setHeadingAlign = function(dir) {
this.__headingAlign = dir
return this
}
/**
* Add a row of information to the table
*
* @param {...|Array} argument values in order of columns
* @api public
*/
AsciiTable.prototype.addRow = function(row) {
if (arguments.length > 1 || toString.call(row) !== '[object Array]') {
row = slice.call(arguments)
}
this.__maxCells = Math.max(this.__maxCells, row.length)
this.__rows.push(row)
return this
}
/**
* Get a copy of all rows of the table
*
* @return {Array} copy of rows
* @api public
*/
AsciiTable.prototype.getRows = function() {
return this.__rows.slice().map(function(row) {
return row.slice()
})
}
/**
* Add rows in the format of a row matrix
*
* @param {Array} row matrix
* @api public
*/
AsciiTable.prototype.addRowMatrix = function(rows) {
for (var i = 0; i < rows.length; i++) {
this.addRow(rows[i])
}
return this
}
/**
* Add rows from the given data array, processed by the callback function rowCallback.
*
* @param {Array} data
* @param (Function) rowCallback
* @param (Boolean) asMatrix - controls if the row created by rowCallback should be assigned as row matrix
* @api public
*/
AsciiTable.prototype.addData = function(data, rowCallback, asMatrix) {
if (toString.call(data) !== '[object Array]') {
return this;
}
for (var index = 0, limit = data.length; index < limit; index++) {
var row = rowCallback(data[index]);
if(asMatrix) {
this.addRowMatrix(row);
} else {
this.addRow(row);
}
}
return this
}
/**
* Reset the current row state
*
* @api public
*/
AsciiTable.prototype.clearRows = function() {
this.__rows = []
this.__maxCells = 0
this.__colMaxes = []
return this
}
/**
* Apply an even spaced column justification
*
* @param {Boolean} on / off
* @api public
*/
AsciiTable.prototype.setJustify = function(val) {
arguments.length === 0 && (val = true)
this.__justify = !!val
return this
}
/**
* Convert the current instance to a JSON structure
*
* @return {Object} json representation
* @api public
*/
AsciiTable.prototype.toJSON = function() {
return {
title: this.getTitle()
, heading: this.getHeading()
, rows: this.getRows()
}
}
/**
* Populate the table from a JSON object
*
* @param {Object} json representation
* @api public
*/
AsciiTable.prototype.parse =
AsciiTable.prototype.fromJSON = function(obj) {
return this
.clear()
.setTitle(obj.title)
.setHeading(obj.heading)
.addRowMatrix(obj.rows)
}
/**
* Render the table with the current information
*
* @return {String} formatted table
* @api public
*/
AsciiTable.prototype.render =
AsciiTable.prototype.valueOf =
AsciiTable.prototype.toString = function() {
var self = this
, body = []
, mLen = this.__maxCells
, max = AsciiTable.arrayFill(mLen, 0)
, total = mLen * 3
, rows = this.__rows
, justify
, border = this.__border
, all = this.__heading
? [this.__heading].concat(rows)
: rows
// Calculate max table cell lengths across all rows
for (var i = 0; i < all.length; i++) {
var row = all[i]
for (var k = 0; k < mLen; k++) {
var cell = row[k]
max[k] = Math.max(max[k], cell ? cell.toString().length : 0)
}
}
this.__colMaxes = max
justify = this.__justify ? Math.max.apply(null, max) : 0
// Get
max.forEach(function(x) {
total += justify ? justify : x + self.__spacing
})
justify && (total += max.length)
total -= this.__spacing
// Heading
border && body.push(this._seperator(total - mLen + 1, this.__top))
if (this.__name) {
body.push(this._renderTitle(total - mLen + 1))
border && body.push(this._seperator(total - mLen + 1))
}
if (this.__heading) {
body.push(this._renderRow(this.__heading, ' ', this.__headingAlign))
body.push(this._rowSeperator(mLen, this.__fill))
}
for (var i = 0; i < this.__rows.length; i++) {
body.push(this._renderRow(this.__rows[i], ' '))
}
border && body.push(this._seperator(total - mLen + 1, this.__bottom))
var prefix = this.options.prefix || ''
return prefix + body.join('\n' + prefix)
}
/**
* Create a line seperator
*
* @param {Number} string size
* @param {String} side values (default '|')
* @api private
*/
AsciiTable.prototype._seperator = function(len, sep) {
sep || (sep = this.__edge)
return sep + AsciiTable.alignRight(sep, len, this.__fill)
}
/**
* Create a row seperator
*
* @return {String} seperator
* @api private
*/
AsciiTable.prototype._rowSeperator = function() {
var blanks = AsciiTable.arrayFill(this.__maxCells, this.__fill)
return this._renderRow(blanks, this.__fill)
}
/**
* Render the table title in a centered box
*
* @param {Number} string size
* @return {String} formatted title
* @api private
*/
AsciiTable.prototype._renderTitle = function(len) {
var name = ' ' + this.__name + ' '
, str = AsciiTable.align(this.__nameAlign, name, len - 1, ' ')
return this.__edge + str + this.__edge
}
/**
* Render an invdividual row
*
* @param {Array} row
* @param {String} column seperator
* @param {Number} total row alignment (optional, default `auto`)
* @return {String} formatted row
* @api private
*/
AsciiTable.prototype._renderRow = function(row, str, align) {
var tmp = ['']
, max = this.__colMaxes
for (var k = 0; k < this.__maxCells; k++) {
var cell = row[k]
, just = this.__justify ? Math.max.apply(null, max) : max[k]
// , pad = k === this.__maxCells - 1 ? just : just + this.__spacing
, pad = just
, cAlign = this.__aligns[k]
, use = align
, method = 'alignAuto'
if (typeof align === 'undefined') use = cAlign
if (use === AsciiTable.LEFT) method = 'alignLeft'
if (use === AsciiTable.CENTER) method = 'alignCenter'
if (use === AsciiTable.RIGHT) method = 'alignRight'
tmp.push(AsciiTable[method](cell, pad, str))
}
var front = tmp.join(str + this.__edge + str)
front = front.substr(1, front.length)
return front + str + this.__edge
}
/*!
* Aliases
*/
// Create method shortcuts to all alignment methods for each direction
;['Left', 'Right', 'Center'].forEach(function(dir) {
var constant = AsciiTable[dir.toUpperCase()]
;['setAlign', 'setTitleAlign', 'setHeadingAlign'].forEach(function(method) {
// Call the base method with the direction constant as the last argument
AsciiTable.prototype[method + dir] = function() {
var args = slice.call(arguments).concat(constant)
return this[method].apply(this, args)
}
})
})
/*!
* Module exports.
*/
if (typeof exports !== 'undefined') {
module.exports = AsciiTable
} else {
this.AsciiTable = AsciiTable
}
}).call(this);

1
node_modules/ascii-table/ascii-table.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

23
node_modules/ascii-table/bower.json generated vendored Normal file
View File

@ -0,0 +1,23 @@
{
"name": "ascii-table",
"main": "ascii-table.js",
"version": "0.0.8",
"homepage": "https://github.com/sorensen/ascii-table",
"authors": [
"Beau Sorensen <mail@beausorensen.com>"
],
"description": "Easy tables for your console data",
"keywords": [
"table",
"ascii",
"console"
],
"license": "MIT",
"ignore": [
"**/.*",
"Makefile",
"test.js",
"index.js",
"package.json"
]
}

1
node_modules/ascii-table/example/simple.js generated vendored Normal file
View File

@ -0,0 +1 @@

1
node_modules/ascii-table/example/simple.txt generated vendored Normal file
View File

@ -0,0 +1 @@

1
node_modules/ascii-table/index.js generated vendored Normal file
View File

@ -0,0 +1 @@
module.exports = require('./ascii-table')

22
node_modules/ascii-table/license generated vendored Normal file
View File

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

34
node_modules/ascii-table/package.json generated vendored Normal file
View File

@ -0,0 +1,34 @@
{
"name": "ascii-table"
, "version": "0.0.9"
, "license": "MIT"
, "keywords": [
"table"
, "ascii"
, "console"
]
, "contributors": [
{
"name": "Matthew Oliveira"
, "github": "https://github.com/m4olivei"
}
, {
"name": "Peter Daum"
, "github": "https://github.com/coders-kitchen"
}
]
, "author": "Beau Sorensen <mail@beausorensen.com> (http://github.com/sorensen)"
, "description": "Easy tables for your console data"
, "repository": {
"type": "git"
, "url": "git://github.com/sorensen/ascii-table.git"
}
, "main": "index.js"
, "scripts": {
"test": "make test"
}
, "devDependencies": {
"mocha": "*"
}
, "dependencies": {}
}

655
node_modules/ascii-table/readme.md generated vendored Normal file
View File

@ -0,0 +1,655 @@
Ascii Table
===========
[![Build Status](https://secure.travis-ci.org/sorensen/ascii-table.png)](http://travis-ci.org/sorensen/ascii-table)
[![devDependency Status](https://david-dm.org/sorensen/ascii-table.png)](https://david-dm.org/sorensen/ascii-table#info=dependencies)
[![NPM version](https://badge.fury.io/js/ascii-table.png)](http://badge.fury.io/js/ascii-table)
Easy table output for node debugging, but you could probably do more with it,
since its just a string.
Table of Contents
-----------------
* [Usage](#usage)
* [Example](#usage)
* [API](#api)
- [Static Methods](#static-methods)
* [factory([title])](#asciitablefactorytitle)
* [align(direction, val, len, [pad])](#asciitablealigndirection-val-len-pad)
* [alignLeft(val, len, [pad])](#asciitablealignleftval-len-pad)
* [alignCenter(val, len, [pad])](#asciitablealigncenterval-len-pad)
* [alignRight(val, len, [pad])](#asciitablealignrightval-len-pad)
* [alignAuto(val, len, [pad])](#asciitablealignautoval-len-pad)
* [arrayFill(len, [val])](#asciitablearrayfilllen-val)
- [Instance Methods](#instance-methods)
* [setBorder([edge], [fill], [top], [bottom])](#instancesetborderedge-fill-top-bottom)
* [removeBorder()](#instanceremoveborder)
* [setAlign(idx, direction)](#instancesetalignidx-direction)
* [setAlignLeft(idx)](#instancesetalignleftidx)
* [setAlignCenter(idx)](#instancesetaligncenteridx)
* [setAlignRight(idx)](#instancesetalignrightidx)
* [setTitle(title)](#instancesettitletitle)
* [getTitle()](#instancegettitle)
* [setTitleAlign(direction)](#instancesettitlealigndirection)
* [setTitleAlignLeft()](#instancesettitlealignleft)
* [setTitleAlignCenter()](#instancesettitlealigncenter)
* [setTitleAlignRight()](#instancesettitlealignright)
* [sort([iterator])](#instancesortiterator)
* [sortColumn(idx, [iterator])](#instancesortcolumnidx-iterator)
* [setHeading(heading, [...])](#instancesetheadingheading)
* [setHeadingAlign(direction)](#instancesetheadingaligndirection)
* [setHeadingAlignLeft()](#instancesetheadingalignleft)
* [setHeadingAlignCenter()](#instancesetheadingaligncenter)
* [setHeadingAlignRight()](#instancesetheadingalignright)
* [addRow(row, [...])](#instanceaddrowrow)
* [addRowMatrix(rows)](#instanceaddrowmatrixrows)
* [setJustify([enabled])](#instancesetjustifyenabled)
* [toString()](#instancetostring)
* [toJSON()](#instancetojson)
* [fromJSON(obj)](#instancefromjsonobj)
* [clear()](#instanceclear)
* [clearRows()](#instanceclearrows)
* [Install](#install)
* [Contributors](#contributors)
* [License](#license)
Usage
-----
Node.js
```js
var AsciiTable = require('ascii-table')
```
Browser
```html
<script src="ascii-table.min.js"></script>
```
*Note*: If using in the browser, it will be placed under `window.AsciiTable`
Example
-------
Basic usage
```js
var table = new AsciiTable('A Title')
table
.setHeading('', 'Name', 'Age')
.addRow(1, 'Bob', 52)
.addRow(2, 'John', 34)
.addRow(3, 'Jim', 83)
console.log(table.toString())
```
```
.----------------.
| A Title |
|----------------|
| | Name | Age |
|---|------|-----|
| 1 | Bob | 52 |
| 2 | John | 34 |
| 3 | Jim | 83 |
'----------------'
```
We can make a simple table without a title or headings as well.
```js
var table = new AsciiTable()
table
.addRow('a', 'apple', 'Some longer string')
.addRow('b', 'banana', 'hi')
.addRow('c', 'carrot', 'meow')
.addRow('e', 'elephants')
console.log(table.toString())
```
```
.------------------------------------.
| a | apple | Some longer string |
| b | banana | hi |
| c | carrot | meow |
| e | elephants | |
'------------------------------------'
```
API
---
### Static Methods
#### AsciiTable
See: `AsciiTable.factory` for details on instantiation
#### AsciiTable.factory([title], [options])
Table instance creator
* `title` - table title (optional, default `null`)
* `options` - table options (optional)
- `prefix` - string prefix to add to each line on render
***Note:*** If an object is passed in place of the `title`, the `fromJSON`
method will be used to populate the table.
Example:
```js
var table = AsciiTable.factory('title')
var table = AsciiTable.factory({
title: 'Title'
, heading: [ 'id', 'name' ]
, rows: [
[ 1, 'Bob' ]
, [ 2, 'Steve' ]
]
})
```
#### AsciiTable.align(direction, val, len, [pad])
Shortcut to one of the three following methods
* `direction` - alignment direction (`AsciiTable.LEFT`, `AsciiTable.CENTER`, `AsciiTable.RIGHT`)
* `val` - string to align
* `len` - total length of created string
* `pad` - padding / fill char (optional, default `' '`)
Example:
```js
table.align(AsciiTable.LEFT, 'hey', 7) // 'hey '
```
#### AsciiTable.alignLeft(val, len, [pad])
* `val` - string to align
* `len` - total length of created string
* `pad` - padding / fill char (optional, default `' '`)
Example:
```js
table.alignLeft('hey', 7, '-') // 'hey----'
```
#### AsciiTable.alignCenter(val, len, [pad])
* `val` - string to align
* `len` - total length of created string
* `pad` - padding / fill char (optional, default `' '`)
Example:
```js
table.alignCenter('hey', 7) // ' hey '
```
#### AsciiTable.alignRight(val, len, [pad])
* `val` - string to align
* `len` - total length of created string
* `pad` - padding / fill char (optional, default `' '`)
Example:
```js
table.alignRight('hey', 7) // ' hey'
```
#### AsciiTable.alignAuto(val, len, [pad])
Attempt to do intelligent alignment of provided `val`, `String` input will
be left aligned, `Number` types will be right aligned.
* `val` - string to align
* `len` - total length of created string
* `pad` - padding / fill char (optional, default `' '`)
Example:
```js
table.align(AsciiTable.LEFT, 'hey', 7) // 'hey '
```
#### AsciiTable.arrayFill(len, [val])
Create a new array at the given len, filled with the given value, mainly used internally
* `len` - length of array
* `val` - fill value (optional)
Example:
```js
AsciiTable.arrayFill(4, 0) // [0, 0, 0, 0]
```
### Instance Methods
#### instance.setBorder([edge], [fill], [top], [bottom])
Set the border characters for rendering, if no arguments are passed it will be
reset to defaults. If a single `edge` arg is passed, it will be used for all borders.
* `edge` - horizontal edges (optional, default `|`)
* `fill` - vertical edges (optional, default `-`)
* `top` - top corners (optional, default `.`)
* `bottom` - bottom corners (optional, default `'`)
Example:
```js
var table = new AsciiTable('Stars')
table
.setBorder('*')
.setHeading('oh', 'look')
.addRow('so much', 'star power')
console.log(table.toString())
```
```
************************
* Stars *
************************
* oh * look *
************************
* so much * star power *
************************
```
#### instance.removeBorder()
Example:
```js
table.removeBorder()
console.log('' + table)
```
```
# Fruit Thing
--- ----------- --------------------
a apple Some longer string
b banana hi
c carrot meow
e elephants
```
#### instance.setAlign(idx, direction)
* `idx` - column index to align
* `direction` - alignment direction, (`AsciiTable.LEFT`, `AsciiTable.CENTER`, `AsciiTable.RIGHT`)
Example:
```js
table
.setAlign(2, AsciiTable.RIGHT)
.setAlign(1, AsciiTable.CENTER)
console.log(table.toString())
```
```
.-------------------------------------.
| a | apple | Some longer string |
| b | banana | hi |
| c | carrot | meow |
| e | elephants | |
'-------------------------------------'
```
#### instance.setAlignLeft(idx)
Alias to `instance.setAlign(idx, AsciiTable.LEFT)`
#### instance.setAlignCenter(idx)
Alias to `instance.setAlign(idx, AsciiTable.CENTER)`
#### instance.setAlignRight(idx)
Alias to `instance.setAlign(idx, AsciiTable.RIGHT)`
#### instance.setTitle(title)
* `title` - table title
Example:
```js
var table = new AsciiTable('Old Title')
table.setTitle('New Title')
```
#### instance.getTitle()
Get the current title of the table
Example:
```js
table.getTitle() // 'New Title'
```
#### instance.setTitleAlign(direction)
* `direction` - table alignment direction
Example:
```js
```
#### instance.setTitleAlignLeft()
Alias to `instance.setTitleAlign(AsciiTable.LEFT)`
#### instance.setTitleAlignCenter()
Alias to `instance.setTitleAlign(AsciiTable.CENTER)`
#### instance.setTitleAlignRight()
Alias to `instance.setTitleAlign(AsciiTable.RIGHT)`
#### instance.sort(iterator)
* `iterator` - sorting method to run against the rows
Example:
```js
table.sort(function(a, b) {
return a[2] - b[2]
})
console.log(table.toString())
```
```
.----------------.
| 2 | John | 34 |
| 1 | Bob | 52 |
| 3 | Jim | 83 |
'----------------'
```
#### instance.sortColumn(index, iterator)
Sorting shortcut for targeting a specific column
* `index` - column idx to sort
* `iterator` - sorting method to run against column values
Example:
```js
// This is quivalent to the `sort` example above
table.sortColumn(2, function(a, b) {
return a - b
})
```
#### instance.setHeading(heading, [...])
Set the column headings for the table, takes arguments the same way as `addRow`
* `heading` - heading array or arguments
Example:
```js
table.setHeading('ID', 'Key', 'Value')
// or:
table.setHeading(['ID', 'Key', 'Value'])
```
#### instance.setHeadingAlign(direction)
* `direction` -
Example:
```js
```
#### instance.setHeadingAlignLeft()
Alias to `instance.setHeadingAlignLeft(AsciiTable.LEFT)`
#### instance.setHeadingAlignCenter()
Alias to `instance.setHeadingAlignLeft(AsciiTable.CENTER)`
#### instance.setHeadingAlignRight()
Alias to `instance.setHeadingAlignLeft(AsciiTable.RIGHT)`
#### instance.addRow(row, [...])
Rows can be added using a single array argument, or the arguments if multiple
args are used when calling the method.
* `row` - array or arguments of column values
Example:
```js
var table = new AsciiTable()
table
.addRow(1, 'Bob', 52)
.addRow([2, 'John', 34])
console.log(table.render())
```
```
.---------------.
| 1 | Bob | 52 |
| 2 | John | 34 |
'---------------'
```
#### instance.addRowMatrix(rows)
Bulk `addRow` operation
* `rows` - multidimentional array of rows
Example:
```js
table.addRowMatrix([
[2, 'John', 34]
, [3, 'Jim', 83]
])
```
#### instance.setJustify(enabled)
Justify all columns to be the same width
* `enabled` - boolean for turning justify on or off, `undefined` considered true
Example:
```js
table
.addRow('1', 'two', 'three')
.setJustify()
console.log(table.toString())
```
```
.-----------------------.
| 1 | two | three |
'-----------------------'
```
#### instance.toString()
Render the instance as a string for output
**Alias**: [`valueOf`, `render`]
#### instance.toJSON()
Return the JSON representation of the table, this also allows us to call
`JSON.stringify` on the instance.
Example:
```js
var table = new AsciiTable('Title')
table
.setHeading('id', 'name')
.addRow(1, 'Bob')
.addRow(2, 'Steve')
console.log(table.toJSON())
console.log(JSON.stringify(table))
```
```js
{
title: 'Title'
, heading: [ 'id', 'name' ]
, rows: [
[ 1, 'Bob' ]
, [ 2, 'Steve' ]
]
}
```
```
{"title":"Title","heading":["id","name"],"rows":[[1,"Bob"],[2,"Steve"]]}
```
#### instance.fromJSON(obj)
Populate the table from json object, should match the `toJSON` output above.
**Alias**: [`parse`]
Example:
```js
var table = new AsciiTable().fromJSON({
title: 'Title'
, heading: [ 'id', 'name' ]
, rows: [
[ 1, 'Bob' ]
, [ 2, 'Steve' ]
]
})
```
#### instance.clear()
Clear / reset all table data
**Alias**: [`reset`]
#### instance.clearRows()
Reset all row data, maintains title and headings.
Install
-------
With [npm](https://npmjs.org)
```
npm install ascii-table
```
Contributors
------------
[Matthew Oliveira](https://github.com/m4olivei)
[Peter Daum](https://github.com/coders-kitchen)
License
-------
(The MIT License)
Copyright (c) 2013 Beau Sorensen
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

388
node_modules/ascii-table/test.js generated vendored Normal file
View File

@ -0,0 +1,388 @@
'use strict';
var assert = require('assert')
, ase = assert.strictEqual
, ade = assert.deepEqual
, AsciiTable = require('./index')
, info = require('./package.json')
describe('Ascii Table v' + info.version, function() {
describe('Examples', function() {
it('default', function() {
var table = new AsciiTable('A Title')
table
.setHeading('', 'Name', 'Age')
.addRow(1, 'Bob', 52)
.addRow(2, 'John', 34)
.addRow(3, 'Jim', 0)
var output = ''
+ '.----------------.'
+ '\n' + '| A Title |'
+ '\n' + '|----------------|'
+ '\n' + '| | Name | Age |'
+ '\n' + '|---|------|-----|'
+ '\n' + '| 1 | Bob | 52 |'
+ '\n' + '| 2 | John | 34 |'
+ '\n' + '| 3 | Jim | 0 |'
+ '\n' + "'----------------'"
var table2 = new AsciiTable('A Title')
, headings = ['', 'Name', 'Age']
, row = [1, 'Bob', 52]
var matrix = [
[2, 'John', 34]
, [3, 'Jim', 0]
]
table2
.setHeading(headings)
.addRow(row)
.addRowMatrix(matrix)
ase(table.toString(), output)
ase(table2.toString(), output)
})
it('dataObjects', function() {
var defaultOutput = ''
+ '.----------------.'
+ '\n' + '| A Title |'
+ '\n' + '|----------------|'
+ '\n' + '| | Name | Age |'
+ '\n' + '|---|------|-----|'
+ '\n' + '| 1 | Bob | 52 |'
+ '\n' + '| 2 | John | 34 |'
+ '\n' + '| 3 | Jim | 83 |'
+ '\n' + "'----------------'"
var matrixOutput = ''
+ '.----------------.'
+ '\n' + '| A Title |'
+ '\n' + '|----------------|'
+ '\n' + '| | Name | Age |'
+ '\n' + '|---|------|-----|'
+ '\n' + '| 1 | Bob | 52 |'
+ '\n' + '| 2 | John | 34 |'
+ '\n' + '| | | 83 |'
+ '\n' + "'----------------'"
var arrayData = [
{index: 2, name: 'John', age: 34, secondAge: 83}
, {index: 3, name: 'Jim', age: 83}
]
var table = new AsciiTable('A Title')
, headings = ['', 'Name', 'Age']
, row = [1, 'Bob', 52]
table
.setHeading(headings)
.addRow(row)
.addData(arrayData, function(data) {return [data.index, data.name, data.age]})
var table2 = new AsciiTable('A Title')
table2
.setHeading(headings)
.addRow(row)
.addData([{index: 2, name: 'John', age: 34, secondAge: 83}], function(data) {return [[data.index, data.name, data.age], ["", "", data.secondAge]]}, true)
ase(table.toString(), defaultOutput)
ase(table2.toString(), matrixOutput)
})
it('prefixed', function() {
var table = new AsciiTable('A Title', {
prefix: ' '
})
table
.setHeading('', 'Name', 'Age')
.addRow(1, 'Bob', 52)
.addRow(2, 'John', 34)
.addRow(3, 'Jim', 83)
var output = ''
+ ' .----------------.'
+ '\n' + ' | A Title |'
+ '\n' + ' |----------------|'
+ '\n' + ' | | Name | Age |'
+ '\n' + ' |---|------|-----|'
+ '\n' + ' | 1 | Bob | 52 |'
+ '\n' + ' | 2 | John | 34 |'
+ '\n' + ' | 3 | Jim | 83 |'
+ '\n' + " '----------------'"
ase(table.toString(), output)
})
it('all', function() {
var table = new AsciiTable('Something')
table
.setBorder()
.removeBorder()
.setAlign(0, AsciiTable.CENTER)
.setAlignLeft(1)
.setAlignCenter(1)
.setAlignRight(1)
.setTitle('Hi')
.setTitleAlign(AsciiTable.LEFT)
.setTitleAlignLeft(1)
.setTitleAlignCenter(1)
.setTitleAlignRight(1)
.setHeading('one', 'two', 'three')
.setHeading(['one', 'two', 'three'])
.setHeadingAlign(0, AsciiTable.CENTER)
.setHeadingAlignLeft(1)
.setHeadingAlignCenter(1)
.setHeadingAlignRight(1)
.addRow(1, 2, 3)
.addRow([4, 5, 6])
.addRowMatrix([
[7, 8, 9]
, [10, 11, 12]
])
.setJustify()
.setJustify(false)
.sort(function(a, b) { return a })
.sortColumn(1, function(a, b) { return a })
table.toJSON()
table.toString()
table.valueOf()
table.render()
})
it('alignment', function() {
var table = new AsciiTable()
table
.setTitle('Something')
.setTitleAlign(AsciiTable.LEFT)
.setHeading('', 'Name', 'Age')
.setHeadingAlign(AsciiTable.RIGHT)
.setAlignCenter(0)
.setAlign(2, AsciiTable.RIGHT)
.addRow('a', 'apple', 'Some longer string')
.addRow('b', 'banana', 'hi')
.addRow('c', 'carrot', 'meow')
.addRow('efg', 'elephants')
var str = ""
+ ".--------------------------------------."
+ "\n" + "| Something |"
+ "\n" + "|--------------------------------------|"
+ "\n" + "| | Name | Age |"
+ "\n" + "|-----|-----------|--------------------|"
+ "\n" + "| a | apple | Some longer string |"
+ "\n" + "| b | banana | hi |"
+ "\n" + "| c | carrot | meow |"
+ "\n" + "| efg | elephants | |"
+ "\n" + "'--------------------------------------'"
ase(str, table.toString())
})
})
describe('Static methods', function() {
it('#version', function() {
ase(info.version, AsciiTable.VERSION)
ase(info.version, require('./ascii-table.min').VERSION)
ase(info.version, require('./bower.json').version)
})
it('#align', function() {
ase(AsciiTable.align(AsciiTable.LEFT, 'a', 10), AsciiTable.alignLeft('a', 10))
ase(AsciiTable.align(AsciiTable.CENTER, 'a', 10), AsciiTable.alignCenter('a', 10))
ase(AsciiTable.align(AsciiTable.RIGHT, 'a', 10), AsciiTable.alignRight('a', 10))
})
it('#alignLeft', function() {
var str = AsciiTable.alignLeft('foo', 30)
ase(str, 'foo ')
var str = AsciiTable.alignLeft(null, 30)
ase(str, ' ')
var str = AsciiTable.alignLeft('bar', 10, '-')
ase(str, 'bar-------')
var str = AsciiTable.alignLeft('meow', 1, '-')
ase(str, 'meow')
})
it('#alignRight', function() {
var str = AsciiTable.alignRight('foo', 30)
ase(str, ' foo')
var str = AsciiTable.alignRight(null, 30)
ase(str, ' ')
var str = AsciiTable.alignRight('bar', 10, '-')
ase(str, '-------bar')
var str = AsciiTable.alignRight('meow', 1, '-')
ase(str, 'meow')
})
it('#alignCenter', function() {
var str = AsciiTable.alignCenter('foo', 30)
ase(str, ' foo ')
var str = AsciiTable.alignCenter(null, 30)
ase(str, ' ')
var str = AsciiTable.alignCenter('bar', 10, '-')
ase(str, '---bar----')
var str = AsciiTable.alignCenter('bars', 10, '-')
ase(str, '---bars---')
var str = AsciiTable.alignCenter('bar', 11, '-')
ase(str, '----bar----')
})
it('#alignAuto', function() {
})
it('#arrayFill', function() {
var arr = AsciiTable.arrayFill(10, '-')
ase(arr.length, 10)
ase(arr[0], '-')
})
it('#factory', function() {
var table = AsciiTable.factory('title')
ase(table instanceof AsciiTable, true)
ase(table.getTitle(), 'title')
})
it('#factory with object', function() {
var obj = {
title: 'foo',
heading: ['id', 'name'],
rows: [
[1, 'bob'],
[2, 'jim']
]
}
var table = AsciiTable.factory(obj)
ase(table instanceof AsciiTable, true)
ase(table.getTitle(), 'foo')
})
})
describe('Instance methods', function() {
it('#setBorder', function() {
var table = new AsciiTable('a')
table
.setBorder('*')
.setHeading('one', 'two')
.addRow('abc', 'def')
var str = ''
+ '*************'
+ '\n' + '* a *'
+ '\n' + '*************'
+ '\n' + '* one * two *'
+ '\n' + '*************'
+ '\n' + '* abc * def *'
+ '\n' + '*************'
ase(str, table.toString())
})
it('#removeBorder', function() {
})
it('#setAlign', function() {
})
it('#setAlignLeft', function() {
})
it('#setAlignCenter', function() {
})
it('#setAlignRight', function() {
})
it('#setTitle', function() {
var table = new AsciiTable('meow')
ase(table.getTitle(), 'meow')
table.setTitle('bark')
ase(table.getTitle(), 'bark')
})
it('#sort', function() {
})
it('#sortColumn', function() {
})
it('#setHeading', function() {
})
it('#addRow', function() {
})
it('#setJustify', function() {
})
it('#toString', function() {
})
it('#toJSON', function() {
var table = new AsciiTable('cat')
table
.setHeading('one', 'two', 'three')
.addRow(1, 2, 3)
.addRow(4, 5, 6)
var output = {
title: 'cat'
, heading: ['one', 'two', 'three']
, rows: [
[1, 2, 3]
, [4, 5, 6]
]
}
var js = table.toJSON()
ade(js, output)
js.heading[0] = 'test'
ase(table.getHeading()[0], 'one')
js.rows[0][0] = 'test'
ase(table.getRows()[0][0], 1)
})
it('#clear', function() {
})
it('#clearRows', function() {
})
})
})

9
package-lock.json generated
View File

@ -7,6 +7,7 @@
"name": "arisu",
"dependencies": {
"@clack/prompts": "^0.10.0",
"ascii-table": "^0.0.9",
"axios": "^1.8.4",
"chalk": "^4.1.2",
"chokidar": "^4.0.3",
@ -16,8 +17,7 @@
"multer": "^1.4.5-lts.2",
"mysql2": "^3.14.0",
"set-interval-async": "^3.0.3",
"typescript": "^4.5.2",
"ascii-table": "^0.0.9"
"typescript": "^4.5.2"
},
"devDependencies": {
"@types/node": "^22.14.0"
@ -247,6 +247,11 @@
"resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz",
"integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw=="
},
"node_modules/ascii-table": {
"version": "0.0.9",
"resolved": "https://registry.npmjs.org/ascii-table/-/ascii-table-0.0.9.tgz",
"integrity": "sha512-xpkr6sCDIYTPqzvjG8M3ncw1YOTaloWZOyrUmicoEifBEKzQzt+ooUpRpQ/AbOoJfO/p2ZKiyp79qHThzJDulQ=="
},
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",

View File

@ -7,6 +7,7 @@
},
"dependencies": {
"@clack/prompts": "^0.10.0",
"ascii-table": "^0.0.9",
"axios": "^1.8.4",
"chalk": "^4.1.2",
"chokidar": "^4.0.3",
@ -16,8 +17,7 @@
"multer": "^1.4.5-lts.2",
"mysql2": "^3.14.0",
"set-interval-async": "^3.0.3",
"typescript": "^4.5.2",
"ascii-table": "^0.0.9"
"typescript": "^4.5.2"
},
"devDependencies": {
"@types/node": "^22.14.0"