Noogλe

search input

Function of the day

  • Split a subpath into its path component strings. Throw an error if the subpath isn't valid. Note that the returned path components are also valid subpath strings, though they are intentionally not normalised.

    Laws:

    • Splitting a subpath into components and joining the components gives the same subpath but normalised:

      subpath.join (subpath.components s) == subpath.normalise s
      

    Inputs

    subpath

    The subpath string to split into components

    Type

    subpath.components :: String -> [String]
    

    Examples

    subpath.components usage example

    subpath.components "."
    => [ ]
    
    subpath.components "./foo//bar/./baz/"
    => [ "foo" "bar" "baz" ]
    
    subpath.components "/foo"
    => <error>