deno.land / std@0.224.0 / path / relative.ts

relative.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// This module is browser compatible.
import { isWindows } from "./_os.ts";import { relative as posixRelative } from "./posix/relative.ts";import { relative as windowsRelative } from "./windows/relative.ts";
/** * Return the relative path from `from` to `to` based on current working directory. * * An example in windws, for instance: * from = 'C:\\orandea\\test\\aaa' * to = 'C:\\orandea\\impl\\bbb' * The output of the function should be: '..\\..\\impl\\bbb' * * @param from path in current working directory * @param to path in current working directory */export function relative(from: string, to: string): string { return isWindows ? windowsRelative(from, to) : posixRelative(from, to);}
std

Version Info

Tagged at
6 months ago