How to use toposort-class - 2 common examples

To help you get started, we’ve selected a few toposort-class examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github KodersLab / topologically-combine-reducers / src / index.js View on Github external
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];
github tunapanda / h5p-standalone / src / js / h5p-standalone.class.js View on Github external
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 => {

toposort-class

Topological sort of directed acyclic graphs (like dependecy lists)

MIT
Latest version published 9 years ago

Package Health Score

66 / 100
Full package analysis

Popular toposort-class functions