17 lines
418 B
TypeScript
17 lines
418 B
TypeScript
import u from '@yanick/updeep-remeda';
|
|
import { D } from '@mobily/ts-belt';
|
|
|
|
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, D.map(subduxes, D.prop('initialState')));
|
|
}
|
|
|
|
return state;
|
|
}
|