UNPKG

@lonu/stc

Version:

A tool for converting OpenApi/Swagger/Apifox into code.

24 lines (23 loc) 720 B
// Copyright 2018-2025 the Deno authors. MIT license. // This module is browser compatible. import { assertPath } from "../_common/assert_path.js"; import { isPosixPathSeparator } from "./_util.js"; /** * Verifies whether provided path is absolute. * * @example Usage * ```ts * import { isAbsolute } from "@std/path/posix/is-absolute"; * import { assert, assertFalse } from "@std/assert"; * * assert(isAbsolute("/home/user/Documents/")); * assertFalse(isAbsolute("home/user/Documents/")); * ``` * * @param path The path to verify. * @returns Whether the path is absolute. */ export function isAbsolute(path) { assertPath(path); return path.length > 0 && isPosixPathSeparator(path.charCodeAt(0)); }