node/deps/npm/node_modules/@npmcli/arborist/lib/peer-set.js
Myles Borins 2e54524955
deps: update npm to 7.0.0-rc.3
PR-URL: https://github.com/nodejs/node/pull/35474
Reviewed-By: Ruy Adorno <ruyadorno@github.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2020-10-07 09:59:49 -04:00

26 lines
883 B
JavaScript

// when we have to dupe a set of peer dependencies deeper into the tree in
// order to make room for a dep that would otherwise conflict, we use
// this to get the set of all deps that have to be checked to ensure
// nothing is locking them into the current location.
//
// this is different in its semantics from an "optional set" (ie, the nodes
// that should be removed if an optional dep fails), because in this case,
// we specifically intend to include deps in the peer set that have
// dependants outside the set.
const peerSet = node => {
const set = new Set([node])
for (const node of set) {
for (const edge of node.edgesOut.values()) {
if (edge.valid && edge.peer && edge.to)
set.add(edge.to)
}
for (const edge of node.edgesIn) {
if (edge.valid && edge.peer)
set.add(edge.from)
}
}
return set
}
module.exports = peerSet