fancy-text-table

    1.0.0 • Public • Published

    Fancy Text Table

    Build Test Coverage Code Climate Downloads Version Dependency Status

    You know, it's like text-table, but kinda fancier. It features mostly the same functionality, but conveniently handles titles spanning all table cells, table breaks, and colors in all cells.

    require('fancy-text-table') → Table

    To manage rows and titles and stuff, you have to initialize an instance of a table whenever you want to create a new table. This table instance will expose an API:

    Table.row({Array} items)

    Creates a row of items. Each item in the array will the converted to a string and become a cell in the table.

    Table.title({String} title)

    Creates a title. This string will span across all cells of the table, and not factor into cell alignment.

    Table.line()

    Creates an empty line in the table. This is useful if you want to break up chunks of cells.

    Table.render() → {String}

    Returns the laid-out table as a string, ready to be printed to standard output.

    Example

    var table = require('fancy-text-table');
     
    var tbl = table();
     
    tbl.title('numbers');
    tbl.row([1, 2, 3, 4]);
    tbl.line();
    tbl.title('letters');
    tbl.row(['a', 'b', 'c', 'd']);
     
    var str = tbl.render();
     
    console.log(str);
     
    // numbers
    // 1  2  3  4
    //
    // letters
    // a  b  c  d

    Install

    npm i fancy-text-table

    DownloadsWeekly Downloads

    4

    Version

    1.0.0

    License

    ISC

    Last publish

    Collaborators

    • kirilv