How to use the lighthouse/lighthouse-core/lib/dependency-graph/base-node.TYPES function in lighthouse

To help you get started, we’ve selected a few lighthouse 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 googleads / publisher-ads-lighthouse-plugin / lighthouse-plugin-publisher-ads / utils / graph.js View on Github external
root.traverse((node) => {
    if (node.type === BaseNode.TYPES.CPU || !isTargetRequest(node.record)) {
      return;
    }
    if (firstTarget && firstTarget.startTime < node.startTime) {
      return;
    }
    firstTarget = node;
  });
  return firstTarget;
github googleads / publisher-ads-lighthouse-plugin / lighthouse-plugin-publisher-ads / utils / graph.js View on Github external
const node = stack.pop();
    if (!node || visited.has(node)) {
      continue;
    }
    visited.add(node);
    if (closure.has(node)) {
      for (const n of stack) {
        closure.add(n);
      }
    }
    stack.push(...node.getDependents());
  }


  for (const node of closure) {
    if (node.type === BaseNode.TYPES.NETWORK) {
      if (node.endTime < assert(firstTarget).startTime) {
        requests.push(node.record);
      }
    } else if (node.type === BaseNode.TYPES.CPU) {
      if (node.event.ts < assert(firstTarget).startTime * 1e6) {
        traceEvents.push(node.event, ...node.childEvents);
      }
    }
  }
  return {requests, traceEvents};
}
github googleads / publisher-ads-lighthouse-plugin / lighthouse-plugin-publisher-ads / utils / graph.js View on Github external
visited.add(node);
    if (closure.has(node)) {
      for (const n of stack) {
        closure.add(n);
      }
    }
    stack.push(...node.getDependents());
  }


  for (const node of closure) {
    if (node.type === BaseNode.TYPES.NETWORK) {
      if (node.endTime < assert(firstTarget).startTime) {
        requests.push(node.record);
      }
    } else if (node.type === BaseNode.TYPES.CPU) {
      if (node.event.ts < assert(firstTarget).startTime * 1e6) {
        traceEvents.push(node.event, ...node.childEvents);
      }
    }
  }
  return {requests, traceEvents};
}