Skip to content

path

import { path } from "@tynd/core/client";

Small synchronous path utilities built on pathe. navigator.platform picks the Windows or POSIX flavour. No round-trip to Rust — these run entirely in the WebView / JS runtime.

Joins path segments and normalizes the result. The output always uses /, on Windows too (pathe behaviour); Windows APIs accept it.

path.join("/tmp", "notes", "hello.md"); // "/tmp/notes/hello.md"
path.join("C:\\", "Users", "me"); // "C:/Users/me" on Windows

Empty strings are ignored.

Parent directory of the path.

path.dirname("/tmp/notes/hello.md"); // "/tmp/notes"
path.dirname("/tmp"); // "/"
path.dirname("hello.md"); // ""

Last segment, optionally with an extension stripped.

path.basename("/tmp/notes/hello.md"); // "hello.md"
path.basename("/tmp/notes/hello.md", ".md"); // "hello"

File extension including the leading dot, or "" if none.

path.extname("hello.md"); // ".md"
path.extname("Makefile"); // ""
  • Always /. Paths these helpers build use / on every OS; inputs may use / or \. There is no sep(): split on /[/\]/ if you need segments.
  • Synchronous. These functions do not return promises — they run in the WebView.
  • No resolve(), normalize(), or isAbsolute() — compose them yourself or use URL / framework helpers if you need them.
  • Absolute paths are produced by joining from a known root (await os.appDataDir(), etc.) — not by a resolve function.
  • fs — every fs.* method accepts path strings.
  • os — homeDir, dataDir, tmpDir, etc. for building absolute paths.