<commit_before>export default function createDispatch(emitData, emitError, abortNestedDispatch = true) {
  let dispatching;

  // TODO: accept SFA-action as a single param; accept function as action creator
  return function dispatch(actionType, payload) {
    if (actionType == null) {
      emitError(new Error("[dispatch] Action type is empty"));
      return;
    }

    if (dispatching) {
      emitError(new Error(
        `[dispatch] A "dispatch(${actionType})" was called, but "dispatch(${dispatching})" is already executing.\n`
        + (abortNestedDispatch
          ? `Handling of "dispatch(${actionType})" will be aborted.`
          : `This potentially means circular updates and should be avoided.`)
      ));

      if (abortNestedDispatch) {
        return;
      }
    }

    dispatching = actionType;

    try {
      emitData({ type: actionType, payload });
    } catch (e) {
      emitError(e);
    } finally {
      dispatching = null;
    }

    // no returned value
  };
}
<commit_msg>some upd. TODO<commit_after>export default function createDispatch(emitData, emitError, abortNestedDispatch = true) {
  let dispatching;

  // TODO: accept FSA as a single param
  return function dispatch(actionType, payload) {
    if (actionType == null) {
      emitError(new Error("[dispatch] Action type is empty"));
      return;
    }

    if (dispatching) {
      emitError(new Error(
        `[dispatch] A "dispatch(${actionType})" was called, but "dispatch(${dispatching})" is already executing.\n`
        + (abortNestedDispatch
          ? `Handling of "dispatch(${actionType})" will be aborted.`
          : `This potentially means circular updates and should be avoided.`)
      ));

      if (abortNestedDispatch) {
        return;
      }
    }

    dispatching = actionType;

    try {
      emitData({ type: actionType, payload });
    } catch (e) {
      emitError(e);
    } finally {
      dispatching = null;
    }

    // no returned value
  };
}

{'fraction_non_alphanumeric': 0.11583206879109763, 'fraction_numerical': 0.0, 'mean_word_length': 2.6494464944649447, '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': '3586629', 'n_tokens_mistral': 571, 'n_tokens_neox': 561, 'n_words': 165}