import reduce from 'lodash/reduce' ; type Reducer < State , Action > = ( state : State , action : Action ) => State ; /**
 * Creates a reducer that calls the specific reducer and returns the default state if the
 * supplied reducer returns undefined
 */ export function wrapWithDefaultState < State , Action > ( reducer , defaultState ) { return ( state , action ) => { const newState = reducer ( state , action ) ; if ( newState === undefined ) { return defaultState ; } return newState ; } ; } ; /**
 * Calls an array of reducers in order, each with the state returned from the previous reducer
 */ export function reduceReducers < State , Action > ( ... reducers ) { return ( previous , current ) => { return reduce < Reducer < State , Action > , State > ( reducers , ( p , r ) => r ( p , current ) , previous ) ; } ; } ;