Skip to main content
Home
This release is 35 versions behind 1.1.4 — the latest version of @std/path. Jump to latest
Works with
This package works with Cloudflare Workers, Deno, Browsers
This package works with Cloudflare Workers
This package works with Deno
This package works with Browsers
JSR Score94%
Downloads107,185/wk
Published2 years ago (0.211.0)

Utilities for working with file system paths

// 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); }