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 0.0.1 to 0.1.0

test.js

22

index.js

@@ -6,6 +6,6 @@ 'use strict';

const log = console.log;
const gradientOptions = {interpolation: 'hsv', hsvSpin: 'long'};
const longHsv = {interpolation: 'hsv', hsvSpin: 'long'};
let currentAnimation = null;
const funcs = {
const consoleFunctions = {
log: console.log.bind(console),

@@ -18,6 +18,6 @@ info: console.info.bind(console),

// eslint-disable-next-line guard-for-in
for (const k in funcs) {
for (const k in consoleFunctions) {
console[k] = function () {
stopLastAnimation();
funcs[k].apply(console, arguments);
consoleFunctions[k].apply(console, arguments);
};

@@ -31,8 +31,14 @@ }

const rightColor = {h: (hue + 1) % 360, s: 1, v: 1};
return gradient(leftColor, rightColor)(str, gradientOptions);
return gradient(leftColor, rightColor)(str, longHsv);
}
};
function animateString(str, effect, delay) {
function animateString(str, effect, delay, speed) {
stopLastAnimation();
speed = speed === undefined ? 1 : parseFloat(speed);
if (!speed || speed <= 0) {
throw new Error(`Expected \`speed\` to be an number greater than 0`);
}
currentAnimation = {

@@ -49,3 +55,3 @@ stopped: false,

}
}, delay);
}, delay / speed);
},

@@ -72,2 +78,2 @@ stop() {

module.exports.rainbow = str => animateString(str, effects.rainbow, 15);
module.exports.rainbow = (str, speed) => animateString(str, effects.rainbow, 15, speed);
{
"name": "chalk-animation",
"description": "TODO",
"version": "0.0.1",
"description": "Colorful animations in terminal stdout",
"version": "0.1.0",
"author": "Boris K",
"bugs": "TODO",
"bugs": "https://github.com/bokub/chalk-animation/issues",
"dependencies": {

@@ -11,2 +11,3 @@ "gradient-string": "^0.1.1"

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

@@ -17,10 +18,29 @@ },

},
"homepage": "TODO",
"keywords": [],
"homepage": "https://github.com/bokub/chalk-animation",
"keywords": [
"animation",
"chalk",
"cli",
"color",
"colors",
"colour",
"command-line",
"console",
"formatting",
"gradient",
"log",
"logging",
"rainbow",
"shell",
"string",
"style",
"styles",
"terminal"
],
"license": "MIT",
"main": "index.js",
"repository": "TODO",
"repository": "bokub/chalk-animation",
"scripts": {
"test": "xo"
"test": "xo && ava"
}
}
# chalk-animation
> Work in progress ⏳
[![Build Status](https://travis-ci.org/bokub/chalk-animation.svg?branch=master)](https://travis-ci.org/bokub/chalk-animation)
[![npm](https://img.shields.io/npm/v/chalk-animation.svg)](https://www.npmjs.com/package/chalk-animation)
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)

@@ -18,3 +20,3 @@

chalkAnimation.rainbow('Lorem ipsum dolor sit amet, consectetur adipiscing elit');
chalkAnimation.rainbow('Lorem ipsum dolor sit amet');
```

@@ -25,10 +27,10 @@

```javascript
const animation = chalkAnimation.rainbow('Lorem ipsum dolor sit amet, consectetur adipiscing elit');
const rainbow = chalkAnimation.rainbow('Lorem ipsum'); // Animation starts
setTimeout(() => {
animation.stop();
rainbow.stop(); // Animation stops
}, 1000);
setTimeout(() => {
animation.start();
rainbow.start(); // Animation resumes
}, 2000);

@@ -43,6 +45,13 @@

setTimeout(() => {
console.log('dolor sit amet');
// 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 dolor sit amet', 2); // Two times faster than default
```
## Dependencies

@@ -49,0 +58,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