<commit_before>import merge from 'lodash/merge';

function resolveHeaderRows(columns) {
  let resolvedChildren = [];

  const ret = columns.map(column => {
    const { children, ...col } = column;

    if (children && children.length) {
      resolvedChildren = resolvedChildren.concat(
        resolveHeaderRows(children)[0]
      );

      return {
        ...col,
        props: {
          ...col.props,
          colSpan: children.length
        }
      };
    }

    return {
      ...col,
      props: {
        ...col.props,
        rowSpan: countRowSpan(columns)
      }
    };
  });

  if (resolvedChildren.length) {
    return [ret].concat([resolvedChildren]);
  }

  return [ret];
}

function countRowSpan(columns) {
  let maximumCount = 0;

  columns.forEach(column => {
    if (column.children) {
      maximumCount = Math.max(
        maximumCount,
        countRowSpan(column.children)
      );
    }
  });

  return maximumCount + 1;
}

function resolveBodyColumns(columns) {
  let ret = [];

  columns.forEach(column => {
    // If a column has children, skip cell specific configuration
    if (column.children) {
      ret = ret.concat(resolveBodyColumns(column.children));
    } else {
      ret.push(column);
    }
  });

  return ret;
}

function evaluateTransforms(transforms, value, extraParameters = {}) {
  return transforms.reduceRight(
    (a, t) => {
      const result = t(value, extraParameters);
      const className = mergeClassNames(a && a.className, result && result.className);

      if (className) {
        return merge({}, a, result, { className });
      }

      return merge({}, a, result);
    },
    {}
  );
}

function mergeProps(propCollections) {
  return propCollections.filter(a => a).reduceRight(
    (all, props) => {
      const className = mergeClassNames(all.className, props.className);

      if (className) {
        return merge({}, all, props, { className });
      }

      return merge({}, all, props);
    },
    {}
  );
}<commit_msg>utils - Write `evaluateTransforms` using `mergeProps`<commit_after>import merge from 'lodash/merge';

function resolveHeaderRows(columns) {
  let resolvedChildren = [];

  const ret = columns.map(column => {
    const { children, ...col } = column;

    if (children && children.length) {
      resolvedChildren = resolvedChildren.concat(
        resolveHeaderRows(children)[0]
      );

      return {
        ...col,
        props: {
          ...col.props,
          colSpan: children.length
        }
      };
    }

    return {
      ...col,
      props: {
        ...col.props,
        rowSpan: countRowSpan(columns)
      }
    };
  });

  if (resolvedChildren.length) {
    return [ret].concat([resolvedChildren]);
  }

  return [ret];
}

function countRowSpan(columns) {
  let maximumCount = 0;

  columns.forEach(column => {
    if (column.children) {
      maximumCount = Math.max(
        maximumCount,
        countRowSpan(column.children)
      );
    }
  });

  return maximumCount + 1;
}

function resolveBodyColumns(columns) {
  let ret = [];

  columns.forEach(column => {
    // If a column has children, skip cell specific configuration
    if (column.children) {
      ret = ret.concat(resolveBodyColumns(column.children));
    } else {
      ret.push(column);
    }
  });

  return ret;
}

function evaluateTransforms(transforms, value, extraParameters = {}) {
  return mergeProps(transforms.map(transform => transform(value, extraParameters)));
}

function mergeProps(propCollections) {
  return propCollections.filter(a => a).reduceRight(
    (all, props) => {
      const className = mergeClassNames(all.className, props.className);

      if (className) {
        return merge({}, all, props, { className });
      }

      return merge({}, all, props);
    },
    {}
  );
}
{'fraction_non_alphanumeric': 0.1376315789473684, 'fraction_numerical': 0.0015789473684210526, 'mean_word_length': 2.4305054151624548, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '1412876', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1095, 'n_words': 237}