How to use ansicolor - 10 common examples

To help you get started, we’ve selected a few ansicolor 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 SAP / fundamental-vue / tests / e2e / plugins / index.js View on Github external
error(message) {
      // eslint-disable-next-line no-console
      console.error(ansi.red(message))
      process.stdout.write(`\u0007`) // make some noise: `beep`
      return null
    }
  })
github ccxt / ccxt / examples / js / bittrex-balance.js View on Github external
"use strict";

const ccxt      = require ('../../ccxt.js')
const asTable   = require ('as-table')
const log       = require ('ololog').configure ({ locate: false })

require ('ansicolor').nice

let sleep = (ms) => new Promise (resolve => setTimeout (resolve, ms))

;(async () => {

    // instantiate the exchange
    let exchange = new ccxt.bittrex  ({
        "apiKey": "471b47a06c384e81b24072e9a8739064",
        "secret": "694025686e9445589787e8ca212b4cff",
    })


    try {

        // fetch account balance from the exchange
        let balance = await exchange.fetchBalance ()
github ccxt / ccxt / examples / js / binance-fetch-ohlcv.js View on Github external
"use strict";

const ccxt       = require ('../../ccxt.js')
const asciichart = require ('asciichart')
const asTable    = require ('as-table')
const log        = require ('ololog').configure ({ locate: false })

require ('ansicolor').nice;

//-----------------------------------------------------------------------------

(async function main () {

    const index = 4 // [ timestamp, open, high, low, close, volume ]


    const ohlcv = await new ccxt.binance ().fetchOHLCV ('BTC/USDT', '1h')


    const lastPrice = ohlcv[ohlcv.length - 1][index] // closing price
    const series = ohlcv.slice (-80).map (x => x[index])         // closing price
    const bitcoinRate = ('₿ = $' + lastPrice).green
    const chart = asciichart.plot (series, { height: 15 })
    log.yellow ("\n" + chart, bitcoinRate, "\n")
github ccxt / ccxt / examples / js / exchange-capabilities.js View on Github external
"use strict";

/*  ------------------------------------------------------------------------ */

const ccxt        = require ('../../ccxt.js')
    , asTable     = require ('as-table') // .configure ({ print: require ('string.ify').noPretty })
    , log         = require ('ololog').noLocate
    , ansi        = require ('ansicolor').nice

;(async function test () {

    let total = 0
    let missing = 0
    let implemented = 0
    let emulated = 0

    log (asTable (ccxt.exchanges.map (id => new ccxt[id]()).map (exchange => {

        let result = {};

        [
            'publicAPI',
            'privateAPI',
            'CORS',
github ccxt / ccxt / examples / js / live-orderbook.js View on Github external
"use strict";

const asTable   = require ('as-table')
    , log       = require ('ololog').noLocate
    , ansi      = require ('ansicolor').nice
    , ccxt      = require ('../../ccxt.js')

let printSupportedExchanges = function () {
    log ('Supported exchanges:', ccxt.exchanges.join (', ').green)
}

let printUsage = function () {
    log ('Usage: node', process.argv[1], 'exchange'.green, 'symbol'.yellow, 'depth'.cyan)
    printSupportedExchanges ()
}

let printOrderBook = async (id, symbol, depth) => {

    // check if the exchange is supported by ccxt
    let exchangeFound = ccxt.exchanges.indexOf (id) > -1
    if (exchangeFound) {
github ccxt / ccxt / examples / js / order-book-extra-level-depth-param.js View on Github external
"use strict";

const ccxt = require ('../../ccxt')
const asTable = require ('as-table')
const log = require ('ololog')

require ('ansicolor').nice

;(async function test () {

    const exchange = new ccxt.bitfinex ()
    const orders = await exchange.fetchOrderBook ('BTC/USD', {
        'limit_bids': 5, // max = 50
        'limit_asks': 5, // may be 0 in which case the array is empty
        'group': 1, // 1 = orders are grouped by price, 0 = orders are separate
    })

    log (orders)
}) ()
github michnovka / ccxt-trading-cp / tradingcp.js View on Github external
terminal.nl();
    terminal.nl();
    terminal.showCentered(title, '-');
    terminal.showCentered(getYmdHisDate(timeStart)+' - '+ getYmdHisDate(timeEnd), '-');
    terminal.nl();

    if(!series)
        return;

    if(!precision)
        precision = 0;

    let asciichart = require ('asciichart');
    let log        = require ('ololog').configure ({ locate: false });

    require('ansicolor').nice;

    series = series.slice(-96);

    let firstPrice = series[0]; // closing price
    let lastPrice = series[series.length - 1]; // closing price
    let difference = (lastPrice/firstPrice -1)*100;

    if(difference < 0){
        difference = (terminal.number_format(difference,2)+'%').red;
    }else{
        difference = ('+'+terminal.number_format(difference,2)+'%').green;
    }
    let padding = '                ';

    let quoteRate = (symbol + ' = ' + quote + lastPrice).green;
    let chart = asciichart.plot(series, { height: 15, format: function (x) {
github mustardamus / nuxt-bulma-slim / lib / index.js View on Github external
// Nuxt's `build` and `start` command. Nuxt strips out the command from
    // process.argv - so this will only work if a user does a `npm start`.
    return
  }

  let outFile, outContent
  const options = getOptions(this.options, moduleOptions)
  const bulmaPath = getBulmaPath(options.rootDir)
  const sassPaths = [join(bulmaPath, 'bulma.sass'), ...options.additionalPaths]
  const license = '/*! bulma.io | MIT License | github.com/jgthms/bulma */'

  if (existsSync(options.variablesPath)) {
    sassPaths.unshift(options.variablesPath)
    debug(
      'Overwriting Bulma variables with',
      ansi.yellow(options.variablesPath)
    )
  }

  const sassContent = sassPaths
    .map(v => v.replace(/\\/g, '\\\\')) // replace backslash by double backslash (needed for windows)
    .map(v => `@import "${v}"`)
    .join('\n')

  if (options.disablePostCSSWarnings) {
    merge(this.options.build, {
      postcss: {
        plugins: {
          'postcss-custom-properties': {
            warnings: false
          }
        }
github ourarash / log-with-statusbar / index.js View on Github external
tag: (
    lines,
    {
      level = "",
      maxVerbosity = 1,
      verbosity = 1,
      enable = true,
      levelColor = {
        info: cyan,
        warn: yellow,
        error: red.bright.inverse,
        debug: blue
      }
    }
  ) => {
    if (!enable) {
      return [];
    }
    const levelStr =
      level && (levelColor[level] || (s => s))(level.toUpperCase());
    if (verbosity <= maxVerbosity) {
      if (level) {
        // Add level only to the first line
        let retVal = lines.map((l, i) => {
          if (i === 0) {
            return levelStr.padStart(6) + ":  " + l;
          } else {
github ccxt / ccxt / run-tests.js View on Github external
ps.on ('exit', code => {
            return_ ({
                failed: code !== 0,
                output,
                hasOutput: output.trim ().length > 0,
                hasWarnings,
                warnings: ansi.strip (stderr).match (/^\[[^\]]+\]/g) || []
            })
        })

ansicolor

A JavaScript ANSI color/style management. ANSI parsing. ANSI to CSS. Small, clean, no dependencies.

Unlicense
Latest version published 8 months ago

Package Health Score

64 / 100
Full package analysis