Options
All
  • Public
  • Public/Protected
  • All
Menu

@vyapti/parser

Index

Type aliases

NodeOrLeaf

Convenience type for creating a tree-like structure

Functions

compareRoots

  • compareRoots(str1: string, str2: string): boolean
  • Compare two roots to determine if they are the same

    This method supports comparing different path formats for the same root path

    compareRoots('/c:/root', 'C:\\root'); // returns true!

    Parameters

    • str1: string
    • str2: string

    Returns boolean

isLeaf

isRoot

  • isRoot(str: string): boolean
  • Check if incoming string is a root path

    remarks

    This method supports unix, dos, and web dos paths such as:

    /unix/root/path
    C:\dos\root\path
    /c:/web/dos/root/path

    Parameters

    • str: string

      the path to test

    Returns boolean

    Whether or not the path contains a root

normalize

  • normalize(str: string): string
  • Normalize a given path to a shared format

    Allows parsing paths to be easier since a single format is used. The format includes normalizing the root (see {@link normalizeRoot | normalizeRoot} for the normalized root format), and converting all path separators to '/'.

    Parameters

    • str: string

    Returns string

normalizeRoot

  • normalizeRoot(str: string): string[]
  • Normalize an incoming path's root and return both the normalized root as well as the originally matched root.

    If the incoming path is not a root path, an empty string is returned for both the normalized root and the original root

    remarks

    Roots are normalized to a unix-like format using '/' as the root. If a dos or web dos path is incoming, the format is '/:/'

    Parameters

    • str: string

      the path whose root should be normalized

    Returns string[]

    an array of length 2 where the first entry is the original root and the second entry is the normalized root

relative

  • relative(from: string, to: string): string
  • Determine the normalized relative path from one path to another

    remarks

    Incoming paths are normalized first and then compared against one another. The inputs can be either both relative paths or both root paths that share the same root.

    The following list of unsupported cases returns the normalized "to" path

    • from is relative, to is a root
    • from is a root, to is relative
    • from and to are both roots, but do not share the same root

    Parameters

    • from: string

      the source path to use as the base of the relative path

    • to: string

      the destination path that should be resolved

    Returns string

    the normalized relative path between the two input paths

Generated using TypeDoc