"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/colors/example.js" (8 Mar 2017, 2423 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 var colors = require('./colors');
    2 
    3 //colors.mode = "browser";
    4 
    5 var test = colors.red("hopefully colorless output");
    6 console.log('Rainbows are fun!'.rainbow);
    7 console.log('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse); // styles not widely supported
    8 console.log('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported
    9 //console.log('zalgo time!'.zalgo);
   10 console.log(test.stripColors);
   11 console.log("a".grey + " b".black);
   12 console.log("Zebras are so fun!".zebra);
   13 console.log('background color attack!'.black.whiteBG)
   14 
   15 //
   16 // Remark: .strikethrough may not work with Mac OS Terminal App
   17 //
   18 console.log("This is " + "not".strikethrough + " fun.");
   19 console.log(colors.rainbow('Rainbows are fun!'));
   20 console.log(colors.italic('So ') + colors.underline('are') + colors.bold(' styles! ') + colors.inverse('inverse')); // styles not widely supported
   21 console.log(colors.bold(colors.italic(colors.underline(colors.red('Chains are also cool.'))))); // styles not widely supported
   22 //console.log(colors.zalgo('zalgo time!'));
   23 console.log(colors.stripColors(test));
   24 console.log(colors.grey("a") + colors.black(" b"));
   25 
   26 colors.addSequencer("america", function(letter, i, exploded) {
   27   if(letter === " ") return letter;
   28   switch(i%3) {
   29     case 0: return letter.red;
   30     case 1: return letter.white;
   31     case 2: return letter.blue;
   32   }
   33 });
   34 
   35 colors.addSequencer("random", (function() {
   36   var available = ['bold', 'underline', 'italic', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'];
   37 
   38   return function(letter, i, exploded) {
   39     return letter === " " ? letter : letter[available[Math.round(Math.random() * (available.length - 1))]];
   40   };
   41 })());
   42 
   43 console.log("AMERICA! F--K YEAH!".america);
   44 console.log("So apparently I've been to Mars, with all the little green men. But you know, I don't recall.".random);
   45 
   46 //
   47 // Custom themes
   48 //
   49 
   50 // Load theme with JSON literal
   51 colors.setTheme({
   52   silly: 'rainbow',
   53   input: 'grey',
   54   verbose: 'cyan',
   55   prompt: 'grey',
   56   info: 'green',
   57   data: 'grey',
   58   help: 'cyan',
   59   warn: 'yellow',
   60   debug: 'blue',
   61   error: 'red'
   62 });
   63 
   64 // outputs red text
   65 console.log("this is an error".error);
   66 
   67 // outputs yellow text
   68 console.log("this is a warning".warn);
   69 
   70 // outputs grey text
   71 console.log("this is an input".input);
   72 
   73 // Load a theme from file
   74 colors.setTheme('./themes/winston-dark.js');
   75 
   76 console.log("this is an input".input);
   77