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

text-spinner

v0.0.4

Published

Spinning progress indicator for console applications

Downloads

255

Readme

npm version Build Status Coverage Status Code Climate Inch CI

Dependency Status devDependency Status

text-spinner

Spinning progress indicator for console applications

Example app1.js

If you have different needs regarding the functionality, please add a feature request.

Installation

npm install --save text-spinner

Usage

// Require the module and set options
var spinner = require('../')({ 
  interval: 100  // default value 
}); 

// Update spinner one time
spinner.spin(); 

Options:

  • interval- minimum interval to print the spinner; if spinner.spin() is called several times during interval, spinner will be updated only once. Default: 100 (ms).
  • prefix - prefix to print before the spinner. Default: ''. You may set it to '\x1B['+column+'G' to position cursor to specific column.
  • postfix - postfix to print after the spinner. Default: \x1B[0G (Move to start of line).
  • auto - automatically rotate spinner (i.e.without calling progress/rotate methods
  • spinner - spinner text definition. You may look to examples/app4.js for the examples.

Methods:

  • progress() - rotate and print spinner, but not frequently than options.interval
  • spin() - same as progress()
  • rotate([index]) - rotate and print spinner now, not checking options.interval. if index is set, then set index of
  • print() - print spinner now at current position
  • start() - start auto rotation
  • stop() - stop auto rotation

Properties:

  • active - status of auto rotation for spinner

You may change the look of the spinner by using spinner option:

Example app4.js

Examples

Example 1 (examples/app1.js)

Simplest example.

var spinner = require('../')();

setInterval(function() {
  spinner.spin();
}, 10); // Spinner is triggered every 10ms, but output is refreshed with 100ms (value of options.interval parameter)

Example 2 (examples/app2.js)

This is minimal example to show progress for file download.

var request = require('request');
var spinner = require('text-spinner')({ interval: 100 });

var url = 'http://mirror.internode.on.net/pub/test/5meg.test1'; // 5 MB File

console.log('* Downloading test file...');

request
  .get(url)
  .on('data', spinner.spin)
;

Example 3 (examples/app3.js)

Extended version of previous example.

var request = require('request');
var spinner = require('text-spinner')({ interval: 100 });

var url = 'http://mirror.internode.on.net/pub/test/5meg.test1'; // 5 MB File

console.log('* Downloading test file...');

request
  .get(url)
  .on('response', function (res) {
    var contentLength = parseInt(res.headers[ 'content-length' ]);
    console.log('* Download started, size: ' + (contentLength ? contentLength + ' bytes' : 'unknown') + '.'); })
  .on('data',     function (chunk) {
    spinner.spin();
  })
  .on('end',      function() {
    console.log('* Download finished.');
  })
  .on('error',      function(err) {
    console.log('* ERROR:', err);
  })
;

Example 4 (examples/app4.js)

Example 4 shows how to customize outlook for the spinner. Please, refer to source of examples/app4.js for more info.

Credits

Alexander

Links to package pages:

github.com   npmjs.com   travis-ci.org   coveralls.io   inch-ci.org

License

MIT