<commit_before>import * as React from 'react';
import { findDOMNode } from 'react-dom';
import { Grid } from 'react-bootstrap';
import { Enumerable } from 'ix';

import { wx } from '../../WebRx';
import { Loading } from '../Common/Loading/Loading';
import { ValueComparison, ValueComparer } from '../../Utils/Compare';

export function renderEnumerable<T>(
  source: T[] | Enumerable<T> | undefined,
  selector: (item: T, index: number, items: T[]) => any = item => item,
  projector: (items: T[]) => any = items => items,
  sortKey?: (item: T) => any,
  sortComparer: ValueComparison<T> = ValueComparer.DefaultComparison,
  defaultSelector: () => any | null = () => null,
) {
  if (source == null) {
    source = Enumerable.empty<T>();
  }
  else if (Array.isArray(source)) {
    source = source.asEnumerable();
  }

  if (sortKey != null) {
    source = source
      .orderBy(sortKey, sortComparer);
  }

  return projector(
    source
      .defaultIfEmpty(defaultSelector())<commit_msg>fixing typing bug with renderEnumerable the default selector produces a data element, not a render element.<commit_after>import * as React from 'react';
import { findDOMNode } from 'react-dom';
import { Grid } from 'react-bootstrap';
import { Enumerable } from 'ix';

import { wx } from '../../WebRx';
import { Loading } from '../Common/Loading/Loading';
import { ValueComparison, ValueComparer } from '../../Utils/Compare';

export function renderEnumerable<T>(
  source: T[] | Enumerable<T> | undefined,
  selector: (item: T, index: number, items: T[]) => any = item => item,
  projector: (items: T[]) => any = items => items,
  sortKey?: (item: T) => any,
  sortComparer: ValueComparison<T> = ValueComparer.DefaultComparison,
  defaultSelector: () => T | undefined = () => undefined,
) {
  if (source == null) {
    source = Enumerable.empty<T>();
  }
  else if (Array.isArray(source)) {
    source = source.asEnumerable();
  }

  if (sortKey != null) {
    source = source
      .orderBy(sortKey, sortComparer);
  }

  return projector(
    source
      .defaultIfEmpty(defaultSelector())
{'fraction_non_alphanumeric': 0.16234390009606148, 'fraction_numerical': 0.0, 'mean_word_length': 3.7665903890160184, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, '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': '4877358', 'n_tokens_mistral': 635, 'n_tokens_neox': 626, 'n_words': 184}