Skip to content

Support rate formatters #211

@slavafomin

Description

@slavafomin

Hello!

Thank you for this great library!

Right now, library gives no control to how :rate is actually formatted. It's pretty standard use case (it's actually used in the README) when bytes are used for total and tick values. However, the library would output rate in plain bytes, which is absolutely unpractical for end users.

I would suggest to introduce a rate formatter function, e.g.:

import prettyBytes from 'pretty-bytes';

const bar = new ProgressBar('  downloading [:bar] :rate/sec :percent :etas', {
  complete: '=',
  incomplete: ' ',
  width: 20,
  total: totalBytes,
  rateFormat: prettyBytes, // <--- using third-party formatter
});

This will output byte rate in a user-friendly fashion, e.g.: 1.56 MB/sec.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions