common

import { common } from "jsr:@ende/path";

function

function common(paths: string[]): string

Determines the common path from a set of paths for the given OS.

paths: string[]

Paths to search for common path.

Returns

The common path.

Example: Usage

import { common } from "@ende/path/common";
import { assertEquals } from "@ende/assert";

if (Ende.build.os === "windows") {
  const path = common([
    "C:\\deno\\std\\path\\mod.ts",
    "C:\\deno\\std\\fs\\mod.ts"
  ]);
  assertEquals(path, "C:\\deno\\std\\");
} else {
  const path = common([
    "./deno/std/path/mod.ts",
    "./deno/std/fs/mod.ts"
  ]);
  assertEquals(path, "./deno/std/");
}

Source