cli-table / cli-table3

Pretty unicode tables for the command line
MIT License
535 stars 44 forks source link

RangeError: Invalid string length #260

Closed plocket closed 2 years ago

plocket commented 2 years ago

Full error:

RangeError: Invalid string length
    at Array.join (<anonymous>)
    at Table.toString (/Users/.../node_modules/cli-table3/src/table.js:59:19)

The table is pretty long, but I do need it. I'm wondering if there's something this library can do about this error. This comment in an atom editor issue seemed to have some useful info.

Here's the table as a text file:

range_error_invalid_string_length.txt

[Edit: Also, if this library can't deal with that error, what the longest a string can be?]

speedytwenty commented 2 years ago

Just wanted to post a response. I dabbled with producing a failing test but it's slow and painful to run. Considering the way cli-table3 is written, it's not very performant with large tables and support for such large tables might be appropriately deemed out-of-scope because the table-rendering is innately slow.

If I needed to render such a large table, I would likely replicate the Table.toString() method to return the array instead of joining it into a string. With that, you could print one-line at time and avoid the RangeError (assuming a single row does not exceed the maximum string length.

Going to close this as "won't fix". But if there is interest in support for this out of the box, it could be facilitated with simple non-breaking changes to the Table class. Open a new issue as a Feature request like "Support tables that exceed the maximum string length" if you'd like to see this as part of cli-table3.