<commit_before>import init from './init';
import createFromHtml from '../util/create-from-html';

function buildFragment (frag, arg) {
  if (arg) {
    if (typeof arg === 'string') {
      arg = fragment(...createFromHtml(arg).childNodes);
    } else if (arg.length) {
      arg = fragment(...arg);
    } else if (arg.nodeType) {
      init(arg);
    }
    frag.appendChild(arg);
  }
  return frag;
}

export default function fragment (...args) {
  return args.reduce(buildFragment, document.createDocumentFragment());
}<commit_msg>Have to use slice() instead of ... because Array.from is es6 only.<commit_after>import init from './init';
import createFromHtml from '../util/create-from-html';

const slice = Array.prototype.slice;

function buildFragment (frag, arg) {
  if (arg) {
    if (typeof arg === 'string') {
      arg = fragment.apply(null, slice.call(createFromHtml(arg).childNodes));
    } else if (arg.length) {
      arg = fragment.apply(null, slice.call(arg));
    } else if (arg.nodeType) {
      init(arg);
    }
    frag.appendChild(arg);
  }
  return frag;
}

export default function fragment (...args) {
  return args.reduce(buildFragment, document.createDocumentFragment());
}
{'fraction_non_alphanumeric': 0.1545530492898914, 'fraction_numerical': 0.000835421888053467, 'mean_word_length': 3.372262773722628, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4290937', 'n_tokens_mistral': 365, 'n_tokens_neox': 363, 'n_words': 95}