Skip to documentation

package

@stackline/vfile-find-up 1.0.2 — installation and API

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

Install @stackline/vfile-find-up

npm install @stackline/[email protected]

Package version: 1.0.2. Metadata verified: 2026-11-12. This is separate from the framework version and demonstration runtime.

Node.js requirement
{}
Accepted peer dependencies (declared ranges)
{}

Tested environments are described in the versioned README and linked source checks. A declared peer range is not evidence that every version in it was tested.

Versioned reference

This reference comes from the published @stackline/[email protected] README. Its upstream attribution and license remain with the source. Benchmark and security statements describe the cited tests and advisories, not a guarantee for every application.

@stackline/vfile-find-up

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

Documentation | npm | Issues | Repository

Current package version: 1.0.2


Why this package?

@stackline/vfile-find-up is the Stackline-maintained distribution of [email protected]. It is an independent continuation of vfile-find-up; original authors and licenses remain credited below.

Compatibility

Item Value
Package @stackline/[email protected]
API target [email protected]
Supported Node.js See supported framework requirements
License MIT
Module type module
Main entry index.js
Types index.d.ts
Runtime dependencies vfile, to-vfile

Installation

npm install @stackline/vfile-find-up

Preserve existing imports and plugin resolution with an npm alias:

npm install vfile-find-up@npm:@stackline/vfile-find-up

Usage and API reference

vfile-find-up

vfile utility to find files by searching the file system upwards.

Contents

What is this?

This utility lets you find one or many files upwards.

When should I use this?

You can use this utility if you want to find, say, a config file. If you instead want to find files downwards, such as all markdown files in a folder, you can use vfile-find-down.

Install

This package is ESM only. In Node.js (version 14.14+ and 16.0+), install with npm:

npm install @stackline/vfile-find-up

Use

import {findUp} from '@stackline/vfile-find-up'

console.log(await findUp('package.json'))

Yields:

[ VFile {
  data: {},
  messages: [],
  history: [ '/Users/tilde/projects/oss/vfile-find-up/package.json' ],
  cwd: '/Users/tilde/projects/oss/vfile-find-up' } ]

API

This package exports the identifiers BREAK, INCLUDE, findUp, and findUpOne. There is no default export.

findUp(tests[, path][, callback])

Find files or folders upwards.

👉 Note: files are not read (their value is not populated).

Signatures
  • (test[, path], callback) => void
  • (test[, path]) => Promise<Array<VFile>>
Parameters
  • test (Test) — things to search for
  • paths (string, default: process.cwd()) — place to search from
  • callback (Callback, optional) — callback called when done
Returns

Nothing when callback is given (void), otherwise a promise that resolves to files (Array<VFile>).

findUpOne(test[, path][, callback])

Find the first file or folder upwards.

👉 Note: files are not read (their value is not populated).

Signatures
  • (test[, path], callback) => void
  • (test[, path]) => Promise<VFile>
Parameters
  • test (Test) — things to search for
  • path (string, default: process.cwd()) — place to search from
  • callback (CallbackOne, optional) — callback called when done
Returns

Nothing when callback is given (void), otherwise a promise that resolves to a file (VFile | null).

BREAK

Stop searching (number).

INCLUDE

Include this file (number).

Assert

Handle a file (TypeScript type).

Parameters
  • file (VFile) — file to handle
Returns

How to handle this file (boolean | number, optional).

true is treated as INCLUDE.

Callback

Callback called when done (TypeScript type).

Parameters
  • error (Error | null) — error; errors are currently never passed
  • files (Array<VFile>) — files
Returns

Nothing (void).

CallbackOne

Callback called when done finding one file (TypeScript type).

Parameters
  • error (Error | null) — error; errors are currently never passed
  • file (VFile | null) — file
Returns

Nothing (void).

Test

Things to search for (TypeScript type).

For strings, the basename or extname of files must match them. For arrays, any test in them must match.

Type
type Test = Array<Assert | string> | Assert | string

Types

This package is fully typed with TypeScript. It exports the additional types Assert, Callback, CallbackOne, and Test.

Compatibility

Projects maintained by the unified collective are compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+ and 16.0+. Our projects sometimes work with older versions, but this is not guaranteed.

Contribute

See contributing.md in vfile/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Credits and original authors

Original copyright, license notices and contributor acknowledgements remain part of this distribution. Stackline maintenance does not replace authorship of the original work.

Use this repository's issue tracker for reproducible bugs and feature requests. Join r/Stackline for examples, usage questions and release discussions.