Class NodePackageFS

Node.js-specific implementation of package file system.

Hierarchy

Constructors

Accessors

  • get root(): string
  • URI of the root package.

    Returns string

Methods

  • Dereferences package entry.

    Parameters

    Returns Promise<undefined | string>

    Promise resolved to either module URI, or undefined if nothing to dereference.

  • Searches for package directory containing the given file or URI.

    Parameters

    • uri: string

      URI of the target file or directory.

    Returns Promise<undefined | PackageDir>

    Promise resolved to either enclosing package directory, or undefined if not found.

  • Initializes FS.

    This method has to be called prior to start using the FS.

    Parameters

    • Optional root: string

      URL or path of the root directory. Defaults to current working directory.

    Returns Promise<NodePackageFS>

    Promise resolved to this instance.

  • Tries to load package info from the given directory.

    By default, detects package info by the loaded package.json contents.

    Parameters

    • uri: string

      Source directory.

    Returns Promise<undefined | PackageInfo>

    Promise resolved to either loaded package info contents, or undefined if directory does not contain valid package.json file.

  • Finds parent directory.

    Parameters

    • uri: string

      File or directory URI.

    Returns undefined | string

    Either URI of the parent directory, or undefined if there is no one.

  • Recognizes Node.js import specifier and parses it accordingly.

    In addition to imports recognized by recognizeImport, this method recognizes Node.js built-ins and Windows/Unix paths.

    Parameters

    • spec: string

      Import specifier to recognize. May be recognized already.

    Returns Import

    Recognized import specifier.

  • Extracts package URI from compatible URI import specifier.

    Parameters

    • importSpec: URI

      Absolute URI import specifier.

    Returns undefined | string

    Either package URI, or undefined if the URI can not be used to access packages.

  • Resolves a package by name against another one.

    Note that returned URI is not necessary the one of package directory. Call findPackageDir in order to find one.

    Parameters

    • relativeTo: PackageResolution

      Package to resolve another one against.

    • name: string

      Package name to resolve.

    Returns Promise<undefined | string>

    Promise resolved to either module URI, or undefined if the name can not be resolved.

  • Resolves path relatively to package.

    By default, uses URI resolution.

    Parameters

    • relativeTo: ImportResolution<Import>

      The base to resolve the path against.

    • path: string

      Path or URI to resolve.

    Returns string

    URI of the resolved path.

Generated using TypeDoc