-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhangfuxing
committed
Jan 5, 2024
1 parent
68c30d4
commit 2b42daa
Showing
22 changed files
with
56 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ ProgressBar in terminal for deno | |
|
||
```ts | ||
import { MultiProgressBar } from "https://deno.land/x/[email protected]/mod.ts"; | ||
export { delay } from "https://deno.land/[email protected]/async/delay.ts"; | ||
|
||
const title = "download files"; | ||
const total = 100; | ||
|
@@ -27,29 +28,26 @@ const bars = new MultiProgressBar({ | |
let completed1 = 0; | ||
let completed2 = 0; | ||
|
||
function downloading() { | ||
if (completed1 <= total || completed2 <= total) { | ||
async function download() { | ||
while (completed1 <= total || completed2 <= total) { | ||
completed1 += 1; | ||
completed2 += 2; | ||
bars.render([ | ||
await bars.render([ | ||
{ | ||
completed: completed1, | ||
total, | ||
text: "file1", | ||
// You can also change the style of the progress bar | ||
// complete: "*", | ||
// incomplete: ".", | ||
complete: "*", | ||
incomplete: ".", | ||
}, | ||
{ completed: completed2, total, text: "file2" }, | ||
]); | ||
|
||
setTimeout(function () { | ||
downloading(); | ||
}, 100); | ||
await delay(50); | ||
} | ||
} | ||
|
||
downloading(); | ||
await download(); | ||
``` | ||
|
||
#### interface | ||
|
@@ -149,6 +147,7 @@ What is displayed and display order, default: ':bar :text :percent :time | |
|
||
```ts | ||
import ProgressBar from "https://deno.land/x/[email protected]/mod.ts"; | ||
export { delay } from "https://deno.land/[email protected]/async/delay.ts"; | ||
|
||
const title = "downloading:"; | ||
const total = 100; | ||
|
@@ -157,22 +156,21 @@ const progress = new ProgressBar({ | |
total, | ||
}); | ||
let completed = 0; | ||
function downloading() { | ||
if (completed <= total) { | ||
progress.render(completed++); | ||
async function download() { | ||
while (completed <= total) { | ||
await progress.render(completed++); | ||
|
||
setTimeout(function () { | ||
downloading(); | ||
}, 100); | ||
await delay(50); | ||
} | ||
} | ||
downloading(); | ||
await download(); | ||
``` | ||
|
||
#### complex example | ||
|
||
```ts | ||
import ProgressBar from "https://deno.land/x/[email protected]/mod.ts"; | ||
export { delay } from "https://deno.land/[email protected]/async/delay.ts"; | ||
|
||
const total = 100; | ||
const progress = new ProgressBar({ | ||
|
@@ -188,16 +186,14 @@ const progress = new ProgressBar({ | |
// ... | ||
}); | ||
let completed = 0; | ||
function run() { | ||
if (completed <= total) { | ||
progress.render(completed++); | ||
async function download() { | ||
while (completed <= total) { | ||
await progress.render(completed++); | ||
|
||
setTimeout(function () { | ||
run(); | ||
}, 100); | ||
await delay(50); | ||
} | ||
} | ||
run(); | ||
await download(); | ||
``` | ||
|
||
More examples in the `examples` folder. | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters