Skip to content

Commit fcc59f2

Browse files
authored
BREAKING(path): remove FormatInputPathObject (denoland#5321)
1 parent edc649b commit fcc59f2

File tree

13 files changed

+24
-28
lines changed

13 files changed

+24
-28
lines changed

path/_common/format.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
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

66
export 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}`,

path/deno.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
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",

path/format.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import { isWindows } from "./_os.ts";
55
import { format as posixFormat } from "./posix/format.ts";
66
import { 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
}

path/mod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export * from "./resolve.ts";
4848
export * from "./to_file_url.ts";
4949
export * from "./to_namespaced_path.ts";
5050
export * from "./common.ts";
51-
export * from "./_interface.ts";
51+
export * from "./types.ts";
5252
export * from "./glob_to_regexp.ts";
5353
export * from "./is_glob.ts";
5454
export * from "./join_globs.ts";

path/parse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// This module is browser compatible.
33

44
import { isWindows } from "./_os.ts";
5-
import type { ParsedPath } from "./_interface.ts";
5+
import type { ParsedPath } from "./types.ts";
66
import { parse as posixParse } from "./posix/parse.ts";
77
import { 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.

path/parse_format_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
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

66
import { assertEquals } from "@std/assert";
77
import * as posix from "./posix/mod.ts";
88
import * as windows from "./windows/mod.ts";
99

10-
type FormatTestCase = [FormatInputPathObject, string];
10+
type FormatTestCase = [Partial<ParsedPath>, string];
1111
type ParseTestCase = [string, ParsedPath];
1212

1313
const winPaths: Array<[string, string]> = [

path/posix/format.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// This module is browser compatible.
33

44
import { _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
}

path/posix/mod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export * from "./resolve.ts";
3434
export * from "./to_file_url.ts";
3535
export * from "./to_namespaced_path.ts";
3636
export * from "./common.ts";
37-
export * from "../_interface.ts";
37+
export * from "../types.ts";
3838
export * from "./glob_to_regexp.ts";
3939
export * from "./is_glob.ts";
4040
export * from "./join_globs.ts";

path/posix/parse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
// This module is browser compatible.
33

44
import { CHAR_DOT } from "../_common/constants.ts";
5-
import type { ParsedPath } from "../_interface.ts";
5+
import type { ParsedPath } from "../types.ts";
66
import { stripTrailingSeparators } from "../_common/strip_trailing_separators.ts";
77
import { assertPath } from "../_common/assert_path.ts";
88
import { 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`.
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff 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>;

0 commit comments

Comments
 (0)