Gathering detailed insights and metrics for easy-table
Gathering detailed insights and metrics for easy-table
Gathering detailed insights and metrics for easy-table
Gathering detailed insights and metrics for easy-table
npm install easy-table
Typescript
Module System
Node Version
NPM Version
99.6
Supply Chain
99.5
Quality
75.3
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
316 Stars
68 Commits
27 Forks
10 Watchers
2 Branches
7 Contributors
Updated on Jul 09, 2025
Latest Version
1.2.0
Package Id
easy-table@1.2.0
Size
6.99 kB
NPM Version
6.14.15
Node Version
14.18.0
Published on
Oct 06, 2021
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
Nice utility for rendering text tables with javascript.
1var Table = require('easy-table') 2 3var data = [ 4 { id: 123123, desc: 'Something awesome', price: 1000.00 }, 5 { id: 245452, desc: 'Very interesting book', price: 11.45}, 6 { id: 232323, desc: 'Yet another product', price: 555.55 } 7] 8 9var t = new Table 10 11data.forEach(function(product) { 12 t.cell('Product Id', product.id) 13 t.cell('Description', product.desc) 14 t.cell('Price, USD', product.price, Table.number(2)) 15 t.newRow() 16}) 17 18console.log(t.toString())
The script above will render:
Product Id Description Price, USD
---------- --------------------- ----------
123123 Something awesome 1000.00
245452 Very interesting book 11.45
232323 Yet another product 555.55
t.printTransposed()
returns
Product Id : 245452 : 232323 : 123123
Description : Very interesting book : Yet another product : Something awesome
Price, USD : 11.45 : 555.55 : 1000.00
t.print()
shows just rows you pushed and nothing more
123123 Something awesome 1000.00
245452 Very interesting book 11.45
232323 Yet another product 555.55
The full signature of .cell()
is:
1t.cell(column, value, printer)
Rendering occures in two phases. At the first phase printer
is called to get the minimal width required to fit the cell content.
At the second phase printer
is called again with
additional width
parameter to get actual string to render.
For example, here is how currency printer might be defined
1function currency(val, width) { 2 var str = val.toFixed(2) 3 return width ? Table.padLeft(str, width) : str 4}
When you already have an array, explicit table instantiation and iteration
becomes an overhead. For such cases it is convenient to use Table.print()
.
1console.log(Table.print(data))
id desc price
------ --------------------- ------
123123 Something awesome 1000
245452 Very interesting book 11.45
232323 Yet another product 555.55
It is possible to pass some options
1Table.print(data, { 2 desc: {name: 'description'} 3 price: {printer: Table.number(2)} 4})
id description price
------ --------------------- -------
123123 Something awesome 1000.00
245452 Very interesting book 11.45
232323 Yet another product 555.55
or have a full control over rendering
1Table.print(data, function(item, cell) { 2 cell('Product id', item.id) 3 cell('Price, USD', item.price) 4}, function(table) { 5 return table.print() 6})
Table.print()
also accepts objects
1Table.print(data[0])
id : 123123
desc : Something awesome
price : 1000
You can sort a table by calling .sort()
, and optionally passing in a list of
column names to sort on (by default uses all columns), or a custom comparator
function. It is also possible to specify the sort order. For example:
1t.sort(['Price, USD|des']) // will sort in descending order 2t.sort(['Price, USD|asc']) // will sort in ascending order 3t.sort(['Price, USD']) // sorts in ascending order by default
Easy table can help to calculate and render totals:
1t.total('Price, USD')
Product Id Description Price, USD
---------- --------------------- ----------
245452 Very interesting book 11.45
232323 Yet another product 555.55
123123 Something awesome 1000.00
---------- --------------------- ----------
1567.00
Here is a more elaborate example
1t.total('Price, USD', { 2 printer: Table.aggr.printer('Avg: ', currency), 3 reduce: Table.aggr.avg, 4 init: 0 5}) 6 7// or alternatively 8 9t.total('Price, USD', { 10 printer: function(val, width) { 11 return padLeft('Avg: ' + currency(val), width) 12 }, 13 reduce: function(acc, val, idx, len) { 14 acc = acc + val 15 return idx + 1 == len ? acc/len : acc 16 } 17})
Product Id Description Price, USD
---------- --------------------- -----------
245452 Very interesting book 11.45
232323 Yet another product 555.55
123123 Something awesome 1000.00
---------- --------------------- -----------
Avg: 522.33
via npm
$ npm install easy-table
(The MIT License)
Copyright (c) 2015 Eldar Gabdullin eldargab@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
6 existing vulnerabilities detected
Details
Reason
Found 5/23 approved changesets -- score normalized to 2
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
license 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-14
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