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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@feng-j/console-progress

v1.5.0

Published

在 node 终端控制台中输出进度条

Readme

console-progress

last update last commit

可以在 NodeJS 程序中展示进度条,用于任务处理进度的可视化反馈。

活动

Alt

SingleLine

constructor

构造函数(均为可选参数):

  • name(string):任务标题
  • leftChar(string):进度条左侧已完成部分字符
  • rightChar(string):进度条右侧未完成部分字符
  • leftColor:已完成部分进度条颜色(HEX颜色)
  • rightColor:未完成部分进度条颜色(HEX颜色)
  • showPercent(boolean):是否显示百分比
  • showTask(boolean):是否显示任务处理数量
  • hideCursor(boolean):隐藏终端光标
  • format(string):进度条格式,会按照字符串模板进行解析,例如{name} | {bar} | {percent}% Percent | {finish}/{total} Chunks,内置的变量有
    • bar:进度条
    • name:任务标题
    • percent:百分比
    • finish:已处理任务数量
    • total:总任务数量

start

开始任务,用于设置总任务数量,(allTask: number, finish: number = 0, formatData?: Record<string, string | number>)

update

更新任务进度,(finish: number, formatData?: Record<string, string | number>)

increment

按照step推进任务进度,(step: number = 1, formatData?: Record<string, string | number>)

const singleLine = new SingleLine({
  name: 'Test',
  leftColor: '#39c5bb',
  format: `${chalk.red('{name}')} | {bar} | ${chalk.yellow('{percent}% Percent')} | ${chalk.green('{finish}/{total} Chunks')}`
})
singleLine.start(100, 0)

setTimeout(() => {
  singleLine.update(30)

  const timer = setInterval(() => {
    singleLine.increment()
    if (singleLine.isFinished()) {
      clearInterval(timer)
    }
  }, 100)
}, 1000)

使用效果 result

文本内容没有自定义颜色配置,如果需要自定义颜色,可以通过format模板配合chalk自行控制,例如

{
  format: `${chalk.red('{name}')} | {bar} | ${chalk.yellow('{percent}% Percent')} | ${chalk.green('{finish}/{total} Chunks')}`
}

MultiLine

同SingleLine构造函数所需参数,会在创建line的时候作为默认参数,也可以创建line的时候手动指定

MultiLine.create,用于创建一行子line(total: number, finish: number = 0, option?: ConstructorParameters<SingleLine>, formatData?: Record<string, string | number>), 后续可以调用子line的update(finish: number, formatData?: Record<string, string | number>)方法更新, 或者是用multiLine的update(index: number, finish: number, formatData?: Record<string, string | number>)进行更新

const multiLine = new MultiLine()
const line1 = multiLine.create(100, 0, { name: 'line1' })
const line2 = multiLine.create(100, 0, { name: 'line2' })

const timer = setInterval(() => {
  const index = Math.floor(Math.random() * 2)
  const line = index === 0 ? line1 : line2
  if (line.isFinished()) {
    return
  }

  line.increment(5)

  if (line1.isFinished() && line2.isFinished()) {
    clearInterval(timer)
  }
}, 50)