Path Operations
Path Operations
This module provides interfaces for path operations, including functions such as path joining, splitting, and simplification.
Importing Modules
import path from '@system.path'
API Definitions
path.basename
Returns the filename portion of the path path. By specifying the suffix parameter, you can also remove the specified filename extension. For example:
path.basename('/foo/bar/baz.txt') // 'baz.txt'
path.basename('/foo/bar/baz.txt', '.txt') // 'baz'
path.dirname
Returns the directory portion of path (opposite to basename(), it discards the filename portion). For example:
path.dirname('/foo/bar/baz') // '/foo/bar'
path.extname
Gets the file extension in path. For example:
path.extname('table.json') // '.json'
path.extname('/images/icon.png') // '.png'
path.isAbsolute
Determines whether path is an absolute path. For example:
path.isAbsolute('/foo/bar'); // true
path.isAbsolute('/baz/..'); // true
path.isAbsolute('qux/'); // false
path.isAbsolute('.'); // false
path.join
Joins multiple paths together and simplifies the result. For example:
path.join('/foo', 'bar', 'baz/asdf', 'quux', '..') // '/foo/bar/baz/asdf'
path.normalize
Normalizes the path path, resolving .. and . segments and removing redundant path separators /.
path.normalize('/foo///bar/.././/baz') // '/foo/baz'
path.relative
Calculates the relative path from from to to.
path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb') // '../../impl/bbb'
