# progress-string

> Get a progess bar as a string

Latest version **1.2.2** (published 2017-11-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install progress-string
pnpm add progress-string
yarn add progress-string
bun add progress-string
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2017-11-09 |
| First published | 2016-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 96 |
| Author | Thomas Watson Steen |
| Maintainers | watson |
| Keywords | progress, bar, cli |

## Links

- npm: https://www.npmjs.com/package/progress-string
- Repository: https://github.com/watson/progress-string
- Homepage: https://github.com/watson/progress-string#readme
- Issues: https://github.com/watson/progress-string/issues
- npm.io page: https://npm.io/package/progress-string

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.2.2 (latest) — 2017-11-09
- 1.2.1 — 2016-11-11
- 1.2.0 — 2016-11-07
- 1.1.0 — 2016-11-07
- 1.0.2 — 2016-11-06
- 1.0.1 — 2016-11-06
- 1.0.0 — 2016-11-06

## README

# progress-string

Generate a CLI progress bar as a string that you can then output in any
way you like.

![progress](https://cloud.githubusercontent.com/assets/10602/20219491/064d4794-a86d-11e6-816c-a0a72d792987.gif)

[![Build status](https://travis-ci.org/watson/progress-string.svg?branch=master)](https://travis-ci.org/watson/progress-string)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)

## Installation

```
npm install progress-string --save
```

## Usage

```js
var progress = require('progress-string')
var diff = require('ansi-diff-stream')()

var value = 0
var total = 42
var bar = progress({width: 50, total: total})

setInterval(function () {
  diff.write(
    'The progress of the program is:\n' +
    bar(++value)
  )
  if (value === total) process.exit()
}, 250)

diff.pipe(process.stdout)
```

## API

### `var bar = progress(options)`

This module exposes a function that takes a single `options` argument
and retuns a bar function.

These are the options:

- `total` - (integer) The max value of the progress bar
- `width` - (integer, default: 42) The width of the progress bar in chars
- `incomplete` - (string, default: `-`) The char used to indicate the
  incomplete part of the progress bar
- `complete` - (string, default: `=`) The char used to indicate the
  completed part of the progress bar
- `style` - (function, optional) See `options.style` below for details

#### `options.style`

You can provide a custom styling function to style the progress bar
returned by the `bar` function.

It will be called with two arguments: `complete` and `incomplete`. Each
a string representing its part of the progress bar.

Whatever the style function returns will be returned by the `bar`
function.

```js
var bar = progress({
  width: 10,
  total: 100,
  style: function (complete, incomplete) {
    // add an arrow at the head of the completed part
    return complete + '>' + incomplete
  }
})

console.log(bar(50)) // =====>-----
```

### `var str = bar(value)`

Call the `bar` function with the `value` you want to the generated
progress bar to have.

The `bar` function will return a string representation of the progress
bar.

## License

MIT

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