@fav/path.relative

Provides same behaviors of `path.relative` module for all versions of node.js

Usage no npm install needed!

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

README

@fav/path.relative NPM version

Provides same behaviors of path.relative module for all versions of node.js

Install

For installing @fav/path with npm:

$ npm install @fav/path --save

For installing only @fav/path.relative with npm:

$ npm install @fav/path.relative --save

Usage

When installing @fav/path:

const path = require('@fav/path');

path.relative('path/to/aaa/bbb', 'path/to/ccc/ddd')
// => '../../ccc/ddd'

When installing @fav/path.relative:

const relative = require('@fav/path.relative');

relative('path/to/aaa/bbb', 'path/to/ccc/ddd')
// => '../../ccc/ddd'

API

relative(from, to)

Returns a relative path from from to to.

Arguments
  • from [string] : an absolute or relative path string.
  • to [string] : an absolute or relative path string.
Errors
  • [TypeError] : if neither from nor to is a string.

License

Copyright (C) 2016 Takayuki Sato

This program is free software under MIT License. See the file LICENSE in this distribution for more details.