<commit_before>// @flow
import R from 'ramda';
import moment from 'moment';
import {createSelector} from 'reselect';
import {getPreviousMonthMoment, getSelectedMonthMoment, getNextMonthMoment} from './month';

type sumOfAmountsType = (items: {amount: number}[]) => number;
export const sumOfAmounts: sumOfAmountsType = R.reduce(
  (acc: number, record: {amount: number}) => acc + record.amount,
  0
);

// Creates a selector that filters a list of items for a selected month
const createInMonthSelector = (itemSelector, itemMonthMapper, monthSelector) =>
  createSelector(itemSelector, monthSelector, (items, month) =>
    items.filter(i => moment(itemMonthMapper(i)).isSame(month))<commit_msg>Typed some selector utility functions<commit_after>// @flow
import R from 'ramda';
import moment from 'moment';
import {createSelector} from 'reselect';
import {getPreviousMonthMoment, getSelectedMonthMoment, getNextMonthMoment} from './month';

type sumOfAmountsType = <T: {amount: number}>(items: T[]) => number;
export const sumOfAmounts: sumOfAmountsType = R.reduce(
  (acc: number, record: {amount: number}) => acc + record.amount,
  0
);

export const beginningOfMonth = (dateString: string): string =>
  moment(dateString).startOf('month').format('YYYY-MM-DD');

// Creates a selector that filters a list of items for a selected month
const createInMonthSelector = (itemSelector, itemMonthMapper, monthSelector) =>
  createSelector(itemSelector, monthSelector, (items, month) =>
    items.filter(i => moment(itemMonthMapper(i)).isSame(month))
{'fraction_non_alphanumeric': 0.12767336357744652, 'fraction_numerical': 0.0012961762799740765, 'mean_word_length': 6.283018867924528, 'pattern_counts': {'":': 0, '<': 4, '<?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': '1035971', 'n_tokens_mistral': 446, 'n_tokens_neox': 446, 'n_words': 137}