Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING(path): remove runtime type-checking #4954

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions path/_common/assert_path.ts

This file was deleted.

3 changes: 0 additions & 3 deletions path/_common/basename.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import { assertPath } from "./assert_path.ts";

export function stripSuffix(name: string, suffix: string): string {
if (suffix.length >= name.length) {
return name;
Expand Down Expand Up @@ -43,7 +41,6 @@ export function lastPathSegment(
}

export function assertArgs(path: string, suffix: string) {
assertPath(path);
if (path.length === 0) return path;
if (typeof suffix !== "string") {
throw new TypeError(
Expand Down
3 changes: 0 additions & 3 deletions path/_common/dirname.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import { assertPath } from "./assert_path.ts";

export function assertArg(path: string) {
assertPath(path);
if (path.length === 0) return ".";
}
3 changes: 0 additions & 3 deletions path/_common/normalize.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import { assertPath } from "./assert_path.ts";

export function assertArg(path: string) {
assertPath(path);
if (path.length === 0) return ".";
}
4 changes: 0 additions & 4 deletions path/_common/relative.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import { assertPath } from "./assert_path.ts";

export function assertArgs(from: string, to: string) {
assertPath(from);
assertPath(to);
if (from === to) return "";
}
3 changes: 0 additions & 3 deletions path/posix/extname.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// This module is browser compatible.

import { CHAR_DOT } from "../_common/constants.ts";
import { assertPath } from "../_common/assert_path.ts";
import { isPosixPathSeparator } from "./_util.ts";

/**
Expand All @@ -22,8 +21,6 @@ import { isPosixPathSeparator } from "./_util.ts";
* @returns The extension (ex. for `file.ts` returns `.ts`).
*/
export function extname(path: string): string {
assertPath(path);

let startDot = -1;
let startPart = 0;
let end = -1;
Expand Down
2 changes: 0 additions & 2 deletions path/posix/is_absolute.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import { assertPath } from "../_common/assert_path.ts";
import { isPosixPathSeparator } from "./_util.ts";

/**
Expand All @@ -20,6 +19,5 @@ import { isPosixPathSeparator } from "./_util.ts";
* @returns Whether the path is absolute.
*/
export function isAbsolute(path: string): boolean {
assertPath(path);
return path.length > 0 && isPosixPathSeparator(path.charCodeAt(0));
}
2 changes: 0 additions & 2 deletions path/posix/join.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import { assertPath } from "../_common/assert_path.ts";
import { normalize } from "./normalize.ts";

/**
Expand All @@ -25,7 +24,6 @@ export function join(...paths: string[]): string {
let joined: string | undefined;
for (let i = 0; i < paths.length; ++i) {
const path = paths[i]!;
assertPath(path);
if (path.length > 0) {
if (!joined) joined = path;
else joined += `/${path}`;
Expand Down
3 changes: 0 additions & 3 deletions path/posix/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { CHAR_DOT } from "../_common/constants.ts";
import type { ParsedPath } from "../_interface.ts";
import { stripTrailingSeparators } from "../_common/strip_trailing_separators.ts";
import { assertPath } from "../_common/assert_path.ts";
import { isPosixPathSeparator } from "./_util.ts";

export type { ParsedPath } from "../_interface.ts";
Expand All @@ -31,8 +30,6 @@ export type { ParsedPath } from "../_interface.ts";
* @returns The parsed path object.
*/
export function parse(path: string): ParsedPath {
assertPath(path);

const ret: ParsedPath = { root: "", dir: "", base: "", ext: "", name: "" };
if (path.length === 0) return ret;
const isAbsolute = isPosixPathSeparator(path.charCodeAt(0));
Expand Down
3 changes: 0 additions & 3 deletions path/posix/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// This module is browser compatible.

import { normalizeString } from "../_common/normalize_string.ts";
import { assertPath } from "../_common/assert_path.ts";
import { isPosixPathSeparator } from "./_util.ts";

/**
Expand Down Expand Up @@ -37,8 +36,6 @@ export function resolve(...pathSegments: string[]): string {
path = Deno.cwd();
}

assertPath(path);

// Skip empty entries
if (path.length === 0) {
continue;
Expand Down
3 changes: 0 additions & 3 deletions path/windows/extname.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// This module is browser compatible.

import { CHAR_COLON, CHAR_DOT } from "../_common/constants.ts";
import { assertPath } from "../_common/assert_path.ts";
import { isPathSeparator, isWindowsDeviceRoot } from "./_util.ts";

/**
Expand All @@ -21,8 +20,6 @@ import { isPathSeparator, isWindowsDeviceRoot } from "./_util.ts";
* @returns The extension of the `path`.
*/
export function extname(path: string): string {
assertPath(path);

let start = 0;
let startDot = -1;
let startPart = 0;
Expand Down
3 changes: 0 additions & 3 deletions path/windows/is_absolute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// This module is browser compatible.

import { CHAR_COLON } from "../_common/constants.ts";
import { assertPath } from "../_common/assert_path.ts";
import { isPathSeparator, isWindowsDeviceRoot } from "./_util.ts";

/**
Expand All @@ -21,8 +20,6 @@ import { isPathSeparator, isWindowsDeviceRoot } from "./_util.ts";
* @returns `true` if the path is absolute, `false` otherwise.
*/
export function isAbsolute(path: string): boolean {
assertPath(path);

const len = path.length;
if (len === 0) return false;

Expand Down
2 changes: 0 additions & 2 deletions path/windows/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// This module is browser compatible.

import { assert } from "@std/assert/assert";
import { assertPath } from "../_common/assert_path.ts";
import { isPathSeparator } from "./_util.ts";
import { normalize } from "./normalize.ts";

Expand All @@ -28,7 +27,6 @@ export function join(...paths: string[]): string {
let firstPart: string | null = null;
for (let i = 0; i < paths.length; ++i) {
const path = paths[i]!;
assertPath(path);
if (path.length > 0) {
if (joined === undefined) joined = firstPart = path;
else joined += `\\${path}`;
Expand Down
3 changes: 0 additions & 3 deletions path/windows/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import { CHAR_COLON, CHAR_DOT } from "../_common/constants.ts";
import type { ParsedPath } from "../_interface.ts";
import { assertPath } from "../_common/assert_path.ts";
import { isPathSeparator, isWindowsDeviceRoot } from "./_util.ts";

export type { ParsedPath } from "../_interface.ts";
Expand All @@ -30,8 +29,6 @@ export type { ParsedPath } from "../_interface.ts";
* @returns The `ParsedPath` object.
*/
export function parse(path: string): ParsedPath {
assertPath(path);

const ret: ParsedPath = { root: "", dir: "", base: "", ext: "", name: "" };

const len = path.length;
Expand Down
3 changes: 0 additions & 3 deletions path/windows/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import { CHAR_COLON } from "../_common/constants.ts";
import { normalizeString } from "../_common/normalize_string.ts";
import { assertPath } from "../_common/assert_path.ts";
import { isPathSeparator, isWindowsDeviceRoot } from "./_util.ts";

/**
Expand Down Expand Up @@ -55,8 +54,6 @@ export function resolve(...pathSegments: string[]): string {
}
}

assertPath(path);

const len = path.length;

// Skip empty entries
Expand Down