seniority
API reference

seniority/find-up

Every export of seniority/find-up, with its signature and doc comment: findUpMultipleSync, findUpMultiple, findUpSync, findUp, findDownSync, findDown and 1 more, plus 3 types.

import { findUpMultipleSync, findUpMultiple, findUpSync, … } from 'seniority/find-up';

Functions

findDown

function findDown(name: Name, options?: FindDownOptions): Promise<string | undefined>;
ParameterType
nameName
options (optional)FindDownOptions

Returns Promise<string \| undefined>

findDownSync

The first match looking down from cwd, depth levels at most, nearest level first unless strategy is 'depth'.

function findDownSync(name: Name, options?: FindDownOptions): string | undefined;
ParameterType
nameName
options (optional)FindDownOptions

Returns string \| undefined

findUp

function findUp(name: Name | Matcher<MatcherResult | Promise<MatcherResult>>, options?: Options): Promise<string | undefined>;
ParameterType
nameName | Matcher<MatcherResult | Promise<MatcherResult>>
options (optional)Options

Returns Promise<string \| undefined>

findUpMultiple

function findUpMultiple(name: Name | Matcher<MatcherResult | Promise<MatcherResult>>, options?: Options): Promise<string[]>;
ParameterType
nameName | Matcher<MatcherResult | Promise<MatcherResult>>
options (optional)Options

Returns Promise<string[]>

findUpMultipleSync

function findUpMultipleSync(name: Name | Matcher<MatcherResult>, options?: Options): string[];
ParameterType
nameName | Matcher<MatcherResult>
options (optional)Options

Returns string[]

findUpSync

The nearest match walking up, or undefined. In a directory, the first name given wins.

function findUpSync(name: Name | Matcher<MatcherResult>, options?: Options): string | undefined;
ParameterType
nameName | Matcher<MatcherResult>
options (optional)Options

Returns string \| undefined

Constants

findUpStop

Return this from a matcher to end the walk with no match.

const findUpStop: unique symbol;

Interfaces

FindDownOptions

interface FindDownOptions {
    /** Where to start. Defaults to the process's working directory. */
    readonly cwd?: URL | string;
    /** How many directories below `cwd` to look. `0` is `cwd` alone; defaults to `1`. */
    readonly depth?: number;
    /** Nearest level first (`'breadth'`, the default) or each branch to the bottom first (`'depth'`). */
    readonly strategy?: 'breadth' | 'depth';
    readonly type?: 'file' | 'directory' | 'both';
    readonly allowSymlinks?: boolean;
}

Options

interface Options {
    /** Where to start. Defaults to the process's working directory. */
    readonly cwd?: URL | string;
    /** The highest directory to look in, inclusive. Defaults to the filesystem root. */
    readonly stopAt?: URL | string;
    /** What a name must be to match. Defaults to `'file'`. */
    readonly type?: 'file' | 'directory' | 'both';
    /** Follow a symbolic link to what it points at. Defaults to `true`. */
    readonly allowSymlinks?: boolean;
    /** How many matches `findUpMultiple` collects at most. Defaults to `Infinity`. */
    readonly limit?: number;
}

Types

Match

type Match = string | typeof findUpStop | undefined;

On this page