<commit_before>'use strict';

import identity from 'lodash.identity';

/**
 * Create a higher-order reducer by combining a set of sub-reducer
 * functions that are indexed by the standard action.type.  When no
 * action.type is acted on, the original state is merely
 * passed-through (using the [identity
 * function](https://lodash.com/docs#identity)).
 *
 * This is one of the more prevalent composition reducers, and
 * provides an alternative to the switch statement (commonly used to
 * provide this control mechanism).
 * 
 * The **User Guide** discusses reducerHash() in more detail (see
 * {@tutorial conceptHash}), and additional examples can be found in
 * {@tutorial conceptJoin} and {@tutorial fullExample}.
 *
 * **NOTE**: Because this function is so central to the rudimentary aspects of
 * reduction, it is common to provide a value-added {@tutorial logExt}.
 *
 * @param {ActionReducerHash} actionHandlers - a hash of reducer functions,
 * indexed by the standard redux action.type.
 * 
 * @returns {reducerFn} a newly created reducer function (described above).
 */
export default function reducerHash(actionHandlers) {

  // TODO: consider validation of actionHandlers param.

  const locateHandler = (action) => actionHandlers[action.type] || identity;

  // expose the new reducer fn, which resolves according the the supplied actionHandlers
  return (state, action) => locateHandler(action)(state, action);<commit_msg>minor comment clarification<commit_after>'use strict';

import identity from 'lodash.identity';

/**
 * Create a higher-order reducer by combining a set of sub-reducer
 * functions that are indexed by the standard action.type.  When no
 * action.type is acted on, the original state is merely
 * passed-through (using the [identity
 * function](https://lodash.com/docs#identity)).
 *
 * This is one of the more prevalent composition reducers, and
 * provides an alternative to the switch statement (commonly used to
 * provide this control mechanism).
 * 
 * The **User Guide** discusses reducerHash() in more detail (see
 * {@tutorial conceptHash}), and additional examples can be found in
 * {@tutorial conceptJoin} and {@tutorial fullExample}.
 *
 * **NOTE**: Because this function is so central to the rudimentary aspects of
 * reduction, it is common to provide a value-added {@tutorial logExt}.
 *
 * @param {ActionReducerHash} actionHandlers - a hash of reducer functions,
 * indexed by the standard redux action.type.
 * 
 * @returns {reducerFn} a newly created reducer function (described above).
 */
export default function reducerHash(actionHandlers) {

  // TODO: consider validation of actionHandlers param.

  // internal function: locate handler from actionHandlers action.type hash lookup
  //                    ... default: identity pass-through
  const locateHandler = (action) => actionHandlers[action.type] || identity;

  // expose the new reducer fn, which resolves according the the supplied actionHandlers
  return (state, action) => locateHandler(action)(state, action);
{'fraction_non_alphanumeric': 0.09255599472990778, 'fraction_numerical': 0.0, 'mean_word_length': 4.328070175438596, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '3798777', 'n_tokens_mistral': 804, 'n_tokens_neox': 762, 'n_words': 341}