https://github.com/cushJS/relative
Ultra fast relative path resolver
https://github.com/cushJS/relative
nodejs path
Last synced: 9 months ago
JSON representation
Ultra fast relative path resolver
- Host: GitHub
- URL: https://github.com/cushJS/relative
- Owner: aleclarson
- License: mit
- Created: 2018-06-25T23:41:50.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-04-01T17:26:38.000Z (about 5 years ago)
- Last Synced: 2025-01-03T19:05:53.930Z (over 1 year ago)
- Topics: nodejs, path
- Language: TypeScript
- Homepage:
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @cush/relative
[](https://www.npmjs.com/package/@cush/relative)
[](https://bundlephobia.com/result?p=@cush/relative)
[](https://github.com/prettier/prettier)
[](https://paypal.me/alecdotbiz)
Ultra fast relative path resolver ⚡️
```js
relative('a/b', './c') // => 'a/c'
relative('a/b', '.') // => 'a'
relative('a/b', '..') // => ''
relative('a/b', '../..') // => null
```
The first argument is known as "the module".
The second argument is known as "the relative".
The relative must begin with a period. Otherwise, `null` is returned.
The basename of the module is always ignored.
When the module is *not* absolute and the relative is pointing to the root directory, an empty string is returned.
When the module is *not* absolute and the relative is pointing outside the root directory, `null` is returned.