Path

lib/path~ Path

path main class

Constructor

new Path()

Version:
  • 0.1.4
Since:
  • 0.0.1
Source:

Methods

equal(path1, path2) → {boolean}

Check two paths are equal.
Version:
  • 0.1.4
Since:
  • 0.0.1
Source:
Parameters:
Name Type Description
path1 string to check path
path2 string to check path
Returns:
Type:
boolean
If paths are equal, returns true.

fromRoot(_path, options, callback) → {string}

goto _path from root if no breaks.
Version:
  • 0.1.4
Since:
  • 0.1.4
Source:
Parameters:
Name Type Description
_path string End point of path.
options Object
Name Type Default Description
reliable boolean false if true, check all directory is exists.
start function '/' Set start directory. It treats as root path.
checker function type.isRoot Check break loop or not, break when it returns true.
callback function If this callback function returns true, loop will be break.
Throws:
Callback or path(options.reliable == true) does not exist.
Type
Error
Returns:
Type:
string
breaked path. If no breaks returns _path

isParent(path1, path2) → {boolean}

Check path1 is parent of path2
Version:
  • 0.1.4
Since:
  • 0.0.1
Source:
Parameters:
Name Type Description
path1 string maybe parent
path2 string maybe child
Returns:
Type:
boolean
If path1 is parent of path2, returns true.

locateBase:(_path, regexp) → {string}

Search base locate
Version:
  • 0.1.4
Since:
  • 0.0.1
Source:
Parameters:
Name Type Description
_path string Starting point
regexp query If matched, will be break.
Throws:
path does not exists.
Type
Error
Returns:
Type:
string
base path or "/"

toRoot(_path, options, callback) → {string}

goto root if no breaks.
Version:
  • 0.1.4
Since:
  • 0.0.1
Source:
Parameters:
Name Type Description
_path string Starting path
options Object
Name Type Default Description
resolve boolean true if true, giving path will be resolved,
reliable boolean false if true, check all directory is exists.
checker function type.isRoot Check break loop or not, break when it returns true.
callback function If this callback function returns true, loop will be break.
Throws:
Callback or path(options.reliable == true) does not exist.
Type
Error
Returns:
Type:
string
breaked path. If no breaks returns "/"