0.0.5 • Published 9 years ago

pathier v0.0.5

Weekly downloads
3
License
BSD
Repository
github
Last release
9 years ago

pathier

A Javascript path tool.

Usage

How to create

var path = require('pathier');

var mypath = path('/this/is/my/path');

How to use

mypath.full()              // Returns the path as a String.

mypath.isAbsolute()        // Returns true if path is absolute.
                           // path('/absolute/path').isAbsolute() == true

mypath.isRelative()        // Returns true if path is relative
                           // Opposite of isAbsolute().

mypath.isFile()            // Returns true if path has no trailing '/'.
                           // path('/this/is/a/file').isFile() == true
                           // path('/this/is/a/directory/').isFile() == false

mypath.isDirectory()       // Returns true if path has trailing '/'.
                           // Opposite of isFile().

mypath.isIn(p)             // Returns true of mypath is within p.
                           // path('/this/is/a/path').isIn('/this/is') == true

mypath.join(p)             // Returns a path with p appended to mypath.
                           // path('/this/is/').join('/a/path').full() == '/this/is/a/path'

mypath.relative(p)         // Returns a path with p relative to mypath.
                           // path('/this/is/').relative('a/path').full() == '/this/is/a/path'
                           // path('/this/is/').relative('/a/path).full() == '/a/path'

mypath.path()              // Returns a new path with the path of mypath.
                           // path('/this/is/a/file.ext').path().full() == '/this/is/a/'

mypath.name()              // Returns the filename base name without extension.
                           // path('/this/is/a/file.ext').base() == 'file'

mypath.ext()               // Returns the filename extension.
                           // path('/this/is/a/file.ext').ext() == 'ext'

mypath.level()             // Returns the depth of the path.
                           // path('/this/is/a/path/').level() == 4
                           // path('/this/is/a/path').level() == 3

mypath.sub(start, [level]) // Return a subpath.
                           // Level is optional. If level is omitted the full path from start is returned.
                           // path('/this/is/a/path').sub(1,2).full() == '/is/a/'
                           // path('/this/is/a/path/').sub(1).full() == '/is/a/path/'

mypath.exists()            // Returns true if file exists.

mypath.stat()              // Returns the stat of path.
                           // Equivalent of fs.statSync.

mypath.newer(p)            // Returns true if mypath is newer than p.

Both exists, stat and newer works asynchronously if a callback is supplied.

Enjoy!

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago