Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@cush/relative

aleclarson818.6kMIT1.0.0TypeScript support: included

Fast relative path resolution

path, resolve, resolution, relative, fs

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.