<commit_before>import React from 'react';
import splitReactElement from './splitReactElement';

const getElementTagLength = (element, type = 'start') => {
  if (React.isValidElement(element)) {
    const length = splitReactElement(element)[type].length;

    const child = React.Children.only(element.props.children);
    return length + (child && React.isValidElement(child)
      ? getElementTagLength(child, type)
      : 0
    );
  }

  if (typeof element === 'object') {
    return element[type] ? element[type].length : 0;
  }

  return 0;
};
<commit_msg>go back to using toArray<commit_after>import React from 'react';
import splitReactElement from './splitReactElement';

const getElementTagLength = (element, type = 'start') => {
  if (React.isValidElement(element)) {
    const length = splitReactElement(element)[type].length;

    const child = React.Children.toArray(element.props.children)[0];
    return length + (child && React.isValidElement(child)
      ? getElementTagLength(child, type)
      : 0
    );
  }

  if (typeof element === 'object') {
    return element[type] ? element[type].length : 0;
  }

  return 0;
};

{'fraction_non_alphanumeric': 0.1369622475856014, 'fraction_numerical': 0.006145741878841089, 'mean_word_length': 3.935064935064935, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6792392', 'n_tokens_mistral': 345, 'n_tokens_neox': 344, 'n_words': 80}