<commit_before>'use strict'

import handlers from './handlers'
import { IMurky } from './interfaces'
import { inspect } from 'util'
import { isString } from 'lodash'
import uncolor = require('uncolor')
import supportsColor = require('supports-color')
import assert = require('assert')

const murky: IMurky = (fmtStr, ...rawReplacers) => {
  // check user input: fmtStr
  if (!isString(fmtStr))
    throw new Error(`murky: input problem: the first arg must be a string!\
      \n\t arg type: ${typeof fmtStr}\
      \n\t arg data: ${inspect(fmtStr)}`)

  // get placeholders info
  const clrStr = fmtStr.replace(/%%/g, '  ')
  const psInfo = handlers.findAll(clrStr)

  // check placeholders info
  const psInfoOrderErrors = psInfo.map((pInfoA, indexA) => {
    return psInfo.slice(0, indexA).map((pInfoB, indexB) => {
      return { pInfoB, indexB }
    }).filter(({ pInfoB }) => {
      return pInfoA !== pInfoB
    }).filter(({ pInfoB }) => {
      return pInfoA.indexStart <= pInfoB.indexStart
    }).map(({ pInfoB, indexB }) => {
      return `wrong order of found placeholders: A should be placed after B:\
        \n\t A index: ${indexA}\
        \n\t B index: ${indexB}\
        \n\t A data: ${inspect(pInfoA)}\
        \n\t B data: ${inspect(pInfoB)}`
    })
  }).reduce((acc, part) => acc.concat(part), [])

  const psInfoCrossErrors = psInfo.map((pInfoA, indexA) => {
    return psInfo.map((pInfoB, indexB) => {
      return { pInfoB, indexB }
    }).filter(({ pInfoB }) => {
      return pInfoA !== pInfoB<commit_msg>added note about placeholders finders<commit_after>'use strict'

import handlers from './handlers'
import { IMurky } from './interfaces'
import { inspect } from 'util'
import { isString } from 'lodash'
import uncolor = require('uncolor')
import supportsColor = require('supports-color')
import assert = require('assert')

const murky: IMurky = (fmtStr, ...rawReplacers) => {
  // check user input: fmtStr
  if (!isString(fmtStr))
    throw new Error(`murky: input problem: the first arg must be a string!\
      \n\t arg type: ${typeof fmtStr}\
      \n\t arg data: ${inspect(fmtStr)}`)

  // get placeholders info
  // placeholder finders may has problems with %%
  // tmpStr used only to get info about placeholders
  const tmpStr = fmtStr.replace(/%%/g, '  ')
  const psInfo = handlers.findAll(tmpStr)

  // check placeholders info
  const psInfoOrderErrors = psInfo.map((pInfoA, indexA) => {
    return psInfo.slice(0, indexA).map((pInfoB, indexB) => {
      return { pInfoB, indexB }
    }).filter(({ pInfoB }) => {
      return pInfoA !== pInfoB
    }).filter(({ pInfoB }) => {
      return pInfoA.indexStart <= pInfoB.indexStart
    }).map(({ pInfoB, indexB }) => {
      return `wrong order of found placeholders: A should be placed after B:\
        \n\t A index: ${indexA}\
        \n\t B index: ${indexB}\
        \n\t A data: ${inspect(pInfoA)}\
        \n\t B data: ${inspect(pInfoB)}`
    })
  }).reduce((acc, part) => acc.concat(part), [])

  const psInfoCrossErrors = psInfo.map((pInfoA, indexA) => {
    return psInfo.map((pInfoB, indexB) => {
      return { pInfoB, indexB }
    }).filter(({ pInfoB }) => {
      return pInfoA !== pInfoB
{'fraction_non_alphanumeric': 0.1608545397423814, 'fraction_numerical': 0.0006283380458686773, 'mean_word_length': 3.071611253196931, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '6383922', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1060, 'n_words': 299}