
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
filter-dependent
Advanced tools
Filters a list of files, leaving only those which transitively dependent on any of the files from the second list
Filters a list of files, leaving only those which transitively dependent on any of the files from the second list.
Because I can! But also, because I failed to find anything like that, except jest-resolve-dependencies, which is not exactly what I need, and also have not very good algorithmic complexity (btw mine is O(n), where n is a number of nodes in a dependency graph fragment between sources and targers).
Similiar to changedSince – it allows you to find all files dependent from other files. And, therefore, skip other files.
For example, you can:
By doing that, you skip non-affected files and speed up your CI/build.
Lets say we have four files:
a.js depends on b.js and c.jsb.js depends on d.jsThen:
import filterDependent from 'filter-dependent'
const filteredFiles = filterDependent([
'./a.js',
'./b.js',
'./c.js',
'./d.js',
], [
'a.js',
'c.js',
])
// → ['/abs/path/to/a.js', '/abs/path/to/b.js', '/abs/path/to/c.js']
// because `d.js` does not depend on `c.js` nor `a.js`
import filterDependent from 'filter-dependent'
const filteredFiles = filterDependent(sources, targets, options)
Where
sources – an array of file paths to be filtered.
targets – an array of file paths to be used for filtering out sources.
options.filter – function, which will be called on each found file (including sources and targers) to filter out some. (f: string) => f.indexOf('node_modules') === -1 && !f.endsWith('.css') by default.
options.onMiss – function, which will be called instead of throwing an error. Arguments are: filename and dep – absolute path of processing file and unresolved dependendy in it
note:
filter-dependentfails on first unresolved dependency (by default).
FAQs
Filters a list of files, leaving only those which transitively dependent on any of the files from the second list
We found that filter-dependent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.

Product
Bringing supply chain security to the next generation of JavaScript package managers