How to use the blue function from colors

Find comprehensive JavaScript colors.blue code examples handpicked from public code repositorys.

colors.blue is a method that applies blue color to the provided text in the console output.

22
23
24
25
26
27
28
29
30
31
  console.log('');
  console.log('Examples:');
  console.log(`  $ ${program._name} -c ./config.json`);
  console.log(`  $ ${program._name} -i NDJjNGVx........GZzZGY=\n`);
  console.log(
    colors.blue(
      'For questions and error reports please visit the github repository: https://github.com/ofarukcaki/duckimport'
    )
  );
});
fork icon2
star icon13
watch icon2

+ 3 other calls in file

10
11
12
13
14
15
16
17
18
    salida+=`${i} ${'x'.green} ${base} ${'='.green} ${i*base}\n`
    consola+=`${i} ${'x'} ${base} ${'='} ${i*base}\n`
}
if(listFlag){
    console.log('================'.green);
    console.log(`Tabla del`.green, colors.blue(base));
    console.log('================'.green);
    console.log(salida);
}
fork icon0
star icon0
watch icon0

How does colors.blue work?

colors.blue is a function provided by the colors library in Node.js that returns a string wrapped in ANSI escape codes to display text in blue color in the console. When a string is passed as an argument to colors.blue, it wraps the string with ANSI escape codes that signify the color blue, and when printed to the console, the text will be displayed in blue color. Under the hood, the colors library uses regular expressions to match the string with ANSI escape codes that signify the desired color.

99
100
101
102
103
104
105
106
107
108

if (!request.response) {
  logger.error('response is null in Logger.hapiApi()')
}
const msToDate = timestamp => {
  return colors.blue(moment(timestamp).format('YYYY-MM-DD HH:mm:ss.SSS'))
}

// console.log(util.inspect(request, true, 2, true))
let message = ''
fork icon0
star icon0
watch icon0

Ai Example

1
2
3
const colors = require("colors");

console.log(colors.blue("This text will be printed in blue color!"));

This will print the text in blue color in the console.