@badrap/bar-of-progress

中文文档
0.3.0发布于 2025/08/05MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 2.7万

A small, easy & zero-dependency progress bar component.

原始使用文档
文档目录5 节
  1. Features
  2. Installation
  3. Usage
  4. Customization
  5. License

bar-of-progress CI npm

A small, easy & zero-dependency progress bar component.

Features

  • Zero dependencies: Also not tied to any framework in particular.
  • Small size: < 500 bytes with Brotli (< 600 bytes gzipped).
  • Easy to use: Just a couple of lines and off you go. And TypeScript types are now available as well!

[!NOTE] We consider this package to be feature-complete, and as such we're not taking in any new feature requests or suggestions. Please use the issue tracker for bug reports and security concerns, which we highly value and welcome. Thank you for your understanding ❤️

Installation

$ npm i @badrap/bar-of-progress

Usage

Import the package and create a progress bar instance:

import ProgressBar from "@badrap/bar-of-progress";

const progress = new ProgressBar();

Show the progress bar and begin animating it by calling the .start() method.

progress.start();

Note By default the progress bar does not appear immediately when .start() is called. Instead there is a 80 millisecond grace period, allowing very quickly completed tasks to avoid showing the progress bar. You can modify this (and other) behavior, see Customization.

End the progress bar animation by calling the .finish() method:

setTimeout(() => {
  progress.finish();
}, 1000);

You can reuse a progress instance multiple times - every time .start() gets called the progress bar starts animation from scratch.

Customization

The progress bar's appearance and behavior can be (slightly) customized with constructor parameters. Here are the different options and their default values:

const progress = new ProgressBar({
  // The size (height) of the progress bar.
  // Numeric values get converted to px.
  size: 2,

  // Color of the progress bar.
  // Also used for the glow around the bar.
  color: "#29e",

  // Class name used for the progress bar element.
  className: "bar-of-progress",

  // How many milliseconds to wait before the progress bar
  // animation starts after calling .start().
  delay: 80,
});

License

This library is licensed under the MIT license. See LICENSE.

版本与发布记录

@badrap/bar-of-progress 共发布 9 个版本,首次发布于 2019/04/12;过去 12 个月发布了 0 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.3.0latest2025/08/051.3 年前
0.2.22022/10/134 年前
0.2.12022/05/154 年前
0.1.22021/01/255 年前
0.1.12019/04/267 年前
0.1.02019/04/237 年前

关于 @badrap/bar-of-progress 的常见问题

@badrap/bar-of-progress 是什么?

A small, easy & zero-dependency progress bar component.

如何安装 @badrap/bar-of-progress?

在项目目录运行 npm install @badrap/bar-of-progress,或使用 pnpm add / yarn add / bun add。

@badrap/bar-of-progress 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@badrap/bar-of-progress 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@badrap/bar-of-progress 可以商用吗?

@badrap/bar-of-progress 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@badrap/bar-of-progress 的下载量有多少?

根据 npm 官方下载统计,@badrap/bar-of-progress 在 2026/10/08 – 2026/11/06 这 30 天内被下载 27,301 次,日均约 910 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@badrap/bar-of-progress 还在维护吗?

最新版本 0.3.0 发布于 2025/08/05(1.3 年前);至今共发布 9 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/04/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。