This article is a showcase of a popular node library to display colors in the console.
The gist Here is the code you need to get started:
var colors = require ('colors' );console .log(colors.red('Love, exciting and new' ));console .log(colors.inverse('Come aboard, we\'re expecting you' ));console .log(colors.rainbow('Love, life\'s sweetest reward' ));console .log(colors.bgMagenta('Let it flow, it floats back to you' ));console .log(colors.bgGreen.black('The Love Boat soon will be making another run' ));
Run it and you will see the following in your console:
Don’t forget to npm install the library with:
String prototype The library will also add string prototypes to simplify the code, use whichever you prefer:
console .log(('Love, exciting and new' ).red);console .log(('Come aboard, we\'re expecting you' ).inverse);console .log(('Love, life\'s sweetest reward' ).rainbow);console .log(('Let it flow, it floats back to you' ).bgMagenta);console .log(('The Love Boat soon will be making another run' ).bgGreen.black);
Easter Egg The library mentions a “a secret undocumented style” . Here it is for those too lazy to look it up.