Skip to content

Commit

Permalink
add invariant comments
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed Sep 1, 2017
1 parent 964cb6a commit 518fb5c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lighthouse-core/gather/computed/dependency-graph/node.js
Expand Up @@ -5,6 +5,18 @@
*/
'use strict';

/**
* @fileoverview This class encapsulates logic for handling resources and tasks used to model the
* execution dependency graph of the page. A node has a unique identifier and can depend on other
* nodes/be depended on. The construction of the graph maintains some important invariants that are
* inherent to the model:
*
* 1. The graph is a DAG, there are no cycles.
* 2. There is always a root node upon which all other nodes eventually depend.
*
* This allows particular optimizations in this class so that we do no need to check for cycles as
* these methods are called and we can always start traversal at the root node.
*/
class Node {

/**
Expand Down Expand Up @@ -84,7 +96,7 @@ class Node {
* node that was called clone is not included in the resulting filtered graph, the return will be
* undefined.
* @param {function(!Node):boolean=} predicate
* @return {?Node}
* @return {!Node|undefined}
*/
cloneWithRelationships(predicate) {
const rootNode = this.getRootNode();
Expand Down

0 comments on commit 518fb5c

Please sign in to comment.