npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

print-details

v1.0.2

Published

help you print table in the terminal quickly.

Downloads

4

Readme

README

安装与使用

安装:

npm install print-details --save

使用:

import PrintTable from 'print-details';
const dataSource = {
  "menu1": [
    { name: 'fn1', type: 'aaa1', return: 'bbb1' },
    { name: 'fn2', type: 'aaa2', return: 'bbb2' }
  ],
  "menu2": [
    { name: 'fn3', type: 'aaa3', return: 'bbb3' }
  ],
  "menu3": [
    { name: 'fn4', type: 'aaa4', return: 'bbb4' },
    { name: 'fn5', type: 'aaa5', return: 'bbb5' },
    { name: 'fn6', type: 'aaa6', return: 'bbb6' },
  ]
}

let table = new PrintTable(dataSource, 'name');

printTitle

作用: 打印一级标题或一级标题下所有的主键,也就是dataSourcekey

语法printTitle(head, cellWidth);

参数:

  • head{string} [必填] 表格的名字
  • cellWidth{number} [必填] 单元格的长度
  • title{string} **[可选]**指定的一级标题

返回值:{void} 无返回值

实例

table.printTitle('The all constructor function', 20);
/**
 * ╔══════════════════════╗
   ║ The all constructor  ║
   ║       function       ║
   ╟──────────────────────╢
   ║ menu1                ║
   ╟──────────────────────╢
   ║ menu2                ║
   ╟──────────────────────╢
   ║ menu3                ║
   ╚══════════════════════╝
 */

table.printTitle('The function', 20, 'menu3');
/**
 * ╔══════════════════════╗
   ║     The function     ║
   ╟──────────────────────╢
   ║ fn4                  ║
   ╟──────────────────────╢
   ║ fn5                  ║
   ╟──────────────────────╢
   ║ fn6                  ║
   ╚══════════════════════╝
 */

printContent

作用: 打印指定name的数据集

语法printContent(tableHead, name, columns);

参数:

  • tableHead{string[]} [必填] 表头 [推荐英文],长度应该与 dataSource 每条数据一样
  • name{string|string[]} [必填] 主键对应的值
  • columns{[{alignment: 'center'|'left'|'right', width: number}]} [可选] 单元格参数的设置,不设置宽度则为自适应

返回值:{void} 无返回值

实例

// 不设置columns参数
table.printContent(['function name', 'type', 'returns'], 'fn2');
/**
 * ╔════════════════════════════════╗
   ║      The result of search      ║
   ╟───────────────┬──────┬─────────╢
   ║ function name │ type │ returns ║
   ╟───────────────┼──────┼─────────╢
   ║ fn2           │ aaa2 │ bbb2    ║
   ╚═══════════════╧══════╧═════════╝
 */

// 设置columns参数
const columns = [
  { alignment: 'center', width: 10},
  { alignment: 'center' },
  { alignment: 'right' }
]
table.printContent(['function name', 'type', 'returns'], 'fn2', columns);

/**
 * ╔═════════════════════════════╗
   ║    The result of search     ║
   ╟────────────┬──────┬─────────╢
   ║ function n │ type │ returns ║
   ║    ame     │      │         ║
   ╟────────────┼──────┼─────────╢
   ║    fn2     │ aaa2 │    bbb2 ║
   ╚════════════╧══════╧═════════╝
 */

// name为数组传输
table.printContent(['function name', 'type', 'returns'], ['fn1', 'fn2']);
/**
 * ╔════════════════════════════════╗
   ║      The result of search      ║
   ╟───────────────┬──────┬─────────╢
   ║ function name │ type │ returns ║
   ╟───────────────┼──────┼─────────╢
   ║ fn1           │ aaa1 │ bbb1    ║
   ╟───────────────┼──────┼─────────╢
   ║ fn2           │ aaa2 │ bbb2    ║
   ╚═══════════════╧══════╧═════════╝
 */