How to use the dependency-graph.DepGraph function in dependency-graph

To help you get started, we’ve selected a few dependency-graph 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 jamesplease / api-pls / packages / api-pls-postgres-adapter / sync / util / resource-dependency-graph.js View on Github external
module.exports = function(resources) {
  const graph = new Graph();

  // First, add all of the nodes to the graph.
  _.forEach(resources, r => graph.addNode(r.name));

  // Then, loop through to set their dependencies on one another.
  _.forEach(resources, resource => {
    const relationships = _.chain(resource.relationships)
      // It is the host of the relationship that has a dependency on the other
      // resource
      .filter(relation => relation.host)
      .map(relation => relation.resource)
      // Self-referential dependencies are no problem for Postgres, but they
      // are for `dependency-graph`, so we filter those out in this algorithm.
      .filter(resourceName => resourceName !== resource.name)
      .value();
github plotly / dash / dash-renderer / src / reducers / dependencyGraph.js View on Github external
const graphs = (state = initialGraph, action) => {
    switch (action.type) {
        case 'COMPUTE_GRAPHS': {
            const dependencies = action.payload;
            const inputGraph = new DepGraph();
            const multiGraph = new DepGraph();

            dependencies.forEach(function registerDependency(dependency) {
                const {output, inputs} = dependency;

                // Multi output supported will be a string already
                // Backward compatibility by detecting object.
                let outputId;
                if (type(output) === 'Object') {
                    outputId = `${output.id}.${output.property}`;
                } else {
                    outputId = output;
                    if (isMultiOutputProp(output)) {
                        parseMultipleOutputs(output).forEach(out => {
                            multiGraph.addNode(out);
                            inputs.forEach(i => {
                                const inputId = `${i.id}.${i.property}`;
github angular / angular / packages / compiler-cli / ngcc / src / dependencies / dependency_resolver.ts View on Github external
private computeDependencyGraph(entryPoints: EntryPoint[]): DependencyGraph {
    const invalidEntryPoints: InvalidEntryPoint[] = [];
    const ignoredDependencies: IgnoredDependency[] = [];
    const graph = new DepGraph();

    const angularEntryPoints = entryPoints.filter(entryPoint => entryPoint.compiledByAngular);

    // Add the Angular compiled entry points to the graph as nodes
    angularEntryPoints.forEach(entryPoint => graph.addNode(entryPoint.path, entryPoint));

    // Now add the dependencies between them
    angularEntryPoints.forEach(entryPoint => {
      const {dependencies, missing, deepImports} = this.getEntryPointDependencies(entryPoint);

      const missingDependencies = Array.from(missing).filter(dep => !builtinNodeJsModules.has(dep));

      if (missingDependencies.length > 0 && !entryPoint.ignoreMissingDependencies) {
        // This entry point has dependencies that are missing
        // so remove it from the graph.
        removeNodes(entryPoint, missingDependencies);
github tivac / modular-css / packages / rollup-rewriter / rewriter.js View on Github external
generateBundle({ format }, chunks) {
            if(!supported.has(format)) {
                // This throws, so execution stops here even though it doesn't look like it
                this.error(`Unsupported format: ${format}. Supported formats are ${JSON.stringify([ ...supported.values() ])}`);
            }

            const entries = new Map();
            const graph = new DepGraph({ circular : true });

            Object.entries(chunks).forEach(([ entry, chunk ]) => {
                const { isAsset, dynamicImports } = chunk;

                if(isAsset) {
                    return;
                }

                // Guard against https://github.com/rollup/rollup/issues/2659
                const imported = dynamicImports.filter(Boolean);

                if(imported.length) {
                    entries.set(entry, imported);
                }

                graph.addNode(entry);
github 11ty / eleventy-navigation / eleventy-navigation.js View on Github external
function findBreadcrumbEntries(nodes, activeKey) {
	let pages = findNavigationEntries(nodes);
	let graph = new DepGraph();
	findDependencies(pages, graph);

	return activeKey ? graph.dependenciesOf(activeKey).map(key => {
		let data = Object.assign({}, graph.getNodeData(key));
		delete data.children;
		data._isBreadcrumb = true;
		return data;
	}) : [];
}
github dotansimha / graphql-code-generator / packages / plugins / typescript-apollo-angular / src / helpers / generate-fragments.ts View on Github external
export const generateFragments = convert => (fragments: any[], options: any): string => {
  const cachedFragments: Record = {};

  if (!fragments) {
    return '';
  }

  const graph = new DepGraph({ circular: true });

  fragments.forEach(fragment => {
    graph.addNode(fragment.name, fragment);
  });

  fragments.forEach(fragment => {
    const depends = extractFragments(fragment.document);

    if (depends) {
      depends.forEach(name => {
        graph.addDependency(fragment.name, name);
      });
    }
  });

  return graph
github jacobp100 / cssta / src / native / enhancers / resolveVariableDependencies.js View on Github external
module.exports = (
  definedVariables /*: { [key:string]: string } */,
  variablesFromScope /*: { [key:string]: string } */
) /*: { [key:string]: string } */ => {
  const graph = new DepGraph();

  const variableNames = Object.keys(definedVariables);

  variableNames.forEach(variableName => {
    graph.addNode(variableName);
  });

  variableNames.forEach(variableName => {
    const referencedVariableMatches = definedVariables[variableName].match(
      varRegExp
    );
    if (referencedVariableMatches == null) return;

    const referencedVariables = referencedVariableMatches
      .map(match => {
        const matchedVariable = match.match(varRegExpNonGlobal);
github digsjs / digs / lib / digs.js View on Github external
constructor(opts) {
    super();

    /**
     * Plugin Configuration
     * @type {Object}
     */
    opts = _.defaults(opts || {}, DEFAULTS);
    opts.broker = _.defaults(opts.broker, DEFAULTS.broker);

    this._opts = opts;
    this._domain = domain.create();
    this._domain.add(this);
    this._unloadedPlugins = {};
    this._graph = new dependencyGraph.DepGraph();
    this._broker = null;
    this._client = null;
    this._ready = null;

    Object.defineProperty(this, 'id', {
      get: function() {
        return this.project;
      }
    });

    debug(`${this}: instantiated w/ options:`, opts);
  }

dependency-graph

Simple dependency graph.

MIT
Latest version published 1 year ago

Package Health Score

67 / 100
Full package analysis