<commit_before>/* eslint no-process-exit: 0 */
import _ from 'lodash';
import yargs from 'yargs';
import common from './common-yargs';
import path from 'path';
import { countPath } from '../count';
import spinner from 'char-spinner';
import colors from 'colors';
import columnify from 'columnify';
import { SELECTOR_LIMIT } from '../constants';

function format(results, srcPath) {
  let formattedData = results
    .map(x => {
      let color = x.exceedsLimit ? colors.red : colors.green;
      let relativeFilepath = path.relative(srcPath, x.filepath);

      return {
        filepath: color(relativeFilepath),
        selectorCount: color(x.selectorCount)
      };
    });

  let formattedResults = columnify(formattedData, {
    columnSplitter: '  ',
    config: {
      filepath: {
        headingTransform() { return 'File Path'.bold.underline; }
      },
      selectorCount: {
        headingTransform() { return `Selector Count (Limit: ${SELECTOR_LIMIT})`.bold.underline; }
      }
    }
  });
<commit_msg>Formatting numbers<commit_after>/* eslint no-process-exit: 0 */
import _ from 'lodash';
import yargs from 'yargs';
import common from './common-yargs';
import path from 'path';
import { countPath } from '../count';
import spinner from 'char-spinner';
import colors from 'colors';
import numberFormatter from 'format-number';
import columnify from 'columnify';
import { SELECTOR_LIMIT } from '../constants';

const formatNumber = numberFormatter();

function format(results, srcPath) {
  let formattedData = results
    .map(x => {
      let color = x.exceedsLimit ? colors.red : colors.green;
      let relativeFilepath = path.relative(srcPath, x.filepath);
      let formattedNumber = formatNumber(x.selectorCount);

      return {
        filepath: color(relativeFilepath),
        selectorCount: color(formattedNumber)
      };
    });

  let formattedResults = columnify(formattedData, {
    columnSplitter: '  ',
    config: {
      filepath: {
        headingTransform() { return 'File Path'.bold.underline; }
      },
      selectorCount: {
        headingTransform() { return `Selector Count (Limit: ${SELECTOR_LIMIT})`.bold.underline; }
      }
    }
  });

{'fraction_non_alphanumeric': 0.12832263978001834, 'fraction_numerical': 0.0009165902841429881, 'mean_word_length': 3.280392156862745, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2603803', 'n_tokens_mistral': 638, 'n_tokens_neox': 628, 'n_words': 165}