summaryrefslogtreecommitdiff
path: root/cli/js/web
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/web')
-rw-r--r--cli/js/web/README.md4
-rw-r--r--cli/js/web/abort_controller.ts1
-rw-r--r--cli/js/web/base64.ts2
-rw-r--r--cli/js/web/blob.ts1
-rw-r--r--cli/js/web/body.ts2
-rw-r--r--cli/js/web/console.ts9
-rw-r--r--cli/js/web/console_table.ts2
-rw-r--r--cli/js/web/custom_event.ts3
-rw-r--r--cli/js/web/decode_utf8.ts2
-rw-r--r--cli/js/web/dom_exception.ts2
-rw-r--r--cli/js/web/dom_file.ts1
-rw-r--r--cli/js/web/dom_iterable.ts1
-rw-r--r--cli/js/web/error_event.ts10
-rw-r--r--cli/js/web/fetch.ts7
-rw-r--r--cli/js/web/fetch/multipart.ts7
-rw-r--r--cli/js/web/form_data.ts12
-rw-r--r--cli/js/web/headers.ts1
-rw-r--r--cli/js/web/performance.ts1
-rw-r--r--cli/js/web/promise.ts8
-rw-r--r--cli/js/web/request.ts4
-rw-r--r--cli/js/web/streams/internals.ts117
-rw-r--r--cli/js/web/text_encoding.ts7
-rw-r--r--cli/js/web/timers.ts1
-rw-r--r--cli/js/web/url.ts11
-rw-r--r--cli/js/web/url_search_params.ts2
-rw-r--r--cli/js/web/workers.ts2
26 files changed, 107 insertions, 113 deletions
diff --git a/cli/js/web/README.md b/cli/js/web/README.md
index f220c0da6..01672fe76 100644
--- a/cli/js/web/README.md
+++ b/cli/js/web/README.md
@@ -2,10 +2,10 @@
This directory facilities Web APIs that are available in Deno.
-Please note, that some of implementations might not be completely aligned with
+Please note, that some implementations might not be completely aligned with
specification.
-Some of the Web APIs are using ops under the hood, eg. `console`, `performance`.
+Some Web APIs are using ops under the hood, eg. `console`, `performance`.
## Implemented Web APIs
diff --git a/cli/js/web/abort_controller.ts b/cli/js/web/abort_controller.ts
index 5b0a3af3c..376376092 100644
--- a/cli/js/web/abort_controller.ts
+++ b/cli/js/web/abort_controller.ts
@@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
import { AbortSignalImpl, signalAbort } from "./abort_signal.ts";
export class AbortControllerImpl implements AbortController {
diff --git a/cli/js/web/base64.ts b/cli/js/web/base64.ts
index 4d30e00f1..328311d03 100644
--- a/cli/js/web/base64.ts
+++ b/cli/js/web/base64.ts
@@ -1,3 +1,5 @@
+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
// Forked from https://github.com/beatgammit/base64-js
// Copyright (c) 2014 Jameson Little. MIT License.
diff --git a/cli/js/web/blob.ts b/cli/js/web/blob.ts
index 899c67135..92286029f 100644
--- a/cli/js/web/blob.ts
+++ b/cli/js/web/blob.ts
@@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
import { TextDecoder, TextEncoder } from "./text_encoding.ts";
import { build } from "../build.ts";
import { ReadableStreamImpl } from "./streams/readable_stream.ts";
diff --git a/cli/js/web/body.ts b/cli/js/web/body.ts
index 35fc5ebbe..80c4b646a 100644
--- a/cli/js/web/body.ts
+++ b/cli/js/web/body.ts
@@ -1,3 +1,5 @@
+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
import * as blob from "./blob.ts";
import * as encoding from "./text_encoding.ts";
import * as domTypes from "./dom_types.d.ts";
diff --git a/cli/js/web/console.ts b/cli/js/web/console.ts
index f6ea7a0a7..1f96bfe9d 100644
--- a/cli/js/web/console.ts
+++ b/cli/js/web/console.ts
@@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
import { isInvalidDate, isTypedArray, TypedArray } from "./util.ts";
import { cliTable } from "./console_table.ts";
import { exposeForTest } from "../internals.ts";
@@ -381,7 +382,7 @@ function createTypedArrayString(
displayName: `${typedArrayName}(${valueLength})`,
delims: ["[", "]"],
entryHandler: (entry, ctx, level, maxLevel): string => {
- const [_, val] = entry;
+ const val = entry[1];
return stringifyWithQuotes(val, ctx, level + 1, maxLevel);
},
group: true,
@@ -400,7 +401,7 @@ function createSetString(
displayName: "Set",
delims: ["{", "}"],
entryHandler: (entry, ctx, level, maxLevel): string => {
- const [_, val] = entry;
+ const val = entry[1];
return stringifyWithQuotes(val, ctx, level + 1, maxLevel);
},
group: false,
@@ -508,7 +509,7 @@ function createRawObjectString(
}
ctx.add(value);
- let baseString = "";
+ let baseString: string;
let shouldShowDisplayName = false;
let displayName = (value as { [Symbol.toStringTag]: string })[
@@ -724,7 +725,7 @@ const timerMap = new Map<string, number>();
const isConsoleInstance = Symbol("isConsoleInstance");
export class Console {
- #printFunc: PrintFunc;
+ readonly #printFunc: PrintFunc;
indentLevel: number;
[isConsoleInstance] = false;
diff --git a/cli/js/web/console_table.ts b/cli/js/web/console_table.ts
index 55808cdc0..ba2d763b7 100644
--- a/cli/js/web/console_table.ts
+++ b/cli/js/web/console_table.ts
@@ -1,3 +1,5 @@
+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
// Copyright Joyent, Inc. and other Node contributors. MIT license.
// Forked from Node's lib/internal/cli_table.js
diff --git a/cli/js/web/custom_event.ts b/cli/js/web/custom_event.ts
index ea76d2c94..dad89f650 100644
--- a/cli/js/web/custom_event.ts
+++ b/cli/js/web/custom_event.ts
@@ -1,10 +1,11 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
import { EventImpl as Event } from "./event.ts";
import { requiredArguments } from "./util.ts";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export class CustomEventImpl<T = any> extends Event implements CustomEvent {
- #detail: T;
+ readonly #detail: T;
constructor(type: string, eventInitDict: CustomEventInit<T> = {}) {
super(type, eventInitDict);
diff --git a/cli/js/web/decode_utf8.ts b/cli/js/web/decode_utf8.ts
index c1f879b54..d82634efe 100644
--- a/cli/js/web/decode_utf8.ts
+++ b/cli/js/web/decode_utf8.ts
@@ -1,3 +1,5 @@
+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
// This module is based on Bjoern Hoehrmann's DFA UTF-8 decoder.
// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
//
diff --git a/cli/js/web/dom_exception.ts b/cli/js/web/dom_exception.ts
index e2c77d41c..5e7d5ee6f 100644
--- a/cli/js/web/dom_exception.ts
+++ b/cli/js/web/dom_exception.ts
@@ -1,7 +1,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
export class DOMExceptionImpl extends Error implements DOMException {
- #name: string;
+ readonly #name: string;
constructor(message = "", name = "Error") {
super(message);
diff --git a/cli/js/web/dom_file.ts b/cli/js/web/dom_file.ts
index 792d96dd1..3d65e5768 100644
--- a/cli/js/web/dom_file.ts
+++ b/cli/js/web/dom_file.ts
@@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
import * as blob from "./blob.ts";
export class DomFileImpl extends blob.DenoBlob implements File {
diff --git a/cli/js/web/dom_iterable.ts b/cli/js/web/dom_iterable.ts
index fcbca307f..271b2f655 100644
--- a/cli/js/web/dom_iterable.ts
+++ b/cli/js/web/dom_iterable.ts
@@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
import { requiredArguments } from "./util.ts";
import { exposeForTest } from "../internals.ts";
diff --git a/cli/js/web/error_event.ts b/cli/js/web/error_event.ts
index fbdd19fb5..8e7853875 100644
--- a/cli/js/web/error_event.ts
+++ b/cli/js/web/error_event.ts
@@ -4,12 +4,12 @@ import { EventImpl as Event } from "./event.ts";
import { defineEnumerableProps } from "./util.ts";
export class ErrorEventImpl extends Event implements ErrorEvent {
- #message: string;
- #filename: string;
- #lineno: number;
- #colno: number;
+ readonly #message: string;
+ readonly #filename: string;
+ readonly #lineno: number;
+ readonly #colno: number;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- #error: any;
+ readonly #error: any;
get message(): string {
return this.#message;
diff --git a/cli/js/web/fetch.ts b/cli/js/web/fetch.ts
index 0c419178a..156c218a4 100644
--- a/cli/js/web/fetch.ts
+++ b/cli/js/web/fetch.ts
@@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
import { notImplemented } from "../util.ts";
import { isTypedArray } from "./util.ts";
import * as domTypes from "./dom_types.d.ts";
@@ -55,7 +56,6 @@ export class Response extends Body.Body implements domTypes.Response {
if (!type) {
type = "default";
} else {
- type = type;
if (type == "error") {
// spec: https://fetch.spec.whatwg.org/#concept-network-error
status = 0;
@@ -144,12 +144,11 @@ export class Response extends Body.Body implements domTypes.Response {
resBody = tees[1];
}
- const cloned = new Response(resBody, {
+ return new Response(resBody, {
status: this.status,
statusText: this.statusText,
headers: new Headers(headersList),
});
- return cloned;
}
static redirect(url: URL | string, status: number): domTypes.Response {
@@ -260,7 +259,7 @@ export async function fetch(
}
let responseBody;
- let responseInit: ResponseInit = {};
+ let responseInit: domTypes.ResponseInit = {};
while (remRedirectCount) {
const fetchResponse = await sendFetchReq(url, method, headers, body);
diff --git a/cli/js/web/fetch/multipart.ts b/cli/js/web/fetch/multipart.ts
index 654d4a0ea..a632d8600 100644
--- a/cli/js/web/fetch/multipart.ts
+++ b/cli/js/web/fetch/multipart.ts
@@ -19,12 +19,9 @@ interface MultipartHeaders {
export class MultipartBuilder {
readonly boundary: string;
- readonly formData: FormData;
- readonly writer: Buffer;
- constructor(formData: FormData, boundary?: string) {
+ readonly writer = new Buffer();
+ constructor(readonly formData: FormData, boundary?: string) {
this.boundary = boundary ?? this.#createBoundary();
- this.formData = formData;
- this.writer = new Buffer();
}
getContentType(): string {
diff --git a/cli/js/web/form_data.ts b/cli/js/web/form_data.ts
index 155f40771..2566943f0 100644
--- a/cli/js/web/form_data.ts
+++ b/cli/js/web/form_data.ts
@@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
import * as blob from "./blob.ts";
import * as domFile from "./dom_file.ts";
import { DomIterableMixin } from "./dom_iterable.ts";
@@ -96,10 +97,13 @@ class FormDataBase {
if (value instanceof domFile.DomFileImpl) {
this[dataSymbol][i][1] = value;
} else if (value instanceof blob.DenoBlob) {
- const dfile = new domFile.DomFileImpl([value], filename || "blob", {
- type: value.type,
- });
- this[dataSymbol][i][1] = dfile;
+ this[dataSymbol][i][1] = new domFile.DomFileImpl(
+ [value],
+ filename || "blob",
+ {
+ type: value.type,
+ }
+ );
} else {
this[dataSymbol][i][1] = String(value);
}
diff --git a/cli/js/web/headers.ts b/cli/js/web/headers.ts
index 9e0a70f0d..5fd6abc44 100644
--- a/cli/js/web/headers.ts
+++ b/cli/js/web/headers.ts
@@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
import { DomIterableMixin } from "./dom_iterable.ts";
import { requiredArguments } from "./util.ts";
import { customInspect } from "./console.ts";
diff --git a/cli/js/web/performance.ts b/cli/js/web/performance.ts
index 7077b1edb..67f8f1b6c 100644
--- a/cli/js/web/performance.ts
+++ b/cli/js/web/performance.ts
@@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
import { now as opNow } from "../ops/timers.ts";
export class Performance {
diff --git a/cli/js/web/promise.ts b/cli/js/web/promise.ts
index b00c0786f..a24e8ed51 100644
--- a/cli/js/web/promise.ts
+++ b/cli/js/web/promise.ts
@@ -1,7 +1,9 @@
+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
export enum PromiseState {
- Pending = 0,
- Fulfilled = 1,
- Rejected = 2,
+ Pending,
+ Fulfilled,
+ Rejected,
}
export type PromiseDetails<T> = [PromiseState, T | undefined];
diff --git a/cli/js/web/request.ts b/cli/js/web/request.ts
index 286aaff56..a9dcce2de 100644
--- a/cli/js/web/request.ts
+++ b/cli/js/web/request.ts
@@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
import * as body from "./body.ts";
import * as domTypes from "./dom_types.d.ts";
import { ReadableStreamImpl } from "./streams/readable_stream.ts";
@@ -128,12 +129,11 @@ export class Request extends body.Body implements domTypes.Request {
body2 = tees[1];
}
- const cloned = new Request(this.url, {
+ return new Request(this.url, {
body: body2,
method: this.method,
headers: new Headers(headersList),
credentials: this.credentials,
});
- return cloned;
}
}
diff --git a/cli/js/web/streams/internals.ts b/cli/js/web/streams/internals.ts
index d0d35a1c3..3fbfb7735 100644
--- a/cli/js/web/streams/internals.ts
+++ b/cli/js/web/streams/internals.ts
@@ -5,7 +5,6 @@
//
// There are some parts that are not fully implemented, and there are some
// comments which point to steps of the specification that are not implemented.
-//
/* eslint-disable @typescript-eslint/no-explicit-any,require-await */
import { ReadableByteStreamControllerImpl } from "./readable_byte_stream_controller.ts";
@@ -62,7 +61,7 @@ export interface ReadableStreamGenericReader<R = any>
export interface ReadableStreamAsyncIterator<T = any> extends AsyncIterator<T> {
[sym.asyncIteratorReader]: ReadableStreamDefaultReaderImpl<T>;
[sym.preventCancel]: boolean;
- return(value?: any | PromiseLike<any>): Promise<IteratorResult<T, any>>;
+ return(value?: any | PromiseLike<any>): Promise<IteratorResult<T>>;
}
export function acquireReadableStreamDefaultReader<T>(
@@ -97,6 +96,7 @@ function createAlgorithmFromUnderlyingMethod<
algoArgCount: 0,
...extraArgs: any[]
): () => Promise<void>;
+
function createAlgorithmFromUnderlyingMethod<
O extends UnderlyingByteSource | UnderlyingSource | Transformer,
P extends keyof O
@@ -317,79 +317,72 @@ function isFiniteNonNegativeNumber(v: unknown): v is number {
export function isReadableByteStreamController(
x: unknown
): x is ReadableByteStreamControllerImpl {
- return typeof x !== "object" ||
+ return !(
+ typeof x !== "object" ||
x === null ||
!(sym.controlledReadableByteStream in x)
- ? false
- : true;
+ );
}
export function isReadableStream(x: unknown): x is ReadableStreamImpl {
- return typeof x !== "object" ||
+ return !(
+ typeof x !== "object" ||
x === null ||
!(sym.readableStreamController in x)
- ? false
- : true;
+ );
}
export function isReadableStreamAsyncIterator(
x: unknown
-): x is ReadableStreamAsyncIterator<any> {
+): x is ReadableStreamAsyncIterator {
if (typeof x !== "object" || x === null) {
return false;
}
- if (!(sym.asyncIteratorReader in x)) {
- return false;
- }
- return true;
+ return sym.asyncIteratorReader in x;
}
export function isReadableStreamDefaultController(
x: unknown
): x is ReadableStreamDefaultControllerImpl {
- return typeof x !== "object" ||
+ return !(
+ typeof x !== "object" ||
x === null ||
!(sym.controlledReadableStream in x)
- ? false
- : true;
+ );
}
export function isReadableStreamDefaultReader<T>(
x: unknown
): x is ReadableStreamDefaultReaderImpl<T> {
- return typeof x !== "object" || x === null || !(sym.readRequests in x)
- ? false
- : true;
+ return !(typeof x !== "object" || x === null || !(sym.readRequests in x));
}
export function isReadableStreamLocked(stream: ReadableStreamImpl): boolean {
assert(isReadableStream(stream));
- return stream[sym.reader] ? true : false;
+ return !!stream[sym.reader];
}
export function isReadableStreamDisturbed(stream: ReadableStream): boolean {
assert(isReadableStream(stream));
- return stream[sym.disturbed] ? true : false;
+ return !!stream[sym.disturbed];
}
-export function isTransformStream(
- x: unknown
-): x is TransformStreamImpl<any, any> {
- return typeof x !== "object" ||
+export function isTransformStream(x: unknown): x is TransformStreamImpl {
+ return !(
+ typeof x !== "object" ||
x === null ||
!(sym.transformStreamController in x)
- ? false
- : true;
+ );
}
export function isTransformStreamDefaultController(
x: unknown
-): x is TransformStreamDefaultControllerImpl<any, any> {
- return typeof x !== "object" ||
+): x is TransformStreamDefaultControllerImpl {
+ return !(
+ typeof x !== "object" ||
x === null ||
!(sym.controlledTransformStream in x)
- ? false
- : true;
+ );
}
export function isUnderlyingByteSource(
@@ -401,37 +394,36 @@ export function isUnderlyingByteSource(
}
export function isWritableStream(x: unknown): x is WritableStreamImpl {
- return typeof x !== "object" ||
+ return !(
+ typeof x !== "object" ||
x === null ||
!(sym.writableStreamController in x)
- ? false
- : true;
+ );
}
export function isWritableStreamDefaultController(
x: unknown
): x is WritableStreamDefaultControllerImpl<any> {
- return typeof x !== "object" ||
+ return !(
+ typeof x !== "object" ||
x === null ||
!(sym.controlledWritableStream in x)
- ? false
- : true;
+ );
}
export function isWritableStreamDefaultWriter(
x: unknown
): x is WritableStreamDefaultWriterImpl<any> {
- return typeof x !== "object" || x === null || !(sym.ownerWritableStream in x)
- ? false
- : true;
+ return !(
+ typeof x !== "object" ||
+ x === null ||
+ !(sym.ownerWritableStream in x)
+ );
}
export function isWritableStreamLocked(stream: WritableStreamImpl): boolean {
assert(isWritableStream(stream));
- if (stream[sym.writer] === undefined) {
- return false;
- }
- return true;
+ return stream[sym.writer] !== undefined;
}
export function makeSizeAlgorithmFromSizeFunction<T>(
@@ -476,10 +468,7 @@ function readableByteStreamControllerShouldCallPull(
// ReadableStreamGetNumReadIntoRequests(stream) > 0, return true.
const desiredSize = readableByteStreamControllerGetDesiredSize(controller);
assert(desiredSize !== null);
- if (desiredSize > 0) {
- return true;
- }
- return false;
+ return desiredSize > 0;
}
export function readableByteStreamControllerCallPullIfNeeded(
@@ -730,10 +719,7 @@ export function readableStreamDefaultControllerCanCloseOrEnqueue<T>(
controller: ReadableStreamDefaultControllerImpl<T>
): boolean {
const state = controller[sym.controlledReadableStream][sym.state];
- if (!controller[sym.closeRequested] && state === "readable") {
- return true;
- }
- return false;
+ return !controller[sym.closeRequested] && state === "readable";
}
export function readableStreamDefaultControllerClearAlgorithms<T>(
@@ -813,9 +799,7 @@ export function readableStreamDefaultControllerError<T>(
function readableStreamDefaultControllerHasBackpressure<T>(
controller: ReadableStreamDefaultControllerImpl<T>
): boolean {
- return readableStreamDefaultControllerShouldCallPull(controller)
- ? true
- : false;
+ return readableStreamDefaultControllerShouldCallPull(controller);
}
function readableStreamDefaultControllerShouldCallPull<T>(
@@ -836,10 +820,7 @@ function readableStreamDefaultControllerShouldCallPull<T>(
}
const desiredSize = readableStreamDefaultControllerGetDesiredSize(controller);
assert(desiredSize !== null);
- if (desiredSize > 0) {
- return true;
- }
- return false;
+ return desiredSize > 0;
}
export function readableStreamDefaultReaderRead<R>(
@@ -914,9 +895,7 @@ export function readableStreamHasDefaultReader(
stream: ReadableStreamImpl
): boolean {
const reader = stream[sym.reader];
- return reader === undefined || !isReadableStreamDefaultReader(reader)
- ? false
- : true;
+ return !(reader === undefined || !isReadableStreamDefaultReader(reader));
}
export function readableStreamPipeTo<T>(
@@ -1927,13 +1906,10 @@ export function writableStreamClose<W>(
export function writableStreamCloseQueuedOrInFlight<W>(
stream: WritableStreamImpl<W>
): boolean {
- if (
+ return !(
stream[sym.closeRequest] === undefined &&
stream[sym.inFlightCloseRequest] === undefined
- ) {
- return false;
- }
- return true;
+ );
}
function writableStreamDealWithRejection<W>(
@@ -2348,13 +2324,10 @@ function writableStreamFinishInFlightWriteWithError<W>(
function writableStreamHasOperationMarkedInFlight<W>(
stream: WritableStreamImpl<W>
): boolean {
- if (
+ return !(
stream[sym.inFlightWriteRequest] === undefined &&
stream[sym.inFlightCloseRequest] === undefined
- ) {
- return false;
- }
- return true;
+ );
}
function writableStreamMarkCloseRequestInFlight<W>(
diff --git a/cli/js/web/text_encoding.ts b/cli/js/web/text_encoding.ts
index cd93d7a89..d225c6928 100644
--- a/cli/js/web/text_encoding.ts
+++ b/cli/js/web/text_encoding.ts
@@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
// The following code is based off of text-encoding at:
// https://github.com/inexorabletash/text-encoding
//
@@ -151,8 +152,8 @@ interface Encoder {
}
class SingleByteDecoder implements Decoder {
- #index: number[];
- #fatal: boolean;
+ readonly #index: number[];
+ readonly #fatal: boolean;
constructor(
index: number[],
@@ -422,7 +423,7 @@ function isEitherArrayBuffer(x: any): x is EitherArrayBuffer {
}
export class TextDecoder {
- #encoding: string;
+ readonly #encoding: string;
get encoding(): string {
return this.#encoding;
diff --git a/cli/js/web/timers.ts b/cli/js/web/timers.ts
index 74347ee7c..e8eacb402 100644
--- a/cli/js/web/timers.ts
+++ b/cli/js/web/timers.ts
@@ -1,4 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+
import { assert } from "../util.ts";
import { startGlobalTimer, stopGlobalTimer } from "../ops/timers.ts";
import { RBTree } from "../rbtree.ts";
diff --git a/cli/js/web/url.ts b/cli/js/web/url.ts
index 60690d46a..b12f6da75 100644
--- a/cli/js/web/url.ts
+++ b/cli/js/web/url.ts
@@ -24,7 +24,7 @@ const searchParamsMethods: Array<keyof URLSearchParams> = [
const specialSchemes = ["ftp", "file", "http", "https", "ws", "wss"];
// https://url.spec.whatwg.org/#special-scheme
-const schemePorts: { [key: string]: string } = {
+const schemePorts: Record<string, string> = {
ftp: "21",
file: "",
http: "80",
@@ -179,8 +179,8 @@ function resolvePathFromBase(
let driveLetterPrefix = "";
if (build.os == "windows" && isFilePath) {
- let driveLetter = "";
- let baseDriveLetter = "";
+ let driveLetter: string;
+ let baseDriveLetter: string;
[driveLetter, normalizedPath] = takePattern(
normalizedPath,
/^(\/[A-Za-z]:)(?=\/)/
@@ -214,7 +214,8 @@ function resolvePathFromBase(
function isValidPort(value: string): boolean {
// https://url.spec.whatwg.org/#port-state
- if (value === "") true;
+ if (value === "") return true;
+
const port = Number(value);
return Number.isInteger(port) && port >= 0 && port <= MAX_PORT;
}
@@ -409,7 +410,7 @@ export class URLImpl implements URL {
let baseParts: URLParts | undefined;
if (base) {
baseParts = typeof base === "string" ? parse(base) : parts.get(base);
- if (baseParts == undefined) {
+ if (baseParts === undefined) {
throw new TypeError("Invalid base URL.");
}
}
diff --git a/cli/js/web/url_search_params.ts b/cli/js/web/url_search_params.ts
index 2abac3cd0..b4d199fbc 100644
--- a/cli/js/web/url_search_params.ts
+++ b/cli/js/web/url_search_params.ts
@@ -6,7 +6,7 @@ import { isIterable, requiredArguments } from "./util.ts";
export const urls = new WeakMap<URLSearchParams, URL | null>();
export class URLSearchParamsImpl implements URLSearchParams {
- #params: Array<[string, string]> = [];
+ readonly #params: Array<[string, string]> = [];
constructor(init: string | string[][] | Record<string, string> = "") {
if (typeof init === "string") {
diff --git a/cli/js/web/workers.ts b/cli/js/web/workers.ts
index 1e0762932..cc40f104c 100644
--- a/cli/js/web/workers.ts
+++ b/cli/js/web/workers.ts
@@ -81,7 +81,7 @@ export interface WorkerOptions {
export class WorkerImpl extends EventTarget implements Worker {
readonly #id: number;
- #name: string;
+ readonly #name: string;
#terminated = false;
public onerror?: (e: ErrorEvent) => void;