chalkercli
Version:
Colorful animations in terminal output
139 lines (92 loc) • 3.16 kB
Markdown
[](https://www.npmjs.com/package/chalkercli)
[](https://www.npmjs.com/package/chalkercli)
> Colorful animations in terminal output
| Name | Preview |
|:---------:|:------------------------------------------:|
| rainbow |  |
| pulse |  |
| glitch |  |
| radar |  |
| neon |  |
| karaoke | |
```bash
$ npm i chalkercli
```
```javascript
const chalkAnimation = require('chalkercli');
chalkAnimation.rainbow('Lorem ipsum dolor sit amet');
```
You can stop and resume an animation with `stop()` and `start()`.
When created, the instance of chalkAnimation **starts automatically**.
```javascript
const rainbow = chalkAnimation.rainbow('Lorem ipsum'); // Animation starts
setTimeout(() => {
rainbow.stop(); // Animation stops
}, 1000);
setTimeout(() => {
rainbow.start(); // Animation resumes
}, 2000);
```
Anything printed to the console will stop the previous animation automatically
```javascript
chalkAnimation.rainbow('Lorem ipsum');
setTimeout(() => {
// Stop the 'Lorem ipsum' animation, then write on a new line.
console.log('dolor sit amet');
}, 1000);
```
Change the animation speed using a second parameter. Should be greater than 0, default is 1.
```javascript
chalkAnimation.rainbow('Lorem ipsum', 2); // Two times faster than default
```
Change the animated text seamlessly with `replace()`
```javascript
let str = 'Loading...';
const rainbow = chalkAnimation.rainbow(str);
// Add a new dot every second
setInterval(() => {
rainbow.replace(str += '.');
}, 1000);
```
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);
```
```bash
$ npm install --global chalkercli
```
```
$ chalkercli --help
Colorful animations in terminal output
Usage
$ chalkercli <name> [options] [text...]
Options
--duration Duration of the animation in ms, defaults to Infinity
--speed Animation speed as number > 0, defaults to 1
Available animations
rainbow
pulse
glitch
radar
neon
karaoke
Example
$ chalkercli rainbow Hello world!
```
MIT c [Ricky Rodrigo](https://github.com/veniqa)