<commit_before>import {
  name as LIB_NAME,
  version as LIB_VERSION
} from '../package.json';

function pretty(arg) {
  let objs = [];
  let keys = [];

  return JSON.stringify(arg, (k, v) => {
    if (v instanceof Object) {
      let seen = objs.indexOf(v);

      if (seen === -1) {
        objs.push(v);
        keys.push(k || 'ROOT');

        return v;
      }

      return `${v} (ref to ${keys[seen]})`;
    }

    return v;
  }, 2);
}

function _output(arg) {
  console.log(String(arg));
}

const peek42 = {
  get [Symbol.toStringTag]() {
    return LIB_NAME;
  },
  version: LIB_VERSION,
  pretty,
  _output
};

export {
  pretty,
  _output
};
export default peek42;<commit_msg>Add function for creating plugins (only works with apivis for now)<commit_after>import {
  name as LIB_NAME,
  version as LIB_VERSION
} from '../package.json';

function _output(arg) {
  console.log(String(arg));
}

function pretty(arg) {
  let objs = [];
  let keys = [];

  return JSON.stringify(arg, (k, v) => {
    if (v instanceof Object) {
      let seen = objs.indexOf(v);

      if (seen === -1) {
        objs.push(v);
        keys.push(k || 'ROOT');

        return v;
      }

      return `${v} (ref to ${keys[seen]})`;
    }

    return v;
  }, 2);
}

// TODO: Only works with apivis for now, develop general plugin model
function use(lib) {
  const {typeStr, descStr, membersStr, chainStr, apiStr} = lib;
  const {p} = peek42;

  p.type = (arg) => p(typeStr(arg));
  p.desc = (arg, k) => p(descStr(arg, k));
  p.members = (arg) => p(membersStr(arg));
  p.chain = (arg) => p(chainStr(arg));
  p.api = (arg) => p(apiStr(arg));

  return peek42;
}

const peek42 = {
  get [Symbol.toStringTag]() {
    return LIB_NAME;
  },
  version: LIB_VERSION,
  _output,
  pretty,
  use
};

export {
  _output,
  pretty,
  use
};
export default peek42;
{'fraction_non_alphanumeric': 0.16757344940152338, 'fraction_numerical': 0.008705114254624592, 'mean_word_length': 2.6927710843373496, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '1912146', 'n_tokens_mistral': 707, 'n_tokens_neox': 672, 'n_words': 175}