yahoo-finance2
Version:
JS API for Yahoo Finance
43 lines (42 loc) • 1.46 kB
JavaScript
;
// Copyright 2018-2025 the Deno authors. MIT license.
// This module is browser compatible.
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = parse;
const os_js_1 = require("../../internal/1.0.13/os.js");
const parse_js_1 = require("./posix/parse.js");
const parse_js_2 = require("./windows/parse.js");
/**
* Return an object containing the parsed components of the path.
*
* Use {@linkcode https://jsr.io/@std/path/doc/~/format | format()} to reverse
* the result.
*
* @example Usage
* ```ts
* import { parse } from "@std/path/parse";
* import { assertEquals } from "@std/assert";
*
* if (Deno.build.os === "windows") {
* const parsedPathObj = parse("C:\\path\\to\\script.ts");
* assertEquals(parsedPathObj.root, "C:\\");
* assertEquals(parsedPathObj.dir, "C:\\path\\to");
* assertEquals(parsedPathObj.base, "script.ts");
* assertEquals(parsedPathObj.ext, ".ts");
* assertEquals(parsedPathObj.name, "script");
* } else {
* 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 Path to process
* @returns An object with the parsed path components.
*/
function parse(path) {
return os_js_1.isWindows ? (0, parse_js_2.parse)(path) : (0, parse_js_1.parse)(path);
}