How to use ansicolors - 10 common examples

To help you get started, we’ve selected a few ansicolors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thlorenz / visulator / test / real.js View on Github external
proto._stepNcheck = function _stepNcheck(step) {
  // print instruction
  // this._t.pass(colors.brightBlue(step.instruction))
  this._t.pass(colors.brightBlue(step.line))
  this._cu.next();
  this._checkRegs(step.regs)
}
github thlorenz / cardinal / test / fixtures / custom.js View on Github external
'true'   :  colors.red

    , 'false'  :  undefined
    , _default :  colors.brightRed
    }

  , 'Identifier': {
      'undefined' :  colors.brightBlack
    , 'self'      :  colors.brightRed
    , 'console'   :  colors.blue
    , 'log'       :  colors.blue
    , 'warn'      :  colors.red
    , 'error'     :  colors.brightRed
    //
      // changed from default
    , _default    :  colors.brightCyan
    }

  , 'Null': {
      _default: colors.brightBlack
    }

  , 'Numeric': {
      _default: colors.blue
    }

  , 'String': {
      _default: colors.brightGreen
    }

  , 'Keyword': {
      'break'       :  undefined
github drewcummins / hodlol / dist / models / trader / index.js View on Github external
let dateEnd = colors.magenta(dateFormat(scenario.end, "mmm d, h:MM:ssTT"));
            date = colors.magenta(dateFormat(Math.min(scenario.time, scenario.end), "mmm d, h:MM:ssTT"));
            out += ` | Backtesting from ${dateStart} to ${dateEnd}\n\n`;
        }
        let columns = [];
        for (var i = 0; i < this.strategies.length; i++) {
            let strategy = this.strategies[i];
            try {
                let value = await strategy.portfolio.value(this.params.quote, this.exchange.price.bind(this.exchange));
                if (!strategy.originalValue)
                    strategy.originalValue = value;
                let total = types_1.BN(value.all.free).plus(value.all.reserved).toFixed(2);
                let originalTotal = types_1.BN(strategy.originalValue.all.free).plus(strategy.originalValue.all.reserved).toFixed(2);
                let valstr = colors.green("$" + total);
                let ovalstr = colors.green("$" + originalTotal);
                columns.push({ strategy: colors.blue(strategy.title), value: valstr, "original value": ovalstr });
            }
            catch (err) {
                throw err;
            }
        }
        let table = columnify(columns, { minWidth: 20 });
        table = table.split("\n").join("\n | ");
        // console.log(" | " + table);
        out += " | " + table + "\n";
        if (types_1.Scenario.getInstance().mode == types_1.ScenarioMode.PLAYBACK) {
            out += (`\n | ${date}\n`);
        }
        console.log(`\n${out}\n`);
        this.print = false;
    }
}
github drewcummins / hodlol / app / model / trader / index.js View on Github external
var date = "";
    if (this.exchange.isBacktesting()) {
      let dateStart = colors.magenta(dateFormat(config.scenario.start, "mmm d, h:MM:ssTT"));
      let dateEnd = colors.magenta(dateFormat(config.scenario.end, "mmm d, h:MM:ssTT"));
      date = colors.magenta(dateFormat(Math.min(this.exchange.time, config.scenario.end), "mmm d, h:MM:ssTT"));
      console.log(` | Backtesting from ${dateStart} to ${dateEnd}\n`);
    }
    let columns = [];
    for (var i = 0; i < this.strategies.length; i++) {
      let strategy = this.strategies[i];
      try {
        let value = await strategy.portfolio.value("USDT");
        if(!strategy.originalValue) strategy.originalValue = value;
        let valstr = colors.green("$" + value.total.toFixed(2));
        let ovalstr = colors.green("$" + strategy.originalValue.total.toFixed(2));
        columns.push({strategy: colors.blue(strategy.title), value: valstr, "original value": ovalstr});
        // console.log(" |=> " + strategy.prettyTitle(), valstr + ", original value:", ovalstr);
      } catch(err) {
        throw err;
        console.log("Error calculating value");
      }
    }
    let table = columnify(columns, {minWidth: 20});
    table = table.split("\n").join("\n | ");
    console.log(" | " + table);
    console.log("");
    console.log(` | ${date}`);
    console.log("\n");
  }
github GLAMpipe / GLAMpipe / glampipe.js View on Github external
self.core.createDirIfNotExist(path.join(self.dataPath, "projects"), function(error, msg) {
					
							if(error) {
								console.log(colors.red("DATAPATH problem: " + self.dataPath));
								console.log(msg);
								cb(error);
							} else {
								global.config.dataPath = self.dataPath;
								global.config.projectsPath = path.join(self.dataPath, "projects");

								// Create the express server and routes.
								self.initializeServer();
								console.log(colors.green("INIT done"));
								cb(); 
							}
						});
					});
