13 lines
474 B
JavaScript
13 lines
474 B
JavaScript
|
import u from '@yanick/updeep-remeda';
|
||
|
import { D } from '@mobily/ts-belt';
|
||
|
export function buildInitialState(localInitialState, subduxes) {
|
||
|
let state = localInitialState !== null && localInitialState !== void 0 ? localInitialState : {};
|
||
|
if (subduxes) {
|
||
|
if (typeof state !== 'object') {
|
||
|
throw new Error('root initial state is not an object');
|
||
|
}
|
||
|
state = u(state, D.map(subduxes, D.prop('initialState')));
|
||
|
}
|
||
|
return state;
|
||
|
}
|