Giter Site home page Giter Site logo

terminal-table's Introduction

terminal-table

View a table in the terminal

screenshot

Features

  • To fit the width of the terminal can be displayed
  • Centered, right-justified
  • Corresponding to the full-width eastasianwidth
  • Coloring is possible colors.js
  • Border can choose from three styles and user custom style.

Installation

$ npm i terminal-table

Usage

var Table = require("terminal-table");
var t = new Table();

t.push(
  ["First", "Second"],
  ["Foo", "Bar"]
);

console.log("" + t);

API

Constructor options

  • borderStyle
    • 1: ascii
      screenshot
    • 2: unicode
      screenshot
    • 3: unicode bold
      screenshot
    • 0: user custom
      var t = new Table({
        borderStyle: 0,
        border: {
          sep: "║",
          topLeft: "╔", topMid: "╦", top: "═", topRight: "╗",
          midLeft: "╠", midMid: "╬", mid: "═", midRight: "╣",
          botLeft: "╚", botMid: "╩", bot: "═", botRight: "╝"
        }
      });
  • horizontalLine - Boolean
  • width - Array
new Table({
  width: [10, "50%", "50%"]
});
  • leftPadding, rightPadding

Methods

  • push(["item", "item2",,,],,,)
  • cell(row, column, text)
  • insertRow(rowIndex, ["item", ...])
  • insertColumn(columnIndex, ["item", ...])
  • attr(row, column, { attrs })
    • attrs
    • align: left, center, right
    • color: from colors.js, e.g. blue, red...
    • bg: blue, black...
  • attrRange({ range }, { attrs })
    • range
    • row: [start, end]
    • column: [start, end]
  • removeCell(row, column)
  • removeRow(row)
  • removeColumn(column)

terminal-table's People

Contributors

zaftzaft avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.