2.4.0 • Published 5 years ago

@dinoabsoluto/flex-progress v2.4.0

Weekly downloads
10
License
Apache-2.0
Repository
github
Last release
5 years ago

flex-progress

CLI progress bar made simple

Build Status Coverage Status npm version

An object-oriented approach to progress bar.

  • Simple: no template, no ticking, just change the ratio property and you're good to go.
  • Theme: personalize with colors and style.
  • Object-oriented: each element is an object, updating its data leads to updating the output. No need to care about what other elements are doing.
const FlexProgress = require('@dinoabsoluto/flex-progress')
// ESModules or Typescript
// import * as FlexProgress from '@dinoabsoluto/flex-progress'

const out = new FlexProgress.Output()
const bar = new FlexProgress.Bar({ width: 25 })

out.append(
  1, new FlexProgress.Spinner(),
  1, 'Hello World!',
  1, new FlexProgress.Spinner(),
  1, '⸨', bar, '⸩'
)

let count = 0
const loop = setInterval(() => {
  count++
  bar.ratio = (count % 39) / 38
}, 80)

NOTE: The images above are screen captures of the demos in folder examples.

Concept: Why is it flex-progress?

This was inspired by CSS Flexbox concept, although much simpler.

Basically, all elements have flexShrink and flexGrow properties, which controls how much they shrink/grow. (flex is a shorthand for both)

In most case, you'll want your progress Bar to have fixed width and a Text with flexShrink set to 1. This way, your text will fill up the CLI width, but will truncate at the end of the line.

Usage

See documents for more details.

For a simple explanation see this example.

2.4.0

5 years ago

2.3.0

5 years ago

2.2.2

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago