MCPcopy Index your code
hub / github.com/NathanPB/progress.js

github.com/NathanPB/progress.js @3.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 3.1.0 ↗ · + Follow
72 symbols 154 edges 23 files 2 documented · 3%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

npm version Tests Status Coverage Status

Simple highly customized CLI-like progress bar for Javascript

If you get any questions or suggestions just open a discussion or an issue

Installation

This package is published in npmjs:

npm i @nathanpb/progress or yarn add @nathanpb/progress

If you want to try the unstable features, use the next tag: npm i @nathanpb/progress@next.

Basic example

import { initSimpleBar, ProgressBar, Tokens } from '@nathanpb/progress'

const bar = new ProgressBar({ total: 100 })
initSimpleBar({ 
  bar,
  template: '[$bar$] $progress$% | eta $eta$ s | elapsed $elapsed$ s',
  stream: process.stdout,
  tokens: {
    bar: Tokens.bar({ length: 30 }),
    eta: Tokens.eta({ interval: 1000 }),
    elapsed: Tokens.elapsedTime({ interval: 1000 }),
    progress: Tokens.progress({ decimalDigits: 2 })
  }
})

bar.on(Events.COMPLETED, () => console.log('Bar completed'))

setInterval(() => bar.tick(1), 500)

You can also group multiple progress bars:

initMultiBar({
  bars: [bar1, bar2, bar3],
  template: '$title$ [$bar$] $progress$% | eta $eta$ s | elapsed $elapsed$ s',
  tokens: {
    bar: Tokens.bar({ length: 30 }),
    eta: Tokens.eta({ interval: 1000 }),
    elapsed: Tokens.elapsedTime({ interval: 1000 }),
    progress: Tokens.progress({ decimalDigits: 2 }),
    title: Tokens.title()
  },
  stream: process.stdout
})

The above code is a shortcut to the full version. If you want to take control over the customization, check the Under the Hood page.

Also, check the examples page.

Downsides

Compared to other similar libraries (special thanks to node-progress which was my inspiration), this lib is a bit overcomplicated. So if you want something dead simple, their solution might suit better for your use case.

License

Copyright 2021 Nathan P. Bombana

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Do whatever you want with my code just don't make it boring

Extension points exported contracts — how you extend this code

ProgressBarState (Interface)
(no doc) [2 implementers]
src/ProgressBar.ts

Core symbols most depended-on inside this repo

tick
called by 24
src/ProgressBar.ts
progress
called by 17
src/ProgressBar.ts
formatNumber
called by 11
src/utils.ts
eta
called by 9
src/ProgressBar.ts
elapsedTime
called by 8
src/ProgressBar.ts
rate
called by 6
src/ProgressBar.ts
initSimpleBar
called by 5
src/index.ts
isComplete
called by 4
src/ProgressBar.ts

Shape

Method 32
Function 21
Class 17
Enum 1
Interface 1

Languages

TypeScript100%

Modules by API surface

src/ProgressBar.ts21 symbols
src/token.ts10 symbols
test/ProgressBarRenderer.test.ts8 symbols
src/render/TTYProgressBarRenderer.ts8 symbols
src/render/BufferProgressBarRenderer.ts8 symbols
src/render/ProgressBarRenderer.ts7 symbols
src/render/RenderTrigger.ts5 symbols
src/index.ts2 symbols
docs/example/custom-token.ts2 symbols
src/utils.ts1 symbols

For agents

$ claude mcp add progress.js \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact