<commit_before>import { takeEvery } from 'redux-saga';
import { call, put, select } from 'redux-saga/effects';
import invariant from 'invariant';

import fetchContent from './fetchContent';
import { REQUEST } from './constants/ActionTypes';
import { startRequest, completeRequest, failRequest } from './actionCreators';

export const configSelector = state => state.$$pepperoni.config;

export function* fetchResource (action) {
  const { contentType, subject } = action;

  const config = yield select(configSelector);

  const contentTypeOptions = config.contentTypes[contentType];

  invariant(
    contentTypeOptions,
    'The content type "%s" is not recognised. ' +
    'Register custom content types at initialisation.',
    action.subject
  );

  yield put(startRequest(contentType));

  const { error, data } = yield call(fetchContent, contentTypeOptions, subject, config, action.options);

  if (error) {
    return put(failRequest(contentType, error));
  }

  return put(completeRequest(contentType, subject, data));
}

export default function* fetchSaga () {<commit_msg>Always yield in a saga;<commit_after>import { takeEvery } from 'redux-saga';
import { call, put, select } from 'redux-saga/effects';
import invariant from 'invariant';

import fetchContent from './fetchContent';
import { REQUEST } from './constants/ActionTypes';
import { startRequest, completeRequest, failRequest } from './actionCreators';

export const configSelector = state => state.$$pepperoni.config;

export function* fetchResource (action) {
  const { contentType, subject } = action;

  const config = yield select(configSelector);

  const contentTypeOptions = config.contentTypes[contentType];

  invariant(
    contentTypeOptions,
    'The content type "%s" is not recognised. ' +
    'Register custom content types at initialisation.',
    action.subject
  );

  yield put(startRequest(contentType));

  const { error, data } = yield call(fetchContent, contentTypeOptions, subject, config, action.options);

  if (error) {
    yield put(failRequest(contentType, error));
  }

  yield put(completeRequest(contentType, subject, data));
}

export default function* fetchSaga () {
{'fraction_non_alphanumeric': 0.11464088397790055, 'fraction_numerical': 0.0, 'mean_word_length': 4.888888888888889, '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': '5746504', 'n_tokens_mistral': 606, 'n_tokens_neox': 580, 'n_words': 180}