github drewcummins / hodlol / app / model / trader / index.js View on Github external
async printPerformance() {
    if (this.strategies.length == 0) return;
    console.log('\x1Bc');
    var date = "";
    if (this.exchange.isBacktesting()) {
      let dateStart = colors.magenta(dateFormat(config.scenario.start, "mmm d, h:MM:ssTT"));
      let dateEnd = colors.magenta(dateFormat(config.scenario.end, "mmm d, h:MM:ssTT"));
      date = colors.magenta(dateFormat(Math.min(this.exchange.time, config.scenario.end), "mmm d, h:MM:ssTT"));
      console.log(` | Backtesting from ${dateStart} to ${dateEnd}\n`);
    }
    let columns = [];
    for (var i = 0; i < this.strategies.length; i++) {
      let strategy = this.strategies[i];
      try {
        let value = await strategy.portfolio.value("USDT");
        if(!strategy.originalValue) strategy.originalValue = value;
        let valstr = colors.green("$" + value.total.toFixed(2));
        let ovalstr = colors.green("$" + strategy.originalValue.total.toFixed(2));
        columns.push({strategy: colors.blue(strategy.title), value: valstr, "original value": ovalstr});
        // console.log(" |=> " + strategy.prettyTitle(), valstr + ", original value:", ovalstr);
      } catch(err) {
        throw err;
        console.log("Error calculating value");
github liquidg3 / altair / node_modules / npm / lib / ls.js View on Github external
if (data.peerInvalid) {
    var peerInvalid = 'peer invalid'
    if (npm.color) peerInvalid = color.bgBlack(color.red(peerInvalid))
    out.label += ' ' + peerInvalid
  }

  if (data.peerMissing) {
    var peerMissing = 'UNMET PEER DEPENDENCY'
    if (npm.color) peerMissing = color.bgBlack(color.red(peerMissing))
    out.label = peerMissing + ' ' + out.label
  }

  if (data.extraneous && data.path !== dir) {
    var extraneous = 'extraneous'
    if (npm.color) extraneous = color.bgBlack(color.green(extraneous))
    out.label += ' ' + extraneous
  }

  if (data.error && depth) {
    var message = data.error.message
    if (message.indexOf('\n')) message = message.slice(0, message.indexOf('\n'))
    var error = 'error: ' + message
    if (npm.color) error = color.bgRed(color.brightWhite(error))
    out.label += ' ' + error
  }

  // add giturl to name@version
  if (data._resolved) {
    try {
      var type = npa(data._resolved).type
      var isGit = type === 'git' || type === 'hosted'
github thlorenz / cardinal / themes / hide-semicolons.js View on Github external
_default: function(s, info) {
        var nextToken = info.tokens[info.tokenIndex + 1]

        // show keys of object literals and json in different color
        return (nextToken && nextToken.type === 'Punctuator' && nextToken.value === ':')
          ? colors.green(s)
          : colors.brightGreen(s)
      }
    }
github liquidg3 / altair / node_modules / npm / lib / outdated.js View on Github external
if (!npm.config.get('global')) {
    dir = path.relative(process.cwd(), dir)
  }

  var columns = [ depname,
                  has || 'MISSING',
                  want,
                  latest,
                  deppath
                ]
  if (long) columns[5] = type

  if (npm.color) {
    columns[0] = color[has === want ? 'yellow' : 'red'](columns[0]) // dep
    columns[2] = color.green(columns[2]) // want
    columns[3] = color.magenta(columns[3]) // latest
    columns[4] = color.brightBlack(columns[4]) // dir
    if (long) columns[5] = color.brightBlack(columns[5]) // type
  }

  return columns
}
github graalvm / graaljs / deps / npm / lib / ls.js View on Github external
function makeArchy_ (data, long, dir, depth, parent, d) {
  if (data.missing) {
    if (depth - 1 <= npm.config.get('depth')) {
      // just missing
      var unmet = 'UNMET ' + (data.optional ? 'OPTIONAL ' : '') + 'DEPENDENCY'
      if (npm.color) {
        if (data.optional) {
          unmet = color.bgBlack(color.yellow(unmet))
        } else {
          unmet = color.bgBlack(color.red(unmet))
        }
      }
      var label = data._id || (d + '@' + data.requiredBy)
      if (data._found === 'explicit' && data._id) {
        if (npm.color) {
          label = color.bgBlack(color.yellow(label.trim())) + ' '
        } else {
          label = label.trim() + ' '
        }
      }
      return {
        label: unmet + ' ' + label,
        nodes: Object.keys(data.dependencies || {})
          .sort(alphasort).filter(function (d) {
            return !isCruft(data.dependencies[d])
          }).map(function (d) {
            return makeArchy_(sortedObject(data.dependencies[d]), long, dir, depth + 1, data, d)
          })
      }
    } else {
      return {label: d + '@' + data.requiredBy}
    }