<commit_before>/*jshint node:true */

'use strict';

var posNotation = require('positional-notation');
var toBigFactory = require('to-decimal-arbitrary-precision');

var R = require('./R');

var defaultB = toBigFactory(require('./Big'));
var defaultSymbols = '<KEY>';
var joinWithoutSep = R.join('');
var splitWithoutSep = R.split('');
var toString = R.invoker(0, 'toString');
var add = R.invoker(1, 'plus');

var indexOfSymbol = R.memoize(function(symbols) {
  return R.memoize(R.indexOf(R.__, symbols));
});

var nthSymbol = R.memoize(function(symbols) {
  return R.memoize(R.nth(R.__, symbols));
});

var postprocess = R.memoize(function(symbols) {
  return R.identical(symbols, defaultSymbols) ?
    R.identity :
    R.pipe(
      R.map(nthSymbol(symbols)),
      joinWithoutSep,
      toString
    );
});

var toDecimalRaw = R.curryN(4, function(b, symbols, base, n) {
  return R.pipe(
    toString,
    splitWithoutSep,
    R.reverse,
    R.map(indexOfSymbol(symbols)),
    R.addIndex(R.map)(posNotation.mapper(b, base)),
    R.reduce(add, b(0)),
    toString,
    postprocess(symbols)
  )(n);
});

var toDecimal = toDecimalRaw(defaultB, defaultSymbols);
<commit_msg>refactor: remove superfluous step<commit_after>/*jshint node:true */

'use strict';

var posNotation = require('positional-notation');
var toBigFactory = require('to-decimal-arbitrary-precision');

var R = require('./R');

var defaultB = toBigFactory(require('./Big'));
var defaultSymbols = '<KEY>';
var joinWithoutSep = R.join('');
var splitWithoutSep = R.split('');
var toString = R.invoker(0, 'toString');
var add = R.invoker(1, 'plus');

var indexOfSymbol = R.memoize(function(symbols) {
  return R.memoize(R.indexOf(R.__, symbols));
});

var nthSymbol = R.memoize(function(symbols) {
  return R.memoize(R.nth(R.__, symbols));
});

var postprocess = R.memoize(function(symbols) {
  return R.identical(symbols, defaultSymbols) ?
    R.identity :
    R.pipe(
      R.map(nthSymbol(symbols)),
      joinWithoutSep,
      toString
    );
});

var toDecimalRaw = R.curryN(4, function(b, symbols, base, n) {
  return R.pipe(
    toString,
    R.reverse,
    R.map(indexOfSymbol(symbols)),
    R.addIndex(R.map)(posNotation.mapper(b, base)),
    R.reduce(add, b(0)),
    toString,
    postprocess(symbols)
  )(n);
});

var toDecimal = toDecimalRaw(defaultB, defaultSymbols);

{'fraction_non_alphanumeric': 0.1697228144989339, 'fraction_numerical': 0.003411513859275053, 'mean_word_length': 4.295711060948081, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1297682', 'n_tokens_mistral': 848, 'n_tokens_neox': 843, 'n_words': 162}