17 lines
416 B
TypeScript
17 lines
416 B
TypeScript
|
import u from '@yanick/updeep-remeda';
|
||
|
import * as R from 'remeda';
|
||
|
|
||
|
export function buildInitialState(localInitialState, subduxes) {
|
||
|
let state = localInitialState ?? {};
|
||
|
|
||
|
if (subduxes) {
|
||
|
if (typeof state !== 'object') {
|
||
|
throw new Error('root initial state is not an object');
|
||
|
}
|
||
|
|
||
|
state = u(state, R.mapValues(subduxes, R.prop('initialState')));
|
||
|
}
|
||
|
|
||
|
return state;
|
||
|
}
|