@wordpress/core-data
Version:
Access to and manipulation of core WordPress entities.
16 lines (13 loc) • 472 B
JavaScript
/** @typedef {import('../types').AnyFunction} AnyFunction */
/**
* Higher-order reducer creator which substitutes the action object before
* passing to the original reducer.
*
* @param {AnyFunction} replacer Function mapping original action to replacement.
*
* @return {AnyFunction} Higher-order reducer.
*/
const replaceAction = ( replacer ) => ( reducer ) => ( state, action ) => {
return reducer( state, replacer( action ) );
};
export default replaceAction;