1.0.0 • Published 3 years ago

nv-repr-mat v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
3 years ago

nv-repr-mat

  • nv-repr-mat is a simple util to display mat

install

  • npm install nv-repr-mat

usage

examples

const repr_mat = require("nv-repr-mat");
var m = [
   [123,"我们",'a',null],
   [undefined,'b',0,null],
   [undefined,'b','uuu',345],
]

var name = "MYTABLE"
var cnl = ['X','Y','Z','W']
var rnl = ['-','-','-','-']
var cfg ={name,cnl,rnl}

console.log(repr_mat.repr(m,{with_color:false}))

console.log(repr_mat.repr(m,cfg))

console.log(repr_mat.repr(m))

> console.log(repr_mat.repr(m,{with_color:false}))
 ──────────────────────────────────────────────
 │ ROWNUM │     col-0 │ col-1 │ col-2 │ col-3 │
 ──────────────────────────────────────────────
 │    0-> │       123 │  我们 │     a │  null │
 ──────────────────────────────────────────────
 │    1-> │ undefined │     b │     0 │  null │
 ──────────────────────────────────────────────
 │    2-> │ undefined │     b │   uuu │   345 │
 ──────────────────────────────────────────────
undefined
>

cfg format

  • cnl column-names, default = 'col-'+
  • rvl row-index-names,default = + '->'
  • name table-name
  • with_color enable ansi8-color

cfg

{
    name:"MYTABLE"
    cnl:['X','Y','Z','W'],
    rnl:['-','-','-','-']
}

APIS

  • repr_mat.repr(m,cfg)
  • repr_mat.CONND
  • repr_mat.COLORD

LICENSE

  • ISC