vfile utility to find one or more files by searching the file system downwards

Downloads in past


206.0.02 years ago7 years agoMinified + gzip package size for vfile-find-down in KB


!Buildbuild-badgebuild !Coveragecoverage-badgecoverage !Downloadsdownloads-badgedownloads !Sponsorssponsors-badgecollective !Backersbackers-badgecollective !Chatchat-badgechat
Find vfiles by searching the file system downwards.


This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.
npm install vfile-find-down
## Use

var findDown = require('vfile-find-down')

findDown('.md', console.log)

null [ VFile {
  data: {},
  messages: [],
  history: [ '/Users/tilde/projects/oss/vfile-find-down/readme.md' ],
  cwd: '/Users/tilde/projects/oss/vfile-find-down' } ]


This package exports the following identifiers: findDown, findDownOne, INCLUDE, SKIP, BREAK. There is no default export.

findDown(tests[, paths][, callback])

Search for tests downwards. Calls callback with either an error or an array of files passing tests. Note: Virtual Files are not read (their contents is not populated).
  • (tests: Tests, paths?: string|Array.<string>, callback: Callback): void
  • (tests: Tests, paths?: string|Array.<string>): Promise.<Array.<VFile>>
Things to search for (string|Function|Array.<Tests>).
If an array is passed in, any test must match a given file for it to be included.
If a string is passed in, the basename or extname of files must match it for them to be included (and hidden directories and node_modules will not be searched).
Otherwise, they must be functiontest.
Place(s) to searching from (Array.<string> or string, default: process.cwd()).
Function called with all matching files (function cb(err[, files])).

findDownOne(tests[, paths][, callback])

Like findDown, but either calls callback with the first found file or null, or returns a promise that resolved to a file or null.

function test(file, stats)

Check whether a virtual file should be included. Called with a vfile and a stats object.
  • true or INCLUDE — Include the file in the results
  • SKIP — Do not search inside this directory
  • BREAK — Stop searching for files
  • anything else is ignored: files are neither included nor skipped

The different flags can be combined by using the pipe operator: INCLUDE | SKIP.


See contributing.mdcontributing in vfile/.githubhealth for ways to get started. See support.mdsupport for ways to get help.
This project has a code of conductcoc. By interacting with this repository, organization, or community you agree to abide by its terms.


MITlicense © Titus Wormerauthor