The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.
When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.
Test if a value is a relative path.
To use as a general utility, install the CLI package globally
npm install -g @stdlib/assert-is-relative-path-cli
Usage: is-relative-path [options] [<path>] Options: -h, --help Print this message. -V, --version Print the package version. --platform name Platform: 'win32' or 'posix'. --split sep Delimiter for stdin data. Default: '/\\r?\\n/'.
If the split separator is a regular expression, ensure that the
splitoption is either properly escaped or enclosed in quotes.
# Not escaped... $ echo -n $'/foo/bar/baz\n./docs/repl.txt' | is-relative-path --split /\r?\n/ # Escaped... $ echo -n $'/foo/bar/baz\n./docs/repl.txt' | is-relative-path --split /\\r?\\n/
The implementation ignores trailing delimiters.
$ is-relative-path ./foo/bar/baz --platform=posix true
To use as a standard stream,
$ echo -n './docs/repl.txt' | is-relative-path true
By default, when used as a standard stream, the implementation assumes newline-delimited data. To specify an alternative delimiter, set the
$ echo -n '/foo/bar/baz\t./docs/repl.txt' | is-relative-path --platform=posix --split '\t' false true
Copyright © 2016-2023. The Stdlib Authors.