<commit_before>import { keys, entries } from "../utils/object";
import { forEach } from "../utils/array";
import { startsWith } from "../utils/string";

const replacePlaceholder = (inputString, element, affix) => {
  const foundPlaceholders = {};

  const outputString = inputString
    ? inputString.replace(
        new RegExp(
          affix +
            "(content|argument|prop" +
            affix +
            "(" +
            Object::keys(element.properties).join("|") +
            "))" +
            affix
        ),
        (match, s1, s2) => {
          if (s1::startsWith("prop")) {
            if (!foundPlaceholders.properties) {
              foundPlaceholders.properties = {};
            }
            foundPlaceholders.properties[s2] = true;
            return element.properties[s2];
          } else {
            foundPlaceholders[s1] = true;
            return element[s1];
          }
        }
      )
    : undefined;

  return {
    newValue: outputString,
    foundPlaceholders
  };
};

/*
  Replace the placeholders on any level
  of the pseudo hast tree by their corresponding
  property and populate the found placeholders object
*/
const replacePlaceholdersInObject = (propertiesObject, element, affix) => {
  const newObject = {};
  let foundPlaceholdersInObject = {};<commit_msg>chore(module): fix branch, increase coverage<commit_after>import { keys, entries } from "../utils/object";
import { forEach } from "../utils/array";
import { startsWith } from "../utils/string";

const replacePlaceholder = (inputString, element, affix) => {
  const foundPlaceholders = {};

  const outputString = inputString
    ? inputString.replace(
        new RegExp(
          affix +
            "(content|argument|prop" +
            affix +
            "(" +
            Object::keys(element.properties).join("|") +
            "))" +
            affix
        ),
        (match, s1, s2) => {
          if (s1::startsWith("prop")) {
            foundPlaceholders.properties = {
              [s2]: true
            };
            return element.properties[s2];
          } else {
            foundPlaceholders[s1] = true;
            return element[s1];
          }
        }
      )
    : undefined;

  return {
    newValue: outputString,
    foundPlaceholders
  };
};

/*
  Replace the placeholders on any level
  of the pseudo hast tree by their corresponding
  property and populate the found placeholders object
*/
const replacePlaceholdersInObject = (propertiesObject, element, affix) => {
  const newObject = {};
  let foundPlaceholdersInObject = {};
{'fraction_non_alphanumeric': 0.11924119241192412, 'fraction_numerical': 0.005420054200542005, 'mean_word_length': 2.0798569725864122, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4368680', 'n_tokens_mistral': 698, 'n_tokens_neox': 689, 'n_words': 168}