<commit_before>import { unflatten } from 'flat';
import * as R from 'ramda';
import * as invariant from 'invariant';

import { State } from "./formsReducer";
import { FormObj, FieldObj } from "./utils/containers";


export interface IState {
  reduxFormLite: State;
}


const memValues = R.memoize(R.compose(
  unflatten,
  R.map(R.prop('value')),
));

export const valueSelector = (name: string, state: IState): Object => {
  const form = R.path<FormObj>(['reduxFormLite', name], state);
  if (!form) {
    return {};
  }

  return memValues(form.fields);
};


const memErrors = R.memoize(R.compose(
  unflatten,
  R.map(R.prop('error')),
));

export const errorSelector = (name: string, state: IState): Object => {
  const form = R.path<FormObj>(['reduxFormLite', name], state);
  if (!form) {
    return {};
  }

  return memErrors(form.fields);
};


const memValid = R.memoize(R.compose(
  R.none(Boolean),
  R.values,
  R.map(R.prop('error')),
));

export const isValid = (name: string, state: IState): boolean => {
  const form = R.path<FormObj>(['reduxFormLite', name], state);
  if (!form) {
    return false;
  }

  return memValid(<any> form.fields);
};


const memTouched = R.memoize(R.compose(
  R.all(R.identity),
  R.values,
  R.map(R.prop('touched')),
));

export const isTouched = (name: string, state: IState): boolean => {
  const form = R.path<FormObj>(['reduxFormLite', name], state);
  if (!form) {
    return false;
  }

  return memTouched(<any> form.fields);
};


export const isSubmitting = (name: string, state: IState): boolean => {
  const form = R.path<FormObj>(['reduxFormLite', name], state);
  if (!form) {
    return false;
  }

  return form.submitting;
};<commit_msg>selectors: Const -> function<commit_after>import { unflatten } from 'flat';
import * as R from 'ramda';
import * as invariant from 'invariant';

import { State } from "./formsReducer";
import { FormObj, FieldObj } from "./utils/containers";


export interface IState {
  reduxFormLite: State;
}


const memValues = R.memoize(R.compose(
  unflatten,
  R.map(R.prop('value')),
));

export function valueSelector(name: string, state: IState): Object {
  const form = R.path<FormObj>(['reduxFormLite', name], state);
  if (!form) {
    return {};
  }

  return memValues(form.fields);
}


const memErrors = R.memoize(R.compose(
  unflatten,
  R.map(R.prop('error')),
));

export function errorSelector(name: string, state: IState): Object {
  const form = R.path<FormObj>(['reduxFormLite', name], state);
  if (!form) {
    return {};
  }

  return memErrors(form.fields);
}


const memValid = R.memoize(R.compose(
  R.none(Boolean),
  R.values,
  R.map(R.prop('error')),
));

export function isValid(name: string, state: IState): boolean {
  const form = R.path<FormObj>(['reduxFormLite', name], state);
  if (!form) {
    return false;
  }

  return memValid(<any> form.fields);
}


const memTouched = R.memoize(R.compose(
  R.all(R.identity),
  R.values,
  R.map(R.prop('touched')),
));

export function isTouched(name: string, state: IState): boolean {
  const form = R.path<FormObj>(['reduxFormLite', name], state);
  if (!form) {
    return false;
  }

  return memTouched(<any> form.fields);
}


export function isSubmitting(name: string, state: IState): boolean {
  const form = R.path<FormObj>(['reduxFormLite', name], state);
  if (!form) {
    return false;
  }

  return form.submitting;
}
{'fraction_non_alphanumeric': 0.1715210355987055, 'fraction_numerical': 0.0, 'mean_word_length': 4.089820359281437, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, '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': '5279033', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1213, 'n_words': 287}