npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

progress-img

v1.1.0

Published

Use images as progress bars in the terminal!

Downloads

8

Readme

progress-img

npm package version Travis build status npm package downloads index.js file size code style license

Use images as progress bars in the terminal!

Requirements

iTerm2 v2.9 or higher is required to display actual images. Otherwise an ASCII version of the images will be displayed.

Installation

npm install --save progress-img

Usage

const ProgressImg = require('progress-img')

var progress = new ProgressImg('awesome.gif', {
  frameThrottle: '500ms',
  textTop: 'Downloading file...',
  width: '100%'
})

// Set progress to a specific frame
progress.set(3)

// Set progress to a percentage
progress.set('26%')

// Display some text below the image
progress.set('52%', { textBottom: 'Please wait...' })

// Clear the progress
progress.clear()

// Finish
progress.done()

Note: The clear() function is optional, however the done() function should always be ran when you are finished with the progress image.

Images

The first parameter of the initial ProgressImg setup function is where you set the image(s) that you would like to use. If one is not supplied, a default one will be used.

This parameter accepts a string or an array filled with strings that contain either a file path, URL, or image buffer.

Options

These options can be passed as the second parameter to either the initial ProgressImg setup, or to the progress.set function.

var options = {
  image: 'awesome.gif',

  width: 'auto',

  height: 'auto',

  preserveAspectRatio: true,

  expandGifs: false,

  useFallback: true,

  textTop: 'Downloading file...',

  textBottom: 'Please wait...',

  saveOptions: true,

  set: '20%',

  frameThrottle: '500ms',

  output: process.stdout
}

image

The image(s) to use. Can be used instead of the image parameter. (Defaults to ./loader.gif)

Note: This option can only be used in the initial ProgressImg setup.

width

height

The width and height of the image. Can be one of the following: (Defaults to auto)

  • N: N character cells.
  • Npx: N pixels.
  • N%: N percent of the session's width or height.
  • auto: The image's inherent size will be used to determine an appropriate dimension.

Note: This option can only be used in the initial ProgressImg setup when using the ASCII fallback.

preserveAspectRatio

Whether to preserve the aspect ratio of the image or not. (Defaults to true)

expandGifs

Whether or not to expand GIFs into separate frames. (Defaults to true)

Note: This option can only be used in the initial ProgressImg setup.

useFallback

Whether to use the fallback progress bar regardless if the user is using a supported terminal or not. Great for testing how the fallback progress bar looks or bypassing the terminal check. (Defaults to null)

Note: This option can only be used in the initial ProgressImg setup.

textTop

textBottom

Text to display above or below the image. (Defaults to null)

saveOptions

Whether to overwrite the options set in the initial ProgressImg setup. (Defaults to false)

Note: This option can only be used in the progress.set function.

set

The frame number or percentage to set the progress to. Can be used instead of set parameter. Can also be used in the initial ProgressImg setup. (Defaults to null)

frameThrottle

Throttle the frame changes by: (Defaults to 0)

  • N: Actual frame count.
  • N%: Frame count percentage.
  • Nms: Milliseconds since the last frame change.

Note: 500ms is recommended for a smoother animation.

output

The stream to output to. (Defaults to process.stdout)

License

MIT. See the License file for more info.