gajus / table Goto Github PK
View Code? Open in Web Editor NEWFormats data into a string table.
License: Other
Formats data into a string table.
License: Other
table package exports 'createStream' function used to draw a table and append rows.
But it uses 'stdout' internally.
However, 'createStream' function should provide a way to write on a user file too.
npm update
reports a security vulnerability tied to this Lodash issue. Upgrading Lodash to >=4.17.5 would solve this problem.
Considering the following row array:
let rows = [
[chalk.blue('foobar'), 'The quick brown fox'],
[chalk.blue('barbaz'), 'Jumps over\nthe lazy dog'],
[chalk.blue('lorem'), 'ipsum']
];
Calling table
results in the following error: Error: Table data must not contain control characters.
Checked the readme and there's nothing about this error. Does this module restrict newlines (and other control characters) in column values, or am I missing something and am a big dummy?
This feature is mentioned in https://github.com/jamestalmage/cli-table2 documentation. Though, there is no documentation or examples of it being in use.
@jamestalmage can you share an example?
I don't understand how some of this be possible given that cells share common borders.
They don't seem to be used anywhere except for tests.
Hi!
i'm run debug my app is ok but when build release then show red error:
TypeError: underfined is not a function (evaluating 'str.normalize()')
please help me.
thanks
npm WARN [email protected] requires a peer of ajv@^5.0.0 but none is installed. You must install peer dependencies yourself.
Changelog for [email protected]:
- uniqueItemProperties keyword (contributed by @blainesch)
I think you just can update the version of ajv-keywords
in package.json
to remove the warning.
Looks like you forgot a dependency:
>> Error: Cannot find module 'chalk'
Right now, basic output might look like:
╔════╤════╤════╗
║ 0A │ 0B │ 0C ║
╟────┼────┼────╢
║ 1A │ 1B │ 1C ║
╟────┼────┼────╢
║ 2A │ 2B │ 2C ║
╚════╧════╧════╝
I am looking for something like this instead:
╔══════════════╗
║no columns here
╟────┼────┼────╢
║ 1A │ 1B │ 1C ║
╟────┼────┼────╢
║ 2A │ 2B │ 2C ║
╚════╧════╧════╝
where the header does not have columns, is this possible?
Make it an option to truncate cell contents using an ellipsis instead of auto-wrap.
The auto-wrapping functionality should be able to wrap lines respecting word barriers.
In the current output, string is chunked into rows simply using length delimiter, e.g.
║ Message ║
╟────────────────────────────────────────────────────────╢
║ Definition for rule 'jsdoc/check-returns-types' wa ║
║ s not found ║
╟────────────────────────────────────────────────────────╢
║ Definition for rule 'jsdoc/check-types' was not fo ║
║ und ║
╟────────────────────────────────────────────────────────╢
║ Definition for rule 'jsdoc/require-param' was not ║
║ found ║
╟────────────────────────────────────────────────────────╢
║ Definition for rule 'jsdoc/require-returns-descrip ║
║ tion' was not found ║
╟────────────────────────────────────────────────────────╢
║ Definition for rule 'jsdoc/require-returns-types' ║
║ was not found ║
╟────────────────────────────────────────────────────────╢
║ Variables within the same declaration block should ║
║ be sorted alphabetically ║
╟────────────────────────────────────────────────────────╢
║ "lintFiles" is defined but never used ║
╟────────────────────────────────────────────────────────╢
║ Missing JSDoc @returns for function ║
It should use word (space) or special character barrier when possible, e.g.
║ Message ║
╟────────────────────────────────────────────────────────╢
║ Definition for rule 'jsdoc/check-returns-types' ║
║ was not found ║
╟────────────────────────────────────────────────────────╢
║ Definition for rule 'jsdoc/check-types' was not ║
║ found ║
╟────────────────────────────────────────────────────────╢
║ Definition for rule 'jsdoc/require-param' was not ║
║ found ║
╟────────────────────────────────────────────────────────╢
║ Definition for rule ║
║ 'jsdoc/require-returns-description' was not found ║
╟────────────────────────────────────────────────────────╢
║ Definition for rule 'jsdoc/require-returns-types' ║
║ was not found ║
╟────────────────────────────────────────────────────────╢
║ Variables within the same declaration block should ║
║ be sorted alphabetically ║
╟────────────────────────────────────────────────────────╢
║ "lintFiles" is defined but never used ║
╟────────────────────────────────────────────────────────╢
║ Missing JSDoc @returns for function ║
We got a problem stylelint/stylelint#2106 in CI after update to latest version (4.0.1). It's hard to keep track of changes not seeing Changelog
.
We have a strange bug in stylelint:
stylelint uses "table" for formatted output (see Implementation)
as we found out, the reason is the new lodash release of version 4.17.5 (see ticket)
but from here we are without a clue and hope that you can help us finding out the root of the problem in lodash.
also, a quick fix could be to make a new release of table with a pinned lodash version to 4.17.4
thanks for help!
I copied and pasted the borderless demo from the README verbatim and it's printing empty lines between rows, which seems to run contrary to the expected output according to that section in the README. Here's my output:
→ node table-test.js
0A 0B 0C
1A 1B 1C
2A 2B 2C
Does the README and the section on borderless tables need updating?
It would be helpful for seeing the state of the code at specific versions if each of them were tagged here in the repo instead of just released on NPM.
To tag older versions with the proper timestamp you can use a script like the following on Windows:
tag-release.ps1:
param([string]$version = "")
$message=(git log -1 --pretty=%B | head -1)
$env:GIT_COMMITTER_DATE=(git show --format=%aD | head -1)
git tag -a "$version" -m "$message"
This is a slightly modified version of this answer which has a version for *NIX shells.
Typescript is great, but not everyone is using it.
I struggled to find out how to use this module as var table = require('table')
does not work (see #14 )
I'm running Node v0.12.0 (my company requires this whole security process in order to upgrade anything, it's a big hassle). When I try to import this library via the require
function, like so:
var table = require("table");
I get this result:
>> Error: Cannot find module './border/'
I would recommend either adding support for pre-ES6 versions of Node, or (more simply) add an engines entry to your package.json file that sets the required version of Node higher than v0.12.0.
Hi. I want to colorize some text in table? What libs is better to use?
I want to start a new line in a single cell, so I tried to add '\r\n' or '\n' at the end of the line. But it seems like it will be forbidden because of the regex test in validateData.js line 58: /[\x01-\x1A]/.test(cell)
. So is there any way to have a new line?
Hello, I have a problem with streaming. I used example code only difference is I changed import with require as const {createStream} = require("table");
const columns = columnSizeIndex.map(size => {
^
TypeError: columnSizeIndex.map is not a function
at drawBorder (C:\nodejs\node_modules\table\dist\drawBorder.js:20:35)
at drawBorderTop (C:\nodejs\node_modules\table\dist\drawBorder.js:41:10)
at create (C:\nodejs\node_modules\table\dist\createStream.js:85:43)
at Object.write (C:\nodejs\node_modules\table\dist\createStream.js:151:16)
at Timeout.setInterval [as _onTimeout] (C:\nodejs\index.js:70:12)
at ontimeout (timers.js:466:11)
at tryOnTimeout (timers.js:304:5)
Hi :-)
I have a case in which it takes time to retrieve all the data I need to display in a tabular way.
I was thinking of rendering the table progressively, as the data fetching progresses.
Do you think this is possible?
The more I think of it, minWidth
and maxWidth
does not add value to the table
package. CLI table output is meant to be predictable. Therefore, a static width definition makes a lot more sense.
Emojis in cell text cause column width corruption:
stringWidth
for ie. 24.2⚠️
returns 6
. I am not Unicode expert, but this is most likely related to ZWJ code points and issue in string-width
dependency: sindresorhus/string-width#2. Since that issue is almost 2 years old, maybe a different module should be used or own approach implemented?
This commit seems to have made this project build out to es6: 8845d31
Is this expected? As I am now getting error such as this:
let userConfig = arguments.length <= 1 || arguments[1] === undefined ? {} :
^^^
SyntaxError: Unexpected strict mode reserved word
ajv publish 6.6.0 equal removed: ajv-validator/ajv@f9fcc50
When is it planned to release a new version?
In 4.0.1, there is still the dependency to ajv ^4.7.0, which leads to a critical dependency warning. The warning would be solved with ajv updated to version 5, which is already on master.
Nixing tests
shaves off about 46KB from the package.
In this section: https://github.com/gajus/table#cell-content-alignment
minWidth is an additional property that is not allowed.
Also https://github.com/gajus/table#borderless-table (drawJoin property)
I'm talking about this specific table: https://raw.githubusercontent.com/gajus/table/master/.README/demo.png
How do you create the header row that's bold?
Would you be willing to write a TypeScript definition file for this package and submit it to the Typings registry? I'm writing a package in TypeScript and it'd be great to use your stuff.
This feature already exists in https://github.com/jamestalmage/cli-table2 package.
Visually, it looks pretty cool:
┌───────┬─────┬────┐
│ hello │ sup │ hi │
├───────┤ │ │
│ howdy │ │ │
├───┬───┼──┬──┤ │
│ o │ k │ │ │ │
└───┴───┴──┴──┴────┘
In cli-table2
the syntax for that is:
var table;
table = new Table({
style: {
head: [],
border: []
}
});
table.push(
[
{
content: 'hello',
colSpan: 2
},
{
rowSpan: 2,
colSpan: 2,
content: 'sup'
},
{
rowSpan: 3,
content: 'hi'
}
],
[
{
content: 'howdy',
colSpan:2
}
],
[
'o',
'k',
'',
''
]
);
Using this :
const data = [
['0A', '0B', '0C'],
['1A', '1B', '1C'],
['2A', '2B', '2C']
];
const config = {
columns: {
0: {
wrapWord: true,
}
}
};
console.log(table(data, config));
Will results with this error :
TSError: ⨯ Unable to compile TypeScript:
src/index.ts(594,27): error TS2345: Argument of type '{ columns: { 0: { wrapWord: boolean; }; }; }' is not assignable to parameter of type 'TableUserConfig'
eslint requires "table": ^4.0.1 which translates to 4.0.3 which requires avj ^6.0.1
eslint also requires "ajv": ^5.3.0
This causes a peer dependency issue.
I only see it used in the test/ directories, so wouldn't it make more sense as a devDependency?
As it is, eslint
imports table
, and table
pulls in ajv
, and ajv
has a variety of issues with webpack, that are supposedly fixed in 5.0.0. But this version is still pinned at 4.x in table
, so I can't just upgrade it in my client...and seems like table
could just do away with the dependency entirely!
This code
const table = require('table');
const config = {
columnDefault: {
width: 5
},
columnCount: 3
};
const stream = table.createStream(config);
const lastCell = '\na\n2\n3';
stream.write([1, 2, 3]);
stream.write([1, 2, lastCell]);
fails with following error:
╔═══════╤═══════╤═══════╗
║ 1 │ 2 │ 3 ║
╚═══════╧═══════╧═══════╝/path_to_prj/node_modules/table/dist/mapDataUsingRowHeightIndex.js:49
rowHeight[index2][index1] = part;
^
TypeError: Cannot set property '2' of undefined
at _lodash2.default.forEach (/path_to_prj/node_modules/table/dist/mapDataUsingRowHeightIndex.js:49:35)
...
Node v6.5.0.
This is a variation of the Automattic/cli-table#43 proposal. @JosePedroDias suggested that he'd like to be able to have a better separation between header column and body.
I think it is a useful suggestion.
This task depends on the status of #4.
This issue has been raised on https://github.com/Automattic/cli-table by @marcelklehr.
The proposal uses 3 ASCII characters to create table: -
, +
, |
.
Hi
The following error is raised by the method calculateCellHeight.js when one cell is empty:
Unhandled rejection Error: Column width must be greater than 0.
I think it should raise such error only when a whole column is empty
The minWidth configuration option should also be used to compute this width
Thanks
Pierre-André
Great existing table templates, but one key item that's missing is the Markdown table.
| 0A | 0B | 0C |
|----|----|----|
| 1A | 1B | 1C |
| 2A | 2B | 2C |
| 2A | 2B | 2C |
| 2A | 2B | 2C |
| 2A | 2B | 2C |
| 2A | 2B | 2C |
Results in cool stuff on github, like so:
0A | 0B | 0C |
---|---|---|
1A | 1B | 1C |
2A | 2B | 2C |
2A | 2B | 2C |
2A | 2B | 2C |
2A | 2B | 2C |
2A | 2B | 2C |
Would be nice if we could give users a copy/paste friendly table for github!
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#tables
Hi,
I tried to use table with Gulp in our starter kit. I had to use require() to import it because I can't install babel
But when I try to use table with your exemple, it return me this error.
data = [
['0A', '0B', '0C'],
['1A', '1B', '1C'],
['2A', '2B', '2C']
];
options = {
column: {
0: {
alignment: 'left',
minWidth: 10
},
1: {
alignment: 'center',
minWidth: 10
},
2: {
alignment: 'right',
minWidth: 10
}
}
};
output = table(data, options);
Is there a way to use table without ES6?
Thanks for your help!
There is a way to close a stream start with createStream
?
Hi! First, thanks for the awesome project.
I'm using it to create tables for a Telegram bot, every response, no matter what table formatting I use, is not showing the top border.
Version 4.0.3
I am trying to use https://github.com/sindresorhus/terminal-link
First I got the error
(node:6881) UnhandledPromiseRejectionWarning: Error: Table data must not contain control characters.
at validateTableData (/Users/alisowski/Documents/perf-table/node_modules/table/dist/validateTableData.js:62:19)
at table (/Users/alisowski/Documents/perf-table/node_modules/table/dist/table.js:95:34)
at Object.<anonymous> (/Users/alisowski/Documents/perf-table/dist/index.js:221:36)
at step (/Users/alisowski/Documents/perf-table/dist/index.js:43:23)
at Object.next (/Users/alisowski/Documents/perf-table/dist/index.js:24:53)
at fulfilled (/Users/alisowski/Documents/perf-table/dist/index.js:15:58)
at process._tickCallback (internal/process/next_tick.js:68:7)
After commenting out the code that threw the error It output
Do you think it will be possible to terminal links inside of the table?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.