Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function topologicallyCombineReducers(reducers, dependencies = {}){
// create the toposort class
var ts = new Toposort();
// add the dependencies into toposort class
Object.keys(reducers)
.forEach(key => {
ts = ts.add(key, dependencies[key] || [])
});
// create the processing order
var order = ts.sort().reverse();
// return the combined reducer
return (state = {}, action) => {
// process the reducers and return the newly combined state
return order.reduce((state, key) => {
var oldChildState = state[key];
sortDependencies(dependencies) {
const dependencySorter = new Toposort();
let CSSDependencies = {};
let JSDependencies = {};
dependencies.forEach(dependency => {
dependencySorter.add(dependency.libraryPath, dependency.dependencies);
if (dependency.preloadedCss) {
CSSDependencies[dependency.libraryPath] = CSSDependencies[dependency.libraryPath] ? CSSDependencies[dependency.libraryPath] : [];
dependency.preloadedCss.forEach(style => {
CSSDependencies[dependency.libraryPath].push(`${this.path}/${dependency.libraryPath}/${style.path}`);
});
}
if (dependency.preloadedJs) {
JSDependencies[dependency.libraryPath] = JSDependencies[dependency.libraryPath] ? JSDependencies[dependency.libraryPath] : [];
dependency.preloadedJs.forEach(script => {