Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const getPluginForTest = (pluginDef, storeState, plugins) => {
const PluginImpl = Object.keys(pluginDef).reduce((previous, key) => {
if (endsWith(key, 'Plugin')) {
return pluginDef[key];
}
return previous;
}, null);
const containers = Object.keys(PluginImpl)
.filter(prop => !plugins || Object.keys(plugins).indexOf(prop + 'Plugin') !== -1)
.reduce((previous, key) => {
return { ...previous, [key]: PluginImpl[key]};
}, {});
const reducer = combineReducers({ ...(pluginDef.reducers || {}), ...rootReducers });
const rootEpic = combineEpics.apply(null, Object.keys(pluginDef.epics || {}).map(key => pluginDef.epics[key]) || []);
const epicMiddleware = createEpicMiddleware(rootEpic);
const actions = [];
const store = applyMiddleware(epicMiddleware, createRegisterActionsMiddleware(actions))(createStore)(reducer, storeState);
return {
Plugin: (props) => ,
store,
actions,
containers
};
};
const fnHandler = handlers[key];
if (Function.prototype.isPrototypeOf(fnHandler)) {
actionHandler[key] = fnHandler;
}
}
return createReducer(actionHandler, {});
};
const epics = [];
for (const key in datum.epics) {
if (datum.epics.hasOwnProperty(key)) {
epics.push(datum.epics[key]);
}
}
export default {
epics: combineEpics.apply(this, epics),
reducers: combineReducers({
routing: routerReducer,
do: createEpics(),
out
})
};