File tree Expand file tree Collapse file tree 13 files changed +24
-28
lines changed
Expand file tree Collapse file tree 13 files changed +24
-28
lines changed Original file line number Diff line number Diff line change 11// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
22// This module is browser compatible.
33
4- import type { FormatInputPathObject } from "../_interface .ts" ;
4+ import type { ParsedPath } from "../types .ts" ;
55
66export function _format (
77 sep : string ,
8- pathObject : FormatInputPathObject ,
8+ pathObject : Partial < ParsedPath > ,
99) : string {
1010 const dir : string | undefined = pathObject . dir || pathObject . root ;
1111 const base : string = pathObject . base ||
@@ -16,7 +16,7 @@ export function _format(
1616 return dir + sep + base ;
1717}
1818
19- export function assertArg ( pathObject : FormatInputPathObject ) {
19+ export function assertArg ( pathObject : Partial < ParsedPath > ) {
2020 if ( pathObject === null || typeof pathObject !== "object" ) {
2121 throw new TypeError (
2222 `The "pathObject" argument must be of type Object. Received type ${ typeof pathObject } ` ,
Original file line number Diff line number Diff line change 4242 "./resolve" : " ./resolve.ts" ,
4343 "./to-file-url" : " ./to_file_url.ts" ,
4444 "./to-namespaced-path" : " ./to_namespaced_path.ts" ,
45+ "./types" : " ./types.ts" ,
4546 "./windows" : " ./windows/mod.ts" ,
4647 "./windows/basename" : " ./windows/basename.ts" ,
4748 "./windows/common" : " ./windows/common.ts" ,
Original file line number Diff line number Diff line change 44import { isWindows } from "./_os.ts" ;
55import { format as posixFormat } from "./posix/format.ts" ;
66import { format as windowsFormat } from "./windows/format.ts" ;
7- import type { FormatInputPathObject } from "./_interface .ts" ;
7+ import type { ParsedPath } from "./types .ts" ;
88
99/**
10- * Generate a path from a {@linkcode FormatInputPathObject } object. It does the
10+ * Generate a path from a {@linkcode ParsedPath } object. It does the
1111 * opposite of {@linkcode https://jsr.io/@std/path/doc/~/parse | parse()}.
1212 *
1313 * @example Usage
@@ -25,6 +25,6 @@ import type { FormatInputPathObject } from "./_interface.ts";
2525 * @param pathObject Object with path components.
2626 * @returns The formatted path.
2727 */
28- export function format ( pathObject : FormatInputPathObject ) : string {
28+ export function format ( pathObject : Partial < ParsedPath > ) : string {
2929 return isWindows ? windowsFormat ( pathObject ) : posixFormat ( pathObject ) ;
3030}
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ export * from "./resolve.ts";
4848export * from "./to_file_url.ts" ;
4949export * from "./to_namespaced_path.ts" ;
5050export * from "./common.ts" ;
51- export * from "./_interface .ts" ;
51+ export * from "./types .ts" ;
5252export * from "./glob_to_regexp.ts" ;
5353export * from "./is_glob.ts" ;
5454export * from "./join_globs.ts" ;
Original file line number Diff line number Diff line change 22// This module is browser compatible.
33
44import { isWindows } from "./_os.ts" ;
5- import type { ParsedPath } from "./_interface .ts" ;
5+ import type { ParsedPath } from "./types .ts" ;
66import { parse as posixParse } from "./posix/parse.ts" ;
77import { parse as windowsParse } from "./windows/parse.ts" ;
88
9- export type { ParsedPath } from "./_interface .ts" ;
9+ export type { ParsedPath } from "./types .ts" ;
1010
1111/**
1212 * Return an object containing the parsed components of the path.
Original file line number Diff line number Diff line change 11// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
22// Copyright the Browserify authors. MIT License.
33// Ported from https://github.com/browserify/path-browserify/
4- import type { FormatInputPathObject , ParsedPath } from "./mod.ts" ;
4+ import type { ParsedPath } from "./mod.ts" ;
55
66import { assertEquals } from "@std/assert" ;
77import * as posix from "./posix/mod.ts" ;
88import * as windows from "./windows/mod.ts" ;
99
10- type FormatTestCase = [ FormatInputPathObject , string ] ;
10+ type FormatTestCase = [ Partial < ParsedPath > , string ] ;
1111type ParseTestCase = [ string , ParsedPath ] ;
1212
1313const winPaths : Array < [ string , string ] > = [
Original file line number Diff line number Diff line change 22// This module is browser compatible.
33
44import { _format , assertArg } from "../_common/format.ts" ;
5- import type { FormatInputPathObject } from "../_interface .ts" ;
5+ import type { ParsedPath } from "../types .ts" ;
66
77/**
8- * Generate a path from `FormatInputPathObject ` object.
8+ * Generate a path from `ParsedPath ` object.
99 *
1010 * @example Usage
1111 * ```ts
@@ -25,7 +25,7 @@ import type { FormatInputPathObject } from "../_interface.ts";
2525 * @param pathObject The path object to format.
2626 * @returns The formatted path.
2727 */
28- export function format ( pathObject : FormatInputPathObject ) : string {
28+ export function format ( pathObject : Partial < ParsedPath > ) : string {
2929 assertArg ( pathObject ) ;
3030 return _format ( "/" , pathObject ) ;
3131}
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ export * from "./resolve.ts";
3434export * from "./to_file_url.ts" ;
3535export * from "./to_namespaced_path.ts" ;
3636export * from "./common.ts" ;
37- export * from "../_interface .ts" ;
37+ export * from "../types .ts" ;
3838export * from "./glob_to_regexp.ts" ;
3939export * from "./is_glob.ts" ;
4040export * from "./join_globs.ts" ;
Original file line number Diff line number Diff line change 22// This module is browser compatible.
33
44import { CHAR_DOT } from "../_common/constants.ts" ;
5- import type { ParsedPath } from "../_interface .ts" ;
5+ import type { ParsedPath } from "../types .ts" ;
66import { stripTrailingSeparators } from "../_common/strip_trailing_separators.ts" ;
77import { assertPath } from "../_common/assert_path.ts" ;
88import { isPosixPathSeparator } from "./_util.ts" ;
99
10- export type { ParsedPath } from "../_interface .ts" ;
10+ export type { ParsedPath } from "../types .ts" ;
1111
1212/**
1313 * Return a `ParsedPath` object of the `path`.
Original file line number Diff line number Diff line change @@ -38,8 +38,3 @@ export interface ParsedPath {
3838 */
3939 name : string ;
4040}
41-
42- /**
43- * A parsed path object to be consumed by `path.format()`.
44- */
45- export type FormatInputPathObject = Partial < ParsedPath > ;
You can’t perform that action at this time.
0 commit comments