UNPKG

@oazmi/build-tools

Version:

general deno build tool scripts which I practically use in all of my typescript repos

25 lines (24 loc) 782 B
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. import { isWindows } from "./_os.js"; import { parse as posixParse } from "./posix/parse.js"; import { parse as windowsParse } from "./windows/parse.js"; /** * Return a `ParsedPath` object of the `path`. Use `format` to reverse the result. * * @example * ```ts * import { parse } from "@std/path"; * * const parsedPathObj = parse("/path/to/dir/script.ts"); * parsedPathObj.root; // "/" * parsedPathObj.dir; // "/path/to/dir" * parsedPathObj.base; // "script.ts" * parsedPathObj.ext; // ".ts" * parsedPathObj.name; // "script" * ``` * @param path to process */ export function parse(path) { return isWindows ? windowsParse(path) : posixParse(path); }