Class PathScurryBaseAbstract

The base class for all PathScurry classes, providing the interface for path resolution and filesystem operations.

Typically, you should not instantiate this class directly, but rather one of the platform-specific classes, or the exported PathScurry which defaults to the current platform.

Hierarchy

Constructors

  • Internal

    This class should not be instantiated directly.

    Use PathScurryWin32, PathScurryDarwin, PathScurryPosix, or PathScurry

    Parameters

    • cwd: string | URL = ...
    • pathImpl: PlatformPath
    • sep: string | RegExp
    • __namedParameters: PathScurryOpts = {}

    Returns PathScurryBase

Properties

#children: ChildrenCache
#fs: FSValue
#resolveCache: ResolveCache
#resolvePosixCache: ResolveCache

The Path entry corresponding to this PathScurry's current working directory.

nocase: boolean

Perform path comparisons case-insensitively.

Defaults true on Darwin and Windows systems, false elsewhere.

root: PathBase

The root Path entry for the current working directory of this Scurry

rootPath: string

The string path for the root of this Scurry's current working directory

roots: {
    [k: string]: PathBase;
}

A collection of all roots encountered, referenced by rootPath

Type declaration

sep: string | RegExp

The path separator used for parsing paths

'/' on Posix systems, either '/' or '\\' on Windows

