Tabnine Logo For Javascript
colors
Code IndexAdd Tabnine to your IDE (free)

How to use colors

Best JavaScript code snippets using colors(Showing top 15 results out of 423)

origin: o1lab/xmysql

function paintHelp(txt) {
 return colors.magenta(txt); //display the help text in a color
}
origin: victorb/trymodule

const logGreen = (msg) => console.log(colors.green(msg))
origin: victorb/trymodule

const loadPackage = (moduleName, moduleAs, installPath) => {
 return new Promise((resolve, reject) => {
  try {
   const loadedPackage = require(packageLocation(moduleName, installPath))
   console.log(colors.blue(`'${moduleName}' was already installed since before!`))
   resolve({name: moduleName, package: loadedPackage, as: moduleAs})
  } catch (err) {
   console.log(colors.yellow(`Couldn't find '${moduleName}' locally, gonna download it now`))
   npmi({name: moduleName, path: installPath}, (err, result) => {
    if (err) {
     console.log(colors.red(err.message))
     if (err.statusCode === 404) {
      throw new Error(`Could not find package ${moduleName}`)
     }
     if (err.code === npmi.LOAD_ERR) {
      throw new Error('npm load error')
     }
     if (err.code === npmi.INSTALL_ERR) {
      throw new Error('npm install error')
     }
    }
    const loadedPackage = require(packageLocation(moduleName, installPath))
    resolve({name: moduleName, package: loadedPackage, as: moduleAs})
   })
  }
 })
}
origin: seanjameshan/blockchain-cli

const blockNumber = object[key]
if (blockNumber === 0) {
 table.push([{colSpan:2,content:colors.green.bold("🏆  Genesis Block"), hAlign:'center'}])
} else {
 table.push([{colSpan:2,content:colors.green.bold(`⛓  Block #${object[key]}`), hAlign:'center'}])
 obj[`⏮  ${colors.red('Previous Hash')}`] = object[key]
} else if (key === 'timestamp') {
 obj[`📅  ${colors.red('Timestamp')}`] = new Date(object[key] * 1000).toUTCString()
} else if (key === 'data') {
  obj[`📄  ${colors.red('Data')}`] = object[key]
} else if (key === 'hash') {
 obj[`📛  ${colors.red('Hash')}`] = object[key]
} else if (key === 'nonce') {
 obj[`🔨  ${colors.red('Nonce')}`] = object[key]
origin: cli-table/cli-table3

it('red-on-green( zebra (hello world) ) truncated to 10 chars', function () {
   let original = colors.red.bgGreen(colors.zebra('hello world'));
   let expected = colors.red.bgGreen(colors.zebra('hello wor')) + '…';
   expect(truncate(original, 10)).toEqual(expected);
  });
origin: alfonsorios96/async-js

example03.conditionalAsync()
  .then(response => {
    console.log(colors.cyan('Async/Await output: '));
    console.log(colors.green(JSON.stringify(response)));
  });
origin: AndiDittrich/Node.CLI-Progress

function myFormatter(options, params, payload){

  // bar grows dynamically by current progrss - no whitespaces are added
  const bar = options.barCompleteString.substr(0, Math.round(params.progress*options.barsize));

  // end value reached ?
  // change color to green when finished
  if (params.value >= params.total){
    return '# ' + _colors.grey(payload.task) + '   ' + _colors.green(params.value + '/' + params.total) + ' --[' + bar + ']-- ';
  }else{
    return '# ' + payload.task + '   ' + _colors.yellow(params.value + '/' + params.total) + ' --[' + bar + ']-- ';
  }    
}
origin: AndiDittrich/Node.CLI-Progress

// helper function to display preset
function showPreset(name){
  console.log(_colors.magenta('Preset: ' + name));

  // create a new progress bar with preset
  var bar = new _progress.Bar({}, _progress.Presets[name] || _progress.Presets.legacy);
  bar.start(200, 0);

  // random value 1..200
  bar.update(Math.floor((Math.random() * 200) + 1));
  bar.stop();
  console.log('');
}
origin: lucamezzalira/micro-runner

const exit_error = (err) => {
  spinner.stop();
  console.error(colors.red(`\n${err}`));
  process.exit();
}
origin: cli-table/cli-table3

it('feel free to use colors in your content strings, column widths will be calculated correctly', function () {
  function makeTable() {
   let table = new Table({
    colWidths: [5],
    style: { head: [], border: [] },
   });

   table.push([colors.red('hello')]);

   return table;
  }

  let expected = ['┌─────┐', '│ ' + colors.red('he') + '… │', '└─────┘'];

  return [makeTable, expected, 'truncation-with-colors'];
 });
origin: Vitagliano/Tauros

/**
 * Initialize and start the bot.
 */
function start() {
 console.log(c.cyan("Carregando eventos..."));
 loadEvents("./events");

 console.log(c.cyan("Carregando comandos..."));
 loadCommands("./commands");

 console.log(c.cyan("Conectando o bot..."));
 client.login(process.env.CLIENT_TOKEN);
 client.mongoose.init();
}
origin: keepitcool/prettyoutput

it('should indent correctly the hashes keys', () => {
    const input = { veryLargeParam: 'first string', param: 'second string' }
    const output = prettyoutput(input)

    output.should.equal(
      [`${colors.green('veryLargeParam: ')}first string`, `${colors.green('param: ')}         second string`, ''].join('\n')
    )
  })
origin: alfonsorios96/async-js

example04.intermediateValuesPromise()
  .then(response => {
    console.log(colors.cyan('Promise output: '));
    console.log(colors.green(response));
  });
origin: cli-table/cli-table3

it('red-on-green( zebra (hello world) ) truncated to 11 chars', function () {
   let original = colors.red.bgGreen(colors.zebra('hello world'));
   let expected = colors.red.bgGreen(colors.zebra('hello world'));
   expect(truncate(original, 11)).toEqual(expected);
  });
origin: keepitcool/prettyoutput

it('should allow turning off aligning hash key values', () => {
    const input = { veryLargeParam: 'first string', param: 'second string' }
    const output = prettyoutput(input, { alignKeyValues: false })

    output.should.equal([`${colors.green('veryLargeParam: ')}first string`, `${colors.green('param: ')}second string`, ''].join('\n'))
  })
colors(npm)

JSDoc

get colors in your node.js console

Most used colors functions

  • red
  • green
  • yellow
  • cyan
  • bold
  • blue,
  • bgRed,
  • grey,
  • Color.bold,
  • gray,
  • white,
  • Color.white,
  • bgWhite,
  • bgYellow,
  • color,
  • error,
  • inverse,
  • rainbow,
  • Color.error

Popular in JavaScript

  • commander
    the complete solution for node.js command-line programs
  • minimist
    parse argument options
  • q
    A library for promises (CommonJS/Promises/A,B,D)
  • js-yaml
    YAML 1.2 parser and serializer
  • mocha
    simple, flexible, fun test framework
  • cheerio
    Tiny, fast, and elegant implementation of core jQuery designed specifically for the server
  • colors
    get colors in your node.js console
  • crypto
  • mkdirp
    Recursively mkdir, like `mkdir -p`
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now