Gathering detailed insights and metrics for ascii-table
Gathering detailed insights and metrics for ascii-table
Gathering detailed insights and metrics for ascii-table
Gathering detailed insights and metrics for ascii-table
npm install ascii-table
Typescript
Module System
Node Version
NPM Version
100
Supply Chain
99.1
Quality
75.4
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
182 Stars
39 Commits
31 Forks
8 Watchers
2 Branches
5 Contributors
Updated on Jun 20, 2025
Latest Version
0.0.9
Package Id
ascii-table@0.0.9
Size
11.86 kB
NPM Version
2.14.12
Node Version
4.2.4
Published on
Apr 11, 2016
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
Easy table output for node debugging, but you could probably do more with it, since its just a string.
Node.js
1var AsciiTable = require('ascii-table')
Browser
1<script src="ascii-table.min.js"></script>
Note: If using in the browser, it will be placed under window.AsciiTable
Basic usage
1var table = new AsciiTable('A Title') 2table 3 .setHeading('', 'Name', 'Age') 4 .addRow(1, 'Bob', 52) 5 .addRow(2, 'John', 34) 6 .addRow(3, 'Jim', 83) 7 8console.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.
1var table = new AsciiTable() 2 3table 4 .addRow('a', 'apple', 'Some longer string') 5 .addRow('b', 'banana', 'hi') 6 .addRow('c', 'carrot', 'meow') 7 .addRow('e', 'elephants') 8 9 10console.log(table.toString())
.------------------------------------.
| a | apple | Some longer string |
| b | banana | hi |
| c | carrot | meow |
| e | elephants | |
'------------------------------------'
See: AsciiTable.factory
for details on instantiation
Table instance creator
title
- table title (optional, default null
)options
- table options (optional)
prefix
- string prefix to add to each line on renderNote: If an object is passed in place of the title
, the fromJSON
method will be used to populate the table.
Example:
1var table = AsciiTable.factory('title') 2 3var table = AsciiTable.factory({ 4 title: 'Title' 5, heading: [ 'id', 'name' ] 6, rows: [ 7 [ 1, 'Bob' ] 8 , [ 2, 'Steve' ] 9 ] 10})
Shortcut to one of the three following methods
direction
- alignment direction (AsciiTable.LEFT
, AsciiTable.CENTER
, AsciiTable.RIGHT
)val
- string to alignlen
- total length of created stringpad
- padding / fill char (optional, default ' '
)Example:
1table.align(AsciiTable.LEFT, 'hey', 7) // 'hey '
val
- string to alignlen
- total length of created stringpad
- padding / fill char (optional, default ' '
)Example:
1table.alignLeft('hey', 7, '-') // 'hey----'
val
- string to alignlen
- total length of created stringpad
- padding / fill char (optional, default ' '
)Example:
1table.alignCenter('hey', 7) // ' hey '
val
- string to alignlen
- total length of created stringpad
- padding / fill char (optional, default ' '
)Example:
1table.alignRight('hey', 7) // ' hey'
Attempt to do intelligent alignment of provided val
, String
input will
be left aligned, Number
types will be right aligned.
val
- string to alignlen
- total length of created stringpad
- padding / fill char (optional, default ' '
)Example:
1table.align(AsciiTable.LEFT, 'hey', 7) // 'hey '
Create a new array at the given len, filled with the given value, mainly used internally
len
- length of arrayval
- fill value (optional)Example:
1AsciiTable.arrayFill(4, 0) // [0, 0, 0, 0]
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:
1var table = new AsciiTable('Stars') 2table 3 .setBorder('*') 4 .setHeading('oh', 'look') 5 .addRow('so much', 'star power') 6 7console.log(table.toString())
************************
* Stars *
************************
* oh * look *
************************
* so much * star power *
************************
Example:
1table.removeBorder() 2 3console.log('' + table)
# Fruit Thing
--- ----------- --------------------
a apple Some longer string
b banana hi
c carrot meow
e elephants
idx
- column index to aligndirection
- alignment direction, (AsciiTable.LEFT
, AsciiTable.CENTER
, AsciiTable.RIGHT
)Example:
1table 2 .setAlign(2, AsciiTable.RIGHT) 3 .setAlign(1, AsciiTable.CENTER) 4 5console.log(table.toString())
.-------------------------------------.
| a | apple | Some longer string |
| b | banana | hi |
| c | carrot | meow |
| e | elephants | |
'-------------------------------------'
Alias to instance.setAlign(idx, AsciiTable.LEFT)
Alias to instance.setAlign(idx, AsciiTable.CENTER)
Alias to instance.setAlign(idx, AsciiTable.RIGHT)
title
- table titleExample:
1var table = new AsciiTable('Old Title') 2 3table.setTitle('New Title')
Get the current title of the table
Example:
1table.getTitle() // 'New Title'
direction
- table alignment directionExample:
1undefined
Alias to instance.setTitleAlign(AsciiTable.LEFT)
Alias to instance.setTitleAlign(AsciiTable.CENTER)
Alias to instance.setTitleAlign(AsciiTable.RIGHT)
iterator
- sorting method to run against the rowsExample:
1table.sort(function(a, b) { 2 return a[2] - b[2] 3}) 4console.log(table.toString())
.----------------.
| 2 | John | 34 |
| 1 | Bob | 52 |
| 3 | Jim | 83 |
'----------------'
Sorting shortcut for targeting a specific column
index
- column idx to sortiterator
- sorting method to run against column valuesExample:
1// This is quivalent to the `sort` example above 2table.sortColumn(2, function(a, b) { 3 return a - b 4})
Set the column headings for the table, takes arguments the same way as addRow
heading
- heading array or argumentsExample:
1table.setHeading('ID', 'Key', 'Value') 2 3// or: 4 5table.setHeading(['ID', 'Key', 'Value'])
direction
-Example:
1undefined
Alias to instance.setHeadingAlignLeft(AsciiTable.LEFT)
Alias to instance.setHeadingAlignLeft(AsciiTable.CENTER)
Alias to instance.setHeadingAlignLeft(AsciiTable.RIGHT)
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 valuesExample:
1var table = new AsciiTable() 2 3table 4 .addRow(1, 'Bob', 52) 5 .addRow([2, 'John', 34]) 6 7console.log(table.render())
.---------------.
| 1 | Bob | 52 |
| 2 | John | 34 |
'---------------'
Bulk addRow
operation
rows
- multidimentional array of rowsExample:
1table.addRowMatrix([ 2 [2, 'John', 34] 3, [3, 'Jim', 83] 4]) 5
Justify all columns to be the same width
enabled
- boolean for turning justify on or off, undefined
considered trueExample:
1table 2 .addRow('1', 'two', 'three') 3 .setJustify() 4 5console.log(table.toString())
.-----------------------.
| 1 | two | three |
'-----------------------'
Render the instance as a string for output
Alias: [valueOf
, render
]
Return the JSON representation of the table, this also allows us to call
JSON.stringify
on the instance.
Example:
1var table = new AsciiTable('Title') 2 3table 4 .setHeading('id', 'name') 5 .addRow(1, 'Bob') 6 .addRow(2, 'Steve') 7 8console.log(table.toJSON()) 9console.log(JSON.stringify(table))
1{ 2 title: 'Title' 3, heading: [ 'id', 'name' ] 4, rows: [ 5 [ 1, 'Bob' ] 6 , [ 2, 'Steve' ] 7 ] 8}
{"title":"Title","heading":["id","name"],"rows":[[1,"Bob"],[2,"Steve"]]}
Populate the table from json object, should match the toJSON
output above.
Alias: [parse
]
Example:
1var table = new AsciiTable().fromJSON({ 2 title: 'Title' 3, heading: [ 'id', 'name' ] 4, rows: [ 5 [ 1, 'Bob' ] 6 , [ 2, 'Steve' ] 7 ] 8})
Clear / reset all table data
Alias: [reset
]
Reset all row data, maintains title and headings.
With npm
npm install ascii-table
(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.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 4/25 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More