# @yetnt/progressbar

> An easy, simple and customizable string progress bar

Latest version **3.0.1** (published 2023-11-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @yetnt/progressbar
pnpm add @yetnt/progressbar
yarn add @yetnt/progressbar
bun add @yetnt/progressbar
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2023-11-06 |
| First published | 2023-06-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 31.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | YetNT |
| Maintainers | yetnt |
| Keywords | progress, bar, easy, customizable, string, discord.js, discordjs, discord, eris, progress bar, progressbar, aoi.js, aoijs, status, statusbar, whatsapp, whatsapp web, emoji, emojibar, nodejs, node.js, baileys |

## Links

- npm: https://www.npmjs.com/package/@yetnt/progressbar
- Repository: https://github.com/YetNT/progressbar
- Homepage: https://github.com/YetNT/progressbar#readme
- Issues: https://github.com/YetNT/progressbar/issues
- npm.io page: https://npm.io/package/@yetnt/progressbar

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 3.0.1 (latest) — 2023-11-06
- 3.0.0 — 2023-11-06
- 2.2.0 — 2023-10-12
- 2.1.0 — 2023-09-20
- 2.0.0 — 2023-08-29
- 1.3.0 — 2023-07-22
- 1.2.0 — 2023-06-09
- 1.0.1 — 2023-06-09
- 1.0.0 — 2023-06-08

## README

# progressbar

A progress bar creator in ~~javascript~~ typescript!

NOTE: All examples and explanations are in javascript.

# Installation

```bash
npm install @yetnt/progressbar
sudo npm install @yetnt/progressbar
yarn add @yetnt/progressbar
```

## (Jump To)

-   [A Simple Bar](#a-simple-bar)
-   [Seperated Bar](#seprated-bar-charsplit-method)
-   [Discord.js Example](#discordjs-example)

# Usage (examples below this)

```js
const { progressBar, ProgressBar } = require('@yetnt/progressbar')

progressBar(percentage, barWidth, emptyChar, fullChar, returnAr?, firstEdgeOverride?, lastEdgeOverride?)

percentage = 45 // How much of the bar is full. If 100% the whole thing is full. If 0 everything is empty.
barWidth = 10 // Width of the bar. If 10 it's 10 characters long
emptyChar = "□" // Empty character to display for parts of the bar that aren't filled.
fullChar = "■" // Full character to display for parts of the bar that  are filled.
returnAr = false // (optional) Return an array or not
firstEdgeOverride = ["◁", "◀"] // (optional) Overrides the first edge with the elements
lastEdgeOverride = ["▷", "▶"] // (optional) Overrides the last edge with elements

// This is exactly the same for class, but returnAr is not a parameter

let bar = new ProgressBar(percentage, barWidth, emptyChar, fullChar, firstEdgeOverride?, lastEdgeOverride?)
```

or if you don't want to deconstruct them (for some reason)

```js
const pb = require("@yetnt/progressbar");
pb.progressBar();
// or
new pb.ProgressBar();
```

## A Simple bar

### Function

```js
progressBar(45, 10, "□", "■");
```

### Class

```js
let bar = new ProgressBar(45, 10, "□", "■");
bar.bar;
```

### Output

```js
"■■■■□□□□□□";
```

## Return Array

### Function

```js
progressBar(45, 10, "□", "■", true);
```

### Class

```js
let bar = new ProgressBar(45, 10, "□", "■", true);
bar.barArray;
```

### Output

```js
["■", "■", "■", "■", "□", "□", "□", "□", "□", "□"];
```

## Edge overrides

If you'd like you can also change the first bar element and the last bar element so you can edge it with emojis or something else.

### Edge Syntax

```js
["emptyChar", "filledChar"];
```

### Edge Use

#### Function

```js
progressBar(56, 30, "▢", "▧", false, ["◁", "◀"], ["▷", "▶"]);
```

#### Class

```js
let bar = new ProgressBar(56, 30, "▢", "▧", ["◁", "◀"], ["▷", "▶"]);
bar.bar;
```

#### Output

```js
"◀▧▧▧▧▧▧▧▧▧▧▧▧▧▧▧▢▢▢▢▢▢▢▢▢▢▢▢▢▷";
```

## Discord.js example

**Code may need to be modified depending on your command handler, currently setup using [ic4d Command Handler](https://github.com/YetNT/ic4d)/[(Under Ctrl's Command Handler)](https://youtu.be/JEEcbVjLyr0)**

```js
const { ProgressBar, progressBar } = require("@yetnt/progressbar"); // deconstructing
module.exports = {
    name: "progressbar",
    description: "useful npm package made by yet",
    callback: async (client, interaction) => {
        const progressBar = new ProgressBar(55, 10, "▢", "▧");

        interaction.reply({
            content: progressBar.bar,
            ephemeral: true,
        });
    },
};
```

### Output

<img src="dbe.png">

## Differences

### Dynamic Bar

Unlike the [function](#function), If you update any one of the properties of the ProgessBar object, the bar updates.

```js
let bar = new ProgressBar(56, 30, "▢", "▧", ["◁", "◀"], ["▷", "▶"]);

bar.bar; // ◀▧▧▧▧▧▧▧▧▧▧▧▧▧▧▧▢▢▢▢▢▢▢▢▢▢▢▢▢▷

bar.barWidth = 20;
bar.bar; // ◀▧▧▧▧▧▧▧▧▧▧▢▢▢▢▢▢▢▢▷

bar.percentage = 80;
bar.bar; // ◀▧▧▧▧▧▧▧▧▧▧▧▧▧▧▧▢▢▢▷

bar.firstEdgeOverride = [];
bar.lastEdgeOberride = [];
bar.bar; // ▧▧▧▧▧▧▧▧▧▧▧▧▧▧▧▧▢▢▢▢ (Removes Edge Overrides)
```

Warning : Bar may not work properly if you edit any other properties that aren't meant to be edited. (these tend to be properties with an \_)

### Seprated Bar (charsplit method)

To seprate a bar with some value (Replace the last filled char), you can use the `charSplit()` method.

```js
let bar = new ProgressBar(56, 30, "▢", "▧");
bar.bar; // ▧▧▧▧▧▧▧▧▧▧▧▧▧▧▧▧▢▢▢▢▢▢▢▢▢▢▢▢▢▢
bar.charSplit("▶");
bar.bar; // ▧▧▧▧▧▧▧▧▧▧▧▧▧▧▧▶▢▢▢▢▢▢▢▢▢▢▢▢▢▢
```

The bar will NOT charSplit if :

> 1. [Last Edge Override](#edge-overrides) is provided
>
>     AND
>
> 2. Bar's percentage is 100%

# Links

[NPM](https://www.npmjs.com/package/@yetnt/progressbar, "takes you to node package manager registery")

[Math on a progress bar](https://stackoverflow.com/a/40323549/16618019, "Takes you to stackoverflow")

[Github](https://github.com/Yetity/progressBar.js/tree/main "Where do you think this takes you?")

---
_Source: https://npm.io/package/@yetnt/progressbar · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
