Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created August 24, 2021 15:40
Show Gist options
  • Save isaacs/40ea407fc3f41080fd2a3d2475dc8946 to your computer and use it in GitHub Desktop.
Save isaacs/40ea407fc3f41080fd2a3d2475dc8946 to your computer and use it in GitHub Desktop.
const Node = require('./lib/node.js')
const gatherDepSet = require('./lib/gather-dep-set.js')
const tree = new Node({
path: '/some/path',
pkg: { name: 'root', version: '1.0.0', dependencies: { a: '', e: '' }},
children: [
{ pkg: { name: 'a', version: '1.0.0', dependencies: { b: '', c: '' }}},
{ pkg: { name: 'b', version: '1.0.0', dependencies: { d: '' }}},
{ pkg: { name: 'c', version: '1.0.0' }},
{ pkg: { name: 'd', version: '1.0.0' }},
{ pkg: { name: 'e', version: '1.0.0', dependencies: { d: '' }}},
],
})
const a = tree.children.get('a')
const aSet = gatherDepSet([a], edge => edge.to !== a)
console.error([...aSet].map(n => n.name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment