Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chalk-animation

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chalk-animation - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

a.js

29

index.js

@@ -129,13 +129,20 @@ 'use strict';

stopped: false,
frame: 0,
nextStep() {
init: false,
f: 0,
render() {
const self = this;
log('\u001B[1F\u001B[G\u001B[2K' + effect(this.text, this.frame));
if (!this.init) {
log('');
this.init = true;
}
log(this.frame());
setTimeout(() => {
self.frame++;
if (!self.stopped) {
self.nextStep();
self.render();
}
}, delay / speed);
},
frame() {
return '\u001B[1F\u001B[G\u001B[2K' + effect(this.text, this.f++);
},
replace(str) {

@@ -146,11 +153,15 @@ this.text = str;

this.stopped = true;
return this;
},
start() {
this.stopped = false;
this.nextStep();
this.render();
return this;
}
};
log('');
currentAnimation.start();
setTimeout(() => {
if (!currentAnimation.stopped) {
currentAnimation.start();
}
}, delay / speed);
return currentAnimation;

@@ -157,0 +168,0 @@ }

{
"name": "chalk-animation",
"description": "Colorful animations in terminal stdout",
"version": "1.2.0",
"description": "Colorful animations in terminal output",
"version": "1.3.0",
"author": "Boris K",

@@ -13,3 +13,3 @@ "bugs": "https://github.com/bokub/chalk-animation/issues",

"devDependencies": {
"ava": "^0.21.0",
"ava": "^0.22.0",
"xo": "^0.18.2"

@@ -16,0 +16,0 @@ },

@@ -8,3 +8,3 @@ # chalk-animation

> Colorful animations in terminal stdout
> Colorful animations in terminal output

@@ -38,4 +38,8 @@

You can stop and restart an animation with `stop()` and `start()`
#### Start and stop
You can stop and resume an animation with `stop()` and `start()`.
When created, the instance of chalkAnimation **starts automatically**.
```javascript

@@ -54,2 +58,4 @@ const rainbow = chalkAnimation.rainbow('Lorem ipsum'); // Animation starts

#### Automatic stop
Anything printed to the console will stop the previous animation automatically

@@ -65,2 +71,4 @@

#### Changing speed
Change the animation speed using a second parameter. Should be greater than 0, default is 1.

@@ -72,2 +80,4 @@

#### Changing text
Change the animated text seamlessly with `replace()`

@@ -81,7 +91,20 @@

setInterval(() => {
str += '.';
rainbow.replace(str);
rainbow.replace(str += '.');
}, 1000);
```
#### Manual rendering
Manually render frames with `render()`, or get the content of the next frame with `frame()`
```javascript
const rainbow = chalkAnimation.rainbow('Lorem ipsum').stop(); // Don't start the animation
rainbow.render(); // Display the first frame
const frame = rainbow.frame(); // Get the second frame
console.log(frame);
```
## CLI mode

@@ -111,2 +134,3 @@

## Related

@@ -113,0 +137,0 @@

Sorry, the diff of this file is not supported yet

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