@cush/relative

Fast relative path resolution

Usage no npm install needed!

<script type="module">
  import cushRelative from 'https://cdn.skypack.dev/@cush/relative';
</script>

README

@cush/relative

npm Bundle size Code style: Prettier Donate

Ultra fast relative path resolver ⚡️

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.