PHP 8.2.30
Preview: peer-entry-sets.js Size: 2.57 KB
/proc/self/root/opt/alt/alt-nodejs18/root/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/peer-entry-sets.js

// Given a node in a tree, return all of the peer dependency sets that
// it is a part of, with the entry (top or non-peer) edges into the sets
// identified.
//
// With this information, we can determine whether it is appropriate to
// replace the entire peer set with another (and remove the old one),
// push the set deeper into the tree, and so on.
//
// Returns a Map of { edge => Set(peerNodes) },

const peerEntrySets = node => {
  // this is the union of all peer groups that the node is a part of
  // later, we identify all of the entry edges, and create a set of
  // 1 or more overlapping sets that this node is a part of.
  const unionSet = new Set([node])
  for (const node of unionSet) {
    for (const edge of node.edgesOut.values()) {
      if (edge.valid && edge.peer && edge.to) {
        unionSet.add(edge.to)
      }
    }
    for (const edge of node.edgesIn) {
      if (edge.valid && edge.peer) {
        unionSet.add(edge.from)
      }
    }
  }
  const entrySets = new Map()
  for (const peer of unionSet) {
    for (const edge of peer.edgesIn) {
      // if not valid, it doesn't matter anyway.  either it's been previously
      // peerConflicted, or it's the thing we're interested in replacing.
      if (!edge.valid) {
        continue
      }
      // this is the entry point into the peer set
      if (!edge.peer || edge.from.isTop) {
        // get the subset of peer brought in by this peer entry edge
        const sub = new Set([peer])
        for (const peer of sub) {
          for (const edge of peer.edgesOut.values()) {
            if (edge.valid && edge.peer && edge.to) {
              sub.add(edge.to)
            }
          }
        }
        // if this subset does not include the node we are focused on,
        // then it is not relevant for our purposes.  Example:
        //
        // a -> (b, c, d)
        // b -> PEER(d) b -> d -> e -> f <-> g
        // c -> PEER(f, h) c -> (f <-> g, h -> g)
        // d -> PEER(e) d -> e -> f <-> g
        // e -> PEER(f)
        // f -> PEER(g)
        // g -> PEER(f)
        // h -> PEER(g)
        //
        // The unionSet(e) will include c, but we don't actually care about
        // it.  We only expanded to the edge of the peer nodes in order to
        // find the entry edges that caused the inclusion of peer sets
        // including (e), so we want:
        //   Map{
        //     Edge(a->b) => Set(b, d, e, f, g)
        //     Edge(a->d) => Set(d, e, f, g)
        //   }
        if (sub.has(node)) {
          entrySets.set(edge, sub)
        }
      }
    }
  }

  return entrySets
}

module.exports = peerEntrySets

Directory Contents

Dirs: 1 × Files: 38

Name Size Perms Modified Actions
arborist DIR
- drwxr-xr-x 2026-03-19 07:09:44
Edit Download
4.89 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
11.95 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
3.42 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
13.94 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
1.21 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
1.29 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
1.25 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
691 B lrw-r--r-- 2026-03-09 09:08:37
Edit Download
5.00 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
9.57 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
6.63 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
1.07 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
1.26 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
273 B lrw-r--r-- 2026-03-09 09:08:37
Edit Download
3.25 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
3.06 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
42.97 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
1.32 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
225 B lrw-r--r-- 2026-03-09 09:08:37
Edit Download
3.12 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
2.50 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
2.57 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
19.75 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
5.10 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
28.84 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
2.59 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
136 B lrw-r--r-- 2026-03-09 09:08:37
Edit Download
638 B lrw-r--r-- 2026-03-09 09:08:37
Edit Download
501 B lrw-r--r-- 2026-03-09 09:08:37
Edit Download
36.89 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
2.19 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
1.35 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
874 B lrw-r--r-- 2026-03-09 09:08:37
Edit Download
2.92 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
4.04 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
1.45 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
5.82 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download
10.56 KB lrw-r--r-- 2026-03-09 09:08:37
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).