Socket
Socket
Sign inDemoInstall

simple-spinner

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-spinner - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

.npmignore

9

package.json
{
"name": "simple-spinner",
"description": "A super simple spinner",
"keywords": ["simple", "spinner", "indicator"],
"version": "0.0.3",
"keywords": [
"simple",
"spinner",
"indicator"
],
"version": "0.0.4",
"licence": "MIT",

@@ -15,3 +19,4 @@ "author": "Ian McCall <imccall@da-puck.com> (http://www.ianmccall.codes/)",

"dependencies": {
"ansi": "^0.3.0"
}
}

@@ -14,7 +14,11 @@ Supper Simple Spinner for Node.js

* start(\[interval in ms\])
* Obviously this starts the spinner. You can give it how quickly you want it to go through the sequence of characters. Defaults to 250ms.
* stop()
* I really shouldn't have to explain this one...
* change_sequence(sequence)
* Use this if you don't like the default spinning stick. Give it an array of strings like this `[".", "o", "0", "@", "*"]`
* `start([interval in ms], [options])`
* Obviously this starts the spinner. You can give it how quickly you want it to go through the sequence of characters. Defaults to 250ms.
* **Update (2015-07-24)**: start can now also take an options object with the following keys:
* `hideCursor` (boolean, default: false): When true, hide the console cursor (uses TooTallNate/ansi.js)
* `doNotBlock` (boolean, default: false): When true, unref the timer so it does not prevent the process from exiting.
* `stop()`
* I really shouldn't have to explain this one...
* `change_sequence(sequence)`
* Use this if you don't like the default spinning stick. Give it an array of strings like this `[".", "o", "0", "@", "*"]`
/***********
* Spinner *
***********/
var cursor = require('ansi')(process.stdout);
var spinner = (function() {
//var util = require('util');
var sequence = ["|","/","-","\\"]; //[".", "o", "0", "@", "*"];
var index = 0;
var timer;
function start(inv) {
var opts = {};
function start(inv, options) {
options = options || {};
opts = options;
if(options.hideCursor) {
cursor.hide();
}
inv = inv || 250;
index = 0;
//util.print(sequence[index]);
process.stdout.write(sequence[index]);
timer = setInterval(function() {
//util.print(sequence[index].replace(/./g,"\r"));
process.stdout.write(sequence[index].replace(/./g,"\r"));
index = (index < sequence.length - 1) ? index + 1 : 0;
//util.print(sequence[index]);
process.stdout.write(sequence[index]);
},inv);
if(options.doNotBlock) {
timer.unref();
}
}
function stop() {
clearInterval(timer);
//util.print(sequence[index].replace(/./g,"\r"));
if(opts.hideCursor) {
cursor.show();
}
process.stdout.write(sequence[index].replace(/./g,"\r"));
}
function change_sequence(seq) {

@@ -35,3 +46,3 @@ if(Array.isArray(seq)) {

}
return {

@@ -38,0 +49,0 @@ start: start,

@@ -16,5 +16,19 @@ var spinner = require('./spinner');

spinner.stop();
test3();
}, 1000);
}
function test3() {
spinner.start(50,{ hideCursor : true });
setTimeout(function() {
spinner.stop();
spinner.start(100, { doNotBlock : true });
}, 1000);
}
process.on("exit", function() {
spinner.stop();
console.log("Have a nice day");
});
test1();
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc