@mpen/progressbar 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
1
|
# @mpen/progressbar
|
|
2
2
|
|
|
3
3
|
Terminal progress bar utilities.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { setTimeout } from 'node:timers/promises'
|
|
9
|
+
import ProgressBar from '@mpen/progressbar'
|
|
10
|
+
|
|
11
|
+
const progress = new ProgressBar({ max: 100 })
|
|
12
|
+
|
|
13
|
+
for (let i = 0; i < 100; ++i) {
|
|
14
|
+
await setTimeout(25) // Replace with your actual work.
|
|
15
|
+
progress.tick()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
progress.complete()
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The bar starts immediately and writes to stdout. Call `tick()` after each item,
|
|
22
|
+
`tick(count)` after a batch, or `update(count)` to set the absolute completed count.
|
|
23
|
+
Call `complete()` to render 100% and finish with a newline.
|
|
24
|
+
|
|
25
|
+
## Customization
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import ProgressBar, { ProgressBarPartialBlocks } from '@mpen/progressbar'
|
|
29
|
+
|
|
30
|
+
const progress = new ProgressBar({
|
|
31
|
+
max: 100,
|
|
32
|
+
width: 40,
|
|
33
|
+
fps: 30,
|
|
34
|
+
partialBlocks: ProgressBarPartialBlocks.shades,
|
|
35
|
+
emptyBlock: '·',
|
|
36
|
+
enableColors: false,
|
|
37
|
+
start: false,
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
progress.start()
|
|
41
|
+
progress.update(25)
|
|
42
|
+
progress.logLine('Finished the first batch')
|
|
43
|
+
progress.tick(75)
|
|
44
|
+
progress.complete()
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Use `logLine()` to write messages above the active bar. If work stops early, call
|
|
48
|
+
`interrupt()` to render the current progress and finish with a newline.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpen/progressbar",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Terminal progress bar utilities.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
},
|
|
18
18
|
"types": "./dist/index.d.mts",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@mpen/ansi-colors": "0.
|
|
20
|
+
"@mpen/ansi-colors": "0.3.0",
|
|
21
21
|
"string-width": "^8.2.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/bun": "^1.4",
|
|
25
|
-
"tsdown": "^0.
|
|
25
|
+
"tsdown": "^0.22",
|
|
26
26
|
"typescript": "^7"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"dev": "bun src/dev.ts"
|
|
31
31
|
},
|
|
32
32
|
"publishHash": {
|
|
33
|
-
"buildDate": "2026-
|
|
34
|
-
"hgChangesetId": "
|
|
35
|
-
"sha256": "
|
|
33
|
+
"buildDate": "2026-10-04T18:59:00.809-07:00",
|
|
34
|
+
"hgChangesetId": "36f79ac2bb8e+",
|
|
35
|
+
"sha256": "aa8016508ef5982c85982679c004cb4a4792a532cd94b58bc8e5693980ad5213"
|
|
36
36
|
}
|
|
37
37
|
}
|