Methods

  • Support for for await

    Alias for iterate

    Note: As of Node 19, this is very slow, compared to other methods of walking. Consider using stream if memory overhead and backpressure are concerns, or walk if not.

    Returns AsyncGenerator<PathBase, void, void>

  • Return the basename for the provided string or Path object

    Parameters

    Returns string

  • Get the depth of a provided path, string, or the cwd

    Parameters

    • path: string | Path = ...

    Returns number

  • Return the dirname for the provided string or Path object

    Parameters

    Returns string

  • Determine whether a given path string is absolute

    Parameters

    • p: string

    Returns boolean

  • Call lstat() on the string or Path object, and update all known information that can be determined.

    Note that unlike fs.lstat(), the returned value does not contain some information, such as mode, dev, nlink, and ino. If that information is required, you will need to call fs.lstat yourself.

    If the Path refers to a nonexistent file, or if the lstat call fails for any reason, undefined is returned. Otherwise the updated Path object is returned.

    Results are cached, and thus may be out of date if the filesystem is mutated.

    Parameters

    Returns Promise<undefined | PathBase>

  • Internal

    Parse the root portion of a path string

    Parameters

    • dir: string

    Returns string

  • Return an array of known child entries.

    First argument may be either a string, or a Path object.

    If the Path cannot or does not contain any children, then an empty array is returned.

    Results are cached, and thus may be out of date if the filesystem is mutated.

    Unlike fs.readdir(), the withFileTypes option defaults to true. Set { withFileTypes: false } to return strings.

    Returns Promise<PathBase[]>

  • Parameters

    • opts: {
          withFileTypes: true;
      }
      • withFileTypes: true

    Returns Promise<PathBase[]>

  • Parameters

    • opts: {
          withFileTypes: false;
      }
      • withFileTypes: false

    Returns Promise<string[]>

  • Parameters

    • opts: {
          withFileTypes: boolean;
      }
      • withFileTypes: boolean

    Returns Promise<string[] | PathBase[]>

  • Parameters

    Returns Promise<PathBase[]>

  • Parameters

    • entry: string | PathBase
    • opts: {
          withFileTypes: true;
      }
      • withFileTypes: true

    Returns Promise<PathBase[]>

  • Parameters

    • entry: string | PathBase
    • opts: {
          withFileTypes: false;
      }
      • withFileTypes: false

    Returns Promise<string[]>

  • Parameters

    • entry: string | PathBase
    • opts: {
          withFileTypes: boolean;
      }
      • withFileTypes: boolean

    Returns Promise<string[] | PathBase[]>

  • synchronous readdir

    Returns PathBase[]

  • Parameters

    • opts: {
          withFileTypes: true;
      }
      • withFileTypes: true

    Returns PathBase[]

  • Parameters

    • opts: {
          withFileTypes: false;
      }
      • withFileTypes: false

    Returns string[]

  • Parameters

    • opts: {
          withFileTypes: boolean;
      }
      • withFileTypes: boolean

    Returns string[] | PathBase[]

  • Parameters

    Returns PathBase[]

  • Parameters

    • entry: string | PathBase
    • opts: {
          withFileTypes: true;
      }
      • withFileTypes: true

    Returns PathBase[]

  • Parameters

    • entry: string | PathBase
    • opts: {
          withFileTypes: false;
      }
      • withFileTypes: false

    Returns string[]

  • Parameters

    • entry: string | PathBase
    • opts: {
          withFileTypes: boolean;
      }
      • withFileTypes: boolean

    Returns string[] | PathBase[]

  • Return the Path object or string path corresponding to the target of a symbolic link.

    If the path is not a symbolic link, or if the readlink call fails for any reason, undefined is returned.

    Result is cached, and thus may be outdated if the filesystem is mutated.

    {withFileTypes} option defaults to false.

    On success, returns a Path object if withFileTypes option is true, otherwise a string.

    Returns Promise<undefined | string>

  • Parameters

    • opt: {
          withFileTypes: false;
      }
      • withFileTypes: false

    Returns Promise<undefined | string>

  • Parameters

    • opt: {
          withFileTypes: true;
      }
      • withFileTypes: true

    Returns Promise<undefined | PathBase>

  • Parameters

    • opt: {
          withFileTypes: boolean;
      }
      • withFileTypes: boolean

    Returns Promise<undefined | string | PathBase>

  • Parameters

    • entry: string | PathBase
    • Optional opt: {
          withFileTypes: false;
      }
      • withFileTypes: false

    Returns Promise<undefined | string>

  • Parameters

    • entry: string | PathBase
    • opt: {
          withFileTypes: true;
      }
      • withFileTypes: true

    Returns Promise<undefined | PathBase>

  • Parameters

    • entry: string | PathBase
    • opt: {
          withFileTypes: boolean;
      }
      • withFileTypes: boolean

    Returns Promise<undefined | string | PathBase>

  • synchronous readlink

    Returns undefined | string

  • Parameters

    • opt: {
          withFileTypes: false;
      }
      • withFileTypes: false

    Returns undefined | string

  • Parameters

    • opt: {
          withFileTypes: true;
      }
      • withFileTypes: true

    Returns undefined | PathBase

  • Parameters

    • opt: {
          withFileTypes: boolean;
      }
      • withFileTypes: boolean

    Returns undefined | string | PathBase

  • Parameters

    • entry: string | PathBase
    • Optional opt: {
          withFileTypes: false;
      }
      • withFileTypes: false

    Returns undefined | string

  • Parameters

    • entry: string | PathBase
    • opt: {
          withFileTypes: true;
      }
      • withFileTypes: true

    Returns undefined | PathBase

  • Parameters

    • entry: string | PathBase
    • opt: {
          withFileTypes: boolean;
      }
      • withFileTypes: boolean

    Returns undefined | string | PathBase

  • Return the Path object or string path corresponding to path as resolved by realpath(3).

    If the realpath call fails for any reason, undefined is returned.

    Result is cached, and thus may be outdated if the filesystem is mutated.

    {withFileTypes} option defaults to false.

    On success, returns a Path object if withFileTypes option is true, otherwise a string.

    Returns Promise<undefined | string>

  • Parameters

    • opt: {
          withFileTypes: false;
      }
      • withFileTypes: false

    Returns Promise<undefined | string>

  • Parameters

    • opt: {
          withFileTypes: true;
      }
      • withFileTypes: true

    Returns Promise<undefined | PathBase>

  • Parameters

    • opt: {
          withFileTypes: boolean;
      }
      • withFileTypes: boolean

    Returns Promise<undefined | string | PathBase>

  • Parameters

    • entry: string | PathBase
    • Optional opt: {
          withFileTypes: false;
      }
      • withFileTypes: false

    Returns Promise<undefined | string>

  • Parameters

    • entry: string | PathBase
    • opt: {
          withFileTypes: true;
      }
      • withFileTypes: true

    Returns Promise<undefined | PathBase>

  • Parameters

    • entry: string | PathBase
    • opt: {
          withFileTypes: boolean;
      }
      • withFileTypes: boolean

    Returns Promise<undefined | string | PathBase>

  • Returns undefined | string

  • Parameters

    • opt: {
          withFileTypes: false;
      }
      • withFileTypes: false

    Returns undefined | string

  • Parameters

    • opt: {
          withFileTypes: true;
      }
      • withFileTypes: true

    Returns undefined | PathBase

  • Parameters

    • opt: {
          withFileTypes: boolean;
      }
      • withFileTypes: boolean

    Returns undefined | string | PathBase

  • Parameters

    • entry: string | PathBase
    • Optional opt: {
          withFileTypes: false;
      }
      • withFileTypes: false

    Returns undefined | string

  • Parameters

    • entry: string | PathBase
    • opt: {
          withFileTypes: true;
      }
      • withFileTypes: true

    Returns undefined | PathBase

  • Parameters

    • entry: string | PathBase
    • opt: {
          withFileTypes: boolean;
      }
      • withFileTypes: boolean

    Returns undefined | string | PathBase

  • find the relative path from the cwd to the supplied path string or entry

    Parameters

    Returns string

  • find the relative path from the cwd to the supplied path string or entry, using / as the path delimiter, even on Windows.

    Parameters

    Returns string

  • Resolve one or more path strings to a resolved string

    Same interface as require('path').resolve.

    Much faster than path.resolve() when called multiple times for the same path, because the resolved Path objects are cached. Much slower otherwise.

    Parameters

    • Rest ...paths: string[]

    Returns string

  • Resolve one or more path strings to a resolved string, returning the posix path. Identical to .resolve() on posix systems, but on windows will return a forward-slash separated UNC path.

    Same interface as require('path').resolve.

    Much faster than path.resolve() when called multiple times for the same path, because the resolved Path objects are cached. Much slower otherwise.

    Parameters

    • Rest ...paths: string[]

    Returns string

Generated using TypeDoc