summaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
Diffstat (limited to 'std')
-rw-r--r--std/_util/assert_test.ts2
-rw-r--r--std/archive/tar.ts28
-rw-r--r--std/archive/tar_test.ts4
-rw-r--r--std/async/mux_async_iterator.ts2
-rw-r--r--std/async/mux_async_iterator_test.ts2
-rw-r--r--std/bytes/README.md4
-rw-r--r--std/bytes/test.ts8
-rw-r--r--std/datetime/mod.ts49
-rw-r--r--std/datetime/test.ts22
-rw-r--r--std/encoding/README.md2
-rw-r--r--std/encoding/_yaml/dumper/dumper.ts74
-rw-r--r--std/encoding/_yaml/dumper/dumper_state.ts2
-rw-r--r--std/encoding/_yaml/error.ts2
-rw-r--r--std/encoding/_yaml/example/dump.ts2
-rw-r--r--std/encoding/_yaml/loader/loader.ts121
-rw-r--r--std/encoding/_yaml/loader/loader_state.ts2
-rw-r--r--std/encoding/_yaml/mark.ts12
-rw-r--r--std/encoding/_yaml/parse.ts2
-rw-r--r--std/encoding/_yaml/schema.ts6
-rw-r--r--std/encoding/_yaml/type/float.ts2
-rw-r--r--std/encoding/_yaml/type/timestamp.ts24
-rw-r--r--std/encoding/ascii85.ts20
-rw-r--r--std/encoding/ascii85_test.ts8
-rw-r--r--std/encoding/base32.ts37
-rw-r--r--std/encoding/base32_test.ts2
-rw-r--r--std/encoding/base64url.ts3
-rw-r--r--std/encoding/binary.ts14
-rw-r--r--std/encoding/binary_test.ts12
-rw-r--r--std/encoding/csv.ts13
-rw-r--r--std/encoding/csv_test.ts8
-rw-r--r--std/encoding/hex.ts2
-rw-r--r--std/encoding/hex_test.ts4
-rw-r--r--std/encoding/toml.ts6
-rw-r--r--std/encoding/toml_test.ts3
-rw-r--r--std/examples/catj.ts9
-rwxr-xr-xstd/examples/gist.ts2
-rw-r--r--std/examples/tests/catj_test.ts2
-rw-r--r--std/examples/tests/echo_server_test.ts2
-rw-r--r--std/examples/tests/xeval_test.ts2
-rw-r--r--std/examples/xeval.ts2
-rwxr-xr-xstd/flags/dash_test.ts2
-rw-r--r--std/flags/mod.ts6
-rwxr-xr-xstd/flags/parse_test.ts2
-rwxr-xr-xstd/flags/unknown_test.ts2
-rw-r--r--std/fmt/colors.ts20
-rw-r--r--std/fmt/colors_test.ts4
-rw-r--r--std/fmt/printf.ts27
-rw-r--r--std/fmt/printf_test.ts36
-rw-r--r--std/fs/_util.ts2
-rw-r--r--std/fs/_util_test.ts2
-rw-r--r--std/fs/copy.ts24
-rw-r--r--std/fs/copy_test.ts96
-rw-r--r--std/fs/empty_dir_test.ts11
-rw-r--r--std/fs/ensure_dir.ts8
-rw-r--r--std/fs/ensure_dir_test.ts8
-rw-r--r--std/fs/ensure_file.ts4
-rw-r--r--std/fs/ensure_file_test.ts8
-rw-r--r--std/fs/ensure_link.ts4
-rw-r--r--std/fs/ensure_link_test.ts22
-rw-r--r--std/fs/ensure_symlink.ts4
-rw-r--r--std/fs/ensure_symlink_test.ts4
-rw-r--r--std/fs/exists_test.ts6
-rw-r--r--std/fs/expand_glob.ts20
-rw-r--r--std/fs/expand_glob_test.ts12
-rw-r--r--std/fs/move.ts8
-rw-r--r--std/fs/move_test.ts32
-rw-r--r--std/fs/read_file_str.ts4
-rw-r--r--std/fs/read_json_test.ts6
-rw-r--r--std/fs/walk.ts6
-rw-r--r--std/fs/walk_test.ts36
-rw-r--r--std/fs/write_file_str.ts2
-rw-r--r--std/fs/write_json.ts8
-rw-r--r--std/fs/write_json_test.ts30
-rw-r--r--std/hash/_fnv/util.ts2
-rw-r--r--std/hash/hash_test.ts2
-rw-r--r--std/hash/sha1.ts6
-rw-r--r--std/hash/sha1_test.ts15
-rw-r--r--std/hash/sha256.ts46
-rw-r--r--std/hash/sha256_test.ts37
-rw-r--r--std/hash/sha3_test.ts4
-rw-r--r--std/hash/sha512.ts11
-rw-r--r--std/hash/sha512_test.ts45
-rw-r--r--std/http/_io.ts26
-rw-r--r--std/http/_io_test.ts40
-rw-r--r--std/http/cookie_test.ts20
-rwxr-xr-xstd/http/file_server.ts20
-rw-r--r--std/http/file_server_test.ts8
-rw-r--r--std/http/racing_server.ts4
-rw-r--r--std/http/server.ts10
-rw-r--r--std/http/server_test.ts60
-rw-r--r--std/io/bufio.ts16
-rw-r--r--std/io/bufio_test.ts19
-rw-r--r--std/io/ioutil.ts4
-rw-r--r--std/io/ioutil_test.ts10
-rw-r--r--std/io/streams.ts4
-rw-r--r--std/io/streams_test.ts4
-rw-r--r--std/io/util.ts4
-rw-r--r--std/log/handlers.ts2
-rw-r--r--std/log/handlers_test.ts58
-rw-r--r--std/log/logger.ts2
-rw-r--r--std/log/logger_test.ts8
-rw-r--r--std/log/mod.ts2
-rw-r--r--std/mime/multipart.ts16
-rw-r--r--std/mime/multipart_test.ts34
-rw-r--r--std/node/_fs/_fs_access.ts2
-rw-r--r--std/node/_fs/_fs_appendFile.ts6
-rw-r--r--std/node/_fs/_fs_appendFile_test.ts14
-rw-r--r--std/node/_fs/_fs_chmod.ts2
-rw-r--r--std/node/_fs/_fs_chown.ts2
-rw-r--r--std/node/_fs/_fs_common.ts9
-rw-r--r--std/node/_fs/_fs_copy.ts2
-rw-r--r--std/node/_fs/_fs_dir_test.ts7
-rw-r--r--std/node/_fs/_fs_dirent.ts4
-rw-r--r--std/node/_fs/_fs_dirent_test.ts4
-rw-r--r--std/node/_fs/_fs_link.ts14
-rw-r--r--std/node/_fs/_fs_mkdir.ts6
-rw-r--r--std/node/_fs/_fs_readFile.ts18
-rw-r--r--std/node/_fs/_fs_readFile_test.ts2
-rw-r--r--std/node/_fs/_fs_readlink.ts12
-rw-r--r--std/node/_fs/_fs_writeFile.ts4
-rw-r--r--std/node/_fs/_fs_writeFile_test.ts42
-rw-r--r--std/node/_fs/promises/_fs_readFile.ts6
-rw-r--r--std/node/_fs/promises/_fs_readFile_test.ts2
-rw-r--r--std/node/_fs/promises/_fs_writeFile.ts2
-rw-r--r--std/node/_fs/promises/_fs_writeFile_test.ts18
-rw-r--r--std/node/_util/_util_callbackify.ts22
-rw-r--r--std/node/_util/_util_callbackify_test.ts22
-rw-r--r--std/node/_util/_util_promisify.ts13
-rw-r--r--std/node/_util/_util_promisify_test.ts22
-rw-r--r--std/node/_util/_util_types.ts3
-rw-r--r--std/node/_util/_util_types_test.ts6
-rw-r--r--std/node/_utils.ts9
-rw-r--r--std/node/buffer.ts112
-rw-r--r--std/node/buffer_test.ts56
-rw-r--r--std/node/events.ts28
-rw-r--r--std/node/events_test.ts17
-rw-r--r--std/node/module.ts71
-rw-r--r--std/node/module_test.ts2
-rw-r--r--std/node/os.ts2
-rw-r--r--std/node/os_test.ts42
-rw-r--r--std/node/process_test.ts6
-rw-r--r--std/node/querystring.ts15
-rw-r--r--std/node/querystring_test.ts2
-rw-r--r--std/node/string_decoder.ts14
-rw-r--r--std/node/string_decoder_test.ts6
-rw-r--r--std/node/url.ts21
-rw-r--r--std/node/util.ts4
-rw-r--r--std/path/_globrex.ts9
-rw-r--r--std/path/_globrex_test.ts258
-rw-r--r--std/path/_util.ts10
-rw-r--r--std/path/basename_test.ts4
-rw-r--r--std/path/common_test.ts6
-rw-r--r--std/path/dirname_test.ts6
-rw-r--r--std/path/glob.ts11
-rw-r--r--std/path/glob_test.ts24
-rw-r--r--std/path/posix.ts4
-rw-r--r--std/path/win32.ts6
-rw-r--r--std/permissions/mod.ts18
-rw-r--r--std/signal/mod.ts2
-rw-r--r--std/signal/test.ts4
-rw-r--r--std/testing/README.md12
-rw-r--r--std/testing/asserts.ts87
-rw-r--r--std/testing/asserts_test.ts112
-rw-r--r--std/testing/bench.ts37
-rw-r--r--std/testing/bench_test.ts20
-rw-r--r--std/testing/diff.ts24
-rw-r--r--std/textproto/mod.ts6
-rw-r--r--std/textproto/test.ts9
-rw-r--r--std/uuid/v1.ts12
-rw-r--r--std/uuid/v4.ts2
-rw-r--r--std/uuid/v5.ts7
-rw-r--r--std/wasi/snapshot_preview1.ts119
-rw-r--r--std/wasi/snapshot_preview1_test.ts2
-rw-r--r--std/ws/mod.ts27
-rw-r--r--std/ws/test.ts54
175 files changed, 1543 insertions, 1550 deletions
diff --git a/std/_util/assert_test.ts b/std/_util/assert_test.ts
index 2c94f8bca..3509619c3 100644
--- a/std/_util/assert_test.ts
+++ b/std/_util/assert_test.ts
@@ -24,7 +24,7 @@ Deno.test({
assert(false, "Oops! Should be true");
},
DenoStdInternalError,
- "Oops! Should be true"
+ "Oops! Should be true",
);
},
});
diff --git a/std/archive/tar.ts b/std/archive/tar.ts
index 8ec240764..5fcfedc0f 100644
--- a/std/archive/tar.ts
+++ b/std/archive/tar.ts
@@ -42,7 +42,7 @@ const initialChecksum = 8 * 32;
async function readBlock(
reader: Deno.Reader,
- p: Uint8Array
+ p: Uint8Array,
): Promise<number | null> {
let bytesRead = 0;
while (bytesRead < p.length) {
@@ -354,21 +354,21 @@ export class Tar {
info = await Deno.stat(opts.filePath);
}
- const mode =
- opts.fileMode || (info && info.mode) || parseInt("777", 8) & 0xfff,
+ const mode = opts.fileMode || (info && info.mode) ||
+ parseInt("777", 8) & 0xfff,
mtime = Math.floor(
- opts.mtime ?? (info?.mtime ?? new Date()).valueOf() / 1000
+ opts.mtime ?? (info?.mtime ?? new Date()).valueOf() / 1000,
),
uid = opts.uid || 0,
gid = opts.gid || 0;
if (typeof opts.owner === "string" && opts.owner.length >= 32) {
throw new Error(
- "ustar format does not allow owner name length >= 32 bytes"
+ "ustar format does not allow owner name length >= 32 bytes",
);
}
if (typeof opts.group === "string" && opts.group.length >= 32) {
throw new Error(
- "ustar format does not allow group name length >= 32 bytes"
+ "ustar format does not allow group name length >= 32 bytes",
);
}
@@ -428,9 +428,9 @@ export class Tar {
new Deno.Buffer(
clean(
recordSize -
- (parseInt(tarData.fileSize, 8) % recordSize || recordSize)
- )
- )
+ (parseInt(tarData.fileSize, 8) % recordSize || recordSize),
+ ),
+ ),
);
});
@@ -450,7 +450,7 @@ class TarEntry implements Reader {
constructor(
meta: TarMeta,
header: TarHeader,
- reader: Reader | (Reader & Deno.Seeker)
+ reader: Reader | (Reader & Deno.Seeker),
) {
Object.assign(this, meta);
this.#header = header;
@@ -473,7 +473,7 @@ class TarEntry implements Reader {
const bufSize = Math.min(
// bufSize can't be greater than p.length nor bytes left in the entry
p.length,
- entryBytesLeft
+ entryBytesLeft,
);
if (entryBytesLeft <= 0) return null;
@@ -503,7 +503,7 @@ class TarEntry implements Reader {
if (typeof (this.#reader as Seeker).seek === "function") {
await (this.#reader as Seeker).seek(
this.#entrySize - this.#read,
- Deno.SeekMode.Current
+ Deno.SeekMode.Current,
);
this.#read = this.#entrySize;
} else {
@@ -576,7 +576,7 @@ export class Untar {
"fileMode",
"mtime",
"uid",
- "gid"
+ "gid",
]).forEach((key): void => {
const arr = trim(header[key]);
if (arr.byteLength > 0) {
@@ -589,7 +589,7 @@ export class Untar {
if (arr.byteLength > 0) {
meta[key] = decoder.decode(arr);
}
- }
+ },
);
meta.fileSize = parseInt(decoder.decode(header.fileSize), 8);
diff --git a/std/archive/tar_test.ts b/std/archive/tar_test.ts
index 69f1ec3f3..17dfe7745 100644
--- a/std/archive/tar_test.ts
+++ b/std/archive/tar_test.ts
@@ -212,7 +212,7 @@ Deno.test(
reader.close();
await Deno.remove(outputFile);
assertEquals(entries.length, 0);
- }
+ },
);
Deno.test("untarAsyncIteratorFromFileReader", async function (): Promise<void> {
@@ -299,7 +299,7 @@ Deno.test(
assertEquals(entries.length, 0);
}
- }
+ },
);
Deno.test("untarLinuxGeneratedTar", async function (): Promise<void> {
diff --git a/std/async/mux_async_iterator.ts b/std/async/mux_async_iterator.ts
index ba6f22775..f9f110e5a 100644
--- a/std/async/mux_async_iterator.ts
+++ b/std/async/mux_async_iterator.ts
@@ -24,7 +24,7 @@ export class MuxAsyncIterator<T> implements AsyncIterable<T> {
}
private async callIteratorNext(
- iterator: AsyncIterableIterator<T>
+ iterator: AsyncIterableIterator<T>,
): Promise<void> {
try {
const { value, done } = await iterator.next();
diff --git a/std/async/mux_async_iterator_test.ts b/std/async/mux_async_iterator_test.ts
index 5ca28903b..7977e4f56 100644
--- a/std/async/mux_async_iterator_test.ts
+++ b/std/async/mux_async_iterator_test.ts
@@ -47,7 +47,7 @@ Deno.test({
}
},
Error,
- "something went wrong"
+ "something went wrong",
);
},
});
diff --git a/std/bytes/README.md b/std/bytes/README.md
index 77f3fdfc8..b1edac1e6 100644
--- a/std/bytes/README.md
+++ b/std/bytes/README.md
@@ -15,7 +15,7 @@ import { findIndex } from "https://deno.land/std/bytes/mod.ts";
findIndex(
new Uint8Array([1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 3]),
- new Uint8Array([0, 1, 2])
+ new Uint8Array([0, 1, 2]),
);
// => returns 2
@@ -30,7 +30,7 @@ import { findLastIndex } from "https://deno.land/std/bytes/mod.ts";
findLastIndex(
new Uint8Array([0, 1, 2, 0, 1, 2, 0, 1, 3]),
- new Uint8Array([0, 1, 2])
+ new Uint8Array([0, 1, 2]),
);
// => returns 3
diff --git a/std/bytes/test.ts b/std/bytes/test.ts
index 25af2a35b..6dffad17f 100644
--- a/std/bytes/test.ts
+++ b/std/bytes/test.ts
@@ -17,7 +17,7 @@ import { encode, decode } from "../encoding/utf8.ts";
Deno.test("[bytes] findIndex1", () => {
const i = findIndex(
new Uint8Array([1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 3]),
- new Uint8Array([0, 1, 2])
+ new Uint8Array([0, 1, 2]),
);
assertEquals(i, 2);
});
@@ -35,7 +35,7 @@ Deno.test("[bytes] findIndex3", () => {
Deno.test("[bytes] findLastIndex1", () => {
const i = findLastIndex(
new Uint8Array([0, 1, 2, 0, 1, 2, 0, 1, 3]),
- new Uint8Array([0, 1, 2])
+ new Uint8Array([0, 1, 2]),
);
assertEquals(i, 3);
});
@@ -80,12 +80,12 @@ Deno.test("[bytes] repeat", () => {
repeat(new TextEncoder().encode(input as string), count as number);
},
Error,
- errMsg as string
+ errMsg as string,
);
} else {
const newBytes = repeat(
new TextEncoder().encode(input as string),
- count as number
+ count as number,
);
assertEquals(new TextDecoder().decode(newBytes), output);
diff --git a/std/datetime/mod.ts b/std/datetime/mod.ts
index 9665a92b2..fe6fe6b3c 100644
--- a/std/datetime/mod.ts
+++ b/std/datetime/mod.ts
@@ -71,7 +71,7 @@ export type DateTimeFormat =
*/
export function parseDateTime(
datetimeStr: string,
- format: DateTimeFormat
+ format: DateTimeFormat,
): Date {
let m, d, y, ho, mi: string;
let datePattern: RegExp;
@@ -114,8 +114,7 @@ export function parseDateTime(
*/
export function dayOfYear(date: Date): number {
const yearStart = new Date(date.getFullYear(), 0, 0);
- const diff =
- date.getTime() -
+ const diff = date.getTime() -
yearStart.getTime() +
(yearStart.getTimezoneOffset() - date.getTimezoneOffset()) * 60 * 1000;
return Math.floor(diff / DAY);
@@ -135,13 +134,12 @@ export function currentDayOfYear(): number {
*/
export function weekOfYear(date: Date): number {
const workingDate = new Date(
- Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())
+ Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()),
);
const day = workingDate.getUTCDay();
- const nearestThursday =
- workingDate.getUTCDate() +
+ const nearestThursday = workingDate.getUTCDate() +
Day.Thu -
(day === Day.Sun ? DAYS_PER_WEEK : day);
@@ -236,21 +234,19 @@ export type DifferenceOptions = {
export function difference(
from: Date,
to: Date,
- options?: DifferenceOptions
+ options?: DifferenceOptions,
): DifferenceFormat {
- const uniqueUnits = options?.units
- ? [...new Set(options?.units)]
- : [
- "miliseconds",
- "seconds",
- "minutes",
- "hours",
- "days",
- "weeks",
- "months",
- "quarters",
- "years",
- ];
+ const uniqueUnits = options?.units ? [...new Set(options?.units)] : [
+ "miliseconds",
+ "seconds",
+ "minutes",
+ "hours",
+ "days",
+ "weeks",
+ "months",
+ "quarters",
+ "years",
+ ];
const bigger = Math.max(from.getTime(), to.getTime());
const smaller = Math.min(from.getTime(), to.getTime());
@@ -285,14 +281,14 @@ export function difference(
differences.quarters = Math.floor(
(typeof differences.months !== "undefined" &&
differences.months / 4) ||
- calculateMonthsDifference(bigger, smaller) / 4
+ calculateMonthsDifference(bigger, smaller) / 4,
);
break;
case "years":
differences.years = Math.floor(
(typeof differences.months !== "undefined" &&
differences.months / 12) ||
- calculateMonthsDifference(bigger, smaller) / 12
+ calculateMonthsDifference(bigger, smaller) / 12,
);
break;
}
@@ -309,10 +305,13 @@ function calculateMonthsDifference(bigger: number, smaller: number): number {
const calendarDiffrences = Math.abs(yearsDiff * 12 + monthsDiff);
const compareResult = biggerDate > smallerDate ? 1 : -1;
biggerDate.setMonth(
- biggerDate.getMonth() - compareResult * calendarDiffrences
+ biggerDate.getMonth() - compareResult * calendarDiffrences,
);
- const isLastMonthNotFull =
- biggerDate > smallerDate ? 1 : -1 === -compareResult ? 1 : 0;
+ const isLastMonthNotFull = biggerDate > smallerDate
+ ? 1
+ : -1 === -compareResult
+ ? 1
+ : 0;
const months = compareResult * (calendarDiffrences - isLastMonthNotFull);
return months === 0 ? 0 : months;
}
diff --git a/std/datetime/test.ts b/std/datetime/test.ts
index a223abce2..d5dccee73 100644
--- a/std/datetime/test.ts
+++ b/std/datetime/test.ts
@@ -7,27 +7,27 @@ Deno.test({
fn: () => {
assertEquals(
datetime.parseDateTime("01-03-2019 16:30", "mm-dd-yyyy hh:mm"),
- new Date(2019, 0, 3, 16, 30)
+ new Date(2019, 0, 3, 16, 30),
);
assertEquals(
datetime.parseDateTime("03-01-2019 16:31", "dd-mm-yyyy hh:mm"),
- new Date(2019, 0, 3, 16, 31)
+ new Date(2019, 0, 3, 16, 31),
);
assertEquals(
datetime.parseDateTime("2019-01-03 16:32", "yyyy-mm-dd hh:mm"),
- new Date(2019, 0, 3, 16, 32)
+ new Date(2019, 0, 3, 16, 32),
);
assertEquals(
datetime.parseDateTime("16:33 01-03-2019", "hh:mm mm-dd-yyyy"),
- new Date(2019, 0, 3, 16, 33)
+ new Date(2019, 0, 3, 16, 33),
);
assertEquals(
datetime.parseDateTime("16:34 03-01-2019", "hh:mm dd-mm-yyyy"),
- new Date(2019, 0, 3, 16, 34)
+ new Date(2019, 0, 3, 16, 34),
);
assertEquals(
datetime.parseDateTime("16:35 2019-01-03", "hh:mm yyyy-mm-dd"),
- new Date(2019, 0, 3, 16, 35)
+ new Date(2019, 0, 3, 16, 35),
);
},
});
@@ -41,7 +41,7 @@ Deno.test({
(datetime as any).parseDateTime("2019-01-01 00:00", "x-y-z");
},
Error,
- "Invalid datetime format!"
+ "Invalid datetime format!",
);
},
});
@@ -51,15 +51,15 @@ Deno.test({
fn: () => {
assertEquals(
datetime.parseDate("01-03-2019", "mm-dd-yyyy"),
- new Date(2019, 0, 3)
+ new Date(2019, 0, 3),
);
assertEquals(
datetime.parseDate("03-01-2019", "dd-mm-yyyy"),
- new Date(2019, 0, 3)
+ new Date(2019, 0, 3),
);
assertEquals(
datetime.parseDate("2019-01-03", "yyyy-mm-dd"),
- new Date(2019, 0, 3)
+ new Date(2019, 0, 3),
);
},
});
@@ -73,7 +73,7 @@ Deno.test({
(datetime as any).parseDate("2019-01-01", "x-y-z");
},
Error,
- "Invalid date format!"
+ "Invalid date format!",
);
},
});
diff --git a/std/encoding/README.md b/std/encoding/README.md
index 588661269..0ec5f4e72 100644
--- a/std/encoding/README.md
+++ b/std/encoding/README.md
@@ -84,7 +84,7 @@ const string = "a,b,c\nd,e,f";
console.log(
await parse(string, {
header: false,
- })
+ }),
);
// output:
// [["a", "b", "c"], ["d", "e", "f"]]
diff --git a/std/encoding/_yaml/dumper/dumper.ts b/std/encoding/_yaml/dumper/dumper.ts
index 2b23d4758..e1f1a142a 100644
--- a/std/encoding/_yaml/dumper/dumper.ts
+++ b/std/encoding/_yaml/dumper/dumper.ts
@@ -92,7 +92,7 @@ function encodeHex(character: number): string {
length = 8;
} else {
throw new YAMLError(
- "code point within a string may not be greater than 0xFFFFFFFF"
+ "code point within a string may not be greater than 0xFFFFFFFF",
);
}
@@ -242,14 +242,13 @@ function chooseScalarStyle(
singleLineOnly: boolean,
indentPerLevel: number,
lineWidth: number,
- testAmbiguousType: (...args: Any[]) => Any
+ testAmbiguousType: (...args: Any[]) => Any,
): number {
const shouldTrackWidth = lineWidth !== -1;
let hasLineBreak = false,
hasFoldableLine = false, // only checked if shouldTrackWidth
previousLineBreak = -1, // count the first line correctly
- plain =
- isPlainSafeFirst(string.charCodeAt(0)) &&
+ plain = isPlainSafeFirst(string.charCodeAt(0)) &&
!isWhitespace(string.charCodeAt(string.length - 1));
let char: number, i: number;
@@ -271,8 +270,7 @@ function chooseScalarStyle(
hasLineBreak = true;
// Check if any line can be folded.
if (shouldTrackWidth) {
- hasFoldableLine =
- hasFoldableLine ||
+ hasFoldableLine = hasFoldableLine ||
// Foldable line = too long, and not more-indented.
(i - previousLineBreak - 1 > lineWidth &&
string[previousLineBreak + 1] !== " ");
@@ -284,8 +282,7 @@ function chooseScalarStyle(
plain = plain && isPlainSafe(char);
}
// in case the end is missing a \n
- hasFoldableLine =
- hasFoldableLine ||
+ hasFoldableLine = hasFoldableLine ||
(shouldTrackWidth &&
i - previousLineBreak - 1 > lineWidth &&
string[previousLineBreak + 1] !== " ");
@@ -387,8 +384,7 @@ function foldString(string: string, width: number): string {
const prefix = match[1],
line = match[2];
moreIndented = line[0] === " ";
- result +=
- prefix +
+ result += prefix +
(!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") +
// eslint-disable-next-line @typescript-eslint/no-use-before-define
foldLine(line, width);
@@ -412,7 +408,7 @@ function escapeString(string: string): string {
if (nextChar >= 0xdc00 && nextChar <= 0xdfff /* low surrogate */) {
// Combine the surrogate pair and store it escaped.
result += encodeHex(
- (char - 0xd800) * 0x400 + nextChar - 0xdc00 + 0x10000
+ (char - 0xd800) * 0x400 + nextChar - 0xdc00 + 0x10000,
);
// Advance index one extra since we already used that char here.
i++;
@@ -420,10 +416,9 @@ function escapeString(string: string): string {
}
}
escapeSeq = ESCAPE_SEQUENCES[char];
- result +=
- !escapeSeq && isPrintable(char)
- ? string[i]
- : escapeSeq || encodeHex(char);
+ result += !escapeSeq && isPrintable(char)
+ ? string[i]
+ : escapeSeq || encodeHex(char);
}
return result;
@@ -453,7 +448,7 @@ function writeScalar(
state: DumperState,
string: string,
level: number,
- iskey: boolean
+ iskey: boolean,
): void {
state.dump = ((): string => {
if (string.length === 0) {
@@ -476,15 +471,13 @@ function writeScalar(
// This behaves better than a constant minimum width which disallows
// narrower options, or an indent threshold which causes the width
// to suddenly increase.
- const lineWidth =
- state.lineWidth === -1
- ? -1
- : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
+ const lineWidth = state.lineWidth === -1
+ ? -1
+ : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
// Without knowing if keys are implicit/explicit,
// assume implicit for safety.
- const singleLineOnly =
- iskey ||
+ const singleLineOnly = iskey ||
// No block styles in flow mode.
(state.flowLevel > -1 && level >= state.flowLevel);
function testAmbiguity(str: string): boolean {
@@ -497,7 +490,7 @@ function writeScalar(
singleLineOnly,
state.indent,
lineWidth,
- testAmbiguity
+ testAmbiguity,
)
) {
case STYLE_PLAIN:
@@ -505,13 +498,15 @@ function writeScalar(
case STYLE_SINGLE:
return `'${string.replace(/'/g, "''")}'`;
case STYLE_LITERAL:
- return `|${blockHeader(string, state.indent)}${dropEndingNewline(
- indentString(string, indent)
- )}`;
+ return `|${blockHeader(string, state.indent)}${
+ dropEndingNewline(indentString(string, indent))
+ }`;
case STYLE_FOLDED:
- return `>${blockHeader(string, state.indent)}${dropEndingNewline(
- indentString(foldString(string, lineWidth), indent)
- )}`;
+ return `>${blockHeader(string, state.indent)}${
+ dropEndingNewline(
+ indentString(foldString(string, lineWidth), indent),
+ )
+ }`;
case STYLE_DOUBLE:
return `"${escapeString(string)}"`;
default:
@@ -523,7 +518,7 @@ function writeScalar(
function writeFlowSequence(
state: DumperState,
level: number,
- object: Any
+ object: Any,
): void {
let _result = "";
const _tag = state.tag;
@@ -545,7 +540,7 @@ function writeBlockSequence(
state: DumperState,
level: number,
object: Any,
- compact = false
+ compact = false,
): void {
let _result = "";
const _tag = state.tag;
@@ -575,7 +570,7 @@ function writeBlockSequence(
function writeFlowMapping(
state: DumperState,
level: number,
- object: Any
+ object: Any,
): void {
let _result = "";
const _tag = state.tag,
@@ -624,7 +619,7 @@ function writeBlockMapping(
state: DumperState,
level: number,
object: Any,
- compact = false
+ compact = false,
): void {
const _tag = state.tag,
objectKeyList = Object.keys(object);
@@ -665,8 +660,7 @@ function writeBlockMapping(
continue; // Skip this pair because of invalid key.
}
- explicitPair =
- (state.tag !== null && state.tag !== "?") ||
+ explicitPair = (state.tag !== null && state.tag !== "?") ||
(state.dump && state.dump.length > 1024);
if (explicitPair) {
@@ -707,7 +701,7 @@ function writeBlockMapping(
function detectType(
state: DumperState,
object: Any,
- explicit = false
+ explicit = false,
): boolean {
const typeList = explicit ? state.explicitTypes : state.implicitTypes;
@@ -733,11 +727,11 @@ function detectType(
} else if (_hasOwnProperty.call(type.represent, style)) {
_result = (type.represent as ArrayObject<RepresentFn>)[style](
object,
- style
+ style,
);
} else {
throw new YAMLError(
- `!<${type.tag}> tag resolver accepts not "${style}" style`
+ `!<${type.tag}> tag resolver accepts not "${style}" style`,
);
}
@@ -760,7 +754,7 @@ function writeNode(
object: Any,
block: boolean,
compact: boolean,
- iskey = false
+ iskey = false,
): boolean {
state.tag = null;
state.dump = object;
@@ -843,7 +837,7 @@ function writeNode(
function inspectNode(
object: Any,
objects: Any[],
- duplicatesIndexes: number[]
+ duplicatesIndexes: number[],
): void {
if (object !== null && typeof object === "object") {
const index = objects.indexOf(object);
diff --git a/std/encoding/_yaml/dumper/dumper_state.ts b/std/encoding/_yaml/dumper/dumper_state.ts
index 2124ecb98..63b04983e 100644
--- a/std/encoding/_yaml/dumper/dumper_state.ts
+++ b/std/encoding/_yaml/dumper/dumper_state.ts
@@ -12,7 +12,7 @@ const _hasOwnProperty = Object.prototype.hasOwnProperty;
function compileStyleMap(
schema: Schema,
- map?: ArrayObject<StyleVariant> | null
+ map?: ArrayObject<StyleVariant> | null,
): ArrayObject<StyleVariant> {
if (typeof map === "undefined" || map === null) return {};
diff --git a/std/encoding/_yaml/error.ts b/std/encoding/_yaml/error.ts
index a96ab11d6..77473fbd8 100644
--- a/std/encoding/_yaml/error.ts
+++ b/std/encoding/_yaml/error.ts
@@ -8,7 +8,7 @@ import type { Mark } from "./mark.ts";
export class YAMLError extends Error {
constructor(
message = "(unknown reason)",
- protected mark: Mark | string = ""
+ protected mark: Mark | string = "",
) {
super(`${message} ${mark}`);
this.name = this.constructor.name;
diff --git a/std/encoding/_yaml/example/dump.ts b/std/encoding/_yaml/example/dump.ts
index db3647274..bc4684dfe 100644
--- a/std/encoding/_yaml/example/dump.ts
+++ b/std/encoding/_yaml/example/dump.ts
@@ -18,5 +18,5 @@ console.log(
],
},
test: "foobar",
- })
+ }),
);
diff --git a/std/encoding/_yaml/loader/loader.ts b/std/encoding/_yaml/loader/loader.ts
index 4ab3e9adc..216e315f2 100644
--- a/std/encoding/_yaml/loader/loader.ts
+++ b/std/encoding/_yaml/loader/loader.ts
@@ -25,12 +25,14 @@ const CHOMPING_CLIP = 1;
const CHOMPING_STRIP = 2;
const CHOMPING_KEEP = 3;
-const PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
+const PATTERN_NON_PRINTABLE =
+ /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
const PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
const PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
const PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
/* eslint-disable-next-line max-len */
-const PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
+const PATTERN_TAG_URI =
+ /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
function _class(obj: unknown): string {
return Object.prototype.toString.call(obj);
@@ -148,7 +150,7 @@ function charFromCodepoint(c: number): string {
// https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
return String.fromCharCode(
((c - 0x010000) >> 10) + 0xd800,
- ((c - 0x010000) & 0x03ff) + 0xdc00
+ ((c - 0x010000) & 0x03ff) + 0xdc00,
);
}
@@ -167,8 +169,8 @@ function generateError(state: LoaderState, message: string): YAMLError {
state.input,
state.position,
state.line,
- state.position - state.lineStart
- )
+ state.position - state.lineStart,
+ ),
);
}
@@ -229,21 +231,21 @@ const directiveHandlers: DirectiveHandlers = {
if (!PATTERN_TAG_HANDLE.test(handle)) {
return throwError(
state,
- "ill-formed tag handle (first argument) of the TAG directive"
+ "ill-formed tag handle (first argument) of the TAG directive",
);
}
if (_hasOwnProperty.call(state.tagMap, handle)) {
return throwError(
state,
- `there is a previously declared suffix for "${handle}" tag handle`
+ `there is a previously declared suffix for "${handle}" tag handle`,
);
}
if (!PATTERN_TAG_URI.test(prefix)) {
return throwError(
state,
- "ill-formed tag prefix (second argument) of the TAG directive"
+ "ill-formed tag prefix (second argument) of the TAG directive",
);
}
@@ -258,7 +260,7 @@ function captureSegment(
state: LoaderState,
start: number,
end: number,
- checkJson: boolean
+ checkJson: boolean,
): void {
let result: string;
if (start < end) {
@@ -289,12 +291,12 @@ function mergeMappings(
state: LoaderState,
destination: ArrayObject,
source: ArrayObject,
- overridableKeys: ArrayObject<boolean>
+ overridableKeys: ArrayObject<boolean>,
): void {
if (!common.isObject(source)) {
return throwError(
state,
- "cannot merge mappings; the provided source object is unacceptable"
+ "cannot merge mappings; the provided source object is unacceptable",
);
}
@@ -316,7 +318,7 @@ function storeMappingPair(
keyNode: Any,
valueNode: unknown,
startLine?: number,
- startPos?: number
+ startPos?: number,
): ArrayObject {
// The output is a plain object here, so keys can only be strings.
// We need to convert keyNode to a string, but doing so can hang the process
@@ -401,7 +403,7 @@ function readLineBreak(state: LoaderState): void {
function skipSeparationSpace(
state: LoaderState,
allowComments: boolean,
- checkIndent: number
+ checkIndent: number,
): number {
let lineBreaks = 0,
ch = state.input.charCodeAt(state.position);
@@ -478,7 +480,7 @@ function writeFoldedLines(state: LoaderState, count: number): void {
function readPlainScalar(
state: LoaderState,
nodeIndent: number,
- withinFlowCollection: boolean
+ withinFlowCollection: boolean,
): boolean {
const kind = state.kind;
const result = state.result;
@@ -587,7 +589,7 @@ function readPlainScalar(
function readSingleQuotedScalar(
state: LoaderState,
- nodeIndent: number
+ nodeIndent: number,
): boolean {
let ch, captureStart, captureEnd;
@@ -624,7 +626,7 @@ function readSingleQuotedScalar(
) {
return throwError(
state,
- "unexpected end of the document within a single quoted scalar"
+ "unexpected end of the document within a single quoted scalar",
);
} else {
state.position++;
@@ -634,13 +636,13 @@ function readSingleQuotedScalar(
return throwError(
state,
- "unexpected end of the stream within a single quoted scalar"
+ "unexpected end of the stream within a single quoted scalar",
);
}
function readDoubleQuotedScalar(
state: LoaderState,
- nodeIndent: number
+ nodeIndent: number,
): boolean {
let ch = state.input.charCodeAt(state.position);
@@ -703,7 +705,7 @@ function readDoubleQuotedScalar(
) {
return throwError(
state,
- "unexpected end of the document within a double quoted scalar"
+ "unexpected end of the document within a double quoted scalar",
);
} else {
state.position++;
@@ -713,7 +715,7 @@ function readDoubleQuotedScalar(
return throwError(
state,
- "unexpected end of the stream within a double quoted scalar"
+ "unexpected end of the stream within a double quoted scalar",
);
}
@@ -808,7 +810,7 @@ function readFlowCollection(state: LoaderState, nodeIndent: number): boolean {
overridableKeys,
keyTag,
keyNode,
- valueNode
+ valueNode,
);
} else if (isPair) {
(result as Array<{}>).push(
@@ -818,8 +820,8 @@ function readFlowCollection(state: LoaderState, nodeIndent: number): boolean {
overridableKeys,
keyTag,
keyNode,
- valueNode
- )
+ valueNode,
+ ),
);
} else {
(result as ResultType[]).push(keyNode as ResultType);
@@ -839,7 +841,7 @@ function readFlowCollection(state: LoaderState, nodeIndent: number): boolean {
return throwError(
state,
- "unexpected end of the stream within a flow collection"
+ "unexpected end of the stream within a flow collection",
);
}
@@ -879,7 +881,7 @@ function readBlockScalar(state: LoaderState, nodeIndent: number): boolean {
if (tmp === 0) {
return throwError(
state,
- "bad explicit indentation width of a block scalar; it cannot be less than one"
+ "bad explicit indentation width of a block scalar; it cannot be less than one",
);
} else if (!detectedIndent) {
textIndent = nodeIndent + tmp - 1;
@@ -933,7 +935,7 @@ function readBlockScalar(state: LoaderState, nodeIndent: number): boolean {
if (chomping === CHOMPING_KEEP) {
state.result += common.repeat(
"\n",
- didReadContent ? 1 + emptyLines : emptyLines
+ didReadContent ? 1 + emptyLines : emptyLines,
);
} else if (chomping === CHOMPING_CLIP) {
if (didReadContent) {
@@ -954,7 +956,7 @@ function readBlockScalar(state: LoaderState, nodeIndent: number): boolean {
// except for the first content line (cf. Example 8.1)
state.result += common.repeat(
"\n",
- didReadContent ? 1 + emptyLines : emptyLines
+ didReadContent ? 1 + emptyLines : emptyLines,
);
// End of more-indented block.
@@ -979,7 +981,7 @@ function readBlockScalar(state: LoaderState, nodeIndent: number): boolean {
// Keep all line breaks except the header line break.
state.result += common.repeat(
"\n",
- didReadContent ? 1 + emptyLines : emptyLines
+ didReadContent ? 1 + emptyLines : emptyLines,
);
}
@@ -1067,7 +1069,7 @@ function readBlockSequence(state: LoaderState, nodeIndent: number): boolean {
function readBlockMapping(
state: LoaderState,
nodeIndent: number,
- flowIndent: number
+ flowIndent: number,
): boolean {
const tag = state.tag,
anchor = state.anchor,
@@ -1112,7 +1114,7 @@ function readBlockMapping(
overridableKeys,
keyTag as string,
keyNode,
- null
+ null,
);
keyTag = keyNode = valueNode = null;
}
@@ -1127,7 +1129,7 @@ function readBlockMapping(
} else {
return throwError(
state,
- "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"
+ "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line",
);
}
@@ -1152,7 +1154,7 @@ function readBlockMapping(
if (!isWsOrEol(ch)) {
return throwError(
state,
- "a whitespace character is expected after the key-value separator within a block mapping"
+ "a whitespace character is expected after the key-value separator within a block mapping",
);
}
@@ -1163,7 +1165,7 @@ function readBlockMapping(
overridableKeys,
keyTag as string,
keyNode,
- null
+ null,
);
keyTag = keyNode = valueNode = null;
}
@@ -1176,7 +1178,7 @@ function readBlockMapping(
} else if (detected) {
return throwError(
state,
- "can not read an implicit mapping pair; a colon is missed"
+ "can not read an implicit mapping pair; a colon is missed",
);
} else {
state.tag = tag;
@@ -1186,7 +1188,7 @@ function readBlockMapping(
} else if (detected) {
return throwError(
state,
- "can not read a block mapping entry; a multiline key may not be an implicit key"
+ "can not read a block mapping entry; a multiline key may not be an implicit key",
);
} else {
state.tag = tag;
@@ -1221,7 +1223,7 @@ function readBlockMapping(
keyNode,
valueNode,
line,
- pos
+ pos,
);
keyTag = keyNode = valueNode = null;
}
@@ -1249,7 +1251,7 @@ function readBlockMapping(
overridableKeys,
keyTag as string,
keyNode,
- null
+ null,
);
}
@@ -1306,7 +1308,7 @@ function readTagProperty(state: LoaderState): boolean {
} else {
return throwError(
state,
- "unexpected end of the stream within a verbatim tag"
+ "unexpected end of the stream within a verbatim tag",
);
}
} else {
@@ -1318,7 +1320,7 @@ function readTagProperty(state: LoaderState): boolean {
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
return throwError(
state,
- "named tag handle cannot contain such characters"
+ "named tag handle cannot contain such characters",
);
}
@@ -1327,7 +1329,7 @@ function readTagProperty(state: LoaderState): boolean {
} else {
return throwError(
state,
- "tag suffix cannot contain exclamation marks"
+ "tag suffix cannot contain exclamation marks",
);
}
}
@@ -1340,7 +1342,7 @@ function readTagProperty(state: LoaderState): boolean {
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
return throwError(
state,
- "tag suffix cannot contain flow indicator characters"
+ "tag suffix cannot contain flow indicator characters",
);
}
}
@@ -1348,7 +1350,7 @@ function readTagProperty(state: LoaderState): boolean {
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
return throwError(
state,
- `tag name cannot contain such characters: ${tagName}`
+ `tag name cannot contain such characters: ${tagName}`,
);
}
@@ -1387,7 +1389,7 @@ function readAnchorProperty(state: LoaderState): boolean {
if (state.position === position) {
return throwError(
state,
- "name of an anchor node must contain at least one character"
+ "name of an anchor node must contain at least one character",
);
}
@@ -1410,7 +1412,7 @@ function readAlias(state: LoaderState): boolean {
if (state.position === _position) {
return throwError(
state,
- "name of an alias node must contain at least one character"
+ "name of an alias node must contain at least one character",
);
}
@@ -1434,7 +1436,7 @@ function composeNode(
parentIndent: number,
nodeContext: number,
allowToSeek: boolean,
- allowCompact: boolean
+ allowCompact: boolean,
): boolean {
let allowBlockScalars: boolean,
allowBlockCollections: boolean,
@@ -1454,8 +1456,9 @@ function composeNode(
state.kind = null;
state.result = null;
- const allowBlockStyles = (allowBlockScalars = allowBlockCollections =
- CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext);
+ const allowBlockStyles =
+ (allowBlockScalars = allowBlockCollections =
+ CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext);
if (allowToSeek) {
if (skipSeparationSpace(state, true, -1)) {
@@ -1495,8 +1498,8 @@ function composeNode(
}
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
- const cond =
- CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext;
+ const cond = CONTEXT_FLOW_IN === nodeContext ||
+ CONTEXT_FLOW_OUT === nodeContext;
flowIndent = cond ? parentIndent : parentIndent + 1;
blockIndent = state.position - state.lineStart;
@@ -1522,7 +1525,7 @@ function composeNode(
if (state.tag !== null || state.anchor !== null) {
return throwError(
state,
- "alias node should not have Any properties"
+ "alias node should not have Any properties",
);
}
} else if (
@@ -1542,8 +1545,8 @@ function composeNode(
} else if (indentStatus === 0) {
// Special case: block sequences are allowed to have same indentation level as the parent.
// http://www.yaml.org/spec/1.2/spec.html#id2799784
- hasContent =
- allowBlockCollections && readBlockSequence(state, blockIndent);
+ hasContent = allowBlockCollections &&
+ readBlockSequence(state, blockIndent);
}
}
@@ -1578,7 +1581,7 @@ function composeNode(
if (state.result !== null && type.kind !== state.kind) {
return throwError(
state,
- `unacceptable node kind for !<${state.tag}> tag; it should be "${type.kind}", not "${state.kind}"`
+ `unacceptable node kind for !<${state.tag}> tag; it should be "${type.kind}", not "${state.kind}"`,
);
}
@@ -1586,7 +1589,7 @@ function composeNode(
// `state.result` updated in resolver if matched
return throwError(
state,
- `cannot resolve a node with !<${state.tag}> explicit tag`
+ `cannot resolve a node with !<${state.tag}> explicit tag`,
);
} else {
state.result = type.construct(state.result);
@@ -1641,7 +1644,7 @@ function readDocument(state: LoaderState): void {
if (directiveName.length < 1) {
return throwError(
state,
- "directive name must not be less than one character in length"
+ "directive name must not be less than one character in length",
);
}
@@ -1697,7 +1700,7 @@ function readDocument(state: LoaderState): void {
if (
state.checkLineBreaks &&
PATTERN_NON_ASCII_LINE_BREAKS.test(
- state.input.slice(documentStart, state.position)
+ state.input.slice(documentStart, state.position),
)
) {
throwWarning(state, "non-ASCII line breaks are interpreted as content");
@@ -1716,7 +1719,7 @@ function readDocument(state: LoaderState): void {
if (state.position < state.length - 1) {
return throwError(
state,
- "end of the stream or a document separator is expected"
+ "end of the stream or a document separator is expected",
);
} else {
return;
@@ -1767,7 +1770,7 @@ function isCbFunction(fn: unknown): fn is CbFunction {
export function loadAll<T extends CbFunction | LoaderStateOptions>(
input: string,
iteratorOrOption?: T,
- options?: LoaderStateOptions
+ options?: LoaderStateOptions,
): T extends CbFunction ? void : unknown[] {
if (!isCbFunction(iteratorOrOption)) {
return loadDocuments(input, iteratorOrOption as LoaderStateOptions) as Any;
@@ -1792,6 +1795,6 @@ export function load(input: string, options?: LoaderStateOptions): unknown {
return documents[0];
}
throw new YAMLError(
- "expected a single document in the stream, but found more"
+ "expected a single document in the stream, but found more",
);
}
diff --git a/std/encoding/_yaml/loader/loader_state.ts b/std/encoding/_yaml/loader/loader_state.ts
index 781a4a086..60a7ccabc 100644
--- a/std/encoding/_yaml/loader/loader_state.ts
+++ b/std/encoding/_yaml/loader/loader_state.ts
@@ -57,7 +57,7 @@ export class LoaderState extends State {
legacy = false,
json = false,
listener = null,
- }: LoaderStateOptions
+ }: LoaderStateOptions,
) {
super(schema);
this.filename = filename;
diff --git a/std/encoding/_yaml/mark.ts b/std/encoding/_yaml/mark.ts
index 44cf175a0..35e986cce 100644
--- a/std/encoding/_yaml/mark.ts
+++ b/std/encoding/_yaml/mark.ts
@@ -11,7 +11,7 @@ export class Mark {
public buffer: string,
public position: number,
public line: number,
- public column: number
+ public column: number,
) {}
public getSnippet(indent = 4, maxLength = 75): string | null {
@@ -48,10 +48,12 @@ export class Mark {
}
const snippet = this.buffer.slice(start, end);
- return `${repeat(" ", indent)}${head}${snippet}${tail}\n${repeat(
- " ",
- indent + this.position - start + head.length
- )}^`;
+ return `${repeat(" ", indent)}${head}${snippet}${tail}\n${
+ repeat(
+ " ",
+ indent + this.position - start + head.length,
+ )
+ }^`;
}
public toString(compact?: boolean): string {
diff --git a/std/encoding/_yaml/parse.ts b/std/encoding/_yaml/parse.ts
index 9a6f325f2..05a9b48ac 100644
--- a/std/encoding/_yaml/parse.ts
+++ b/std/encoding/_yaml/parse.ts
@@ -26,7 +26,7 @@ export function parse(content: string, options?: ParseOptions): unknown {
export function parseAll(
content: string,
iterator?: CbFunction,
- options?: ParseOptions
+ options?: ParseOptions,
): unknown {
return loadAll(content, iterator, options);
}
diff --git a/std/encoding/_yaml/schema.ts b/std/encoding/_yaml/schema.ts
index 98b49203c..b955e5df8 100644
--- a/std/encoding/_yaml/schema.ts
+++ b/std/encoding/_yaml/schema.ts
@@ -10,7 +10,7 @@ import type { ArrayObject, Any } from "./utils.ts";
function compileList(
schema: Schema,
name: "implicit" | "explicit",
- result: Type[]
+ result: Type[],
): Type[] {
const exclude: number[] = [];
@@ -78,7 +78,7 @@ export class Schema implements SchemaDefinition {
if (type.loadKind && type.loadKind !== "scalar") {
throw new YAMLError(
// eslint-disable-next-line max-len
- "There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported."
+ "There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.",
);
}
}
@@ -87,7 +87,7 @@ export class Schema implements SchemaDefinition {
this.compiledExplicit = compileList(this, "explicit", []);
this.compiledTypeMap = compileMap(
this.compiledImplicit,
- this.compiledExplicit
+ this.compiledExplicit,
);
}
diff --git a/std/encoding/_yaml/type/float.ts b/std/encoding/_yaml/type/float.ts
index 5ae0689b2..6d59ed9ed 100644
--- a/std/encoding/_yaml/type/float.ts
+++ b/std/encoding/_yaml/type/float.ts
@@ -17,7 +17,7 @@ const YAML_FLOAT_PATTERN = new RegExp(
// .inf
"|[-+]?\\.(?:inf|Inf|INF)" +
// .nan
- "|\\.(?:nan|NaN|NAN))$"
+ "|\\.(?:nan|NaN|NAN))$",
);
function resolveYamlFloat(data: string): boolean {
diff --git a/std/encoding/_yaml/type/timestamp.ts b/std/encoding/_yaml/type/timestamp.ts
index eb03b3825..231908231 100644
--- a/std/encoding/_yaml/type/timestamp.ts
+++ b/std/encoding/_yaml/type/timestamp.ts
@@ -7,21 +7,21 @@ import { Type } from "../type.ts";
const YAML_DATE_REGEXP = new RegExp(
"^([0-9][0-9][0-9][0-9])" + // [1] year
- "-([0-9][0-9])" + // [2] month
- "-([0-9][0-9])$" // [3] day
+ "-([0-9][0-9])" + // [2] month
+ "-([0-9][0-9])$", // [3] day
);
const YAML_TIMESTAMP_REGEXP = new RegExp(
"^([0-9][0-9][0-9][0-9])" + // [1] year
- "-([0-9][0-9]?)" + // [2] month
- "-([0-9][0-9]?)" + // [3] day
- "(?:[Tt]|[ \\t]+)" + // ...
- "([0-9][0-9]?)" + // [4] hour
- ":([0-9][0-9])" + // [5] minute
- ":([0-9][0-9])" + // [6] second
- "(?:\\.([0-9]*))?" + // [7] fraction
- "(?:[ \\t]*(Z|([-+])([0-9][0-9]?)" + // [8] tz [9] tz_sign [10] tz_hour
- "(?::([0-9][0-9]))?))?$" // [11] tz_minute
+ "-([0-9][0-9]?)" + // [2] month
+ "-([0-9][0-9]?)" + // [3] day
+ "(?:[Tt]|[ \\t]+)" + // ...
+ "([0-9][0-9]?)" + // [4] hour
+ ":([0-9][0-9])" + // [5] minute
+ ":([0-9][0-9])" + // [6] second
+ "(?:\\.([0-9]*))?" + // [7] fraction
+ "(?:[ \\t]*(Z|([-+])([0-9][0-9]?)" + // [8] tz [9] tz_sign [10] tz_hour
+ "(?::([0-9][0-9]))?))?$", // [11] tz_minute
);
function resolveYamlTimestamp(data: string): boolean {
@@ -75,7 +75,7 @@ function constructYamlTimestamp(data: string): Date {
}
const date = new Date(
- Date.UTC(year, month, day, hour, minute, second, fraction)
+ Date.UTC(year, month, day, hour, minute, second, fraction),
);
if (delta) date.setTime(date.getTime() - delta);
diff --git a/std/encoding/ascii85.ts b/std/encoding/ascii85.ts
index b7a2e2065..6a303ebda 100644
--- a/std/encoding/ascii85.ts
+++ b/std/encoding/ascii85.ts
@@ -65,9 +65,11 @@ export function encode(uint8: Uint8Array, options?: Ascii85Options): string {
break;
case "btoa":
if (options?.delimiter) {
- return `xbtoa Begin\n${output
- .slice(0, output.length - difference)
- .join("")}\nxbtoa End`;
+ return `xbtoa Begin\n${
+ output
+ .slice(0, output.length - difference)
+ .join("")
+ }\nxbtoa End`;
}
break;
case "RFC 1924":
@@ -99,13 +101,15 @@ export function decode(ascii85: string, options?: Ascii85Options): Uint8Array {
.replaceAll("y", "+<VdL");
break;
case "RFC 1924":
- ascii85 = ascii85.replaceAll(/./g, (match) =>
- String.fromCharCode(rfc1924.indexOf(match) + 33)
+ ascii85 = ascii85.replaceAll(
+ /./g,
+ (match) => String.fromCharCode(rfc1924.indexOf(match) + 33),
);
break;
case "Z85":
- ascii85 = ascii85.replaceAll(/./g, (match) =>
- String.fromCharCode(Z85.indexOf(match) + 33)
+ ascii85 = ascii85.replaceAll(
+ /./g,
+ (match) => String.fromCharCode(Z85.indexOf(match) + 33),
);
break;
}
@@ -117,7 +121,7 @@ export function decode(ascii85: string, options?: Ascii85Options): Uint8Array {
let v = 0,
n = 0,
max = 0;
- for (let i = 0; i < len; ) {
+ for (let i = 0; i < len;) {
for (max += 5; i < max; i++) {
v = v * 85 + (i < len ? ascii85.charCodeAt(i) : 117) - 33;
}
diff --git a/std/encoding/ascii85_test.ts b/std/encoding/ascii85_test.ts
index d068c0bf6..02af70964 100644
--- a/std/encoding/ascii85_test.ts
+++ b/std/encoding/ascii85_test.ts
@@ -126,7 +126,7 @@ for (const [standard, tests] of Object.entries(testCasesNoDelimeter)) {
encode(utf8encoder.encode(bin), {
standard: standard as Ascii85Standard,
}),
- b85
+ b85,
);
}
},
@@ -138,7 +138,7 @@ for (const [standard, tests] of Object.entries(testCasesNoDelimeter)) {
for (const [bin, b85] of tests) {
assertEquals(
decode(b85, { standard: standard as Ascii85Standard }),
- utf8encoder.encode(bin)
+ utf8encoder.encode(bin),
);
}
},
@@ -155,7 +155,7 @@ for (const [standard, tests] of Object.entries(testCasesDelimeter)) {
standard: standard as Ascii85Standard,
delimiter: true,
}),
- b85
+ b85,
);
}
},
@@ -170,7 +170,7 @@ for (const [standard, tests] of Object.entries(testCasesDelimeter)) {
standard: standard as Ascii85Standard,
delimiter: true,
}),
- utf8encoder.encode(bin)
+ utf8encoder.encode(bin),
);
}
},
diff --git a/std/encoding/base32.ts b/std/encoding/base32.ts
index e7d3332fd..7d0ec81f3 100644
--- a/std/encoding/base32.ts
+++ b/std/encoding/base32.ts
@@ -65,8 +65,7 @@ export function decode(b32: string): Uint8Array {
let i: number;
for (i = 0; i < len; i += 8) {
- tmp =
- (revLookup[b32.charCodeAt(i)] << 20) |
+ tmp = (revLookup[b32.charCodeAt(i)] << 20) |
(revLookup[b32.charCodeAt(i + 1)] << 15) |
(revLookup[b32.charCodeAt(i + 2)] << 10) |
(revLookup[b32.charCodeAt(i + 3)] << 5) |
@@ -75,8 +74,7 @@ export function decode(b32: string): Uint8Array {
arr[curByte++] = (tmp >> 9) & 0xff;
arr[curByte++] = (tmp >> 1) & 0xff;
- tmp =
- ((tmp & 1) << 15) |
+ tmp = ((tmp & 1) << 15) |
(revLookup[b32.charCodeAt(i + 5)] << 10) |
(revLookup[b32.charCodeAt(i + 6)] << 5) |
revLookup[b32.charCodeAt(i + 7)];
@@ -85,8 +83,7 @@ export function decode(b32: string): Uint8Array {
}
if (placeHoldersLen === 1) {
- tmp =
- (revLookup[b32.charCodeAt(i)] << 20) |
+ tmp = (revLookup[b32.charCodeAt(i)] << 20) |
(revLookup[b32.charCodeAt(i + 1)] << 15) |
(revLookup[b32.charCodeAt(i + 2)] << 10) |
(revLookup[b32.charCodeAt(i + 3)] << 5) |
@@ -94,14 +91,12 @@ export function decode(b32: string): Uint8Array {
arr[curByte++] = (tmp >> 17) & 0xff;
arr[curByte++] = (tmp >> 9) & 0xff;
arr[curByte++] = (tmp >> 1) & 0xff;
- tmp =
- ((tmp & 1) << 7) |
+ tmp = ((tmp & 1) << 7) |
(revLookup[b32.charCodeAt(i + 5)] << 2) |
(revLookup[b32.charCodeAt(i + 6)] >> 3);
arr[curByte++] = tmp & 0xff;
} else if (placeHoldersLen === 3) {
- tmp =
- (revLookup[b32.charCodeAt(i)] << 19) |
+ tmp = (revLookup[b32.charCodeAt(i)] << 19) |
(revLookup[b32.charCodeAt(i + 1)] << 14) |
(revLookup[b32.charCodeAt(i + 2)] << 9) |
(revLookup[b32.charCodeAt(i + 3)] << 4) |
@@ -110,16 +105,14 @@ export function decode(b32: string): Uint8Array {
arr[curByte++] = (tmp >> 8) & 0xff;
arr[curByte++] = tmp & 0xff;
} else if (placeHoldersLen === 4) {
- tmp =
- (revLookup[b32.charCodeAt(i)] << 11) |
+ tmp = (revLookup[b32.charCodeAt(i)] << 11) |
(revLookup[b32.charCodeAt(i + 1)] << 6) |
(revLookup[b32.charCodeAt(i + 2)] << 1) |
(revLookup[b32.charCodeAt(i + 3)] >> 4);
arr[curByte++] = (tmp >> 8) & 0xff;
arr[curByte++] = tmp & 0xff;
} else if (placeHoldersLen === 6) {
- tmp =
- (revLookup[b32.charCodeAt(i)] << 3) |
+ tmp = (revLookup[b32.charCodeAt(i)] << 3) |
(revLookup[b32.charCodeAt(i + 1)] >> 2);
arr[curByte++] = tmp & 0xff;
}
@@ -131,16 +124,14 @@ function encodeChunk(uint8: Uint8Array, start: number, end: number): string {
let tmp: number;
const output = [];
for (let i = start; i < end; i += 5) {
- tmp =
- ((uint8[i] << 16) & 0xff0000) |
+ tmp = ((uint8[i] << 16) & 0xff0000) |
((uint8[i + 1] << 8) & 0xff00) |
(uint8[i + 2] & 0xff);
output.push(lookup[(tmp >> 19) & 0x1f]);
output.push(lookup[(tmp >> 14) & 0x1f]);
output.push(lookup[(tmp >> 9) & 0x1f]);
output.push(lookup[(tmp >> 4) & 0x1f]);
- tmp =
- ((tmp & 0xf) << 16) |
+ tmp = ((tmp & 0xf) << 16) |
((uint8[i + 3] << 8) & 0xff00) |
(uint8[i + 4] & 0xff);
output.push(lookup[(tmp >> 15) & 0x1f]);
@@ -169,15 +160,14 @@ export function encode(uint8: Uint8Array): string {
encodeChunk(
uint8,
i,
- i + maxChunkLength > len2 ? len2 : i + maxChunkLength
- )
+ i + maxChunkLength > len2 ? len2 : i + maxChunkLength,
+ ),
);
}
// pad the end with zeros, but make sure to not forget the extra bytes
if (extraBytes === 4) {
- tmp =
- ((uint8[len2] & 0xff) << 16) |
+ tmp = ((uint8[len2] & 0xff) << 16) |
((uint8[len2 + 1] & 0xff) << 8) |
(uint8[len2 + 2] & 0xff);
parts.push(lookup[(tmp >> 19) & 0x1f]);
@@ -190,8 +180,7 @@ export function encode(uint8: Uint8Array): string {
parts.push(lookup[tmp & 0x1f]);
parts.push("=");
} else if (extraBytes === 3) {
- tmp =
- ((uint8[len2] & 0xff) << 17) |
+ tmp = ((uint8[len2] & 0xff) << 17) |
((uint8[len2 + 1] & 0xff) << 9) |
((uint8[len2 + 2] & 0xff) << 1);
parts.push(lookup[(tmp >> 20) & 0x1f]);
diff --git a/std/encoding/base32_test.ts b/std/encoding/base32_test.ts
index 2bd7acea1..cfefe54d7 100644
--- a/std/encoding/base32_test.ts
+++ b/std/encoding/base32_test.ts
@@ -112,7 +112,7 @@ Deno.test({
decode("OOOO==");
} catch (e) {
assert(
- e.message.includes("Invalid string. Length must be a multiple of 8")
+ e.message.includes("Invalid string. Length must be a multiple of 8"),
);
errorCaught = true;
}
diff --git a/std/encoding/base64url.ts b/std/encoding/base64url.ts
index 726ea2eb8..b20878554 100644
--- a/std/encoding/base64url.ts
+++ b/std/encoding/base64url.ts
@@ -12,8 +12,9 @@ import {
export function addPaddingToBase64url(base64url: string): string {
if (base64url.length % 4 === 2) return base64url + "==";
if (base64url.length % 4 === 3) return base64url + "=";
- if (base64url.length % 4 === 1)
+ if (base64url.length % 4 === 1) {
throw new TypeError("Illegal base64url string!");
+ }
return base64url;
}
diff --git a/std/encoding/binary.ts b/std/encoding/binary.ts
index aed9343b9..f4918e750 100644
--- a/std/encoding/binary.ts
+++ b/std/encoding/binary.ts
@@ -47,7 +47,7 @@ export function sizeof(dataType: DataType): number {
* Resolves it in a `Uint8Array`, or throws `Deno.errors.UnexpectedEof` if `n` bytes cannot be read. */
export async function getNBytes(
r: Deno.Reader,
- n: number
+ n: number,
): Promise<Uint8Array> {
const scratch = new Uint8Array(n);
const nRead = await r.read(scratch);
@@ -117,7 +117,7 @@ export function varbig(b: Uint8Array, o: VarbigOptions = {}): bigint | null {
export function putVarnum(
b: Uint8Array,
x: number,
- o: VarnumOptions = {}
+ o: VarnumOptions = {},
): number {
o.dataType = o.dataType ?? "int32";
const littleEndian = (o.endian ?? "big") === "little" ? true : false;
@@ -158,7 +158,7 @@ export function putVarnum(
export function putVarbig(
b: Uint8Array,
x: bigint,
- o: VarbigOptions = {}
+ o: VarbigOptions = {},
): number {
o.dataType = o.dataType ?? "int64";
const littleEndian = (o.endian ?? "big") === "little" ? true : false;
@@ -198,7 +198,7 @@ export function putVarbig(
* `o.dataType` defaults to `"int32"`. */
export async function readVarnum(
r: Deno.Reader,
- o: VarnumOptions = {}
+ o: VarnumOptions = {},
): Promise<number> {
o.dataType = o.dataType ?? "int32";
const scratch = await getNBytes(r, sizeof(o.dataType));
@@ -210,7 +210,7 @@ export async function readVarnum(
* `o.dataType` defaults to `"int64"`. */
export async function readVarbig(
r: Deno.Reader,
- o: VarbigOptions = {}
+ o: VarbigOptions = {},
): Promise<bigint> {
o.dataType = o.dataType ?? "int64";
const scratch = await getNBytes(r, sizeof(o.dataType));
@@ -223,7 +223,7 @@ export async function readVarbig(
export function writeVarnum(
w: Deno.Writer,
x: number,
- o: VarnumOptions = {}
+ o: VarnumOptions = {},
): Promise<number> {
o.dataType = o.dataType ?? "int32";
const scratch = new Uint8Array(sizeof(o.dataType));
@@ -237,7 +237,7 @@ export function writeVarnum(
export function writeVarbig(
w: Deno.Writer,
x: bigint,
- o: VarbigOptions = {}
+ o: VarbigOptions = {},
): Promise<number> {
o.dataType = o.dataType ?? "int64";
const scratch = new Uint8Array(sizeof(o.dataType));
diff --git a/std/encoding/binary_test.ts b/std/encoding/binary_test.ts
index 6213bc2e3..89a5b8c8e 100644
--- a/std/encoding/binary_test.ts
+++ b/std/encoding/binary_test.ts
@@ -36,7 +36,7 @@ Deno.test("testPutVarbig", function (): void {
putVarbig(buff, 0xffeeddccbbaa9988n);
assertEquals(
buff,
- new Uint8Array([0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88])
+ new Uint8Array([0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88]),
);
});
@@ -45,7 +45,7 @@ Deno.test("testPutVarbigLittleEndian", function (): void {
putVarbig(buff, 0x8899aabbccddeeffn, { endian: "little" });
assertEquals(
buff,
- new Uint8Array([0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88])
+ new Uint8Array([0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88]),
);
});
@@ -132,7 +132,7 @@ Deno.test("testWriteVarbig", async function (): Promise<void> {
await buff.read(data);
assertEquals(
data,
- new Uint8Array([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08])
+ new Uint8Array([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]),
);
});
@@ -143,7 +143,7 @@ Deno.test("testWriteVarbigLittleEndian", async function (): Promise<void> {
await buff.read(data);
assertEquals(
data,
- new Uint8Array([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08])
+ new Uint8Array([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]),
);
});
@@ -167,7 +167,7 @@ Deno.test("testVarbigBytes", function (): void {
const rslt = varbigBytes(0x0102030405060708n);
assertEquals(
rslt,
- new Uint8Array([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08])
+ new Uint8Array([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]),
);
});
@@ -175,7 +175,7 @@ Deno.test("testVarbigBytesLittleEndian", function (): void {
const rslt = varbigBytes(0x0807060504030201n, { endian: "little" });
assertEquals(
rslt,
- new Uint8Array([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08])
+ new Uint8Array([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]),
);
});
diff --git a/std/encoding/csv.ts b/std/encoding/csv.ts
index 5af054530..27b40c566 100644
--- a/std/encoding/csv.ts
+++ b/std/encoding/csv.ts
@@ -63,7 +63,7 @@ function chkOptions(opt: ReadOptions): void {
async function readRecord(
Startline: number,
reader: BufReader,
- opt: ReadOptions = { comma: ",", trimLeadingSpace: false }
+ opt: ReadOptions = { comma: ",", trimLeadingSpace: false },
): Promise<string[] | null> {
const tp = new TextProtoReader(reader);
const lineIndex = Startline;
@@ -86,7 +86,8 @@ async function readRecord(
const commaLen = opt.comma.length;
let recordBuffer = "";
const fieldIndexes = [] as number[];
- parseField: for (;;) {
+ parseField:
+ for (;;) {
if (opt.trimLeadingSpace) {
line = line.trimLeft();
}
@@ -221,7 +222,7 @@ export async function readMatrix(
comma: ",",
trimLeadingSpace: false,
lazyQuotes: false,
- }
+ },
): Promise<string[][]> {
const result: string[][] = [];
let _nbFields: number | undefined;
@@ -315,7 +316,7 @@ export async function parse(
input: string | BufReader,
opt: ParseOptions = {
header: false,
- }
+ },
): Promise<unknown[]> {
let r: string[][];
if (input instanceof BufReader) {
@@ -336,7 +337,7 @@ export async function parse(
return {
name: e,
};
- }
+ },
);
}
} else {
@@ -347,7 +348,7 @@ export async function parse(
return {
name: e,
};
- }
+ },
);
i++;
}
diff --git a/std/encoding/csv_test.ts b/std/encoding/csv_test.ts
index 60d43e35e..07a8e0965 100644
--- a/std/encoding/csv_test.ts
+++ b/std/encoding/csv_test.ts
@@ -381,8 +381,8 @@ x,,,
*/
{
Name: "HugeLines",
- Input:
- "#ignore\n".repeat(10000) + "@".repeat(5000) + "," + "*".repeat(5000),
+ Input: "#ignore\n".repeat(10000) + "@".repeat(5000) + "," +
+ "*".repeat(5000),
Output: [["@".repeat(5000), "*".repeat(5000)]],
Comment: "#",
},
@@ -488,7 +488,7 @@ for (const t of testCases) {
trimLeadingSpace: trim,
fieldsPerRecord: fieldsPerRec,
lazyQuotes: lazyquote,
- }
+ },
);
} catch (e) {
err = e;
@@ -504,7 +504,7 @@ for (const t of testCases) {
trimLeadingSpace: trim,
fieldsPerRecord: fieldsPerRec,
lazyQuotes: lazyquote,
- }
+ },
);
const expected = t.Output;
assertEquals(actual, expected);
diff --git a/std/encoding/hex.ts b/std/encoding/hex.ts
index 729df6c49..5b09422a9 100644
--- a/std/encoding/hex.ts
+++ b/std/encoding/hex.ts
@@ -10,7 +10,7 @@ const hextable = new TextEncoder().encode("0123456789abcdef");
export function errInvalidByte(byte: number): Error {
return new Error(
"encoding/hex: invalid byte: " +
- new TextDecoder().decode(new Uint8Array([byte]))
+ new TextDecoder().decode(new Uint8Array([byte])),
);
}
diff --git a/std/encoding/hex_test.ts b/std/encoding/hex_test.ts
index a42238e53..0cf39ad2e 100644
--- a/std/encoding/hex_test.ts
+++ b/std/encoding/hex_test.ts
@@ -132,7 +132,7 @@ Deno.test({
assertThrows(
() => decode(new TextEncoder().encode(input as string)),
Error,
- (expectedErr as Error).message
+ (expectedErr as Error).message,
);
}
},
@@ -147,7 +147,7 @@ Deno.test({
decodeString(input as string);
},
Error,
- (expectedErr as Error).message
+ (expectedErr as Error).message,
);
}
},
diff --git a/std/encoding/toml.ts b/std/encoding/toml.ts
index 8a0715ab6..7d340c8e8 100644
--- a/std/encoding/toml.ts
+++ b/std/encoding/toml.ts
@@ -110,7 +110,7 @@ class Parser {
.join("\n")
.replace(/"""/g, '"')
.replace(/'''/g, `'`)
- .replace(/\n/g, "\\n")
+ .replace(/\n/g, "\\n"),
);
isLiteral = false;
} else {
@@ -321,7 +321,7 @@ class Parser {
this.context.currentGroup.type === "array"
) {
this.context.currentGroup.arrValues.push(
- this.context.currentGroup.objValues
+ this.context.currentGroup.objValues,
);
this.context.currentGroup.objValues = {};
}
@@ -350,7 +350,7 @@ class Parser {
if (this.context.currentGroup) {
if (this.context.currentGroup.type === "array") {
this.context.currentGroup.arrValues.push(
- this.context.currentGroup.objValues
+ this.context.currentGroup.objValues,
);
}
this._groupToOutput();
diff --git a/std/encoding/toml_test.ts b/std/encoding/toml_test.ts
index d272a29ff..5c4c63b5a 100644
--- a/std/encoding/toml_test.ts
+++ b/std/encoding/toml_test.ts
@@ -27,8 +27,7 @@ Deno.test({
str4: 'this is a "quote"',
str5: "The quick brown\nfox jumps over\nthe lazy dog.",
str6: "The quick brown\nfox jumps over\nthe lazy dog.",
- lines:
- "The first newline is\ntrimmed in raw strings.\n All other " +
+ lines: "The first newline is\ntrimmed in raw strings.\n All other " +
"whitespace\n is preserved.",
},
};
diff --git a/std/examples/catj.ts b/std/examples/catj.ts
index 93fc68a1d..6013a8ac6 100644
--- a/std/examples/catj.ts
+++ b/std/examples/catj.ts
@@ -19,9 +19,8 @@ function isObject(arg: any): arg is object {
function isValidIdentifier(value: string): boolean {
// eslint-disable-next-line max-len
- return /^(?!(?:do|if|in|for|let|new|try|var|case|else|enum|eval|null|this|true|void|with|break|catch|class|const|false|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$)[\x24A-Z\x5Fa-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC][\x240-9A-Z\x5Fa-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0\u08A2-\u08AC\u08E4-\u08FE\u0900-\u0963\u0966-\u096F\u0971-\u0977\u0979-\u097F\u0981-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C82\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D02\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191C\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1D00-\u1DE6\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA697\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7B\uAA80-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE26\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]*$/.test(
- value
- );
+ return /^(?!(?:do|if|in|for|let|new|try|var|case|else|enum|eval|null|this|true|void|with|break|catch|class|const|false|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$)[\x24A-Z\x5Fa-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC][\x240-9A-Z\x5Fa-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0\u08A2-\u08AC\u08E4-\u08FE\u0900-\u0963\u0966-\u096F\u0971-\u0977\u0979-\u097F\u0981-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C82\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D02\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191C\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1D00-\u1DE6\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA697\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7B\uAA80-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE26\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]*$/
+ .test(value);
}
function printValue(value: unknown, path: string): void {
@@ -59,8 +58,8 @@ function printObject(obj: { [key: string]: any }, path: string): void {
function printArray(array: unknown[], path: string): void {
for (const index in array) {
const value = array[index];
- const nodePath =
- (path ? path : colors.cyan(".")) + "[" + colors.cyan(index) + "]";
+ const nodePath = (path ? path : colors.cyan(".")) + "[" +
+ colors.cyan(index) + "]";
if (Array.isArray(value)) {
printArray(value, nodePath);
diff --git a/std/examples/gist.ts b/std/examples/gist.ts
index 555ec8056..31a22d750 100755
--- a/std/examples/gist.ts
+++ b/std/examples/gist.ts
@@ -21,7 +21,7 @@ const parsedArgs = parse(Deno.args);
if (parsedArgs._.length === 0) {
console.error(
"Usage: gist.ts --allow-env --allow-net [-t|--title Example] some_file " +
- "[next_file]"
+ "[next_file]",
);
Deno.exit(1);
}
diff --git a/std/examples/tests/catj_test.ts b/std/examples/tests/catj_test.ts
index 58533ab60..99320fd1d 100644
--- a/std/examples/tests/catj_test.ts
+++ b/std/examples/tests/catj_test.ts
@@ -45,7 +45,7 @@ Deno.test("[examples/catj] print multiple files", async () => {
const decoder = new TextDecoder();
const process = catj(
"testdata/catj/simple-object.json",
- "testdata/catj/simple-array.json"
+ "testdata/catj/simple-array.json",
);
try {
const output = await process.output();
diff --git a/std/examples/tests/echo_server_test.ts b/std/examples/tests/echo_server_test.ts
index 2cf52e466..61afb9756 100644
--- a/std/examples/tests/echo_server_test.ts
+++ b/std/examples/tests/echo_server_test.ts
@@ -19,7 +19,7 @@ Deno.test("[examples/echo_server]", async () => {
assertNotEquals(message, null);
assertStrictEquals(
decoder.decode((message as ReadLineResult).line).trim(),
- "Listening on 0.0.0.0:8080"
+ "Listening on 0.0.0.0:8080",
);
conn = await Deno.connect({ hostname: "127.0.0.1", port: 8080 });
diff --git a/std/examples/tests/xeval_test.ts b/std/examples/tests/xeval_test.ts
index 9f7c5db9e..cc74c5226 100644
--- a/std/examples/tests/xeval_test.ts
+++ b/std/examples/tests/xeval_test.ts
@@ -21,7 +21,7 @@ Deno.test("xevalDelimiter", async function (): Promise<void> {
($): number => chunks.push($),
{
delimiter: "MADAM",
- }
+ },
);
assertEquals(chunks, ["!MAD", "ADAM!"]);
});
diff --git a/std/examples/xeval.ts b/std/examples/xeval.ts
index 814d306cd..be326a4ad 100644
--- a/std/examples/xeval.ts
+++ b/std/examples/xeval.ts
@@ -40,7 +40,7 @@ const DEFAULT_DELIMITER = "\n";
export async function xeval(
reader: Deno.Reader,
xevalFunc: XevalFunc,
- { delimiter = DEFAULT_DELIMITER }: XevalOptions = {}
+ { delimiter = DEFAULT_DELIMITER }: XevalOptions = {},
): Promise<void> {
for await (const chunk of readStringDelim(reader, delimiter)) {
// Ignore empty chunks.
diff --git a/std/flags/dash_test.ts b/std/flags/dash_test.ts
index 896305cc4..7a4f7dd1e 100755
--- a/std/flags/dash_test.ts
+++ b/std/flags/dash_test.ts
@@ -23,6 +23,6 @@ Deno.test("moveArgsAfterDoubleDashIntoOwnArray", function (): void {
name: "John",
_: ["before"],
"--": ["after"],
- }
+ },
);
});
diff --git a/std/flags/mod.ts b/std/flags/mod.ts
index a961e6c68..09b5afa8a 100644
--- a/std/flags/mod.ts
+++ b/std/flags/mod.ts
@@ -104,7 +104,7 @@ export function parse(
stopEarly = false,
string = [],
unknown = (i: string): unknown => i,
- }: ArgParsingOptions = {}
+ }: ArgParsingOptions = {},
): Args {
const flags: Flags = {
bools: {},
@@ -191,7 +191,7 @@ export function parse(
function setArg(
key: string,
val: unknown,
- arg: string | undefined = undefined
+ arg: string | undefined = undefined,
): void {
if (arg && flags.unknownFn && !argDefined(key, arg)) {
if (flags.unknownFn(arg, key, val) === false) return;
@@ -210,7 +210,7 @@ export function parse(
function aliasIsBoolean(key: string): boolean {
return getForce(aliases, key).some(
- (x) => typeof get(flags.bools, x) === "boolean"
+ (x) => typeof get(flags.bools, x) === "boolean",
);
}
diff --git a/std/flags/parse_test.ts b/std/flags/parse_test.ts
index c6a40d1ee..9a19e5634 100755
--- a/std/flags/parse_test.ts
+++ b/std/flags/parse_test.ts
@@ -43,7 +43,7 @@ Deno.test("comprehensive", function (): void {
meep: false,
name: "meowmers",
_: ["bare", "--not-a-flag", "eek"],
- }
+ },
);
});
diff --git a/std/flags/unknown_test.ts b/std/flags/unknown_test.ts
index d6db78371..d17fb8111 100755
--- a/std/flags/unknown_test.ts
+++ b/std/flags/unknown_test.ts
@@ -45,7 +45,7 @@ Deno.test(
honk: true,
_: [],
});
- }
+ },
);
Deno.test("stringAndAliasIsNotUnkown", function (): void {
diff --git a/std/fmt/colors.ts b/std/fmt/colors.ts
index a020657d9..7a12b2883 100644
--- a/std/fmt/colors.ts
+++ b/std/fmt/colors.ts
@@ -186,7 +186,10 @@ export function rgb24(str: string, color: number | Rgb): string {
if (typeof color === "number") {
return run(
str,
- code([38, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff], 39)
+ code(
+ [38, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff],
+ 39,
+ ),
);
}
return run(
@@ -199,8 +202,8 @@ export function rgb24(str: string, color: number | Rgb): string {
clampAndTruncate(color.g),
clampAndTruncate(color.b),
],
- 39
- )
+ 39,
+ ),
);
}
@@ -217,7 +220,10 @@ export function bgRgb24(str: string, color: number | Rgb): string {
if (typeof color === "number") {
return run(
str,
- code([48, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff], 49)
+ code(
+ [48, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff],
+ 49,
+ ),
);
}
return run(
@@ -230,8 +236,8 @@ export function bgRgb24(str: string, color: number | Rgb): string {
clampAndTruncate(color.g),
clampAndTruncate(color.b),
],
- 49
- )
+ 49,
+ ),
);
}
@@ -241,7 +247,7 @@ const ANSI_PATTERN = new RegExp(
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))",
].join("|"),
- "g"
+ "g",
);
export function stripColor(string: string): string {
diff --git a/std/fmt/colors_test.ts b/std/fmt/colors_test.ts
index 7a312202a..dea27f84e 100644
--- a/std/fmt/colors_test.ts
+++ b/std/fmt/colors_test.ts
@@ -142,7 +142,7 @@ Deno.test("test_rgb24", function (): void {
g: 42,
b: 43,
}),
- "foo bar"
+ "foo bar",
);
});
@@ -157,7 +157,7 @@ Deno.test("test_bgRgb24", function (): void {
g: 42,
b: 43,
}),
- "foo bar"
+ "foo bar",
);
});
diff --git a/std/fmt/printf.ts b/std/fmt/printf.ts
index bf5feaaed..36b6dddb0 100644
--- a/std/fmt/printf.ts
+++ b/std/fmt/printf.ts
@@ -153,8 +153,9 @@ class Printf {
break;
case State.POSITIONAL: // either a verb or * only verb for now, TODO
if (c === "*") {
- const worp =
- this.flags.precision === -1 ? WorP.WIDTH : WorP.PRECISION;
+ const worp = this.flags.precision === -1
+ ? WorP.WIDTH
+ : WorP.PRECISION;
this.handleWidthOrPrecisionRef(worp);
this.state = State.PERCENT;
break;
@@ -503,8 +504,9 @@ class Printf {
}
let fractional = m[F.fractional];
- const precision =
- this.flags.precision !== -1 ? this.flags.precision : DEFAULT_PRECISION;
+ const precision = this.flags.precision !== -1
+ ? this.flags.precision
+ : DEFAULT_PRECISION;
fractional = this.roundFractionToPrecision(fractional, precision);
let e = m[F.exponent];
@@ -553,8 +555,9 @@ class Printf {
const dig = arr[0];
let fractional = arr[1];
- const precision =
- this.flags.precision !== -1 ? this.flags.precision : DEFAULT_PRECISION;
+ const precision = this.flags.precision !== -1
+ ? this.flags.precision
+ : DEFAULT_PRECISION;
fractional = this.roundFractionToPrecision(fractional, precision);
return this.padNum(`${dig}.${fractional}`, n < 0);
@@ -589,8 +592,9 @@ class Printf {
// converted in the style of an f or F conversion specifier.
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html
- let P =
- this.flags.precision !== -1 ? this.flags.precision : DEFAULT_PRECISION;
+ let P = this.flags.precision !== -1
+ ? this.flags.precision
+ : DEFAULT_PRECISION;
P = P === 0 ? 1 : P;
const m = n.toExponential().match(FLOAT_REGEXP);
@@ -650,15 +654,16 @@ class Printf {
}
default:
throw new Error(
- "currently only number and string are implemented for hex"
+ "currently only number and string are implemented for hex",
);
}
}
fmtV(val: object): string {
if (this.flags.sharp) {
- const options =
- this.flags.precision !== -1 ? { depth: this.flags.precision } : {};
+ const options = this.flags.precision !== -1
+ ? { depth: this.flags.precision }
+ : {};
return this.pad(Deno.inspect(val, options));
} else {
const p = this.flags.precision;
diff --git a/std/fmt/printf_test.ts b/std/fmt/printf_test.ts
index a10fdf516..54adc8b55 100644
--- a/std/fmt/printf_test.ts
+++ b/std/fmt/printf_test.ts
@@ -35,19 +35,19 @@ Deno.test("testIntegerB", function (): void {
assertEquals(S("%b", -4), "-100");
assertEquals(
S("%b", 4.1),
- "100.0001100110011001100110011001100110011001100110011"
+ "100.0001100110011001100110011001100110011001100110011",
);
assertEquals(
S("%b", -4.1),
- "-100.0001100110011001100110011001100110011001100110011"
+ "-100.0001100110011001100110011001100110011001100110011",
);
assertEquals(
S("%b", Number.MAX_SAFE_INTEGER),
- "11111111111111111111111111111111111111111111111111111"
+ "11111111111111111111111111111111111111111111111111111",
);
assertEquals(
S("%b", Number.MIN_SAFE_INTEGER),
- "-11111111111111111111111111111111111111111111111111111"
+ "-11111111111111111111111111111111111111111111111111111",
);
// width
@@ -137,18 +137,18 @@ Deno.test("testFloatfF", function (): void {
assertEquals(
S("%.324f", Number.MIN_VALUE),
// eslint-disable-next-line max-len
- "0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005"
+ "0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005",
);
assertEquals(S("%F", Number.MIN_VALUE), "0.000000");
assertEquals(
S("%f", Number.MAX_VALUE),
// eslint-disable-next-line max-len
- "179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000"
+ "179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000",
);
assertEquals(
S("%F", Number.MAX_VALUE),
// eslint-disable-next-line max-len
- "179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000"
+ "179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000",
);
});
@@ -190,7 +190,7 @@ Deno.test("testWidthAndPrecision", function (): void {
assertEquals(
S("%9.99d", 9),
// eslint-disable-next-line max-len
- "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009"
+ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009",
);
assertEquals(S("%1.12d", 9), "000000000009");
assertEquals(S("%2s", "a"), " a");
@@ -200,12 +200,12 @@ Deno.test("testWidthAndPrecision", function (): void {
assertEquals(
S("%*.99d", 9, 9),
// eslint-disable-next-line max-len
- "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009"
+ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009",
);
assertEquals(
S("%9.*d", 99, 9),
// eslint-disable-next-line max-len
- "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009"
+ "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009",
);
assertEquals(S("%*s", 2, "a"), " a");
assertEquals(S("%*d", 2, 1), " 1");
@@ -591,7 +591,7 @@ Deno.test("testThorough", function (): void {
assertEquals(
is,
should,
- `failed case[${i}] : is >${is}< should >${should}<`
+ `failed case[${i}] : is >${is}< should >${should}<`,
);
});
});
@@ -600,7 +600,7 @@ Deno.test("testWeirdos", function (): void {
assertEquals(S("%.d", 9), "9");
assertEquals(
S("dec[%d]=%d hex[%[1]d]=%#x oct[%[1]d]=%#o %s", 1, 255, "Third"),
- "dec[1]=255 hex[1]=0xff oct[1]=0377 Third"
+ "dec[1]=255 hex[1]=0xff oct[1]=0377 Third",
);
});
@@ -610,7 +610,7 @@ Deno.test("formatV", function (): void {
assertEquals(S("%#v", a), `{ a: { a: { a: { a: ${cyan("[Object]")} } } } }`);
assertEquals(
S("%#.8v", a),
- "{ a: { a: { a: { a: { a: { a: { a: {} } } } } } } }"
+ "{ a: { a: { a: { a: { a: { a: { a: {} } } } } } } }",
);
assertEquals(S("%#.1v", a), `{ a: ${cyan("[Object]")} }`);
});
@@ -625,9 +625,9 @@ Deno.test("flagLessThan", function (): void {
const aArray = [a, a, a];
assertEquals(
S("%<#.1v", aArray),
- `[ { a: ${cyan("[Object]")} }, { a: ${cyan("[Object]")} }, { a: ${cyan(
- "[Object]"
- )} } ]`
+ `[ { a: ${cyan("[Object]")} }, { a: ${cyan("[Object]")} }, { a: ${
+ cyan("[Object]")
+ } } ]`,
);
const fArray = [1.2345, 0.98765, 123456789.5678];
assertEquals(S("%<.2f", fArray), "[ 1.23, 0.99, 123456789.57 ]");
@@ -649,7 +649,7 @@ Deno.test("testErrors", function (): void {
assertEquals(S("%.*f", "a", 1.1), "%!(BAD PREC 'a')");
assertEquals(
S("%.[2]*f", 1.23, "p"),
- `%!(BAD PREC 'p')%!(EXTRA '${yellow("1.23")}')`
+ `%!(BAD PREC 'p')%!(EXTRA '${yellow("1.23")}')`,
);
assertEquals(S("%.[2]*[1]f Yippie!", 1.23, "p"), "%!(BAD PREC 'p') Yippie!");
@@ -663,7 +663,7 @@ Deno.test("testErrors", function (): void {
assertEquals(S("%[hallo]s %d %d %d", 1, 2, 3, 4), "%!(BAD INDEX) 2 3 4");
assertEquals(
S("%[5]s", 1, 2, 3, 4),
- `%!(BAD INDEX)%!(EXTRA '${yellow("2")}' '${yellow("3")}' '${yellow("4")}')`
+ `%!(BAD INDEX)%!(EXTRA '${yellow("2")}' '${yellow("3")}' '${yellow("4")}')`,
);
assertEquals(S("%[5]f"), "%!(BAD INDEX)");
assertEquals(S("%.[5]f"), "%!(BAD INDEX)");
diff --git a/std/fs/_util.ts b/std/fs/_util.ts
index bae48c970..6866526cd 100644
--- a/std/fs/_util.ts
+++ b/std/fs/_util.ts
@@ -9,7 +9,7 @@ import * as path from "../path/mod.ts";
export function isSubdir(
src: string,
dest: string,
- sep: string = path.sep
+ sep: string = path.sep,
): boolean {
if (src === dest) {
return false;
diff --git a/std/fs/_util_test.ts b/std/fs/_util_test.ts
index 48fc33ecd..a05f2cb2d 100644
--- a/std/fs/_util_test.ts
+++ b/std/fs/_util_test.ts
@@ -28,7 +28,7 @@ Deno.test("_isSubdir", function (): void {
assertEquals(
isSubdir(src, dest, sep),
expected,
- `'${src}' should ${expected ? "" : "not"} be parent dir of '${dest}'`
+ `'${src}' should ${expected ? "" : "not"} be parent dir of '${dest}'`,
);
});
});
diff --git a/std/fs/copy.ts b/std/fs/copy.ts
index 269340e85..b1b340354 100644
--- a/std/fs/copy.ts
+++ b/std/fs/copy.ts
@@ -24,7 +24,7 @@ async function ensureValidCopy(
src: string,
dest: string,
options: CopyOptions,
- isCopyFolder = false
+ isCopyFolder = false,
): Promise<Deno.FileInfo | undefined> {
let destStat: Deno.FileInfo;
@@ -39,7 +39,7 @@ async function ensureValidCopy(
if (isCopyFolder && !destStat.isDirectory) {
throw new Error(
- `Cannot overwrite non-directory '${dest}' with directory '${src}'.`
+ `Cannot overwrite non-directory '${dest}' with directory '${src}'.`,
);
}
if (!options.overwrite) {
@@ -53,7 +53,7 @@ function ensureValidCopySync(
src: string,
dest: string,
options: CopyOptions,
- isCopyFolder = false
+ isCopyFolder = false,
): Deno.FileInfo | undefined {
let destStat: Deno.FileInfo;
try {
@@ -67,7 +67,7 @@ function ensureValidCopySync(
if (isCopyFolder && !destStat.isDirectory) {
throw new Error(
- `Cannot overwrite non-directory '${dest}' with directory '${src}'.`
+ `Cannot overwrite non-directory '${dest}' with directory '${src}'.`,
);
}
if (!options.overwrite) {
@@ -81,7 +81,7 @@ function ensureValidCopySync(
async function copyFile(
src: string,
dest: string,
- options: CopyOptions
+ options: CopyOptions,
): Promise<void> {
await ensureValidCopy(src, dest, options);
await Deno.copyFile(src, dest);
@@ -108,7 +108,7 @@ function copyFileSync(src: string, dest: string, options: CopyOptions): void {
async function copySymLink(
src: string,
dest: string,
- options: CopyOptions
+ options: CopyOptions,
): Promise<void> {
await ensureValidCopy(src, dest, options);
const originSrcFilePath = await Deno.readLink(src);
@@ -132,7 +132,7 @@ async function copySymLink(
function copySymlinkSync(
src: string,
dest: string,
- options: CopyOptions
+ options: CopyOptions,
): void {
ensureValidCopySync(src, dest, options);
const originSrcFilePath = Deno.readLinkSync(src);
@@ -157,7 +157,7 @@ function copySymlinkSync(
async function copyDir(
src: string,
dest: string,
- options: CopyOptions
+ options: CopyOptions,
): Promise<void> {
const destStat = await ensureValidCopy(src, dest, options, true);
@@ -227,7 +227,7 @@ function copyDirSync(src: string, dest: string, options: CopyOptions): void {
export async function copy(
src: string,
dest: string,
- options: CopyOptions = {}
+ options: CopyOptions = {},
): Promise<void> {
src = path.resolve(src);
dest = path.resolve(dest);
@@ -240,7 +240,7 @@ export async function copy(
if (srcStat.isDirectory && isSubdir(src, dest)) {
throw new Error(
- `Cannot copy '${src}' to a subdirectory of itself, '${dest}'.`
+ `Cannot copy '${src}' to a subdirectory of itself, '${dest}'.`,
);
}
@@ -266,7 +266,7 @@ export async function copy(
export function copySync(
src: string,
dest: string,
- options: CopyOptions = {}
+ options: CopyOptions = {},
): void {
src = path.resolve(src);
dest = path.resolve(dest);
@@ -279,7 +279,7 @@ export function copySync(
if (srcStat.isDirectory && isSubdir(src, dest)) {
throw new Error(
- `Cannot copy '${src}' to a subdirectory of itself, '${dest}'.`
+ `Cannot copy '${src}' to a subdirectory of itself, '${dest}'.`,
);
}
diff --git a/std/fs/copy_test.ts b/std/fs/copy_test.ts
index dd9b90ff6..75efd7cc0 100644
--- a/std/fs/copy_test.ts
+++ b/std/fs/copy_test.ts
@@ -17,7 +17,7 @@ const testdataDir = path.resolve("fs", "testdata");
function testCopy(
name: string,
cb: (tempDir: string) => Promise<void>,
- ignore = false
+ ignore = false,
): void {
Deno.test({
name,
@@ -34,7 +34,7 @@ function testCopy(
function testCopyIgnore(
name: string,
- cb: (tempDir: string) => Promise<void>
+ cb: (tempDir: string) => Promise<void>,
): void {
testCopy(name, cb, true);
}
@@ -60,9 +60,9 @@ testCopy(
await assertThrowsAsync(
async (): Promise<void> => {
await copy(srcFile, destFile);
- }
+ },
);
- }
+ },
);
testCopy(
@@ -75,9 +75,9 @@ testCopy(
await copy(srcFile, destFile);
},
Error,
- "Source and destination cannot be the same."
+ "Source and destination cannot be the same.",
);
- }
+ },
);
testCopy(
@@ -91,12 +91,12 @@ testCopy(
assertEquals(
await exists(srcFile),
true,
- `source should exist before copy`
+ `source should exist before copy`,
);
assertEquals(
await exists(destFile),
false,
- "destination should not exist before copy"
+ "destination should not exist before copy",
);
await copy(srcFile, destFile);
@@ -105,7 +105,7 @@ testCopy(
assertEquals(
await exists(destFile),
true,
- "destination should exist before copy"
+ "destination should exist before copy",
);
const destContent = new TextDecoder().decode(await Deno.readFile(destFile));
@@ -113,7 +113,7 @@ testCopy(
assertEquals(
srcContent,
destContent,
- "source and destination should have the same content"
+ "source and destination should have the same content",
);
// Copy again and it should throw an error.
@@ -122,7 +122,7 @@ testCopy(
await copy(srcFile, destFile);
},
Error,
- `'${destFile}' already exists.`
+ `'${destFile}' already exists.`,
);
// Modify destination file.
@@ -130,7 +130,7 @@ testCopy(
assertEquals(
new TextDecoder().decode(await Deno.readFile(destFile)),
- "txt copy"
+ "txt copy",
);
// Copy again with overwrite option.
@@ -139,9 +139,9 @@ testCopy(
// Make sure the file has been overwritten.
assertEquals(
new TextDecoder().decode(await Deno.readFile(destFile)),
- "txt"
+ "txt",
);
- }
+ },
);
// TODO(#6644) This case is ignored because of the issue #5065.
@@ -168,7 +168,7 @@ testCopyIgnore(
assert(destStatInfo.mtime instanceof Date);
assertEquals(destStatInfo.atime, srcStatInfo.atime);
assertEquals(destStatInfo.mtime, srcStatInfo.mtime);
- }
+ },
);
testCopy(
@@ -184,9 +184,9 @@ testCopy(
await copy(srcDir, destDir);
},
Error,
- `Cannot copy '${srcDir}' to a subdirectory of itself, '${destDir}'.`
+ `Cannot copy '${srcDir}' to a subdirectory of itself, '${destDir}'.`,
);
- }
+ },
);
testCopy(
@@ -203,9 +203,9 @@ testCopy(
await copy(srcDir, destDir);
},
Error,
- `Cannot overwrite non-directory '${destDir}' with directory '${srcDir}'.`
+ `Cannot overwrite non-directory '${destDir}' with directory '${srcDir}'.`,
);
- }
+ },
);
testCopy(
@@ -226,11 +226,11 @@ testCopy(
// After copy. The source and destination should have the same content.
assertEquals(
new TextDecoder().decode(await Deno.readFile(srcFile)),
- new TextDecoder().decode(await Deno.readFile(destFile))
+ new TextDecoder().decode(await Deno.readFile(destFile)),
);
assertEquals(
new TextDecoder().decode(await Deno.readFile(srcNestFile)),
- new TextDecoder().decode(await Deno.readFile(destNestFile))
+ new TextDecoder().decode(await Deno.readFile(destNestFile)),
);
// Copy again without overwrite option and it should throw an error.
@@ -239,14 +239,14 @@ testCopy(
await copy(srcDir, destDir);
},
Error,
- `'${destDir}' already exists.`
+ `'${destDir}' already exists.`,
);
// Modify the file in the destination directory.
await Deno.writeFile(destNestFile, new TextEncoder().encode("nest copy"));
assertEquals(
new TextDecoder().decode(await Deno.readFile(destNestFile)),
- "nest copy"
+ "nest copy",
);
// Copy again with overwrite option.
@@ -255,9 +255,9 @@ testCopy(
// Make sure the file has been overwritten.
assertEquals(
new TextDecoder().decode(await Deno.readFile(destNestFile)),
- "nest"
+ "nest",
);
- }
+ },
);
testCopy(
@@ -269,7 +269,7 @@ testCopy(
assert(
(await Deno.lstat(srcLink)).isSymlink,
- `'${srcLink}' should be symlink type`
+ `'${srcLink}' should be symlink type`,
);
await copy(srcLink, destLink);
@@ -277,7 +277,7 @@ testCopy(
const statInfo = await Deno.lstat(destLink);
assert(statInfo.isSymlink, `'${destLink}' should be symlink type`);
- }
+ },
);
testCopy(
@@ -291,7 +291,7 @@ testCopy(
assert(
(await Deno.lstat(srcLink)).isSymlink,
- `'${srcLink}' should be symlink type`
+ `'${srcLink}' should be symlink type`,
);
await copy(srcLink, destLink);
@@ -299,7 +299,7 @@ testCopy(
const statInfo = await Deno.lstat(destLink);
assert(statInfo.isSymlink);
- }
+ },
);
testCopySync(
@@ -310,7 +310,7 @@ testCopySync(
assertThrows((): void => {
copySync(srcFile, destFile);
});
- }
+ },
);
testCopySync(
@@ -338,7 +338,7 @@ testCopySync(
// is fixed
// assertEquals(destStatInfo.atime, srcStatInfo.atime);
// assertEquals(destStatInfo.mtime, srcStatInfo.mtime);
- }
+ },
);
testCopySync(
@@ -350,9 +350,9 @@ testCopySync(
copySync(srcFile, srcFile);
},
Error,
- "Source and destination cannot be the same."
+ "Source and destination cannot be the same.",
);
- }
+ },
);
testCopySync("[fs] copy file synchronously", (tempDir: string): void => {
@@ -379,7 +379,7 @@ testCopySync("[fs] copy file synchronously", (tempDir: string): void => {
copySync(srcFile, destFile);
},
Error,
- `'${destFile}' already exists.`
+ `'${destFile}' already exists.`,
);
// Modify destination file.
@@ -387,7 +387,7 @@ testCopySync("[fs] copy file synchronously", (tempDir: string): void => {
assertEquals(
new TextDecoder().decode(Deno.readFileSync(destFile)),
- "txt copy"
+ "txt copy",
);
// Copy again with overwrite option.
@@ -410,9 +410,9 @@ testCopySync(
copySync(srcDir, destDir);
},
Error,
- `Cannot copy '${srcDir}' to a subdirectory of itself, '${destDir}'.`
+ `Cannot copy '${srcDir}' to a subdirectory of itself, '${destDir}'.`,
);
- }
+ },
);
testCopySync(
@@ -430,9 +430,9 @@ testCopySync(
copySync(srcDir, destDir);
},
Error,
- `Cannot overwrite non-directory '${destDir}' with directory '${srcDir}'.`
+ `Cannot overwrite non-directory '${destDir}' with directory '${srcDir}'.`,
);
- }
+ },
);
testCopySync("[fs] copy directory synchronously", (tempDir: string): void => {
@@ -451,11 +451,11 @@ testCopySync("[fs] copy directory synchronously", (tempDir: string): void => {
// After copy. The source and destination should have the same content.
assertEquals(
new TextDecoder().decode(Deno.readFileSync(srcFile)),
- new TextDecoder().decode(Deno.readFileSync(destFile))
+ new TextDecoder().decode(Deno.readFileSync(destFile)),
);
assertEquals(
new TextDecoder().decode(Deno.readFileSync(srcNestFile)),
- new TextDecoder().decode(Deno.readFileSync(destNestFile))
+ new TextDecoder().decode(Deno.readFileSync(destNestFile)),
);
// Copy again without overwrite option and it should throw an error.
@@ -464,14 +464,14 @@ testCopySync("[fs] copy directory synchronously", (tempDir: string): void => {
copySync(srcDir, destDir);
},
Error,
- `'${destDir}' already exists.`
+ `'${destDir}' already exists.`,
);
// Modify the file in the destination directory.
Deno.writeFileSync(destNestFile, new TextEncoder().encode("nest copy"));
assertEquals(
new TextDecoder().decode(Deno.readFileSync(destNestFile)),
- "nest copy"
+ "nest copy",
);
// Copy again with overwrite option.
@@ -480,7 +480,7 @@ testCopySync("[fs] copy directory synchronously", (tempDir: string): void => {
// Make sure the file has been overwritten.
assertEquals(
new TextDecoder().decode(Deno.readFileSync(destNestFile)),
- "nest"
+ "nest",
);
});
@@ -493,7 +493,7 @@ testCopySync(
assert(
Deno.lstatSync(srcLink).isSymlink,
- `'${srcLink}' should be symlink type`
+ `'${srcLink}' should be symlink type`,
);
copySync(srcLink, destLink);
@@ -501,7 +501,7 @@ testCopySync(
const statInfo = Deno.lstatSync(destLink);
assert(statInfo.isSymlink, `'${destLink}' should be symlink type`);
- }
+ },
);
testCopySync(
@@ -515,7 +515,7 @@ testCopySync(
assert(
Deno.lstatSync(srcLink).isSymlink,
- `'${srcLink}' should be symlink type`
+ `'${srcLink}' should be symlink type`,
);
copySync(srcLink, destLink);
@@ -523,5 +523,5 @@ testCopySync(
const statInfo = Deno.lstatSync(destLink);
assert(statInfo.isSymlink);
- }
+ },
);
diff --git a/std/fs/empty_dir_test.ts b/std/fs/empty_dir_test.ts
index e0e4c58fa..6c06c9d52 100644
--- a/std/fs/empty_dir_test.ts
+++ b/std/fs/empty_dir_test.ts
@@ -71,14 +71,14 @@ Deno.test("emptyDirIfItExist", async function (): Promise<void> {
await assertThrowsAsync(
async (): Promise<void> => {
await Deno.stat(testNestDir);
- }
+ },
);
// test file have been removed
await assertThrowsAsync(
async (): Promise<void> => {
await Deno.stat(testDirFile);
- }
+ },
);
} finally {
// remote test dir
@@ -199,7 +199,7 @@ for (const s of scenes) {
await Deno.writeFile(
path.join(testfolder, "child.txt"),
- new TextEncoder().encode("hello world")
+ new TextEncoder().encode("hello world"),
);
try {
@@ -215,7 +215,10 @@ for (const s of scenes) {
}
args.push(
- path.join(testdataDir, s.async ? "empty_dir.ts" : "empty_dir_sync.ts")
+ path.join(
+ testdataDir,
+ s.async ? "empty_dir.ts" : "empty_dir_sync.ts",
+ ),
);
args.push("testfolder");
diff --git a/std/fs/ensure_dir.ts b/std/fs/ensure_dir.ts
index 961476028..f5b5cd309 100644
--- a/std/fs/ensure_dir.ts
+++ b/std/fs/ensure_dir.ts
@@ -11,7 +11,9 @@ export async function ensureDir(dir: string): Promise<void> {
const fileInfo = await Deno.lstat(dir);
if (!fileInfo.isDirectory) {
throw new Error(
- `Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`
+ `Ensure path exists, expected 'dir', got '${
+ getFileInfoType(fileInfo)
+ }'`,
);
}
} catch (err) {
@@ -34,7 +36,9 @@ export function ensureDirSync(dir: string): void {
const fileInfo = Deno.lstatSync(dir);
if (!fileInfo.isDirectory) {
throw new Error(
- `Ensure path exists, expected 'dir', got '${getFileInfoType(fileInfo)}'`
+ `Ensure path exists, expected 'dir', got '${
+ getFileInfoType(fileInfo)
+ }'`,
);
}
} catch (err) {
diff --git a/std/fs/ensure_dir_test.ts b/std/fs/ensure_dir_test.ts
index d70f5eb1a..c24e14d1a 100644
--- a/std/fs/ensure_dir_test.ts
+++ b/std/fs/ensure_dir_test.ts
@@ -17,7 +17,7 @@ Deno.test("ensureDirIfItNotExist", async function (): Promise<void> {
await Deno.stat(testDir).then((): void => {
throw new Error("test dir should exists.");
});
- }
+ },
);
await Deno.remove(baseDir, { recursive: true });
@@ -48,7 +48,7 @@ Deno.test("ensureDirIfItExist", async function (): Promise<void> {
await Deno.stat(testDir).then((): void => {
throw new Error("test dir should still exists.");
});
- }
+ },
);
await Deno.remove(baseDir, { recursive: true });
@@ -82,7 +82,7 @@ Deno.test("ensureDirIfItAsFile", async function (): Promise<void> {
await ensureDir(testFile);
},
Error,
- `Ensure path exists, expected 'dir', got 'file'`
+ `Ensure path exists, expected 'dir', got 'file'`,
);
await Deno.remove(baseDir, { recursive: true });
@@ -99,7 +99,7 @@ Deno.test("ensureDirSyncIfItAsFile", function (): void {
ensureDirSync(testFile);
},
Error,
- `Ensure path exists, expected 'dir', got 'file'`
+ `Ensure path exists, expected 'dir', got 'file'`,
);
Deno.removeSync(baseDir, { recursive: true });
diff --git a/std/fs/ensure_file.ts b/std/fs/ensure_file.ts
index b36379b3d..41565795c 100644
--- a/std/fs/ensure_file.ts
+++ b/std/fs/ensure_file.ts
@@ -17,7 +17,7 @@ export async function ensureFile(filePath: string): Promise<void> {
const stat = await Deno.lstat(filePath);
if (!stat.isFile) {
throw new Error(
- `Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`
+ `Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`,
);
}
} catch (err) {
@@ -48,7 +48,7 @@ export function ensureFileSync(filePath: string): void {
const stat = Deno.lstatSync(filePath);
if (!stat.isFile) {
throw new Error(
- `Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`
+ `Ensure path exists, expected 'file', got '${getFileInfoType(stat)}'`,
);
}
} catch (err) {
diff --git a/std/fs/ensure_file_test.ts b/std/fs/ensure_file_test.ts
index 1e51db451..d87de0051 100644
--- a/std/fs/ensure_file_test.ts
+++ b/std/fs/ensure_file_test.ts
@@ -16,7 +16,7 @@ Deno.test("ensureFileIfItNotExist", async function (): Promise<void> {
await Deno.stat(testFile).then((): void => {
throw new Error("test file should exists.");
});
- }
+ },
);
await Deno.remove(testDir, { recursive: true });
@@ -50,7 +50,7 @@ Deno.test("ensureFileIfItExist", async function (): Promise<void> {
await Deno.stat(testFile).then((): void => {
throw new Error("test file should exists.");
});
- }
+ },
);
await Deno.remove(testDir, { recursive: true });
@@ -83,7 +83,7 @@ Deno.test("ensureFileIfItExistAsDir", async function (): Promise<void> {
await ensureFile(testDir);
},
Error,
- `Ensure path exists, expected 'file', got 'dir'`
+ `Ensure path exists, expected 'file', got 'dir'`,
);
await Deno.remove(testDir, { recursive: true });
@@ -99,7 +99,7 @@ Deno.test("ensureFileSyncIfItExistAsDir", function (): void {
ensureFileSync(testDir);
},
Error,
- `Ensure path exists, expected 'file', got 'dir'`
+ `Ensure path exists, expected 'file', got 'dir'`,
);
Deno.removeSync(testDir, { recursive: true });
diff --git a/std/fs/ensure_link.ts b/std/fs/ensure_link.ts
index f446df781..ea8501b03 100644
--- a/std/fs/ensure_link.ts
+++ b/std/fs/ensure_link.ts
@@ -17,7 +17,7 @@ export async function ensureLink(src: string, dest: string): Promise<void> {
const destFilePathType = getFileInfoType(destStatInfo);
if (destFilePathType !== "file") {
throw new Error(
- `Ensure path exists, expected 'file', got '${destFilePathType}'`
+ `Ensure path exists, expected 'file', got '${destFilePathType}'`,
);
}
return;
@@ -41,7 +41,7 @@ export function ensureLinkSync(src: string, dest: string): void {
const destFilePathType = getFileInfoType(destStatInfo);
if (destFilePathType !== "file") {
throw new Error(
- `Ensure path exists, expected 'file', got '${destFilePathType}'`
+ `Ensure path exists, expected 'file', got '${destFilePathType}'`,
);
}
return;
diff --git a/std/fs/ensure_link_test.ts b/std/fs/ensure_link_test.ts
index e05d3a648..d4f2f30c2 100644
--- a/std/fs/ensure_link_test.ts
+++ b/std/fs/ensure_link_test.ts
@@ -19,7 +19,7 @@ Deno.test("ensureLinkIfItNotExist", async function (): Promise<void> {
await assertThrowsAsync(
async (): Promise<void> => {
await ensureLink(testFile, linkFile);
- }
+ },
);
await Deno.remove(destDir, { recursive: true });
@@ -59,10 +59,10 @@ Deno.test("ensureLinkIfItExist", async function (): Promise<void> {
await Deno.writeFile(testFile, new TextEncoder().encode("123"));
const testFileContent1 = new TextDecoder().decode(
- await Deno.readFile(testFile)
+ await Deno.readFile(testFile),
);
const linkFileContent1 = new TextDecoder().decode(
- await Deno.readFile(testFile)
+ await Deno.readFile(testFile),
);
assertEquals(testFileContent1, "123");
@@ -72,10 +72,10 @@ Deno.test("ensureLinkIfItExist", async function (): Promise<void> {
await Deno.writeFile(testFile, new TextEncoder().encode("abc"));
const testFileContent2 = new TextDecoder().decode(
- await Deno.readFile(testFile)
+ await Deno.readFile(testFile),
);
const linkFileContent2 = new TextDecoder().decode(
- await Deno.readFile(testFile)
+ await Deno.readFile(testFile),
);
assertEquals(testFileContent2, "abc");
@@ -107,10 +107,10 @@ Deno.test("ensureLinkSyncIfItExist", function (): void {
Deno.writeFileSync(testFile, new TextEncoder().encode("123"));
const testFileContent1 = new TextDecoder().decode(
- Deno.readFileSync(testFile)
+ Deno.readFileSync(testFile),
);
const linkFileContent1 = new TextDecoder().decode(
- Deno.readFileSync(testFile)
+ Deno.readFileSync(testFile),
);
assertEquals(testFileContent1, "123");
@@ -120,10 +120,10 @@ Deno.test("ensureLinkSyncIfItExist", function (): void {
Deno.writeFileSync(testFile, new TextEncoder().encode("abc"));
const testFileContent2 = new TextDecoder().decode(
- Deno.readFileSync(testFile)
+ Deno.readFileSync(testFile),
);
const linkFileContent2 = new TextDecoder().decode(
- Deno.readFileSync(testFile)
+ Deno.readFileSync(testFile),
);
assertEquals(testFileContent2, "abc");
@@ -143,7 +143,7 @@ Deno.test("ensureLinkDirectoryIfItExist", async function (): Promise<void> {
await assertThrowsAsync(
async (): Promise<void> => {
await ensureLink(testDir, linkDir);
- }
+ },
// "Operation not permitted (os error 1)" // throw an local matching test
// "Access is denied. (os error 5)" // throw in CI
);
@@ -162,7 +162,7 @@ Deno.test("ensureLinkSyncDirectoryIfItExist", function (): void {
assertThrows(
(): void => {
ensureLinkSync(testDir, linkDir);
- }
+ },
// "Operation not permitted (os error 1)" // throw an local matching test
// "Access is denied. (os error 5)" // throw in CI
);
diff --git a/std/fs/ensure_symlink.ts b/std/fs/ensure_symlink.ts
index be96d5b13..03a8db930 100644
--- a/std/fs/ensure_symlink.ts
+++ b/std/fs/ensure_symlink.ts
@@ -20,7 +20,7 @@ export async function ensureSymlink(src: string, dest: string): Promise<void> {
const destFilePathType = getFileInfoType(destStatInfo);
if (destFilePathType !== "symlink") {
throw new Error(
- `Ensure path exists, expected 'symlink', got '${destFilePathType}'`
+ `Ensure path exists, expected 'symlink', got '${destFilePathType}'`,
);
}
return;
@@ -53,7 +53,7 @@ export function ensureSymlinkSync(src: string, dest: string): void {
const destFilePathType = getFileInfoType(destStatInfo);
if (destFilePathType !== "symlink") {
throw new Error(
- `Ensure path exists, expected 'symlink', got '${destFilePathType}'`
+ `Ensure path exists, expected 'symlink', got '${destFilePathType}'`,
);
}
return;
diff --git a/std/fs/ensure_symlink_test.ts b/std/fs/ensure_symlink_test.ts
index d90495cbf..bc0741fed 100644
--- a/std/fs/ensure_symlink_test.ts
+++ b/std/fs/ensure_symlink_test.ts
@@ -17,7 +17,7 @@ Deno.test("ensureSymlinkIfItNotExist", async function (): Promise<void> {
await assertThrowsAsync(
async (): Promise<void> => {
await ensureSymlink(testFile, path.join(testDir, "test1.txt"));
- }
+ },
);
await assertThrowsAsync(
@@ -25,7 +25,7 @@ Deno.test("ensureSymlinkIfItNotExist", async function (): Promise<void> {
await Deno.stat(testFile).then((): void => {
throw new Error("test file should exists.");
});
- }
+ },
);
});
diff --git a/std/fs/exists_test.ts b/std/fs/exists_test.ts
index 8b584d861..3c280f4c4 100644
--- a/std/fs/exists_test.ts
+++ b/std/fs/exists_test.ts
@@ -8,7 +8,7 @@ const testdataDir = path.resolve("fs", "testdata");
Deno.test("[fs] existsFile", async function (): Promise<void> {
assertEquals(
await exists(path.join(testdataDir, "not_exist_file.ts")),
- false
+ false,
);
assertEquals(await existsSync(path.join(testdataDir, "0.ts")), true);
});
@@ -21,7 +21,7 @@ Deno.test("[fs] existsFileSync", function (): void {
Deno.test("[fs] existsDirectory", async function (): Promise<void> {
assertEquals(
await exists(path.join(testdataDir, "not_exist_directory")),
- false
+ false,
);
assertEquals(existsSync(testdataDir), true);
});
@@ -29,7 +29,7 @@ Deno.test("[fs] existsDirectory", async function (): Promise<void> {
Deno.test("[fs] existsDirectorySync", function (): void {
assertEquals(
existsSync(path.join(testdataDir, "not_exist_directory")),
- false
+ false,
);
assertEquals(existsSync(testdataDir), true);
});
diff --git a/std/fs/expand_glob.ts b/std/fs/expand_glob.ts
index 8a4b0ed03..6d1f883b5 100644
--- a/std/fs/expand_glob.ts
+++ b/std/fs/expand_glob.ts
@@ -77,7 +77,7 @@ export async function* expandGlob(
includeDirs = true,
extended = false,
globstar = false,
- }: ExpandGlobOptions = {}
+ }: ExpandGlobOptions = {},
): AsyncIterableIterator<WalkEntry> {
const globOptions: GlobOptions = { extended, globstar };
const absRoot = isAbsolute(root)
@@ -110,7 +110,7 @@ export async function* expandGlob(
async function* advanceMatch(
walkInfo: WalkEntry,
- globSegment: string
+ globSegment: string,
): AsyncIterableIterator<WalkEntry> {
if (!walkInfo.isDirectory) {
return;
@@ -135,7 +135,7 @@ export async function* expandGlob(
match: [
globToRegExp(
joinGlobs([walkInfo.path, globSegment], globOptions),
- globOptions
+ globOptions,
),
],
skip: excludePatterns,
@@ -156,12 +156,12 @@ export async function* expandGlob(
}
if (hasTrailingSep) {
currentMatches = currentMatches.filter(
- (entry: WalkEntry): boolean => entry.isDirectory
+ (entry: WalkEntry): boolean => entry.isDirectory,
);
}
if (!includeDirs) {
currentMatches = currentMatches.filter(
- (entry: WalkEntry): boolean => !entry.isDirectory
+ (entry: WalkEntry): boolean => !entry.isDirectory,
);
}
yield* currentMatches;
@@ -184,7 +184,7 @@ export function* expandGlobSync(
includeDirs = true,
extended = false,
globstar = false,
- }: ExpandGlobOptions = {}
+ }: ExpandGlobOptions = {},
): IterableIterator<WalkEntry> {
const globOptions: GlobOptions = { extended, globstar };
const absRoot = isAbsolute(root)
@@ -217,7 +217,7 @@ export function* expandGlobSync(
function* advanceMatch(
walkInfo: WalkEntry,
- globSegment: string
+ globSegment: string,
): IterableIterator<WalkEntry> {
if (!walkInfo.isDirectory) {
return;
@@ -242,7 +242,7 @@ export function* expandGlobSync(
match: [
globToRegExp(
joinGlobs([walkInfo.path, globSegment], globOptions),
- globOptions
+ globOptions,
),
],
skip: excludePatterns,
@@ -263,12 +263,12 @@ export function* expandGlobSync(
}
if (hasTrailingSep) {
currentMatches = currentMatches.filter(
- (entry: WalkEntry): boolean => entry.isDirectory
+ (entry: WalkEntry): boolean => entry.isDirectory,
);
}
if (!includeDirs) {
currentMatches = currentMatches.filter(
- (entry: WalkEntry): boolean => !entry.isDirectory
+ (entry: WalkEntry): boolean => !entry.isDirectory,
);
}
yield* currentMatches;
diff --git a/std/fs/expand_glob_test.ts b/std/fs/expand_glob_test.ts
index 1eec4df42..8b4a90754 100644
--- a/std/fs/expand_glob_test.ts
+++ b/std/fs/expand_glob_test.ts
@@ -19,7 +19,7 @@ import {
async function expandGlobArray(
globString: string,
- options: ExpandGlobOptions
+ options: ExpandGlobOptions,
): Promise<string[]> {
const paths: string[] = [];
for await (const { path } of expandGlob(globString, options)) {
@@ -27,7 +27,7 @@ async function expandGlobArray(
}
paths.sort();
const pathsSync = [...expandGlobSync(globString, options)].map(
- ({ path }): string => path
+ ({ path }): string => path,
);
pathsSync.sort();
assertEquals(paths, pathsSync);
@@ -36,7 +36,7 @@ async function expandGlobArray(
assert(path.startsWith(root));
}
const relativePaths = paths.map(
- (path: string): string => relative(root, path) || "."
+ (path: string): string => relative(root, path) || ".",
);
relativePaths.sort();
return relativePaths;
@@ -98,7 +98,7 @@ Deno.test("expandGlobGlobstar", async function (): Promise<void> {
const options = { ...EG_OPTIONS, globstar: true };
assertEquals(
await expandGlobArray(joinGlobs(["**", "abc"], options), options),
- ["abc", join("subdir", "abc")]
+ ["abc", join("subdir", "abc")],
);
});
@@ -106,7 +106,7 @@ Deno.test("expandGlobGlobstarParent", async function (): Promise<void> {
const options = { ...EG_OPTIONS, globstar: true };
assertEquals(
await expandGlobArray(joinGlobs(["subdir", "**", ".."], options), options),
- ["."]
+ ["."],
);
});
@@ -127,7 +127,7 @@ Deno.test("expandGlobPermError", async function (): Promise<void> {
assertEquals(decode(await p.output()), "");
assertStringContains(
decode(await p.stderrOutput()),
- "Uncaught PermissionDenied"
+ "Uncaught PermissionDenied",
);
p.close();
});
diff --git a/std/fs/move.ts b/std/fs/move.ts
index 6aeca29ea..421ca0771 100644
--- a/std/fs/move.ts
+++ b/std/fs/move.ts
@@ -10,13 +10,13 @@ interface MoveOptions {
export async function move(
src: string,
dest: string,
- { overwrite = false }: MoveOptions = {}
+ { overwrite = false }: MoveOptions = {},
): Promise<void> {
const srcStat = await Deno.stat(src);
if (srcStat.isDirectory && isSubdir(src, dest)) {
throw new Error(
- `Cannot move '${src}' to a subdirectory of itself, '${dest}'.`
+ `Cannot move '${src}' to a subdirectory of itself, '${dest}'.`,
);
}
@@ -39,13 +39,13 @@ export async function move(
export function moveSync(
src: string,
dest: string,
- { overwrite = false }: MoveOptions = {}
+ { overwrite = false }: MoveOptions = {},
): void {
const srcStat = Deno.statSync(src);
if (srcStat.isDirectory && isSubdir(src, dest)) {
throw new Error(
- `Cannot move '${src}' to a subdirectory of itself, '${dest}'.`
+ `Cannot move '${src}' to a subdirectory of itself, '${dest}'.`,
);
}
diff --git a/std/fs/move_test.ts b/std/fs/move_test.ts
index fdf451125..73a96ce46 100644
--- a/std/fs/move_test.ts
+++ b/std/fs/move_test.ts
@@ -19,7 +19,7 @@ Deno.test("moveDirectoryIfSrcNotExists", async function (): Promise<void> {
await assertThrowsAsync(
async (): Promise<void> => {
await move(srcDir, destDir);
- }
+ },
);
});
@@ -36,7 +36,7 @@ Deno.test("moveDirectoryIfDestNotExists", async function (): Promise<void> {
throw new Error("should not throw error");
},
Error,
- "should not throw error"
+ "should not throw error",
);
await Deno.remove(destDir);
@@ -57,11 +57,11 @@ Deno.test(
throw new Error("should not throw error");
},
Error,
- "should not throw error"
+ "should not throw error",
);
await Deno.remove(destDir);
- }
+ },
);
Deno.test("moveFileIfSrcNotExists", async function (): Promise<void> {
@@ -72,7 +72,7 @@ Deno.test("moveFileIfSrcNotExists", async function (): Promise<void> {
await assertThrowsAsync(
async (): Promise<void> => {
await move(srcFile, destFile);
- }
+ },
);
});
@@ -103,7 +103,7 @@ Deno.test("moveFileIfDestExists", async function (): Promise<void> {
await move(srcFile, destFile);
},
Error,
- "dest already exists"
+ "dest already exists",
);
// move again with overwrite
@@ -113,7 +113,7 @@ Deno.test("moveFileIfDestExists", async function (): Promise<void> {
throw new Error("should not throw error");
},
Error,
- "should not throw error"
+ "should not throw error",
);
assertEquals(await exists(srcFile), false);
@@ -144,7 +144,7 @@ Deno.test("moveDirectory", async function (): Promise<void> {
assertEquals(await exists(destFile), true);
const destFileContent = new TextDecoder().decode(
- await Deno.readFile(destFile)
+ await Deno.readFile(destFile),
);
assertEquals(destFileContent, "src");
@@ -179,12 +179,12 @@ Deno.test(
assertEquals(await exists(destFile), true);
const destFileContent = new TextDecoder().decode(
- await Deno.readFile(destFile)
+ await Deno.readFile(destFile),
);
assertEquals(destFileContent, "src");
await Deno.remove(destDir, { recursive: true });
- }
+ },
);
Deno.test("moveIntoSubDir", async function (): Promise<void> {
@@ -198,7 +198,7 @@ Deno.test("moveIntoSubDir", async function (): Promise<void> {
await move(srcDir, destDir);
},
Error,
- `Cannot move '${srcDir}' to a subdirectory of itself, '${destDir}'.`
+ `Cannot move '${srcDir}' to a subdirectory of itself, '${destDir}'.`,
);
await Deno.remove(srcDir, { recursive: true });
});
@@ -225,7 +225,7 @@ Deno.test("moveSyncDirectoryIfDestNotExists", function (): void {
throw new Error("should not throw error");
},
Error,
- "should not throw error"
+ "should not throw error",
);
Deno.removeSync(destDir);
@@ -244,7 +244,7 @@ Deno.test("moveSyncDirectoryIfDestNotExistsAndOverwrite", function (): void {
throw new Error("should not throw error");
},
Error,
- "should not throw error"
+ "should not throw error",
);
Deno.removeSync(destDir);
@@ -286,7 +286,7 @@ Deno.test("moveSyncFileIfDestExists", function (): void {
moveSync(srcFile, destFile);
},
Error,
- "dest already exists"
+ "dest already exists",
);
// move again with overwrite
@@ -296,7 +296,7 @@ Deno.test("moveSyncFileIfDestExists", function (): void {
throw new Error("should not throw error");
},
Error,
- "should not throw error"
+ "should not throw error",
);
assertEquals(existsSync(srcFile), false);
@@ -368,7 +368,7 @@ Deno.test("moveSyncIntoSubDir", function (): void {
moveSync(srcDir, destDir);
},
Error,
- `Cannot move '${srcDir}' to a subdirectory of itself, '${destDir}'.`
+ `Cannot move '${srcDir}' to a subdirectory of itself, '${destDir}'.`,
);
Deno.removeSync(srcDir, { recursive: true });
});
diff --git a/std/fs/read_file_str.ts b/std/fs/read_file_str.ts
index 7420183e2..9aa50f15a 100644
--- a/std/fs/read_file_str.ts
+++ b/std/fs/read_file_str.ts
@@ -12,7 +12,7 @@ export interface ReadOptions {
*/
export function readFileStrSync(
filename: string,
- opts: ReadOptions = {}
+ opts: ReadOptions = {},
): string {
const decoder = new TextDecoder(opts.encoding);
return decoder.decode(Deno.readFileSync(filename));
@@ -26,7 +26,7 @@ export function readFileStrSync(
*/
export async function readFileStr(
filename: string,
- opts: ReadOptions = {}
+ opts: ReadOptions = {},
): Promise<string> {
const decoder = new TextDecoder(opts.encoding);
return decoder.decode(await Deno.readFile(filename));
diff --git a/std/fs/read_json_test.ts b/std/fs/read_json_test.ts
index edc5d8800..c910c6334 100644
--- a/std/fs/read_json_test.ts
+++ b/std/fs/read_json_test.ts
@@ -15,7 +15,7 @@ Deno.test("readJsonFileNotExists", async function (): Promise<void> {
await assertThrowsAsync(
async (): Promise<void> => {
await readJson(emptyJsonFile);
- }
+ },
);
});
@@ -25,7 +25,7 @@ Deno.test("readEmptyJsonFile", async function (): Promise<void> {
await assertThrowsAsync(
async (): Promise<void> => {
await readJson(emptyJsonFile);
- }
+ },
);
});
@@ -35,7 +35,7 @@ Deno.test("readInvalidJsonFile", async function (): Promise<void> {
await assertThrowsAsync(
async (): Promise<void> => {
await readJson(invalidJsonFile);
- }
+ },
);
});
diff --git a/std/fs/walk.ts b/std/fs/walk.ts
index 0292b77ef..8f2196833 100644
--- a/std/fs/walk.ts
+++ b/std/fs/walk.ts
@@ -44,7 +44,7 @@ function include(
path: string,
exts?: string[],
match?: RegExp[],
- skip?: RegExp[]
+ skip?: RegExp[],
): boolean {
if (exts && !exts.some((ext): boolean => path.endsWith(ext))) {
return false;
@@ -91,7 +91,7 @@ export async function* walk(
exts = undefined,
match = undefined,
skip = undefined,
- }: WalkOptions = {}
+ }: WalkOptions = {},
): AsyncIterableIterator<WalkEntry> {
if (maxDepth < 0) {
return;
@@ -144,7 +144,7 @@ export function* walkSync(
exts = undefined,
match = undefined,
skip = undefined,
- }: WalkOptions = {}
+ }: WalkOptions = {},
): IterableIterator<WalkEntry> {
if (maxDepth < 0) {
return;
diff --git a/std/fs/walk_test.ts b/std/fs/walk_test.ts
index 52fd4ff57..df4525b95 100644
--- a/std/fs/walk_test.ts
+++ b/std/fs/walk_test.ts
@@ -4,7 +4,7 @@ import { assert, assertEquals, assertThrowsAsync } from "../testing/asserts.ts";
export function testWalk(
setup: (arg0: string) => void | Promise<void>,
t: () => void | Promise<void>,
- ignore = false
+ ignore = false,
): void {
const name = t.name;
async function fn(): Promise<void> {
@@ -28,7 +28,7 @@ function normalize({ path }: WalkEntry): string {
export async function walkArray(
root: string,
- options: WalkOptions = {}
+ options: WalkOptions = {},
): Promise<string[]> {
const arr: string[] = [];
for await (const w of walk(root, { ...options })) {
@@ -59,7 +59,7 @@ testWalk(
async function emptyDir(): Promise<void> {
const arr = await walkArray(".");
assertEquals(arr, [".", "empty"]);
- }
+ },
);
testWalk(
@@ -69,7 +69,7 @@ testWalk(
async function singleFile(): Promise<void> {
const arr = await walkArray(".");
assertEquals(arr, [".", "x"]);
- }
+ },
);
testWalk(
@@ -86,7 +86,7 @@ testWalk(
count += 1;
}
assertEquals(count, 4);
- }
+ },
);
testWalk(
@@ -97,7 +97,7 @@ testWalk(
async function nestedSingleFile(): Promise<void> {
const arr = await walkArray(".");
assertEquals(arr, [".", "a", "a/x"]);
- }
+ },
);
testWalk(
@@ -111,7 +111,7 @@ testWalk(
assertEquals(arr3, [".", "a", "a/b", "a/b/c"]);
const arr5 = await walkArray(".", { maxDepth: 5 });
assertEquals(arr5, [".", "a", "a/b", "a/b/c", "a/b/c/d", "a/b/c/d/x"]);
- }
+ },
);
testWalk(
@@ -124,7 +124,7 @@ testWalk(
assertReady(4);
const arr = await walkArray(".", { includeDirs: false });
assertEquals(arr, ["a", "b/c"]);
- }
+ },
);
testWalk(
@@ -137,7 +137,7 @@ testWalk(
assertReady(4);
const arr = await walkArray(".", { includeFiles: false });
assertEquals(arr, [".", "b"]);
- }
+ },
);
testWalk(
@@ -149,7 +149,7 @@ testWalk(
assertReady(3);
const arr = await walkArray(".", { exts: [".ts"] });
assertEquals(arr, ["x.ts"]);
- }
+ },
);
testWalk(
@@ -162,7 +162,7 @@ testWalk(
assertReady(4);
const arr = await walkArray(".", { exts: [".rs", ".ts"] });
assertEquals(arr, ["x.ts", "y.rs"]);
- }
+ },
);
testWalk(
@@ -174,7 +174,7 @@ testWalk(
assertReady(3);
const arr = await walkArray(".", { match: [/x/] });
assertEquals(arr, ["x"]);
- }
+ },
);
testWalk(
@@ -187,7 +187,7 @@ testWalk(
assertReady(4);
const arr = await walkArray(".", { match: [/x/, /y/] });
assertEquals(arr, ["x", "y"]);
- }
+ },
);
testWalk(
@@ -199,7 +199,7 @@ testWalk(
assertReady(3);
const arr = await walkArray(".", { skip: [/x/] });
assertEquals(arr, [".", "y"]);
- }
+ },
);
testWalk(
@@ -212,7 +212,7 @@ testWalk(
assertReady(4);
const arr = await walkArray(".", { skip: [/x/, /y/] });
assertEquals(arr, [".", "z"]);
- }
+ },
);
testWalk(
@@ -227,7 +227,7 @@ testWalk(
assertReady(6);
const arr = await walkArray("b");
assertEquals(arr, ["b", "b/z"]);
- }
+ },
);
testWalk(
@@ -236,7 +236,7 @@ testWalk(
await assertThrowsAsync(async () => {
await walkArray("nonexistent");
}, Deno.errors.NotFound);
- }
+ },
);
testWalk(
@@ -258,5 +258,5 @@ testWalk(
assertEquals(arr.length, 3);
assert(arr.some((f): boolean => f.endsWith("/b/z")));
},
- true
+ true,
);
diff --git a/std/fs/write_file_str.ts b/std/fs/write_file_str.ts
index 670399dcc..bf972f204 100644
--- a/std/fs/write_file_str.ts
+++ b/std/fs/write_file_str.ts
@@ -21,7 +21,7 @@ export function writeFileStrSync(filename: string, content: string): void {
*/
export async function writeFileStr(
filename: string,
- content: string
+ content: string,
): Promise<void> {
const encoder = new TextEncoder();
await Deno.writeFile(filename, encoder.encode(content));
diff --git a/std/fs/write_json.ts b/std/fs/write_json.ts
index 28eb80d44..015957bba 100644
--- a/std/fs/write_json.ts
+++ b/std/fs/write_json.ts
@@ -12,7 +12,7 @@ export async function writeJson(
filePath: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
object: any,
- options: WriteJsonOptions = {}
+ options: WriteJsonOptions = {},
): Promise<void> {
let contentRaw = "";
@@ -20,7 +20,7 @@ export async function writeJson(
contentRaw = JSON.stringify(
object,
options.replacer as string[],
- options.spaces
+ options.spaces,
);
} catch (err) {
err.message = `${filePath}: ${err.message}`;
@@ -35,7 +35,7 @@ export function writeJsonSync(
filePath: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
object: any,
- options: WriteJsonOptions = {}
+ options: WriteJsonOptions = {},
): void {
let contentRaw = "";
@@ -43,7 +43,7 @@ export function writeJsonSync(
contentRaw = JSON.stringify(
object,
options.replacer as string[],
- options.spaces
+ options.spaces,
);
} catch (err) {
err.message = `${filePath}: ${err.message}`;
diff --git a/std/fs/write_json_test.ts b/std/fs/write_json_test.ts
index 45d27c4f1..c22bd7bf1 100644
--- a/std/fs/write_json_test.ts
+++ b/std/fs/write_json_test.ts
@@ -18,7 +18,7 @@ Deno.test("writeJsonIfNotExists", async function (): Promise<void> {
throw new Error("should write success");
},
Error,
- "should write success"
+ "should write success",
);
const content = await Deno.readFile(notExistsJsonFile);
@@ -39,7 +39,7 @@ Deno.test("writeJsonIfExists", async function (): Promise<void> {
throw new Error("should write success");
},
Error,
- "should write success"
+ "should write success",
);
const content = await Deno.readFile(existsJsonFile);
@@ -52,7 +52,7 @@ Deno.test("writeJsonIfExists", async function (): Promise<void> {
Deno.test("writeJsonIfExistsAnInvalidJson", async function (): Promise<void> {
const existsInvalidJsonFile = path.join(
testdataDir,
- "file_write_invalid.json"
+ "file_write_invalid.json",
);
const invalidJsonContent = new TextEncoder().encode("[123}");
@@ -64,7 +64,7 @@ Deno.test("writeJsonIfExistsAnInvalidJson", async function (): Promise<void> {
throw new Error("should write success");
},
Error,
- "should write success"
+ "should write success",
);
const content = await Deno.readFile(existsInvalidJsonFile);
@@ -86,7 +86,7 @@ Deno.test("writeJsonWithSpaces", async function (): Promise<void> {
throw new Error("should write success");
},
Error,
- "should write success"
+ "should write success",
);
const content = await Deno.readFile(existsJsonFile);
@@ -109,12 +109,12 @@ Deno.test("writeJsonWithReplacer", async function (): Promise<void> {
{ a: "1", b: "2", c: "3" },
{
replacer: ["a"],
- }
+ },
);
throw new Error("should write success");
},
Error,
- "should write success"
+ "should write success",
);
const content = await Deno.readFile(existsJsonFile);
@@ -133,7 +133,7 @@ Deno.test("writeJsonSyncIfNotExists", function (): void {
throw new Error("should write success");
},
Error,
- "should write success"
+ "should write success",
);
const content = Deno.readFileSync(notExistsJsonFile);
@@ -154,7 +154,7 @@ Deno.test("writeJsonSyncIfExists", function (): void {
throw new Error("should write success");
},
Error,
- "should write success"
+ "should write success",
);
const content = Deno.readFileSync(existsJsonFile);
@@ -167,7 +167,7 @@ Deno.test("writeJsonSyncIfExists", function (): void {
Deno.test("writeJsonSyncIfExistsAnInvalidJson", function (): void {
const existsInvalidJsonFile = path.join(
testdataDir,
- "file_write_invalid_sync.json"
+ "file_write_invalid_sync.json",
);
const invalidJsonContent = new TextEncoder().encode("[123}");
@@ -179,7 +179,7 @@ Deno.test("writeJsonSyncIfExistsAnInvalidJson", function (): void {
throw new Error("should write success");
},
Error,
- "should write success"
+ "should write success",
);
const content = Deno.readFileSync(existsInvalidJsonFile);
@@ -201,7 +201,7 @@ Deno.test("writeJsonWithSpaces", function (): void {
throw new Error("should write success");
},
Error,
- "should write success"
+ "should write success",
);
const content = Deno.readFileSync(existsJsonFile);
@@ -214,7 +214,7 @@ Deno.test("writeJsonWithSpaces", function (): void {
Deno.test("writeJsonWithReplacer", function (): void {
const existsJsonFile = path.join(
testdataDir,
- "file_write_replacer_sync.json"
+ "file_write_replacer_sync.json",
);
const invalidJsonContent = new TextEncoder().encode();
@@ -227,12 +227,12 @@ Deno.test("writeJsonWithReplacer", function (): void {
{ a: "1", b: "2", c: "3" },
{
replacer: ["a"],
- }
+ },
);
throw new Error("should write success");
},
Error,
- "should write success"
+ "should write success",
);
const content = Deno.readFileSync(existsJsonFile);
diff --git a/std/hash/_fnv/util.ts b/std/hash/_fnv/util.ts
index 3d1cb5bac..096b70815 100644
--- a/std/hash/_fnv/util.ts
+++ b/std/hash/_fnv/util.ts
@@ -45,7 +45,7 @@ export function mul32(a: number, b: number): number {
*/
export function mul64(
[ah, al]: [number, number],
- [bh, bl]: [number, number]
+ [bh, bl]: [number, number],
): [number, number] {
const [n, c] = mul32WithCarry(al, bl);
return [n32(mul32(al, bh) + mul32(ah, bl) + c), n];
diff --git a/std/hash/hash_test.ts b/std/hash/hash_test.ts
index 5169c2107..4d7d7465d 100644
--- a/std/hash/hash_test.ts
+++ b/std/hash/hash_test.ts
@@ -311,6 +311,6 @@ Deno.test("[hash/double_digest] testDoubleDigest", () => {
assertEquals(h1, h2);
},
Error,
- "hash: already digested"
+ "hash: already digested",
);
});
diff --git a/std/hash/sha1.ts b/std/hash/sha1.ts
index e55b5e8d3..6a79db27b 100644
--- a/std/hash/sha1.ts
+++ b/std/hash/sha1.ts
@@ -33,6 +33,7 @@ export class Sha1 {
constructor(sharedMemory = false) {
if (sharedMemory) {
+ // deno-fmt-ignore
blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
this.#blocks = blocks;
} else {
@@ -70,6 +71,7 @@ export class Sha1 {
if (this.#hashed) {
this.#hashed = false;
blocks[0] = this.#block;
+ // deno-fmt-ignore
blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
}
@@ -90,8 +92,7 @@ export class Sha1 {
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
} else {
- code =
- 0x10000 +
+ code = 0x10000 +
(((code & 0x3ff) << 10) | (msg.charCodeAt(++index) & 0x3ff));
blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
@@ -134,6 +135,7 @@ export class Sha1 {
this.hash();
}
blocks[0] = this.#block;
+ // deno-fmt-ignore
blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
}
blocks[14] = (this.#hBytes << 3) | (this.#bytes >>> 29);
diff --git a/std/hash/sha1_test.ts b/std/hash/sha1_test.ts
index 2c78bb1c8..25571947f 100644
--- a/std/hash/sha1_test.ts
+++ b/std/hash/sha1_test.ts
@@ -16,7 +16,6 @@ function toHexString(value: number[] | ArrayBuffer): string {
return hex;
}
-// prettier-ignore
// deno-fmt-ignore
const fixtures: {
sha1: Record<string, Record<string, Message>>;
@@ -74,10 +73,9 @@ for (const method of methods) {
fn() {
const algorithm = new Sha1();
algorithm.update(message);
- const actual =
- method === "hex"
- ? algorithm[method]()
- : toHexString(algorithm[method]());
+ const actual = method === "hex"
+ ? algorithm[method]()
+ : toHexString(algorithm[method]());
assertEquals(actual, expected);
},
});
@@ -94,10 +92,9 @@ for (const method of methods) {
fn() {
const algorithm = new Sha1(true);
algorithm.update(message);
- const actual =
- method === "hex"
- ? algorithm[method]()
- : toHexString(algorithm[method]());
+ const actual = method === "hex"
+ ? algorithm[method]()
+ : toHexString(algorithm[method]());
assertEquals(actual, expected);
},
});
diff --git a/std/hash/sha256.ts b/std/hash/sha256.ts
index 61da5a578..e2456d7a1 100644
--- a/std/hash/sha256.ts
+++ b/std/hash/sha256.ts
@@ -14,7 +14,6 @@ export type Message = string | number[] | ArrayBuffer;
const HEX_CHARS = "0123456789abcdef".split("");
const EXTRA = [-2147483648, 8388608, 32768, 128] as const;
const SHIFT = [24, 16, 8, 0] as const;
-// prettier-ignore
// deno-fmt-ignore
const K = [
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
@@ -58,6 +57,7 @@ export class Sha256 {
protected init(is224: boolean, sharedMemory: boolean): void {
if (sharedMemory) {
+ // deno-fmt-ignore
blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
this.#blocks = blocks;
} else {
@@ -116,6 +116,7 @@ export class Sha256 {
if (this.#hashed) {
this.#hashed = false;
blocks[0] = this.#block;
+ // deno-fmt-ignore
blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
}
@@ -136,8 +137,7 @@ export class Sha256 {
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
} else {
- code =
- 0x10000 +
+ code = 0x10000 +
(((code & 0x3ff) << 10) | (msg.charCodeAt(++index) & 0x3ff));
blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
@@ -180,6 +180,7 @@ export class Sha256 {
this.hash();
}
blocks[0] = this.#block;
+ // deno-fmt-ignore
blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
}
blocks[14] = (this.#hBytes << 3) | (this.#bytes >>> 29);
@@ -213,8 +214,8 @@ export class Sha256 {
t1 = blocks[j - 15];
s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3);
t1 = blocks[j - 2];
- s1 =
- ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10);
+ s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^
+ (t1 >>> 10);
blocks[j] = (blocks[j - 16] + s0 + blocks[j - 7] + s1) << 0;
}
@@ -234,12 +235,10 @@ export class Sha256 {
}
this.#first = false;
} else {
- s0 =
- ((a >>> 2) | (a << 30)) ^
+ s0 = ((a >>> 2) | (a << 30)) ^
((a >>> 13) | (a << 19)) ^
((a >>> 22) | (a << 10));
- s1 =
- ((e >>> 6) | (e << 26)) ^
+ s1 = ((e >>> 6) | (e << 26)) ^
((e >>> 11) | (e << 21)) ^
((e >>> 25) | (e << 7));
ab = a & b;
@@ -250,12 +249,10 @@ export class Sha256 {
h = (d + t1) << 0;
d = (t1 + t2) << 0;
}
- s0 =
- ((d >>> 2) | (d << 30)) ^
+ s0 = ((d >>> 2) | (d << 30)) ^
((d >>> 13) | (d << 19)) ^
((d >>> 22) | (d << 10));
- s1 =
- ((h >>> 6) | (h << 26)) ^
+ s1 = ((h >>> 6) | (h << 26)) ^
((h >>> 11) | (h << 21)) ^
((h >>> 25) | (h << 7));
da = d & a;
@@ -265,12 +262,10 @@ export class Sha256 {
t2 = s0 + maj;
g = (c + t1) << 0;
c = (t1 + t2) << 0;
- s0 =
- ((c >>> 2) | (c << 30)) ^
+ s0 = ((c >>> 2) | (c << 30)) ^
((c >>> 13) | (c << 19)) ^
((c >>> 22) | (c << 10));
- s1 =
- ((g >>> 6) | (g << 26)) ^
+ s1 = ((g >>> 6) | (g << 26)) ^
((g >>> 11) | (g << 21)) ^
((g >>> 25) | (g << 7));
cd = c & d;
@@ -280,12 +275,10 @@ export class Sha256 {
t2 = s0 + maj;
f = (b + t1) << 0;
b = (t1 + t2) << 0;
- s0 =
- ((b >>> 2) | (b << 30)) ^
+ s0 = ((b >>> 2) | (b << 30)) ^
((b >>> 13) | (b << 19)) ^
((b >>> 22) | (b << 10));
- s1 =
- ((f >>> 6) | (f << 26)) ^
+ s1 = ((f >>> 6) | (f << 26)) ^
((f >>> 11) | (f << 21)) ^
((f >>> 25) | (f << 7));
bc = b & c;
@@ -320,8 +313,7 @@ export class Sha256 {
const h6 = this.#h6;
const h7 = this.#h7;
- let hex =
- HEX_CHARS[(h0 >> 28) & 0x0f] +
+ let hex = HEX_CHARS[(h0 >> 28) & 0x0f] +
HEX_CHARS[(h0 >> 24) & 0x0f] +
HEX_CHARS[(h0 >> 20) & 0x0f] +
HEX_CHARS[(h0 >> 16) & 0x0f] +
@@ -378,8 +370,7 @@ export class Sha256 {
HEX_CHARS[(h6 >> 4) & 0x0f] +
HEX_CHARS[h6 & 0x0f];
if (!this.#is224) {
- hex +=
- HEX_CHARS[(h7 >> 28) & 0x0f] +
+ hex += HEX_CHARS[(h7 >> 28) & 0x0f] +
HEX_CHARS[(h7 >> 24) & 0x0f] +
HEX_CHARS[(h7 >> 20) & 0x0f] +
HEX_CHARS[(h7 >> 16) & 0x0f] +
@@ -444,7 +435,7 @@ export class Sha256 {
(h7 >> 24) & 0xff,
(h7 >> 16) & 0xff,
(h7 >> 8) & 0xff,
- h7 & 0xff
+ h7 & 0xff,
);
}
return arr;
@@ -501,8 +492,7 @@ export class HmacSha256 extends Sha256 {
bytes[index++] = 0x80 | ((code >> 6) & 0x3f);
bytes[index++] = 0x80 | (code & 0x3f);
} else {
- code =
- 0x10000 +
+ code = 0x10000 +
(((code & 0x3ff) << 10) | (secretKey.charCodeAt(++i) & 0x3ff));
bytes[index++] = 0xf0 | (code >> 18);
bytes[index++] = 0x80 | ((code >> 12) & 0x3f);
diff --git a/std/hash/sha256_test.ts b/std/hash/sha256_test.ts
index 3cf4cbdf2..ba7efe4d1 100644
--- a/std/hash/sha256_test.ts
+++ b/std/hash/sha256_test.ts
@@ -16,7 +16,6 @@ function toHexString(value: number[] | ArrayBuffer): string {
return hex;
}
-// prettier-ignore
// deno-fmt-ignore
const fixtures: {
sha256: Record<string, Record<string, Message>>;
@@ -155,35 +154,29 @@ const fixtures: {
},
};
-// prettier-ignore
// deno-fmt-ignore
fixtures.sha256.Uint8Array = {
'182889f925ae4e5cc37118ded6ed87f7bdc7cab5ec5e78faef2e50048999473f': new Uint8Array([211, 212]),
'd7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592': new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103])
};
-// prettier-ignore
// deno-fmt-ignore
fixtures.sha256.Int8Array = {
'd7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592': new Int8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103])
};
-// prettier-ignore
// deno-fmt-ignore
fixtures.sha256.ArrayBuffer = {
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855': new ArrayBuffer(0),
'6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d': new ArrayBuffer(1)
};
-// prettier-ignore
// deno-fmt-ignore
fixtures.sha224.Uint8Array = {
'e17541396a3ecd1cd5a2b968b84e597e8eae3b0ea3127963bf48dd3b': new Uint8Array([211, 212]),
'730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525': new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103])
};
-// prettier-ignore
// deno-fmt-ignore
fixtures.sha224.Int8Array = {
'730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525': new Int8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103])
};
-// prettier-ignore
// deno-fmt-ignore
fixtures.sha224.ArrayBuffer = {
'd14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f': new ArrayBuffer(0),
@@ -225,10 +218,9 @@ for (const method of methods) {
fn() {
const algorithm = new Sha256();
algorithm.update(message);
- const actual =
- method === "hex"
- ? algorithm[method]()
- : toHexString(algorithm[method]());
+ const actual = method === "hex"
+ ? algorithm[method]()
+ : toHexString(algorithm[method]());
assertEquals(actual, expected);
},
});
@@ -245,10 +237,9 @@ for (const method of methods) {
fn() {
const algorithm = new Sha256(true);
algorithm.update(message);
- const actual =
- method === "hex"
- ? algorithm[method]()
- : toHexString(algorithm[method]());
+ const actual = method === "hex"
+ ? algorithm[method]()
+ : toHexString(algorithm[method]());
assertEquals(actual, expected);
},
});
@@ -265,10 +256,9 @@ for (const method of methods) {
fn() {
const algorithm = new HmacSha256(key);
algorithm.update(message);
- const actual =
- method === "hex"
- ? algorithm[method]()
- : toHexString(algorithm[method]());
+ const actual = method === "hex"
+ ? algorithm[method]()
+ : toHexString(algorithm[method]());
assertEquals(actual, expected);
},
});
@@ -285,10 +275,9 @@ for (const method of methods) {
fn() {
const algorithm = new HmacSha256(key, true);
algorithm.update(message);
- const actual =
- method === "hex"
- ? algorithm[method]()
- : toHexString(algorithm[method]());
+ const actual = method === "hex"
+ ? algorithm[method]()
+ : toHexString(algorithm[method]());
assertEquals(actual, expected);
},
});
@@ -302,6 +291,6 @@ Deno.test("[hash/sha256] test Uint8Array from Reader", async () => {
const hash = new Sha256().update(data).hex();
assertEquals(
hash,
- "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
+ "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
);
});
diff --git a/std/hash/sha3_test.ts b/std/hash/sha3_test.ts
index 64e426385..b5936f960 100644
--- a/std/hash/sha3_test.ts
+++ b/std/hash/sha3_test.ts
@@ -554,7 +554,7 @@ Deno.test("[hash/sha3] testSha3-256Chain", () => {
assertEquals(
output,
- "3a985da74fe225b2045c172d6bd390bd855f086e3e9d525b46bfe24511431532"
+ "3a985da74fe225b2045c172d6bd390bd855f086e3e9d525b46bfe24511431532",
);
});
@@ -567,6 +567,6 @@ Deno.test("[hash/sha3] testSha3UpdateFinalized", () => {
assertEquals(hash, hash2);
},
Error,
- "sha3: cannot update already finalized hash"
+ "sha3: cannot update already finalized hash",
);
});
diff --git a/std/hash/sha512.ts b/std/hash/sha512.ts
index b55069f4d..1eef85a47 100644
--- a/std/hash/sha512.ts
+++ b/std/hash/sha512.ts
@@ -9,11 +9,11 @@
export type Message = string | number[] | ArrayBuffer;
-// prettier-ignore
+// deno-fmt-ignore
const HEX_CHARS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"] as const;
const EXTRA = [-2147483648, 8388608, 32768, 128] as const;
const SHIFT = [24, 16, 8, 0] as const;
-// prettier-ignore
+// deno-fmt-ignore
const K = [
0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, 0x3956c25b,
0xf348b538, 0x59f111f1, 0xb605d019, 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, 0xd807aa98, 0xa3030242,
@@ -37,7 +37,7 @@ const K = [
const blocks: number[] = [];
-// prettier-ignore
+// deno-fmt-ignore
export class Sha512 {
#blocks!: number[];
#block!: number;
@@ -564,7 +564,7 @@ export class Sha512 {
h0h = this.#h0h, h0l = this.#h0l, h1h = this.#h1h, h1l = this.#h1l, h2h = this.#h2h, h2l = this.#h2l,
h3h = this.#h3h, h3l = this.#h3l, h4h = this.#h4h, h4l = this.#h4l, h5h = this.#h5h, h5l = this.#h5l,
h6h = this.#h6h, h6l = this.#h6l, h7h = this.#h7h, h7l = this.#h7l, bits = this.#bits;
- let hex =
+ let hex =
HEX_CHARS[(h0h >> 28) & 0x0f] + HEX_CHARS[(h0h >> 24) & 0x0f] +
HEX_CHARS[(h0h >> 20) & 0x0f] + HEX_CHARS[(h0h >> 16) & 0x0f] +
HEX_CHARS[(h0h >> 12) & 0x0f] + HEX_CHARS[(h0h >> 8) & 0x0f] +
@@ -747,8 +747,7 @@ export class HmacSha512 extends Sha512 {
bytes[index++] = 0x80 | ((code >> 6) & 0x3f);
bytes[index++] = 0x80 | (code & 0x3f);
} else {
- code =
- 0x10000 +
+ code = 0x10000 +
(((code & 0x3ff) << 10) | (secretKey.charCodeAt(++i) & 0x3ff));
bytes[index++] = 0xf0 | (code >> 18);
bytes[index++] = 0x80 | ((code >> 12) & 0x3f);
diff --git a/std/hash/sha512_test.ts b/std/hash/sha512_test.ts
index c656731a3..d8d69a923 100644
--- a/std/hash/sha512_test.ts
+++ b/std/hash/sha512_test.ts
@@ -16,7 +16,6 @@ function toHexString(value: number[] | ArrayBuffer): string {
return hex;
}
-// prettier-ignore
// deno-fmt-ignore
const fixtures: {
sha512bits224: Record<string, Record<string, Message>>,
@@ -285,10 +284,9 @@ for (const method of methods) {
fn() {
const algorithm = new Sha512(224);
algorithm.update(message);
- const actual =
- method === "hex"
- ? algorithm[method]()
- : toHexString(algorithm[method]());
+ const actual = method === "hex"
+ ? algorithm[method]()
+ : toHexString(algorithm[method]());
assertEquals(actual, expected);
},
});
@@ -305,10 +303,9 @@ for (const method of methods) {
fn() {
const algorithm = new Sha512(256);
algorithm.update(message);
- const actual =
- method === "hex"
- ? algorithm[method]()
- : toHexString(algorithm[method]());
+ const actual = method === "hex"
+ ? algorithm[method]()
+ : toHexString(algorithm[method]());
assertEquals(actual, expected);
},
});
@@ -325,10 +322,9 @@ for (const method of methods) {
fn() {
const algorithm = new Sha512();
algorithm.update(message);
- const actual =
- method === "hex"
- ? algorithm[method]()
- : toHexString(algorithm[method]());
+ const actual = method === "hex"
+ ? algorithm[method]()
+ : toHexString(algorithm[method]());
assertEquals(actual, expected);
},
});
@@ -345,10 +341,9 @@ for (const method of methods) {
fn() {
const algorithm = new HmacSha512(key, 224);
algorithm.update(message);
- const actual =
- method === "hex"
- ? algorithm[method]()
- : toHexString(algorithm[method]());
+ const actual = method === "hex"
+ ? algorithm[method]()
+ : toHexString(algorithm[method]());
assertEquals(actual, expected);
},
});
@@ -365,10 +360,9 @@ for (const method of methods) {
fn() {
const algorithm = new HmacSha512(key, 256);
algorithm.update(message);
- const actual =
- method === "hex"
- ? algorithm[method]()
- : toHexString(algorithm[method]());
+ const actual = method === "hex"
+ ? algorithm[method]()
+ : toHexString(algorithm[method]());
assertEquals(actual, expected);
},
});
@@ -385,10 +379,9 @@ for (const method of methods) {
fn() {
const algorithm = new HmacSha512(key);
algorithm.update(message);
- const actual =
- method === "hex"
- ? algorithm[method]()
- : toHexString(algorithm[method]());
+ const actual = method === "hex"
+ ? algorithm[method]()
+ : toHexString(algorithm[method]());
assertEquals(actual, expected);
},
});
@@ -401,6 +394,6 @@ Deno.test("[hash/sha512] test Uint8Array from Reader", async () => {
const hash = new Sha512().update(data).hex();
assertEquals(
hash,
- "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff"
+ "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff",
);
});
diff --git a/std/http/_io.ts b/std/http/_io.ts
index 1db0fc292..743f52556 100644
--- a/std/http/_io.ts
+++ b/std/http/_io.ts
@@ -122,7 +122,7 @@ function isProhibidedForTrailer(key: string): boolean {
* field will be deleted. */
export async function readTrailers(
headers: Headers,
- r: BufReader
+ r: BufReader,
): Promise<void> {
const trailers = parseTrailer(headers.get("trailer"));
if (trailers == null) return;
@@ -133,11 +133,11 @@ export async function readTrailers(
throw new Deno.errors.InvalidData("Missing trailer header.");
}
const undeclared = [...result.keys()].filter(
- (k) => !trailerNames.includes(k)
+ (k) => !trailerNames.includes(k),
);
if (undeclared.length > 0) {
throw new Deno.errors.InvalidData(
- `Undeclared trailers: ${Deno.inspect(undeclared)}.`
+ `Undeclared trailers: ${Deno.inspect(undeclared)}.`,
);
}
for (const [k, v] of result) {
@@ -146,7 +146,7 @@ export async function readTrailers(
const missingTrailers = trailerNames.filter((k) => !result.has(k));
if (missingTrailers.length > 0) {
throw new Deno.errors.InvalidData(
- `Missing trailers: ${Deno.inspect(missingTrailers)}.`
+ `Missing trailers: ${Deno.inspect(missingTrailers)}.`,
);
}
headers.delete("trailer");
@@ -163,7 +163,7 @@ function parseTrailer(field: string | null): Headers | undefined {
const prohibited = trailerNames.filter((k) => isProhibidedForTrailer(k));
if (prohibited.length > 0) {
throw new Deno.errors.InvalidData(
- `Prohibited trailer names: ${Deno.inspect(prohibited)}.`
+ `Prohibited trailer names: ${Deno.inspect(prohibited)}.`,
);
}
return new Headers(trailerNames.map((key) => [key, ""]));
@@ -171,7 +171,7 @@ function parseTrailer(field: string | null): Headers | undefined {
export async function writeChunkedBody(
w: Deno.Writer,
- r: Deno.Reader
+ r: Deno.Reader,
): Promise<void> {
const writer = BufWriter.create(w);
for await (const chunk of Deno.iter(r)) {
@@ -192,7 +192,7 @@ export async function writeChunkedBody(
export async function writeTrailers(
w: Deno.Writer,
headers: Headers,
- trailers: Headers
+ trailers: Headers,
): Promise<void> {
const trailer = headers.get("trailer");
if (trailer === null) {
@@ -201,7 +201,7 @@ export async function writeTrailers(
const transferEncoding = headers.get("transfer-encoding");
if (transferEncoding === null || !transferEncoding.match(/^chunked/)) {
throw new TypeError(
- `Trailers are only allowed for "transfer-encoding: chunked", got "transfer-encoding: ${transferEncoding}".`
+ `Trailers are only allowed for "transfer-encoding: chunked", got "transfer-encoding: ${transferEncoding}".`,
);
}
const writer = BufWriter.create(w);
@@ -211,11 +211,11 @@ export async function writeTrailers(
);
if (prohibitedTrailers.length > 0) {
throw new TypeError(
- `Prohibited trailer names: ${Deno.inspect(prohibitedTrailers)}.`
+ `Prohibited trailer names: ${Deno.inspect(prohibitedTrailers)}.`,
);
}
const undeclared = [...trailers.keys()].filter(
- (k) => !trailerNames.includes(k)
+ (k) => !trailerNames.includes(k),
);
if (undeclared.length > 0) {
throw new TypeError(`Undeclared trailers: ${Deno.inspect(undeclared)}.`);
@@ -229,7 +229,7 @@ export async function writeTrailers(
export async function writeResponse(
w: Deno.Writer,
- r: Response
+ r: Response,
): Promise<void> {
const protoMajor = 1;
const protoMinor = 1;
@@ -333,7 +333,7 @@ export function parseHTTPVersion(vers: string): [number, number] {
export async function readRequest(
conn: Deno.Conn,
- bufr: BufReader
+ bufr: BufReader,
): Promise<ServerRequest | null> {
const tp = new TextProtoReader(bufr);
const firstLine = await tp.readLine(); // e.g. GET /index.html HTTP/1.0
@@ -372,7 +372,7 @@ function fixLength(req: ServerRequest): void {
// that contains a Transfer-Encoding header field.
// rfc: https://tools.ietf.org/html/rfc7230#section-3.3.2
throw new Error(
- "http: Transfer-Encoding and Content-Length cannot be send together"
+ "http: Transfer-Encoding and Content-Length cannot be send together",
);
}
}
diff --git a/std/http/_io_test.ts b/std/http/_io_test.ts
index 473c40637..77d8288f2 100644
--- a/std/http/_io_test.ts
+++ b/std/http/_io_test.ts
@@ -23,7 +23,7 @@ Deno.test("bodyReader", async () => {
const text = "Hello, Deno";
const r = bodyReader(
text.length,
- new BufReader(new Deno.Buffer(encode(text)))
+ new BufReader(new Deno.Buffer(encode(text))),
);
assertEquals(decode(await Deno.readAll(r)), text);
});
@@ -108,14 +108,14 @@ Deno.test(
async () => {
await readTrailers(
h,
- new BufReader(new Deno.Buffer(encode(trailer)))
+ new BufReader(new Deno.Buffer(encode(trailer))),
);
},
Deno.errors.InvalidData,
- `Undeclared trailers: [ "`
+ `Undeclared trailers: [ "`,
);
}
- }
+ },
);
Deno.test(
@@ -130,10 +130,10 @@ Deno.test(
await readTrailers(h, new BufReader(new Deno.Buffer()));
},
Deno.errors.InvalidData,
- `Prohibited trailer names: [ "`
+ `Prohibited trailer names: [ "`,
);
}
- }
+ },
);
Deno.test("writeTrailer", async () => {
@@ -141,11 +141,11 @@ Deno.test("writeTrailer", async () => {
await writeTrailers(
w,
new Headers({ "transfer-encoding": "chunked", trailer: "deno,node" }),
- new Headers({ deno: "land", node: "js" })
+ new Headers({ deno: "land", node: "js" }),
);
assertEquals(
new TextDecoder().decode(w.bytes()),
- "deno: land\r\nnode: js\r\n\r\n"
+ "deno: land\r\nnode: js\r\n\r\n",
);
});
@@ -156,14 +156,14 @@ Deno.test("writeTrailer should throw", async () => {
return writeTrailers(w, new Headers(), new Headers());
},
TypeError,
- "Missing trailer header."
+ "Missing trailer header.",
);
await assertThrowsAsync(
() => {
return writeTrailers(w, new Headers({ trailer: "deno" }), new Headers());
},
TypeError,
- `Trailers are only allowed for "transfer-encoding: chunked", got "transfer-encoding: null".`
+ `Trailers are only allowed for "transfer-encoding: chunked", got "transfer-encoding: null".`,
);
for (const f of ["content-length", "trailer", "transfer-encoding"]) {
await assertThrowsAsync(
@@ -171,11 +171,11 @@ Deno.test("writeTrailer should throw", async () => {
return writeTrailers(
w,
new Headers({ "transfer-encoding": "chunked", trailer: f }),
- new Headers({ [f]: "1" })
+ new Headers({ [f]: "1" }),
);
},
TypeError,
- `Prohibited trailer names: [ "`
+ `Prohibited trailer names: [ "`,
);
}
await assertThrowsAsync(
@@ -183,11 +183,11 @@ Deno.test("writeTrailer should throw", async () => {
return writeTrailers(
w,
new Headers({ "transfer-encoding": "chunked", trailer: "deno" }),
- new Headers({ node: "js" })
+ new Headers({ node: "js" }),
);
},
TypeError,
- `Undeclared trailers: [ "node" ].`
+ `Undeclared trailers: [ "node" ].`,
);
});
@@ -419,20 +419,17 @@ Deno.test("testReadRequestError", async function (): Promise<void> {
// deduplicated if same or reject otherwise
// See Issue 16490.
{
- in:
- "POST / HTTP/1.1\r\nContent-Length: 10\r\nContent-Length: 0\r\n\r\n" +
+ in: "POST / HTTP/1.1\r\nContent-Length: 10\r\nContent-Length: 0\r\n\r\n" +
"Gopher hey\r\n",
err: "cannot contain multiple Content-Length headers",
},
{
- in:
- "POST / HTTP/1.1\r\nContent-Length: 10\r\nContent-Length: 6\r\n\r\n" +
+ in: "POST / HTTP/1.1\r\nContent-Length: 10\r\nContent-Length: 6\r\n\r\n" +
"Gopher\r\n",
err: "cannot contain multiple Content-Length headers",
},
{
- in:
- "PUT / HTTP/1.1\r\nContent-Length: 6 \r\nContent-Length: 6\r\n" +
+ in: "PUT / HTTP/1.1\r\nContent-Length: 6 \r\nContent-Length: 6\r\n" +
"Content-Length:6\r\n\r\nGopher\r\n",
headers: [{ key: "Content-Length", value: "6" }],
},
@@ -451,8 +448,7 @@ Deno.test("testReadRequestError", async function (): Promise<void> {
headers: [{ key: "Content-Length", value: "0" }],
},
{
- in:
- "POST / HTTP/1.1\r\nContent-Length:0\r\ntransfer-encoding: " +
+ in: "POST / HTTP/1.1\r\nContent-Length:0\r\ntransfer-encoding: " +
"chunked\r\n\r\n",
headers: [],
err: "http: Transfer-Encoding and Content-Length cannot be send together",
diff --git a/std/http/cookie_test.ts b/std/http/cookie_test.ts
index 0b412d8e4..f34f5acae 100644
--- a/std/http/cookie_test.ts
+++ b/std/http/cookie_test.ts
@@ -38,7 +38,7 @@ Deno.test({
deleteCookie(res, "deno");
assertEquals(
res.headers?.get("Set-Cookie"),
- "deno=; Expires=Thu, 01 Jan 1970 00:00:00 GMT"
+ "deno=; Expires=Thu, 01 Jan 1970 00:00:00 GMT",
);
},
});
@@ -79,7 +79,7 @@ Deno.test({
});
assertEquals(
res.headers.get("Set-Cookie"),
- "Space=Cat; Secure; HttpOnly; Max-Age=2"
+ "Space=Cat; Secure; HttpOnly; Max-Age=2",
);
let error = false;
@@ -108,7 +108,7 @@ Deno.test({
});
assertEquals(
res.headers.get("Set-Cookie"),
- "Space=Cat; Secure; HttpOnly; Max-Age=2; Domain=deno.land"
+ "Space=Cat; Secure; HttpOnly; Max-Age=2; Domain=deno.land",
);
res.headers = new Headers();
@@ -124,7 +124,7 @@ Deno.test({
assertEquals(
res.headers.get("Set-Cookie"),
"Space=Cat; Secure; HttpOnly; Max-Age=2; Domain=deno.land; " +
- "SameSite=Strict"
+ "SameSite=Strict",
);
res.headers = new Headers();
@@ -139,7 +139,7 @@ Deno.test({
});
assertEquals(
res.headers.get("Set-Cookie"),
- "Space=Cat; Secure; HttpOnly; Max-Age=2; Domain=deno.land; SameSite=Lax"
+ "Space=Cat; Secure; HttpOnly; Max-Age=2; Domain=deno.land; SameSite=Lax",
);
res.headers = new Headers();
@@ -154,7 +154,7 @@ Deno.test({
});
assertEquals(
res.headers.get("Set-Cookie"),
- "Space=Cat; Secure; HttpOnly; Max-Age=2; Domain=deno.land; Path=/"
+ "Space=Cat; Secure; HttpOnly; Max-Age=2; Domain=deno.land; Path=/",
);
res.headers = new Headers();
@@ -171,7 +171,7 @@ Deno.test({
assertEquals(
res.headers.get("Set-Cookie"),
"Space=Cat; Secure; HttpOnly; Max-Age=2; Domain=deno.land; Path=/; " +
- "unparsed=keyvalue; batman=Bruce"
+ "unparsed=keyvalue; batman=Bruce",
);
res.headers = new Headers();
@@ -188,7 +188,7 @@ Deno.test({
assertEquals(
res.headers.get("Set-Cookie"),
"Space=Cat; Secure; HttpOnly; Max-Age=2; Domain=deno.land; Path=/; " +
- "Expires=Fri, 07 Jan 1983 15:32:00 GMT"
+ "Expires=Fri, 07 Jan 1983 15:32:00 GMT",
);
res.headers = new Headers();
@@ -203,7 +203,7 @@ Deno.test({
});
assertEquals(
res.headers.get("Set-Cookie"),
- "__Host-Kitty=Meow; Secure; Path=/"
+ "__Host-Kitty=Meow; Secure; Path=/",
);
res.headers = new Headers();
@@ -211,7 +211,7 @@ Deno.test({
setCookie(res, { name: "cookie-2", value: "value-2", maxAge: 3600 });
assertEquals(
res.headers.get("Set-Cookie"),
- "cookie-1=value-1; Secure, cookie-2=value-2; Max-Age=3600"
+ "cookie-1=value-1; Secure, cookie-2=value-2; Max-Age=3600",
);
res.headers = new Headers();
diff --git a/std/http/file_server.ts b/std/http/file_server.ts
index a66118e74..ffcf31e54 100755
--- a/std/http/file_server.ts
+++ b/std/http/file_server.ts
@@ -97,7 +97,7 @@ function fileLenToString(len: number): string {
export async function serveFile(
req: ServerRequest,
- filePath: string
+ filePath: string,
): Promise<Response> {
const [file, fileInfo] = await Promise.all([
Deno.open(filePath),
@@ -122,7 +122,7 @@ export async function serveFile(
// TODO: simplify this after deno.stat and deno.readDir are fixed
async function serveDir(
req: ServerRequest,
- dirPath: string
+ dirPath: string,
): Promise<Response> {
const dirUrl = `/${posix.relative(target, dirPath)}`;
const listEntry: EntryInfo[] = [];
@@ -192,7 +192,7 @@ function setCORS(res: Response): void {
res.headers.append("access-control-allow-origin", "*");
res.headers.append(
"access-control-allow-headers",
- "Origin, X-Requested-With, Content-Type, Accept, Range"
+ "Origin, X-Requested-With, Content-Type, Accept, Range",
);
}
@@ -263,9 +263,10 @@ function dirViewerTemplate(dirname: string, entries: EntryInfo[]): string {
<th>Size</th>
<th>Name</th>
</tr>
- ${entries.map(
- (entry) =>
- html`
+ ${
+ entries.map(
+ (entry) =>
+ html`
<tr>
<td class="mode">
${entry.mode}
@@ -277,8 +278,9 @@ function dirViewerTemplate(dirname: string, entries: EntryInfo[]): string {
<a href="${entry.url}">${entry.name}</a>
</td>
</tr>
- `
- )}
+ `,
+ )
+ }
</table>
</main>
</body>
@@ -359,7 +361,7 @@ function main(): void {
console.error(e.message);
}
}
- }
+ },
);
console.log(`HTTP server listening on http://${addr}/`);
diff --git a/std/http/file_server_test.ts b/std/http/file_server_test.ts
index 66c1d7d04..486bc514c 100644
--- a/std/http/file_server_test.ts
+++ b/std/http/file_server_test.ts
@@ -78,13 +78,13 @@ Deno.test(
assertEquals(res.headers.get("content-type"), "text/markdown");
const downloadedFile = await res.text();
const localFile = new TextDecoder().decode(
- await Deno.readFile("README.md")
+ await Deno.readFile("README.md"),
);
assertEquals(downloadedFile, localFile);
} finally {
await killFileServer();
}
- }
+ },
);
Deno.test(
@@ -98,14 +98,14 @@ Deno.test(
assertEquals(res.headers.get("content-type"), "text/markdown");
const downloadedFile = await res.text();
const localFile = new TextDecoder().decode(
- await Deno.readFile("./http/README.md")
+ await Deno.readFile("./http/README.md"),
);
console.log(downloadedFile, localFile);
assertEquals(downloadedFile, localFile);
} finally {
await killFileServer();
}
- }
+ },
);
Deno.test("serveDirectory", async function (): Promise<void> {
diff --git a/std/http/racing_server.ts b/std/http/racing_server.ts
index 67db029e0..1770443af 100644
--- a/std/http/racing_server.ts
+++ b/std/http/racing_server.ts
@@ -10,7 +10,7 @@ function body(i: number): string {
}
async function delayedRespond(
request: ServerRequest,
- step: number
+ step: number,
): Promise<void> {
await delay(3000);
await request.respond({ status: 200, body: body(step) });
@@ -24,7 +24,7 @@ async function largeRespond(request: ServerRequest, c: string): Promise<void> {
async function ignoreToConsume(
request: ServerRequest,
- step: number
+ step: number,
): Promise<void> {
await request.respond({ status: 200, body: body(step) });
}
diff --git a/std/http/server.ts b/std/http/server.ts
index b1ffed96b..93f116fff 100644
--- a/std/http/server.ts
+++ b/std/http/server.ts
@@ -65,7 +65,7 @@ export class ServerRequest {
.map((e): string => e.trim().toLowerCase());
assert(
parts.includes("chunked"),
- 'transfer-encoding must include "chunked" if content-length is not set'
+ 'transfer-encoding must include "chunked" if content-length is not set',
);
this._body = chunkedBodyReader(this.headers, this.r);
} else {
@@ -136,7 +136,7 @@ export class Server implements AsyncIterable<ServerRequest> {
// Yields all HTTP requests on a single TCP connection.
private async *iterateHttpRequests(
- conn: Deno.Conn
+ conn: Deno.Conn,
): AsyncIterableIterator<ServerRequest> {
const reader = new BufReader(conn);
const writer = new BufWriter(conn);
@@ -203,7 +203,7 @@ export class Server implements AsyncIterable<ServerRequest> {
// same kind and adds it to the request multiplexer so that another TCP
// connection can be accepted.
private async *acceptConnAndIterateHttpRequests(
- mux: MuxAsyncIterator<ServerRequest>
+ mux: MuxAsyncIterator<ServerRequest>,
): AsyncIterableIterator<ServerRequest> {
if (this.closing) return;
// Wait for a new connection.
@@ -302,7 +302,7 @@ export function serve(addr: string | HTTPOptions): Server {
*/
export async function listenAndServe(
addr: string | HTTPOptions,
- handler: (req: ServerRequest) => void
+ handler: (req: ServerRequest) => void,
): Promise<void> {
const server = serve(addr);
@@ -359,7 +359,7 @@ export function serveTLS(options: HTTPSOptions): Server {
*/
export async function listenAndServeTLS(
options: HTTPSOptions,
- handler: (req: ServerRequest) => void
+ handler: (req: ServerRequest) => void,
): Promise<void> {
const server = serveTLS(options);
diff --git a/std/http/server_test.ts b/std/http/server_test.ts
index f6bff1c5f..bc9b52341 100644
--- a/std/http/server_test.ts
+++ b/std/http/server_test.ts
@@ -51,8 +51,7 @@ const responseTests: ResponseTest[] = [
body: new Deno.Buffer(new TextEncoder().encode("abcdef")),
},
- raw:
- "HTTP/1.1 200 OK\r\n" +
+ raw: "HTTP/1.1 200 OK\r\n" +
"transfer-encoding: chunked\r\n\r\n" +
"6\r\nabcdef\r\n0\r\n\r\n",
},
@@ -94,10 +93,9 @@ Deno.test("requestContentLength", function (): void {
const maxChunkSize = 70;
while (chunkOffset < shortText.length) {
const chunkSize = Math.min(maxChunkSize, shortText.length - chunkOffset);
- chunksData += `${chunkSize.toString(16)}\r\n${shortText.substr(
- chunkOffset,
- chunkSize
- )}\r\n`;
+ chunksData += `${chunkSize.toString(16)}\r\n${
+ shortText.substr(chunkOffset, chunkSize)
+ }\r\n`;
chunkOffset += chunkSize;
}
chunksData += "0\r\n\r\n";
@@ -164,7 +162,7 @@ Deno.test(
assertEquals(tr.total, 0);
await req.finalize();
assertEquals(tr.total, text.length);
- }
+ },
);
Deno.test(
"ServerRequest.finalize() should consume unread body / chunked, trailers",
@@ -199,7 +197,7 @@ Deno.test(
assertEquals(req.headers.has("trailer"), false);
assertEquals(req.headers.get("deno"), "land");
assertEquals(req.headers.get("node"), "js");
- }
+ },
);
Deno.test("requestBodyWithTransferEncoding", async function (): Promise<void> {
{
@@ -212,10 +210,9 @@ Deno.test("requestBodyWithTransferEncoding", async function (): Promise<void> {
const maxChunkSize = 70;
while (chunkOffset < shortText.length) {
const chunkSize = Math.min(maxChunkSize, shortText.length - chunkOffset);
- chunksData += `${chunkSize.toString(16)}\r\n${shortText.substr(
- chunkOffset,
- chunkSize
- )}\r\n`;
+ chunksData += `${chunkSize.toString(16)}\r\n${
+ shortText.substr(chunkOffset, chunkSize)
+ }\r\n`;
chunkOffset += chunkSize;
}
chunksData += "0\r\n\r\n";
@@ -236,10 +233,9 @@ Deno.test("requestBodyWithTransferEncoding", async function (): Promise<void> {
const maxChunkSize = 70;
while (chunkOffset < longText.length) {
const chunkSize = Math.min(maxChunkSize, longText.length - chunkOffset);
- chunksData += `${chunkSize.toString(16)}\r\n${longText.substr(
- chunkOffset,
- chunkSize
- )}\r\n`;
+ chunksData += `${chunkSize.toString(16)}\r\n${
+ longText.substr(chunkOffset, chunkSize)
+ }\r\n`;
chunkOffset += chunkSize;
}
chunksData += "0\r\n\r\n";
@@ -308,10 +304,9 @@ Deno.test("requestBodyReaderWithTransferEncoding", async function (): Promise<
const maxChunkSize = 70;
while (chunkOffset < shortText.length) {
const chunkSize = Math.min(maxChunkSize, shortText.length - chunkOffset);
- chunksData += `${chunkSize.toString(16)}\r\n${shortText.substr(
- chunkOffset,
- chunkSize
- )}\r\n`;
+ chunksData += `${chunkSize.toString(16)}\r\n${
+ shortText.substr(chunkOffset, chunkSize)
+ }\r\n`;
chunkOffset += chunkSize;
}
chunksData += "0\r\n\r\n";
@@ -341,10 +336,9 @@ Deno.test("requestBodyReaderWithTransferEncoding", async function (): Promise<
const maxChunkSize = 70;
while (chunkOffset < longText.length) {
const chunkSize = Math.min(maxChunkSize, longText.length - chunkOffset);
- chunksData += `${chunkSize.toString(16)}\r\n${longText.substr(
- chunkOffset,
- chunkSize
- )}\r\n`;
+ chunksData += `${chunkSize.toString(16)}\r\n${
+ longText.substr(chunkOffset, chunkSize)
+ }\r\n`;
chunkOffset += chunkSize;
}
chunksData += "0\r\n\r\n";
@@ -436,7 +430,7 @@ Deno.test({
const s = await r.readLine();
assert(
s !== null && s.includes("server listening"),
- "server must be started"
+ "server must be started",
);
// Requests to the server and immediately closes the connection
const conn = await Deno.connectTls({
@@ -446,7 +440,7 @@ Deno.test({
});
await Deno.writeAll(
conn,
- new TextEncoder().encode("GET / HTTP/1.0\r\n\r\n")
+ new TextEncoder().encode("GET / HTTP/1.0\r\n\r\n"),
);
const res = new Uint8Array(100);
const nread = await conn.read(res);
@@ -475,7 +469,7 @@ Deno.test(
const nextAfterClosing = server[Symbol.asyncIterator]().next();
assertEquals(await nextAfterClosing, { value: undefined, done: true });
- }
+ },
);
Deno.test({
@@ -492,7 +486,7 @@ Deno.test({
const conn = await Deno.connect({ hostname: "127.0.0.1", port: 8123 });
await Deno.writeAll(
conn,
- new TextEncoder().encode("GET /hello HTTP/1.1\r\n\r\n")
+ new TextEncoder().encode("GET /hello HTTP/1.1\r\n\r\n"),
);
const res = new Uint8Array(100);
const nread = await conn.read(res);
@@ -533,7 +527,7 @@ Deno.test({
});
await Deno.writeAll(
conn,
- new TextEncoder().encode("GET / HTTP/1.1\r\n\r\n")
+ new TextEncoder().encode("GET / HTTP/1.1\r\n\r\n"),
);
conn.close();
await p;
@@ -551,12 +545,12 @@ Deno.test({
});
await Deno.writeAll(
conn,
- encode("GET / HTTP/1.1\r\nmalformedHeader\r\n\r\n\r\n\r\n")
+ encode("GET / HTTP/1.1\r\nmalformedHeader\r\n\r\n\r\n\r\n"),
);
const responseString = decode(await Deno.readAll(conn));
assertMatch(
responseString,
- /^HTTP\/1\.1 400 Bad Request\r\ncontent-length: \d+\r\n\r\n.*\r\n\r\n$/ms
+ /^HTTP\/1\.1 400 Bad Request\r\ncontent-length: \d+\r\n\r\n.*\r\n\r\n$/ms,
);
conn.close();
server.close();
@@ -592,7 +586,7 @@ Deno.test({
port,
// certFile
}),
- Deno.errors.InvalidData
+ Deno.errors.InvalidData,
);
// Valid request after invalid
@@ -604,7 +598,7 @@ Deno.test({
await Deno.writeAll(
conn,
- new TextEncoder().encode("GET / HTTP/1.0\r\n\r\n")
+ new TextEncoder().encode("GET / HTTP/1.0\r\n\r\n"),
);
const res = new Uint8Array(100);
const nread = await conn.read(res);
diff --git a/std/io/bufio.ts b/std/io/bufio.ts
index a1e6f67aa..682f96499 100644
--- a/std/io/bufio.ts
+++ b/std/io/bufio.ts
@@ -95,7 +95,7 @@ export class BufReader implements Reader {
}
throw new Error(
- `No progress after ${MAX_CONSECUTIVE_EMPTY_READS} read() calls`
+ `No progress after ${MAX_CONSECUTIVE_EMPTY_READS} read() calls`,
);
}
@@ -252,7 +252,7 @@ export class BufReader implements Reader {
let { partial } = err;
assert(
partial instanceof Uint8Array,
- "bufio: caught error from `readSlice()` without `partial` property"
+ "bufio: caught error from `readSlice()` without `partial` property",
);
// Don't throw if `readSlice()` failed with `BufferFullError`, instead we
@@ -466,7 +466,7 @@ export class BufWriter extends AbstractBufBase implements Writer {
try {
await Deno.writeAll(
this.writer,
- this.buf.subarray(0, this.usedBufferBytes)
+ this.buf.subarray(0, this.usedBufferBytes),
);
} catch (e) {
this.err = e;
@@ -527,7 +527,7 @@ export class BufWriterSync extends AbstractBufBase implements WriterSync {
/** return new BufWriterSync unless writer is BufWriterSync */
static create(
writer: WriterSync,
- size: number = DEFAULT_BUF_SIZE
+ size: number = DEFAULT_BUF_SIZE,
): BufWriterSync {
return writer instanceof BufWriterSync
? writer
@@ -559,7 +559,7 @@ export class BufWriterSync extends AbstractBufBase implements WriterSync {
try {
Deno.writeAllSync(
this.writer,
- this.buf.subarray(0, this.usedBufferBytes)
+ this.buf.subarray(0, this.usedBufferBytes),
);
} catch (e) {
this.err = e;
@@ -633,7 +633,7 @@ function createLPS(pat: Uint8Array): Uint8Array {
/** Read delimited bytes from a Reader. */
export async function* readDelim(
reader: Reader,
- delim: Uint8Array
+ delim: Uint8Array,
): AsyncIterableIterator<Uint8Array> {
// Avoid unicode problems
const delimLen = delim.length;
@@ -692,7 +692,7 @@ export async function* readDelim(
/** Read delimited strings from a Reader. */
export async function* readStringDelim(
reader: Reader,
- delim: string
+ delim: string,
): AsyncIterableIterator<string> {
const encoder = new TextEncoder();
const decoder = new TextDecoder();
@@ -704,7 +704,7 @@ export async function* readStringDelim(
/** Read strings line-by-line from a Reader. */
// eslint-disable-next-line require-await
export async function* readLines(
- reader: Reader
+ reader: Reader,
): AsyncIterableIterator<string> {
yield* readStringDelim(reader, "\n");
}
diff --git a/std/io/bufio_test.ts b/std/io/bufio_test.ts
index ad02703de..1ad6c7ac6 100644
--- a/std/io/bufio_test.ts
+++ b/std/io/bufio_test.ts
@@ -122,8 +122,7 @@ Deno.test("bufioBufReader", async function (): Promise<void> {
const read = readmaker.fn(new StringReader(text));
const buf = new BufReader(read, bufsize);
const s = await bufreader.fn(buf);
- const debugStr =
- `reader=${readmaker.name} ` +
+ const debugStr = `reader=${readmaker.name} ` +
`fn=${bufreader.name} bufsize=${bufsize} want=${text} got=${s}`;
assertEquals(s, text, debugStr);
}
@@ -179,11 +178,11 @@ Deno.test("bufioReadString", async function (): Promise<void> {
});
const testInput = encoder.encode(
- "012\n345\n678\n9ab\ncde\nfgh\nijk\nlmn\nopq\nrst\nuvw\nxy"
+ "012\n345\n678\n9ab\ncde\nfgh\nijk\nlmn\nopq\nrst\nuvw\nxy",
);
const testInputrn = encoder.encode(
"012\r\n345\r\n678\r\n9ab\r\ncde\r\nfgh\r\nijk\r\nlmn\r\nopq\r\nrst\r\n" +
- "uvw\r\nxy\r\n\n\r\n"
+ "uvw\r\nxy\r\n\n\r\n",
);
const testOutput = encoder.encode("0123456789abcdefghijklmnopqrstuvwxy");
@@ -225,7 +224,7 @@ async function testReadLine(input: Uint8Array): Promise<void> {
assertEquals(
line,
want,
- `Bad line at stride ${stride}: want: ${want} got: ${line}`
+ `Bad line at stride ${stride}: want: ${want} got: ${line}`,
);
done += line.byteLength;
}
@@ -233,7 +232,7 @@ async function testReadLine(input: Uint8Array): Promise<void> {
done,
testOutput.byteLength,
`readLine didn't return everything: got: ${done}, ` +
- `want: ${testOutput} (stride: ${stride})`
+ `want: ${testOutput} (stride: ${stride})`,
);
}
}
@@ -249,7 +248,7 @@ Deno.test("bufioPeek", async function (): Promise<void> {
// string is 16 (minReadBufferSize) long.
const buf = new BufReader(
new StringReader("abcdefghijklmnop"),
- MIN_READ_BUFFER_SIZE
+ MIN_READ_BUFFER_SIZE,
);
let actual = await buf.peek(1);
@@ -425,7 +424,7 @@ Deno.test("bufReaderReadFull", async function (): Promise<void> {
Deno.test("readStringDelimAndLines", async function (): Promise<void> {
const enc = new TextEncoder();
const data = new Deno.Buffer(
- enc.encode("Hello World\tHello World 2\tHello World 3")
+ enc.encode("Hello World\tHello World 2\tHello World 3"),
);
const chunks_ = [];
@@ -464,9 +463,9 @@ Deno.test(
assertEquals(decoder.decode(r2.line), "z");
assert(
r1.line.buffer !== r2.line.buffer,
- "array buffer should not be shared across reads"
+ "array buffer should not be shared across reads",
);
- }
+ },
);
Deno.test({
diff --git a/std/io/ioutil.ts b/std/io/ioutil.ts
index ac6d103a3..da48e95ab 100644
--- a/std/io/ioutil.ts
+++ b/std/io/ioutil.ts
@@ -12,7 +12,7 @@ const DEFAULT_BUFFER_SIZE = 32 * 1024;
export async function copyN(
r: Reader,
dest: Writer,
- size: number
+ size: number,
): Promise<number> {
let bytesRead = 0;
let buf = new Uint8Array(DEFAULT_BUFFER_SIZE);
@@ -67,7 +67,7 @@ export async function readLong(buf: BufReader): Promise<number | null> {
// We probably should provide a similar API that returns BigInt values.
if (big > MAX_SAFE_INTEGER) {
throw new RangeError(
- "Long value too big to be represented as a JavaScript number."
+ "Long value too big to be represented as a JavaScript number.",
);
}
return Number(big);
diff --git a/std/io/ioutil_test.ts b/std/io/ioutil_test.ts
index dfdda23fb..69f76f691 100644
--- a/std/io/ioutil_test.ts
+++ b/std/io/ioutil_test.ts
@@ -38,7 +38,7 @@ Deno.test("testReadInt", async function (): Promise<void> {
Deno.test("testReadLong", async function (): Promise<void> {
const r = new BinaryReader(
- new Uint8Array([0x00, 0x00, 0x00, 0x78, 0x12, 0x34, 0x56, 0x78])
+ new Uint8Array([0x00, 0x00, 0x00, 0x78, 0x12, 0x34, 0x56, 0x78]),
);
const long = await readLong(new BufReader(r));
assertEquals(long, 0x7812345678);
@@ -46,7 +46,7 @@ Deno.test("testReadLong", async function (): Promise<void> {
Deno.test("testReadLong2", async function (): Promise<void> {
const r = new BinaryReader(
- new Uint8Array([0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78])
+ new Uint8Array([0, 0, 0, 0, 0x12, 0x34, 0x56, 0x78]),
);
const long = await readLong(new BufReader(r));
assertEquals(long, 0x12345678);
@@ -58,9 +58,9 @@ Deno.test("testSliceLongToBytes", function (): void {
const expected = readLong(
new BufReader(
new BinaryReader(
- new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef])
- )
- )
+ new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef]),
+ ),
+ ),
);
assertEquals(actual, expected);
});
diff --git a/std/io/streams.ts b/std/io/streams.ts
index 3969746ef..89cc6bd45 100644
--- a/std/io/streams.ts
+++ b/std/io/streams.ts
@@ -1,7 +1,7 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
export function fromStreamWriter(
- streamWriter: WritableStreamDefaultWriter<Uint8Array>
+ streamWriter: WritableStreamDefaultWriter<Uint8Array>,
): Deno.Writer {
return {
async write(p: Uint8Array): Promise<number> {
@@ -13,7 +13,7 @@ export function fromStreamWriter(
}
export function fromStreamReader(
- streamReader: ReadableStreamDefaultReader<Uint8Array>
+ streamReader: ReadableStreamDefaultReader<Uint8Array>,
): Deno.Reader {
const buffer = new Deno.Buffer();
diff --git a/std/io/streams_test.ts b/std/io/streams_test.ts
index 00d056e2f..4579e3668 100644
--- a/std/io/streams_test.ts
+++ b/std/io/streams_test.ts
@@ -64,7 +64,7 @@ Deno.test("toReaderCheck", async function (): Promise<void> {
assertEquals(
expected,
- readChunks.map((chunk) => decoder.decode(chunk))
+ readChunks.map((chunk) => decoder.decode(chunk)),
);
});
@@ -115,7 +115,7 @@ Deno.test("toReaderBigIrregularChunksCheck", async function (): Promise<void> {
chunks
.slice()
.map((chunk) => [...chunk])
- .flat()
+ .flat(),
);
const readableStream = new ReadableStream({
pull(controller): void {
diff --git a/std/io/util.ts b/std/io/util.ts
index f4b7bf8bb..0055d7094 100644
--- a/std/io/util.ts
+++ b/std/io/util.ts
@@ -13,11 +13,11 @@ export async function tempFile(
opts: {
prefix?: string;
postfix?: string;
- } = { prefix: "", postfix: "" }
+ } = { prefix: "", postfix: "" },
): Promise<{ file: Deno.File; filepath: string }> {
const r = Math.floor(Math.random() * 1000000);
const filepath = path.resolve(
- `${dir}/${opts.prefix || ""}${r}${opts.postfix || ""}`
+ `${dir}/${opts.prefix || ""}${r}${opts.postfix || ""}`,
);
await Deno.mkdir(path.dirname(filepath), { recursive: true });
const file = await Deno.open(filepath, {
diff --git a/std/log/handlers.ts b/std/log/handlers.ts
index e09dc648c..21c25a816 100644
--- a/std/log/handlers.ts
+++ b/std/log/handlers.ts
@@ -195,7 +195,7 @@ export class RotatingFileHandler extends FileHandler {
if (await exists(this._filename + "." + i)) {
this.destroy();
throw new Deno.errors.AlreadyExists(
- "Backup log file " + this._filename + "." + i + " already exists"
+ "Backup log file " + this._filename + "." + i + " already exists",
);
}
}
diff --git a/std/log/handlers_test.ts b/std/log/handlers_test.ts
index ef4b69000..8921dd542 100644
--- a/std/log/handlers_test.ts
+++ b/std/log/handlers_test.ts
@@ -67,7 +67,7 @@ Deno.test("simpleHandler", function (): void {
args: [],
level: level,
loggerName: "default",
- })
+ }),
);
}
@@ -88,7 +88,7 @@ Deno.test("testFormatterAsString", function (): void {
args: [],
level: LogLevels.DEBUG,
loggerName: "default",
- })
+ }),
);
assertEquals(handler.messages, ["test DEBUG Hello, world!"]);
@@ -105,7 +105,7 @@ Deno.test("testFormatterWithEmptyMsg", function () {
args: [],
level: LogLevels.DEBUG,
loggerName: "default",
- })
+ }),
);
assertEquals(handler.messages, ["test DEBUG "]);
@@ -123,7 +123,7 @@ Deno.test("testFormatterAsFunction", function (): void {
args: [],
level: LogLevels.ERROR,
loggerName: "default",
- })
+ }),
);
assertEquals(handler.messages, ["fn formatter ERROR Hello, world!"]);
@@ -144,7 +144,7 @@ Deno.test({
args: [],
level: LogLevels.WARNING,
loggerName: "default",
- })
+ }),
);
await fileHandler.destroy();
const firstFileSize = (await Deno.stat(LOG_FILE)).size;
@@ -156,7 +156,7 @@ Deno.test({
args: [],
level: LogLevels.WARNING,
loggerName: "default",
- })
+ }),
);
await fileHandler.destroy();
const secondFileSize = (await Deno.stat(LOG_FILE)).size;
@@ -192,15 +192,15 @@ Deno.test({
Deno.writeFileSync(LOG_FILE, new TextEncoder().encode("hello world"));
Deno.writeFileSync(
LOG_FILE + ".1",
- new TextEncoder().encode("hello world")
+ new TextEncoder().encode("hello world"),
);
Deno.writeFileSync(
LOG_FILE + ".2",
- new TextEncoder().encode("hello world")
+ new TextEncoder().encode("hello world"),
);
Deno.writeFileSync(
LOG_FILE + ".3",
- new TextEncoder().encode("hello world")
+ new TextEncoder().encode("hello world"),
);
const fileHandler = new RotatingFileHandler("WARNING", {
@@ -227,7 +227,7 @@ Deno.test({
async fn() {
Deno.writeFileSync(
LOG_FILE + ".3",
- new TextEncoder().encode("hello world")
+ new TextEncoder().encode("hello world"),
);
const fileHandler = new RotatingFileHandler("WARNING", {
filename: LOG_FILE,
@@ -240,7 +240,7 @@ Deno.test({
await fileHandler.setup();
},
Deno.errors.AlreadyExists,
- "Backup log file " + LOG_FILE + ".3 already exists"
+ "Backup log file " + LOG_FILE + ".3 already exists",
);
fileHandler.destroy();
@@ -266,7 +266,7 @@ Deno.test({
args: [],
level: LogLevels.ERROR,
loggerName: "default",
- })
+ }),
); // 'ERROR AAA\n' = 10 bytes
fileHandler.flush();
assertEquals((await Deno.stat(LOG_FILE)).size, 10);
@@ -276,7 +276,7 @@ Deno.test({
args: [],
level: LogLevels.ERROR,
loggerName: "default",
- })
+ }),
);
fileHandler.flush();
assertEquals((await Deno.stat(LOG_FILE)).size, 20);
@@ -286,7 +286,7 @@ Deno.test({
args: [],
level: LogLevels.ERROR,
loggerName: "default",
- })
+ }),
);
fileHandler.flush();
// Rollover occurred. Log file now has 1 record, rollover file has the original 2
@@ -316,7 +316,7 @@ Deno.test({
args: [],
level: LogLevels.ERROR,
loggerName: "default",
- })
+ }),
); // 'ERROR AAA\n' = 10 bytes
fileHandler.handle(
new LogRecord({
@@ -324,7 +324,7 @@ Deno.test({
args: [],
level: LogLevels.ERROR,
loggerName: "default",
- })
+ }),
);
fileHandler.handle(
new LogRecord({
@@ -332,7 +332,7 @@ Deno.test({
args: [],
level: LogLevels.ERROR,
loggerName: "default",
- })
+ }),
);
await fileHandler.destroy();
@@ -351,15 +351,15 @@ Deno.test({
Deno.writeFileSync(LOG_FILE, new TextEncoder().encode("original log file"));
Deno.writeFileSync(
LOG_FILE + ".1",
- new TextEncoder().encode("original log.1 file")
+ new TextEncoder().encode("original log.1 file"),
);
Deno.writeFileSync(
LOG_FILE + ".2",
- new TextEncoder().encode("original log.2 file")
+ new TextEncoder().encode("original log.2 file"),
);
Deno.writeFileSync(
LOG_FILE + ".3",
- new TextEncoder().encode("original log.3 file")
+ new TextEncoder().encode("original log.3 file"),
);
const fileHandler = new RotatingFileHandler("WARNING", {
@@ -375,7 +375,7 @@ Deno.test({
args: [],
level: LogLevels.ERROR,
loggerName: "default",
- })
+ }),
); // 'ERROR AAA\n' = 10 bytes
await fileHandler.destroy();
@@ -383,15 +383,15 @@ Deno.test({
assertEquals(decoder.decode(Deno.readFileSync(LOG_FILE)), "ERROR AAA\n");
assertEquals(
decoder.decode(Deno.readFileSync(LOG_FILE + ".1")),
- "original log file"
+ "original log file",
);
assertEquals(
decoder.decode(Deno.readFileSync(LOG_FILE + ".2")),
- "original log.1 file"
+ "original log.1 file",
);
assertEquals(
decoder.decode(Deno.readFileSync(LOG_FILE + ".3")),
- "original log.2 file"
+ "original log.2 file",
);
assert(!existsSync(LOG_FILE + ".4"));
@@ -416,7 +416,7 @@ Deno.test({
await fileHandler.setup();
},
Error,
- "maxBytes cannot be less than 1"
+ "maxBytes cannot be less than 1",
);
},
});
@@ -435,7 +435,7 @@ Deno.test({
await fileHandler.setup();
},
Error,
- "maxBackupCount cannot be less than 1"
+ "maxBackupCount cannot be less than 1",
);
},
});
@@ -454,7 +454,7 @@ Deno.test({
args: [],
level: LogLevels.ERROR,
loggerName: "default",
- })
+ }),
); // 'ERROR AAA\n' = 10 bytes
assertEquals((await Deno.stat(LOG_FILE)).size, 0);
@@ -514,7 +514,7 @@ Deno.test({
args: [],
level: LogLevels.ERROR,
loggerName: "default",
- })
+ }),
);
// ERROR won't trigger immediate flush
@@ -527,7 +527,7 @@ Deno.test({
args: [],
level: LogLevels.CRITICAL,
loggerName: "default",
- })
+ }),
);
// CRITICAL will trigger immediate flush
diff --git a/std/log/logger.ts b/std/log/logger.ts
index 482047f2a..ef4bfd58f 100644
--- a/std/log/logger.ts
+++ b/std/log/logger.ts
@@ -50,7 +50,7 @@ export class Logger {
constructor(
loggerName: string,
levelName: LevelName,
- options: LoggerOptions = {}
+ options: LoggerOptions = {},
) {
this.#loggerName = loggerName;
this.#level = getLevelByName(levelName);
diff --git a/std/log/logger_test.ts b/std/log/logger_test.ts
index f7b438cba..08080356b 100644
--- a/std/log/logger_test.ts
+++ b/std/log/logger_test.ts
@@ -129,11 +129,11 @@ Deno.test(
const inlineData: string | undefined = logger.debug(
expensiveFunction,
1,
- 2
+ 2,
);
assert(!called);
assertEquals(inlineData, undefined);
- }
+ },
);
Deno.test("String resolver fn resolves as expected", function (): void {
@@ -235,7 +235,7 @@ Deno.test(
});
const data18: { payload: string; other: number } = logger.error(
{ payload: "data", other: 123 },
- 1
+ 1,
);
assertEquals(data18, {
payload: "data",
@@ -243,5 +243,5 @@ Deno.test(
});
assertEquals(handler.messages[16], 'ERROR {"payload":"data","other":123}');
assertEquals(handler.messages[17], 'ERROR {"payload":"data","other":123}');
- }
+ },
);
diff --git a/std/log/mod.ts b/std/log/mod.ts
index 9565749aa..3960a65a3 100644
--- a/std/log/mod.ts
+++ b/std/log/mod.ts
@@ -60,7 +60,7 @@ export function getLogger(name?: string): Logger {
const d = state.loggers.get("default");
assert(
d != null,
- `"default" logger must be set for getting logger without name`
+ `"default" logger must be set for getting logger without name`,
);
return d;
}
diff --git a/std/mime/multipart.ts b/std/mime/multipart.ts
index 0d60fd00b..6597a1bea 100644
--- a/std/mime/multipart.ts
+++ b/std/mime/multipart.ts
@@ -59,7 +59,7 @@ function randomBoundary(): string {
export function matchAfterPrefix(
buf: Uint8Array,
prefix: Uint8Array,
- eof: boolean
+ eof: boolean,
): -1 | 0 | 1 {
if (buf.length === prefix.length) {
return eof ? 1 : 0;
@@ -98,7 +98,7 @@ export function scanUntilBoundary(
dashBoundary: Uint8Array,
newLineDashBoundary: Uint8Array,
total: number,
- eof: boolean
+ eof: boolean,
): number | null {
if (total === 0) {
// At beginning of body, allow dashBoundary.
@@ -168,7 +168,7 @@ class PartReader implements Deno.Reader, Deno.Closer {
this.mr.dashBoundary,
this.mr.newLineDashBoundary,
this.total,
- eof
+ eof,
);
if (this.n === 0) {
// Force buffered I/O to read more into buffer.
@@ -417,7 +417,7 @@ export class MultipartReader {
function multipatFormData(
fileMap: Map<string, FormFile | FormFile[]>,
- valueMap: Map<string, string>
+ valueMap: Map<string, string>,
): MultipartFormData {
function file(key: string): FormFile | FormFile[] | undefined {
return fileMap.get(key);
@@ -468,7 +468,7 @@ class PartWriter implements Deno.Writer {
private writer: Deno.Writer,
readonly boundary: string,
public headers: Headers,
- isFirstBoundary: boolean
+ isFirstBoundary: boolean,
) {
let buf = "";
if (isFirstBoundary) {
@@ -549,7 +549,7 @@ export class MultipartWriter {
this.writer,
this.boundary,
headers,
- !this.lastPart
+ !this.lastPart,
);
this.lastPart = part;
return part;
@@ -559,7 +559,7 @@ export class MultipartWriter {
const h = new Headers();
h.set(
"Content-Disposition",
- `form-data; name="${field}"; filename="${filename}"`
+ `form-data; name="${field}"; filename="${filename}"`,
);
h.set("Content-Type", "application/octet-stream");
return this.createPart(h);
@@ -580,7 +580,7 @@ export class MultipartWriter {
async writeFile(
field: string,
filename: string,
- file: Deno.Reader
+ file: Deno.Reader,
): Promise<void> {
const f = await this.createFormFile(field, filename);
await Deno.copy(file, f);
diff --git a/std/mime/multipart_test.ts b/std/mime/multipart_test.ts
index c0282ee3b..d2cfb2ee5 100644
--- a/std/mime/multipart_test.ts
+++ b/std/mime/multipart_test.ts
@@ -28,7 +28,7 @@ Deno.test("multipartScanUntilBoundary1", function (): void {
dashBoundary,
nlDashBoundary,
0,
- true
+ true,
);
assertEquals(n, null);
});
@@ -40,7 +40,7 @@ Deno.test("multipartScanUntilBoundary2", function (): void {
dashBoundary,
nlDashBoundary,
0,
- true
+ true,
);
assertEquals(n, 3);
});
@@ -52,7 +52,7 @@ Deno.test("multipartScanUntilBoundary3", function (): void {
dashBoundary,
nlDashBoundary,
0,
- false
+ false,
);
assertEquals(n, data.length);
});
@@ -64,7 +64,7 @@ Deno.test("multipartScanUntilBoundary4", function (): void {
dashBoundary,
nlDashBoundary,
0,
- false
+ false,
);
assertEquals(n, 3);
});
@@ -105,27 +105,27 @@ Deno.test("multipartMultipartWriter2", function (): void {
assertThrows(
(): MultipartWriter => new MultipartWriter(w, ""),
Error,
- "invalid boundary length"
+ "invalid boundary length",
);
assertThrows(
(): MultipartWriter =>
new MultipartWriter(
w,
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
- "aaaaaaaa"
+ "aaaaaaaa",
),
Error,
- "invalid boundary length"
+ "invalid boundary length",
);
assertThrows(
(): MultipartWriter => new MultipartWriter(w, "aaa aaa"),
Error,
- "invalid boundary character"
+ "invalid boundary character",
);
assertThrows(
(): MultipartWriter => new MultipartWriter(w, "boundary¥¥"),
Error,
- "invalid boundary character"
+ "invalid boundary character",
);
});
@@ -139,7 +139,7 @@ Deno.test("multipartMultipartWriter3", async function (): Promise<void> {
await mw.close();
},
Error,
- "closed"
+ "closed",
);
await assertThrowsAsync(
async (): Promise<void> => {
@@ -147,28 +147,28 @@ Deno.test("multipartMultipartWriter3", async function (): Promise<void> {
await mw.writeFile("bar", "file", null as any);
},
Error,
- "closed"
+ "closed",
);
await assertThrowsAsync(
async (): Promise<void> => {
await mw.writeField("bar", "bar");
},
Error,
- "closed"
+ "closed",
);
assertThrows(
(): void => {
mw.createFormField("bar");
},
Error,
- "closed"
+ "closed",
);
assertThrows(
(): void => {
mw.createFormFile("bar", "file");
},
Error,
- "closed"
+ "closed",
);
});
@@ -178,7 +178,7 @@ Deno.test({
const o = await Deno.open(path.resolve("./mime/testdata/sample.txt"));
const mr = new MultipartReader(
o,
- "--------------------------434049563556637648550474"
+ "--------------------------434049563556637648550474",
);
const form = await mr.readForm();
assertEquals(form.value("foo"), "foo");
@@ -250,7 +250,7 @@ Deno.test({
const o = await Deno.open(path.resolve("./mime/testdata/sample.txt"));
const mr = new MultipartReader(
o,
- "--------------------------434049563556637648550474"
+ "--------------------------434049563556637648550474",
);
const form = await mr.readForm(20);
let file = form.file("file");
@@ -277,7 +277,7 @@ Deno.test({
const o = await Deno.open(path.resolve("./mime/testdata/sample.txt"));
const mr = new MultipartReader(
o,
- "--------------------------434049563556637648550474"
+ "--------------------------434049563556637648550474",
);
const form = await mr.readForm();
const map = new Map(form.entries());
diff --git a/std/node/_fs/_fs_access.ts b/std/node/_fs/_fs_access.ts
index 79e4ca96d..df84eac9c 100644
--- a/std/node/_fs/_fs_access.ts
+++ b/std/node/_fs/_fs_access.ts
@@ -10,7 +10,7 @@ import { notImplemented } from "../_utils.ts";
export function access(
path: string | URL, // eslint-disable-line @typescript-eslint/no-unused-vars
modeOrCallback: number | Function, // eslint-disable-line @typescript-eslint/no-unused-vars
- callback?: CallbackWithError // eslint-disable-line @typescript-eslint/no-unused-vars
+ callback?: CallbackWithError, // eslint-disable-line @typescript-eslint/no-unused-vars
): void {
notImplemented("Not yet available");
}
diff --git a/std/node/_fs/_fs_appendFile.ts b/std/node/_fs/_fs_appendFile.ts
index c057c1f65..bc30de609 100644
--- a/std/node/_fs/_fs_appendFile.ts
+++ b/std/node/_fs/_fs_appendFile.ts
@@ -17,7 +17,7 @@ export function appendFile(
pathOrRid: string | number | URL,
data: string,
optionsOrCallback: Encodings | WriteFileOptions | CallbackWithError,
- callback?: CallbackWithError
+ callback?: CallbackWithError,
): void {
pathOrRid = pathOrRid instanceof URL ? fromFileUrl(pathOrRid) : pathOrRid;
const callbackFn: CallbackWithError | undefined =
@@ -80,7 +80,7 @@ function closeRidIfNecessary(isPathString: boolean, rid: number): void {
export function appendFileSync(
pathOrRid: string | number | URL,
data: string,
- options?: Encodings | WriteFileOptions
+ options?: Encodings | WriteFileOptions,
): void {
let rid = -1;
@@ -116,7 +116,7 @@ export function appendFileSync(
}
function validateEncoding(
- encodingOption: Encodings | WriteFileOptions | undefined
+ encodingOption: Encodings | WriteFileOptions | undefined,
): void {
if (!encodingOption) return;
diff --git a/std/node/_fs/_fs_appendFile_test.ts b/std/node/_fs/_fs_appendFile_test.ts
index 9c0ccb666..d41065205 100644
--- a/std/node/_fs/_fs_appendFile_test.ts
+++ b/std/node/_fs/_fs_appendFile_test.ts
@@ -13,7 +13,7 @@ Deno.test({
appendFile("some/path", "some data", "utf8");
},
Error,
- "No callback function supplied"
+ "No callback function supplied",
);
},
});
@@ -27,7 +27,7 @@ Deno.test({
appendFile("some/path", "some data", "made-up-encoding", () => {});
},
Error,
- "Only 'utf8' encoding is currently supported"
+ "Only 'utf8' encoding is currently supported",
);
assertThrows(
() => {
@@ -36,17 +36,17 @@ Deno.test({
"some data",
// @ts-expect-error Type '"made-up-encoding"' is not assignable to type
{ encoding: "made-up-encoding" },
- () => {}
+ () => {},
);
},
Error,
- "Only 'utf8' encoding is currently supported"
+ "Only 'utf8' encoding is currently supported",
);
assertThrows(
// @ts-expect-error Type '"made-up-encoding"' is not assignable to type
() => appendFileSync("some/path", "some data", "made-up-encoding"),
Error,
- "Only 'utf8' encoding is currently supported"
+ "Only 'utf8' encoding is currently supported",
);
assertThrows(
() =>
@@ -55,7 +55,7 @@ Deno.test({
encoding: "made-up-encoding",
}),
Error,
- "Only 'utf8' encoding is currently supported"
+ "Only 'utf8' encoding is currently supported",
);
},
});
@@ -200,7 +200,7 @@ Deno.test({
assertThrows(
() => appendFileSync(tempFile, "hello world", { flag: "ax" }),
Deno.errors.AlreadyExists,
- ""
+ "",
);
assertEquals(Deno.resources(), openResourcesBeforeAppend);
Deno.removeSync(tempFile);
diff --git a/std/node/_fs/_fs_chmod.ts b/std/node/_fs/_fs_chmod.ts
index 844afd21d..9a8277b45 100644
--- a/std/node/_fs/_fs_chmod.ts
+++ b/std/node/_fs/_fs_chmod.ts
@@ -12,7 +12,7 @@ const allowedModes = /^[0-7]{3}/;
export function chmod(
path: string | URL,
mode: string | number,
- callback: CallbackWithError
+ callback: CallbackWithError,
): void {
path = path instanceof URL ? fromFileUrl(path) : path;
diff --git a/std/node/_fs/_fs_chown.ts b/std/node/_fs/_fs_chown.ts
index 56068ef73..ae3af0121 100644
--- a/std/node/_fs/_fs_chown.ts
+++ b/std/node/_fs/_fs_chown.ts
@@ -11,7 +11,7 @@ export function chown(
path: string | URL,
uid: number,
gid: number,
- callback: CallbackWithError
+ callback: CallbackWithError,
): void {
path = path instanceof URL ? fromFileUrl(path) : path;
diff --git a/std/node/_fs/_fs_common.ts b/std/node/_fs/_fs_common.ts
index 3c20ca73e..165b9aeca 100644
--- a/std/node/_fs/_fs_common.ts
+++ b/std/node/_fs/_fs_common.ts
@@ -35,7 +35,7 @@ export interface WriteFileOptions extends FileOptions {
}
export function isFileOptions(
- fileOptions: string | WriteFileOptions | undefined
+ fileOptions: string | WriteFileOptions | undefined,
): fileOptions is FileOptions {
if (!fileOptions) return false;
@@ -47,14 +47,15 @@ export function isFileOptions(
}
export function getEncoding(
- optOrCallback?: FileOptions | WriteFileOptions | Function | Encodings | null
+ optOrCallback?: FileOptions | WriteFileOptions | Function | Encodings | null,
): Encodings | null {
if (!optOrCallback || typeof optOrCallback === "function") {
return null;
}
- const encoding =
- typeof optOrCallback === "string" ? optOrCallback : optOrCallback.encoding;
+ const encoding = typeof optOrCallback === "string"
+ ? optOrCallback
+ : optOrCallback.encoding;
if (!encoding) return null;
return encoding;
}
diff --git a/std/node/_fs/_fs_copy.ts b/std/node/_fs/_fs_copy.ts
index 72f43d18f..ba530a85c 100644
--- a/std/node/_fs/_fs_copy.ts
+++ b/std/node/_fs/_fs_copy.ts
@@ -6,7 +6,7 @@ import { fromFileUrl } from "../path.ts";
export function copyFile(
source: string | URL,
destination: string,
- callback: CallbackWithError
+ callback: CallbackWithError,
): void {
source = source instanceof URL ? fromFileUrl(source) : source;
diff --git a/std/node/_fs/_fs_dir_test.ts b/std/node/_fs/_fs_dir_test.ts
index 2d2d5f585..4c2806389 100644
--- a/std/node/_fs/_fs_dir_test.ts
+++ b/std/node/_fs/_fs_dir_test.ts
@@ -49,7 +49,7 @@ Deno.test({
let calledBack = false;
const fileFromCallback: Dirent | null = await new Dir(
- testDir
+ testDir,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
).read((err: any, res: Dirent) => {
assert(res === null);
@@ -83,10 +83,11 @@ Deno.test({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(err: any, secondResult: Dirent) => {
assert(
- secondResult.name === "bar.txt" || secondResult.name === "foo.txt"
+ secondResult.name === "bar.txt" ||
+ secondResult.name === "foo.txt",
);
secondCallback = true;
- }
+ },
);
const thirdRead: Dirent | null = await dir.read();
const fourthRead: Dirent | null = await dir.read();
diff --git a/std/node/_fs/_fs_dirent.ts b/std/node/_fs/_fs_dirent.ts
index 3ea1def42..24e43145c 100644
--- a/std/node/_fs/_fs_dirent.ts
+++ b/std/node/_fs/_fs_dirent.ts
@@ -10,7 +10,7 @@ export default class Dirent {
isCharacterDevice(): boolean {
notImplemented(
- "Deno does not yet support identification of character devices"
+ "Deno does not yet support identification of character devices",
);
return false;
}
@@ -21,7 +21,7 @@ export default class Dirent {
isFIFO(): boolean {
notImplemented(
- "Deno does not yet support identification of FIFO named pipes"
+ "Deno does not yet support identification of FIFO named pipes",
);
return false;
}
diff --git a/std/node/_fs/_fs_dirent_test.ts b/std/node/_fs/_fs_dirent_test.ts
index 8c4b98214..aeb20f1d5 100644
--- a/std/node/_fs/_fs_dirent_test.ts
+++ b/std/node/_fs/_fs_dirent_test.ts
@@ -65,14 +65,14 @@ Deno.test({
new Dirent(entry).isFIFO();
},
Error,
- "does not yet support"
+ "does not yet support",
);
assertThrows(
() => {
new Dirent(entry).isSocket();
},
Error,
- "does not yet support"
+ "does not yet support",
);
},
});
diff --git a/std/node/_fs/_fs_link.ts b/std/node/_fs/_fs_link.ts
index df08e13b1..42ca3de89 100644
--- a/std/node/_fs/_fs_link.ts
+++ b/std/node/_fs/_fs_link.ts
@@ -10,10 +10,11 @@ import { fromFileUrl } from "../path.ts";
export function link(
existingPath: string | URL,
newPath: string | URL,
- callback: CallbackWithError
+ callback: CallbackWithError,
): void {
- existingPath =
- existingPath instanceof URL ? fromFileUrl(existingPath) : existingPath;
+ existingPath = existingPath instanceof URL
+ ? fromFileUrl(existingPath)
+ : existingPath;
newPath = newPath instanceof URL ? fromFileUrl(newPath) : newPath;
Deno.link(existingPath, newPath)
@@ -27,10 +28,11 @@ export function link(
*/
export function linkSync(
existingPath: string | URL,
- newPath: string | URL
+ newPath: string | URL,
): void {
- existingPath =
- existingPath instanceof URL ? fromFileUrl(existingPath) : existingPath;
+ existingPath = existingPath instanceof URL
+ ? fromFileUrl(existingPath)
+ : existingPath;
newPath = newPath instanceof URL ? fromFileUrl(newPath) : newPath;
Deno.linkSync(existingPath, newPath);
diff --git a/std/node/_fs/_fs_mkdir.ts b/std/node/_fs/_fs_mkdir.ts
index 8578f4653..63aabd010 100644
--- a/std/node/_fs/_fs_mkdir.ts
+++ b/std/node/_fs/_fs_mkdir.ts
@@ -14,7 +14,7 @@ type MkdirOptions =
export function mkdir(
path: string | URL,
options?: MkdirOptions | CallbackWithError,
- callback?: CallbackWithError
+ callback?: CallbackWithError,
): void {
path = path instanceof URL ? fromFileUrl(path) : path;
@@ -33,7 +33,7 @@ export function mkdir(
}
if (typeof recursive !== "boolean") {
throw new Deno.errors.InvalidData(
- "invalid recursive option , must be a boolean"
+ "invalid recursive option , must be a boolean",
);
}
Deno.mkdir(path, { recursive, mode })
@@ -64,7 +64,7 @@ export function mkdirSync(path: string | URL, options?: MkdirOptions): void {
}
if (typeof recursive !== "boolean") {
throw new Deno.errors.InvalidData(
- "invalid recursive option , must be a boolean"
+ "invalid recursive option , must be a boolean",
);
}
diff --git a/std/node/_fs/_fs_readFile.ts b/std/node/_fs/_fs_readFile.ts
index 39c3d8393..2aef28290 100644
--- a/std/node/_fs/_fs_readFile.ts
+++ b/std/node/_fs/_fs_readFile.ts
@@ -14,11 +14,11 @@ import { fromFileUrl } from "../path.ts";
function maybeDecode(data: Uint8Array, encoding: TextEncodings): string;
function maybeDecode(
data: Uint8Array,
- encoding: BinaryEncodings | null
+ encoding: BinaryEncodings | null,
): Buffer;
function maybeDecode(
data: Uint8Array,
- encoding: Encodings | null
+ encoding: Encodings | null,
): string | Buffer {
const buffer = new Buffer(data.buffer, data.byteOffset, data.byteLength);
if (encoding && encoding !== "binary") return buffer.toString(encoding);
@@ -33,23 +33,23 @@ type Callback = TextCallback | BinaryCallback | GenericCallback;
export function readFile(
path: string | URL,
options: TextOptionsArgument,
- callback: TextCallback
+ callback: TextCallback,
): void;
export function readFile(
path: string | URL,
options: BinaryOptionsArgument,
- callback: BinaryCallback
+ callback: BinaryCallback,
): void;
export function readFile(
path: string | URL,
options: null | undefined | FileOptionsArgument,
- callback: BinaryCallback
+ callback: BinaryCallback,
): void;
export function readFile(path: string | URL, callback: BinaryCallback): void;
export function readFile(
path: string | URL,
optOrCallback?: FileOptionsArgument | Callback | null | undefined,
- callback?: Callback
+ callback?: Callback,
): void {
path = path instanceof URL ? fromFileUrl(path) : path;
let cb: Callback | undefined;
@@ -77,15 +77,15 @@ export function readFile(
export function readFileSync(
path: string | URL,
- opt: TextOptionsArgument
+ opt: TextOptionsArgument,
): string;
export function readFileSync(
path: string | URL,
- opt?: BinaryOptionsArgument
+ opt?: BinaryOptionsArgument,
): Buffer;
export function readFileSync(
path: string | URL,
- opt?: FileOptionsArgument
+ opt?: FileOptionsArgument,
): string | Buffer {
path = path instanceof URL ? fromFileUrl(path) : path;
const data = Deno.readFileSync(path);
diff --git a/std/node/_fs/_fs_readFile_test.ts b/std/node/_fs/_fs_readFile_test.ts
index 076c4b276..ff449dbb2 100644
--- a/std/node/_fs/_fs_readFile_test.ts
+++ b/std/node/_fs/_fs_readFile_test.ts
@@ -3,7 +3,7 @@ import * as path from "../../path/mod.ts";
import { assertEquals, assert } from "../../testing/asserts.ts";
const testData = path.resolve(
- path.join("node", "_fs", "testdata", "hello.txt")
+ path.join("node", "_fs", "testdata", "hello.txt"),
);
Deno.test("readFileSuccess", async function () {
diff --git a/std/node/_fs/_fs_readlink.ts b/std/node/_fs/_fs_readlink.ts
index 11ce43f55..866ea187b 100644
--- a/std/node/_fs/_fs_readlink.ts
+++ b/std/node/_fs/_fs_readlink.ts
@@ -8,7 +8,7 @@ import { fromFileUrl } from "../path.ts";
type ReadlinkCallback = (
err: MaybeEmpty<Error>,
- linkString: MaybeEmpty<string | Uint8Array>
+ linkString: MaybeEmpty<string | Uint8Array>,
) => void;
interface ReadlinkOptions {
@@ -17,7 +17,7 @@ interface ReadlinkOptions {
function maybeEncode(
data: string,
- encoding: string | null
+ encoding: string | null,
): string | Uint8Array {
if (encoding === "buffer") {
return new TextEncoder().encode(data);
@@ -26,7 +26,7 @@ function maybeEncode(
}
function getEncoding(
- optOrCallback?: ReadlinkOptions | ReadlinkCallback
+ optOrCallback?: ReadlinkOptions | ReadlinkCallback,
): string | null {
if (!optOrCallback || typeof optOrCallback === "function") {
return null;
@@ -50,7 +50,7 @@ function getEncoding(
export function readlink(
path: string | URL,
optOrCallback: ReadlinkCallback | ReadlinkOptions,
- callback?: ReadlinkCallback
+ callback?: ReadlinkCallback,
): void {
path = path instanceof URL ? fromFileUrl(path) : path;
@@ -67,13 +67,13 @@ export function readlink(
Deno.readLink,
(data: string): string | Uint8Array => maybeEncode(data, encoding),
cb,
- path
+ path,
);
}
export function readlinkSync(
path: string | URL,
- opt?: ReadlinkOptions
+ opt?: ReadlinkOptions,
): string | Uint8Array {
path = path instanceof URL ? fromFileUrl(path) : path;
diff --git a/std/node/_fs/_fs_writeFile.ts b/std/node/_fs/_fs_writeFile.ts
index 8a66f3f3d..a8ae1f586 100644
--- a/std/node/_fs/_fs_writeFile.ts
+++ b/std/node/_fs/_fs_writeFile.ts
@@ -17,7 +17,7 @@ export function writeFile(
pathOrRid: string | number | URL,
data: string | Uint8Array,
optOrCallback: Encodings | CallbackWithError | WriteFileOptions | undefined,
- callback?: CallbackWithError
+ callback?: CallbackWithError,
): void {
const callbackFn: CallbackWithError | undefined =
optOrCallback instanceof Function ? optOrCallback : callback;
@@ -72,7 +72,7 @@ export function writeFile(
export function writeFileSync(
pathOrRid: string | number | URL,
data: string | Uint8Array,
- options?: Encodings | WriteFileOptions
+ options?: Encodings | WriteFileOptions,
): void {
pathOrRid = pathOrRid instanceof URL ? fromFileUrl(pathOrRid) : pathOrRid;
diff --git a/std/node/_fs/_fs_writeFile_test.ts b/std/node/_fs/_fs_writeFile_test.ts
index 015ed6553..a11e0fb67 100644
--- a/std/node/_fs/_fs_writeFile_test.ts
+++ b/std/node/_fs/_fs_writeFile_test.ts
@@ -18,7 +18,7 @@ Deno.test("Callback must be a function error", function fn() {
writeFile("some/path", "some data", "utf8");
},
TypeError,
- "Callback must be a function."
+ "Callback must be a function.",
);
});
@@ -29,7 +29,7 @@ Deno.test("Invalid encoding results in error()", function testEncodingErrors() {
writeFile("some/path", "some data", "made-up-encoding", () => {});
},
Error,
- `The value "made-up-encoding" is invalid for option "encoding"`
+ `The value "made-up-encoding" is invalid for option "encoding"`,
);
assertThrows(
@@ -38,7 +38,7 @@ Deno.test("Invalid encoding results in error()", function testEncodingErrors() {
writeFileSync("some/path", "some data", "made-up-encoding");
},
Error,
- `The value "made-up-encoding" is invalid for option "encoding"`
+ `The value "made-up-encoding" is invalid for option "encoding"`,
);
assertThrows(
@@ -50,11 +50,11 @@ Deno.test("Invalid encoding results in error()", function testEncodingErrors() {
// @ts-expect-error Type '"made-up-encoding"' is not assignable to type
encoding: "made-up-encoding",
},
- () => {}
+ () => {},
);
},
Error,
- `The value "made-up-encoding" is invalid for option "encoding"`
+ `The value "made-up-encoding" is invalid for option "encoding"`,
);
assertThrows(
@@ -65,7 +65,7 @@ Deno.test("Invalid encoding results in error()", function testEncodingErrors() {
});
},
Error,
- `The value "made-up-encoding" is invalid for option "encoding"`
+ `The value "made-up-encoding" is invalid for option "encoding"`,
);
});
@@ -77,7 +77,7 @@ Deno.test(
writeFile("some/path", "some data", "utf16le", () => {});
},
Error,
- `Not implemented: "utf16le" encoding`
+ `Not implemented: "utf16le" encoding`,
);
assertThrows(
@@ -85,9 +85,9 @@ Deno.test(
writeFileSync("some/path", "some data", "utf16le");
},
Error,
- `Not implemented: "utf16le" encoding`
+ `Not implemented: "utf16le" encoding`,
);
- }
+ },
);
Deno.test(
@@ -111,7 +111,7 @@ Deno.test(
const data = await Deno.readFile(tempFile);
await Deno.remove(tempFile);
assertEquals(decoder.decode(data), "hello world");
- }
+ },
);
Deno.test(
@@ -125,7 +125,7 @@ Deno.test(
await Deno.remove("_fs_writeFile_test_file.txt");
assertEquals(res, null);
assertEquals(decoder.decode(data), "hello world");
- }
+ },
);
Deno.test(
@@ -146,7 +146,7 @@ Deno.test(
"_fs_writeFile_test_file.txt",
value,
encoding as TextEncodings,
- resolve
+ resolve,
);
});
@@ -155,7 +155,7 @@ Deno.test(
assertEquals(res, null);
assertEquals(decoder.decode(data), "hello world");
}
- }
+ },
);
Deno.test("Path can be an URL", async function testCorrectWriteUsingURL() {
@@ -165,7 +165,7 @@ Deno.test("Path can be an URL", async function testCorrectWriteUsingURL() {
path
.join(testDataDir, "_fs_writeFile_test_file_url.txt")
.replace(/\\/g, "/")
- : "file://" + path.join(testDataDir, "_fs_writeFile_test_file_url.txt")
+ : "file://" + path.join(testDataDir, "_fs_writeFile_test_file_url.txt"),
);
const filePath = path.fromFileUrl(url);
const res = await new Promise((resolve) => {
@@ -218,7 +218,7 @@ Deno.test(
await Deno.remove(filename);
assert(fileInfo.mode);
assertNotEquals(fileInfo.mode & 0o777, 0o777);
- }
+ },
);
Deno.test(
@@ -237,7 +237,7 @@ Deno.test(
const data = Deno.readFileSync(tempFile);
Deno.removeSync(tempFile);
assertEquals(decoder.decode(data), "hello world");
- }
+ },
);
Deno.test(
@@ -260,7 +260,7 @@ Deno.test(
Deno.removeSync(file);
assertEquals(decoder.decode(data), "hello world");
}
- }
+ },
);
Deno.test(
@@ -273,18 +273,18 @@ Deno.test(
const data = Deno.readFileSync(file);
Deno.removeSync(file);
assertEquals(decoder.decode(data), "hello world");
- }
+ },
);
Deno.test("sync: Path can be an URL", function testCorrectWriteSyncUsingURL() {
const filePath = path.join(
testDataDir,
- "_fs_writeFileSync_test_file_url.txt"
+ "_fs_writeFileSync_test_file_url.txt",
);
const url = new URL(
Deno.build.os === "windows"
? "file:///" + filePath.replace(/\\/g, "/")
- : "file://" + filePath
+ : "file://" + filePath,
);
writeFileSync(url, "hello world");
@@ -305,5 +305,5 @@ Deno.test(
Deno.removeSync(filename);
assert(fileInfo && fileInfo.mode);
assertEquals(fileInfo.mode & 0o777, 0o777);
- }
+ },
);
diff --git a/std/node/_fs/promises/_fs_readFile.ts b/std/node/_fs/promises/_fs_readFile.ts
index 8677e05cd..446c48625 100644
--- a/std/node/_fs/promises/_fs_readFile.ts
+++ b/std/node/_fs/promises/_fs_readFile.ts
@@ -8,15 +8,15 @@ import { readFile as readFileCallback } from "../_fs_readFile.ts";
export function readFile(
path: string | URL,
- options: TextOptionsArgument
+ options: TextOptionsArgument,
): Promise<string>;
export function readFile(
path: string | URL,
- options?: BinaryOptionsArgument
+ options?: BinaryOptionsArgument,
): Promise<Uint8Array>;
export function readFile(
path: string | URL,
- options?: FileOptionsArgument
+ options?: FileOptionsArgument,
): Promise<string | Uint8Array> {
return new Promise((resolve, reject) => {
readFileCallback(path, options, (err, data): void => {
diff --git a/std/node/_fs/promises/_fs_readFile_test.ts b/std/node/_fs/promises/_fs_readFile_test.ts
index 1d2097881..a5f5a1327 100644
--- a/std/node/_fs/promises/_fs_readFile_test.ts
+++ b/std/node/_fs/promises/_fs_readFile_test.ts
@@ -3,7 +3,7 @@ import * as path from "../../../path/mod.ts";
import { assertEquals, assert } from "../../../testing/asserts.ts";
const testData = path.resolve(
- path.join("node", "_fs", "testdata", "hello.txt")
+ path.join("node", "_fs", "testdata", "hello.txt"),
);
Deno.test("readFileSuccess", async function () {
diff --git a/std/node/_fs/promises/_fs_writeFile.ts b/std/node/_fs/promises/_fs_writeFile.ts
index 48b9bf0ea..1c9ea5032 100644
--- a/std/node/_fs/promises/_fs_writeFile.ts
+++ b/std/node/_fs/promises/_fs_writeFile.ts
@@ -6,7 +6,7 @@ import { writeFile as writeFileCallback } from "../_fs_writeFile.ts";
export function writeFile(
pathOrRid: string | number | URL,
data: string | Uint8Array,
- options?: Encodings | WriteFileOptions
+ options?: Encodings | WriteFileOptions,
): Promise<void> {
return new Promise((resolve, reject) => {
writeFileCallback(pathOrRid, data, options, (err?: Error | null) => {
diff --git a/std/node/_fs/promises/_fs_writeFile_test.ts b/std/node/_fs/promises/_fs_writeFile_test.ts
index 6901fff22..698284057 100644
--- a/std/node/_fs/promises/_fs_writeFile_test.ts
+++ b/std/node/_fs/promises/_fs_writeFile_test.ts
@@ -17,7 +17,7 @@ Deno.test("Invalid encoding results in error()", function testEncodingErrors() {
await writeFile("some/path", "some data", "made-up-encoding");
},
Error,
- `The value "made-up-encoding" is invalid for option "encoding"`
+ `The value "made-up-encoding" is invalid for option "encoding"`,
);
assertThrowsAsync(
async () => {
@@ -27,7 +27,7 @@ Deno.test("Invalid encoding results in error()", function testEncodingErrors() {
});
},
Error,
- `The value "made-up-encoding" is invalid for option "encoding"`
+ `The value "made-up-encoding" is invalid for option "encoding"`,
);
});
@@ -39,9 +39,9 @@ Deno.test(
await writeFile("some/path", "some data", "utf16le");
},
Error,
- `Not implemented: "utf16le" encoding`
+ `Not implemented: "utf16le" encoding`,
);
- }
+ },
);
Deno.test(
@@ -60,7 +60,7 @@ Deno.test(
const data = await Deno.readFile(tempFile);
await Deno.remove(tempFile);
assertEquals(decoder.decode(data), "hello world");
- }
+ },
);
Deno.test(
@@ -74,7 +74,7 @@ Deno.test(
const data = await Deno.readFile("_fs_writeFile_test_file.txt");
await Deno.remove("_fs_writeFile_test_file.txt");
assertEquals(decoder.decode(data), "hello world");
- }
+ },
);
Deno.test(
@@ -93,14 +93,14 @@ Deno.test(
await writeFile(
"_fs_writeFile_test_file.txt",
value,
- encoding as TextEncodings
+ encoding as TextEncodings,
);
const data = await Deno.readFile("_fs_writeFile_test_file.txt");
await Deno.remove("_fs_writeFile_test_file.txt");
assertEquals(decoder.decode(data), "hello world");
}
- }
+ },
);
Deno.test("Mode is correctly set", async function testCorrectFileMode() {
@@ -133,5 +133,5 @@ Deno.test(
await Deno.remove(filename);
assert(fileInfo.mode);
assertNotEquals(fileInfo.mode & 0o777, 0o777);
- }
+ },
);
diff --git a/std/node/_util/_util_callbackify.ts b/std/node/_util/_util_callbackify.ts
index 4c752e7ef..b37bf829a 100644
--- a/std/node/_util/_util_callbackify.ts
+++ b/std/node/_util/_util_callbackify.ts
@@ -42,30 +42,30 @@ type Callback<ResultT> =
| ((err: null, result: ResultT) => void);
function callbackify<ResultT>(
- fn: () => PromiseLike<ResultT>
+ fn: () => PromiseLike<ResultT>,
): (callback: Callback<ResultT>) => void;
function callbackify<ArgT, ResultT>(
- fn: (arg: ArgT) => PromiseLike<ResultT>
+ fn: (arg: ArgT) => PromiseLike<ResultT>,
): (arg: ArgT, callback: Callback<ResultT>) => void;
function callbackify<Arg1T, Arg2T, ResultT>(
- fn: (arg1: Arg1T, arg2: Arg2T) => PromiseLike<ResultT>
+ fn: (arg1: Arg1T, arg2: Arg2T) => PromiseLike<ResultT>,
): (arg1: Arg1T, arg2: Arg2T, callback: Callback<ResultT>) => void;
function callbackify<Arg1T, Arg2T, Arg3T, ResultT>(
- fn: (arg1: Arg1T, arg2: Arg2T, arg3: Arg3T) => PromiseLike<ResultT>
+ fn: (arg1: Arg1T, arg2: Arg2T, arg3: Arg3T) => PromiseLike<ResultT>,
): (arg1: Arg1T, arg2: Arg2T, arg3: Arg3T, callback: Callback<ResultT>) => void;
function callbackify<Arg1T, Arg2T, Arg3T, Arg4T, ResultT>(
fn: (
arg1: Arg1T,
arg2: Arg2T,
arg3: Arg3T,
- arg4: Arg4T
- ) => PromiseLike<ResultT>
+ arg4: Arg4T,
+ ) => PromiseLike<ResultT>,
): (
arg1: Arg1T,
arg2: Arg2T,
arg3: Arg3T,
arg4: Arg4T,
- callback: Callback<ResultT>
+ callback: Callback<ResultT>,
) => void;
function callbackify<Arg1T, Arg2T, Arg3T, Arg4T, Arg5T, ResultT>(
fn: (
@@ -73,15 +73,15 @@ function callbackify<Arg1T, Arg2T, Arg3T, Arg4T, Arg5T, ResultT>(
arg2: Arg2T,
arg3: Arg3T,
arg4: Arg4T,
- arg5: Arg5T
- ) => PromiseLike<ResultT>
+ arg5: Arg5T,
+ ) => PromiseLike<ResultT>,
): (
arg1: Arg1T,
arg2: Arg2T,
arg3: Arg3T,
arg4: Arg4T,
arg5: Arg5T,
- callback: Callback<ResultT>
+ callback: Callback<ResultT>,
) => void;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -105,7 +105,7 @@ function callbackify(original: any): any {
(rej: unknown) => {
rej = rej || new NodeFalsyValueRejectionError(rej);
queueMicrotask(cb.bind(this, rej));
- }
+ },
);
};
diff --git a/std/node/_util/_util_callbackify_test.ts b/std/node/_util/_util_callbackify_test.ts
index e8a313905..d585f0551 100644
--- a/std/node/_util/_util_callbackify_test.ts
+++ b/std/node/_util/_util_callbackify_test.ts
@@ -58,7 +58,7 @@ class TestQueue {
if (this.#queueSize === 0) {
assert(
this.#resolve,
- "Test setup error; async queue is missing #resolve"
+ "Test setup error; async queue is missing #resolve",
);
this.#resolve();
}
@@ -127,7 +127,7 @@ Deno.test(
}
await testQueue.waitForCompletion();
- }
+ },
);
Deno.test(
@@ -152,7 +152,7 @@ Deno.test(
assertStrictEquals(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(err as any).code,
- "ERR_FALSY_VALUE_REJECTION"
+ "ERR_FALSY_VALUE_REJECTION",
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
assertStrictEquals((err as any).reason, value);
@@ -188,7 +188,7 @@ Deno.test(
assertStrictEquals(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(err as any).code,
- "ERR_FALSY_VALUE_REJECTION"
+ "ERR_FALSY_VALUE_REJECTION",
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
assertStrictEquals((err as any).reason, value);
@@ -222,7 +222,7 @@ Deno.test(
assertStrictEquals(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(err as any).code,
- "ERR_FALSY_VALUE_REJECTION"
+ "ERR_FALSY_VALUE_REJECTION",
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
assertStrictEquals((err as any).reason, value);
@@ -238,7 +238,7 @@ Deno.test(
}
await testQueue.waitForCompletion();
- }
+ },
);
Deno.test("callbackify passes arguments to the original", async () => {
@@ -304,7 +304,7 @@ Deno.test("callbackify preserves the `this` binding", async () => {
cbSyncFunction.call(objectWithSyncFunction, value, function (
this: unknown,
err: unknown,
- ret: unknown
+ ret: unknown,
) {
assertStrictEquals(err, null);
assertStrictEquals(ret, value);
@@ -325,7 +325,7 @@ Deno.test("callbackify preserves the `this` binding", async () => {
cbAsyncFunction.call(objectWithAsyncFunction, value, function (
this: unknown,
err: unknown,
- ret: unknown
+ ret: unknown,
) {
assertStrictEquals(err, null);
assertStrictEquals(ret, value);
@@ -351,7 +351,7 @@ Deno.test("callbackify throws with non-function inputs", () => {
assertStrictEquals(err.name, "TypeError");
assertStrictEquals(
err.message,
- 'The "original" argument must be of type function.'
+ 'The "original" argument must be of type function.',
);
}
});
@@ -382,9 +382,9 @@ Deno.test(
assertStrictEquals(err.name, "TypeError");
assertStrictEquals(
err.message,
- "The last argument must be of type function."
+ "The last argument must be of type function.",
);
}
});
- }
+ },
);
diff --git a/std/node/_util/_util_promisify.ts b/std/node/_util/_util_promisify.ts
index ea2fb6a5e..9e86b5a09 100644
--- a/std/node/_util/_util_promisify.ts
+++ b/std/node/_util/_util_promisify.ts
@@ -32,7 +32,7 @@ declare let Symbol: SymbolConstructor;
interface SymbolConstructor {
for(key: "nodejs.util.promisify.custom"): typeof _CustomPromisifiedSymbol;
for(
- key: "nodejs.util.promisify.customArgs"
+ key: "nodejs.util.promisify.customArgs",
): typeof _CustomPromisifyArgsSymbol;
}
// End hack.
@@ -44,21 +44,22 @@ const kCustomPromisifiedSymbol = Symbol.for("nodejs.util.promisify.custom");
// This is an internal Node symbol used by functions returning multiple
// arguments, e.g. ['bytesRead', 'buffer'] for fs.read().
const kCustomPromisifyArgsSymbol = Symbol.for(
- "nodejs.util.promisify.customArgs"
+ "nodejs.util.promisify.customArgs",
);
class NodeInvalidArgTypeError extends TypeError {
public code = "ERR_INVALID_ARG_TYPE";
constructor(argumentName: string, type: string, received: unknown) {
super(
- `The "${argumentName}" argument must be of type ${type}. Received ${typeof received}`
+ `The "${argumentName}" argument must be of type ${type}. Received ${typeof received}`,
);
}
}
export function promisify(original: Function): Function {
- if (typeof original !== "function")
+ if (typeof original !== "function") {
throw new NodeInvalidArgTypeError("original", "Function", original);
+ }
// @ts-ignore TypeScript (as of 3.7) does not support indexing namespaces by symbol
if (original[kCustomPromisifiedSymbol]) {
@@ -68,7 +69,7 @@ export function promisify(original: Function): Function {
throw new NodeInvalidArgTypeError(
"util.promisify.custom",
"Function",
- fn
+ fn,
);
}
return Object.defineProperty(fn, kCustomPromisifiedSymbol, {
@@ -115,7 +116,7 @@ export function promisify(original: Function): Function {
});
return Object.defineProperties(
fn,
- Object.getOwnPropertyDescriptors(original)
+ Object.getOwnPropertyDescriptors(original),
);
}
diff --git a/std/node/_util/_util_promisify_test.ts b/std/node/_util/_util_promisify_test.ts
index 4369a0132..5148bc609 100644
--- a/std/node/_util/_util_promisify_test.ts
+++ b/std/node/_util/_util_promisify_test.ts
@@ -36,7 +36,7 @@ Deno.test(
"Errors should reject the promise",
async function testPromiseRejection() {
await assertThrowsAsync(() => readFile("/dontexist"), Deno.errors.NotFound);
- }
+ },
);
Deno.test("Promisify.custom", async function testPromisifyCustom() {
@@ -106,7 +106,7 @@ Deno.test(
}
const value = await promisify(fn)();
assertStrictEquals(value, "foo");
- }
+ },
);
Deno.test(
@@ -117,7 +117,7 @@ Deno.test(
}
const value = await promisify(fn)();
assertStrictEquals(value, undefined);
- }
+ },
);
Deno.test(
@@ -128,7 +128,7 @@ Deno.test(
}
const value = await promisify(fn)();
assertStrictEquals(value, undefined);
- }
+ },
);
Deno.test(
@@ -139,7 +139,7 @@ Deno.test(
}
const value = await promisify(fn)(null, 42);
assertStrictEquals(value, 42);
- }
+ },
);
Deno.test(
@@ -151,9 +151,9 @@ Deno.test(
await assertThrowsAsync(
() => promisify(fn)(new Error("oops"), null),
Error,
- "oops"
+ "oops",
);
- }
+ },
);
Deno.test("Rejected value", async function testPromisifyWithAsObjectMethod() {
@@ -173,7 +173,7 @@ Deno.test(
"Multiple callback",
async function testPromisifyWithMultipleCallback() {
const err = new Error(
- "Should not have called the callback with the error."
+ "Should not have called the callback with the error.",
);
const stack = err.stack;
@@ -185,7 +185,7 @@ Deno.test(
await fn();
await Promise.resolve();
return assertStrictEquals(stack, err.stack);
- }
+ },
);
Deno.test("Promisify a promise", function testPromisifyPromise() {
@@ -203,7 +203,7 @@ Deno.test("Test error", async function testInvalidArguments() {
a: number,
b: number,
c: number,
- cb: Function
+ cb: Function,
): void {
errToThrow = new Error(`${a}-${b}-${c}-${cb}`);
throw errToThrow;
@@ -227,7 +227,7 @@ Deno.test("Test invalid arguments", function testInvalidArguments() {
assert(e instanceof TypeError);
assertEquals(
e.message,
- `The "original" argument must be of type Function. Received ${typeof input}`
+ `The "original" argument must be of type Function. Received ${typeof input}`,
);
}
});
diff --git a/std/node/_util/_util_types.ts b/std/node/_util/_util_types.ts
index df8ccbb05..eaf955b35 100644
--- a/std/node/_util/_util_types.ts
+++ b/std/node/_util/_util_types.ts
@@ -194,7 +194,8 @@ export function isSymbolObject(value: unknown): boolean {
// Adapted from Lodash
export function isTypedArray(value: unknown): boolean {
/** Used to match `toStringTag` values of typed arrays. */
- const reTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/;
+ const reTypedTag =
+ /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/;
return _isObjectLike(value) && reTypedTag.test(_toString.call(value));
}
diff --git a/std/node/_util/_util_types_test.ts b/std/node/_util/_util_types_test.ts
index f6dfcfe89..fff0dad0c 100644
--- a/std/node/_util/_util_types_test.ts
+++ b/std/node/_util/_util_types_test.ts
@@ -229,14 +229,14 @@ Deno.test("Should return false for invalid Float64Array types", () => {
Deno.test("Should return true for valid generator functions", () => {
assertStrictEquals(
isGeneratorFunction(function* foo() {}),
- true
+ true,
);
});
Deno.test("Should return false for invalid generator functions", () => {
assertStrictEquals(
isGeneratorFunction(function foo() {}),
- false
+ false,
);
});
@@ -249,7 +249,7 @@ Deno.test("Should return true for valid generator object types", () => {
Deno.test("Should return false for invalid generation object types", () => {
assertStrictEquals(
isGeneratorObject(function* foo() {}),
- false
+ false,
);
});
diff --git a/std/node/_utils.ts b/std/node/_utils.ts
index 66b7b10d9..0e8b26fb5 100644
--- a/std/node/_utils.ts
+++ b/std/node/_utils.ts
@@ -65,8 +65,9 @@ function slowCases(enc: string): string | undefined {
if (enc === "ucs2") return "utf16le";
break;
case 3:
- if (enc === "hex" || enc === "HEX" || `${enc}`.toLowerCase() === "hex")
+ if (enc === "hex" || enc === "HEX" || `${enc}`.toLowerCase() === "hex") {
return "hex";
+ }
break;
case 5:
if (enc === "ascii") return "ascii";
@@ -93,16 +94,18 @@ function slowCases(enc: string): string | undefined {
enc === "utf16le" ||
enc === "UTF16LE" ||
`${enc}`.toLowerCase() === "utf16le"
- )
+ ) {
return "utf16le";
+ }
break;
case 8:
if (
enc === "utf-16le" ||
enc === "UTF-16LE" ||
`${enc}`.toLowerCase() === "utf-16le"
- )
+ ) {
return "utf16le";
+ }
break;
default:
if (enc === "") return "utf8";
diff --git a/std/node/buffer.ts b/std/node/buffer.ts
index 9c8d8784c..7656803d9 100644
--- a/std/node/buffer.ts
+++ b/std/node/buffer.ts
@@ -18,8 +18,9 @@ function checkEncoding(encoding = "utf8", strict = true): string {
const normalized = normalizeEncoding(encoding);
- if (normalized === undefined)
+ if (normalized === undefined) {
throw new TypeError(`Unkown encoding: ${encoding}`);
+ }
if (notImplementedEncodings.includes(encoding)) {
notImplemented(`"${encoding}" encoding`);
@@ -78,11 +79,11 @@ export default class Buffer extends Uint8Array {
static alloc(
size: number,
fill?: number | string | Uint8Array | Buffer,
- encoding = "utf8"
+ encoding = "utf8",
): Buffer {
if (typeof size !== "number") {
throw new TypeError(
- `The "size" argument must be of type number. Received type ${typeof size}`
+ `The "size" argument must be of type number. Received type ${typeof size}`,
);
}
@@ -92,15 +93,17 @@ export default class Buffer extends Uint8Array {
let bufFill;
if (typeof fill === "string") {
encoding = checkEncoding(encoding);
- if (typeof fill === "string" && fill.length === 1 && encoding === "utf8")
+ if (
+ typeof fill === "string" && fill.length === 1 && encoding === "utf8"
+ ) {
buf.fill(fill.charCodeAt(0));
- else bufFill = Buffer.from(fill, encoding);
+ } else bufFill = Buffer.from(fill, encoding);
} else if (typeof fill === "number") {
buf.fill(fill);
} else if (fill instanceof Uint8Array) {
if (fill.length === 0) {
throw new TypeError(
- `The argument "value" is invalid. Received ${fill.constructor.name} []`
+ `The argument "value" is invalid. Received ${fill.constructor.name} []`,
);
}
@@ -108,8 +111,9 @@ export default class Buffer extends Uint8Array {
}
if (bufFill) {
- if (bufFill.length > buf.length)
+ if (bufFill.length > buf.length) {
bufFill = bufFill.subarray(0, buf.length);
+ }
let offset = 0;
while (offset < size) {
@@ -136,7 +140,7 @@ export default class Buffer extends Uint8Array {
*/
static byteLength(
string: string | Buffer | ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
- encoding = "utf8"
+ encoding = "utf8",
): number {
if (typeof string != "string") return string.byteLength;
@@ -180,7 +184,7 @@ export default class Buffer extends Uint8Array {
static from(
arrayBuffer: ArrayBuffer | SharedArrayBuffer,
byteOffset?: number,
- length?: number
+ length?: number,
): Buffer;
/**
* Copies the passed buffer data onto a new Buffer instance.
@@ -194,12 +198,14 @@ export default class Buffer extends Uint8Array {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
value: any,
offsetOrEncoding?: number | string,
- length?: number
+ length?: number,
): Buffer {
- const offset =
- typeof offsetOrEncoding === "string" ? undefined : offsetOrEncoding;
- let encoding =
- typeof offsetOrEncoding === "string" ? offsetOrEncoding : undefined;
+ const offset = typeof offsetOrEncoding === "string"
+ ? undefined
+ : offsetOrEncoding;
+ let encoding = typeof offsetOrEncoding === "string"
+ ? offsetOrEncoding
+ : undefined;
if (typeof value == "string") {
encoding = checkEncoding(encoding, false);
@@ -236,7 +242,7 @@ export default class Buffer extends Uint8Array {
targetBuffer: Buffer | Uint8Array,
targetStart = 0,
sourceStart = 0,
- sourceEnd = this.length
+ sourceEnd = this.length,
): number {
const sourceBuffer = this.subarray(sourceStart, sourceEnd);
targetBuffer.set(sourceBuffer, targetStart);
@@ -249,7 +255,7 @@ export default class Buffer extends Uint8Array {
equals(otherBuffer: Uint8Array | Buffer): boolean {
if (!(otherBuffer instanceof Uint8Array)) {
throw new TypeError(
- `The "otherBuffer" argument must be an instance of Buffer or Uint8Array. Received type ${typeof otherBuffer}`
+ `The "otherBuffer" argument must be an instance of Buffer or Uint8Array. Received type ${typeof otherBuffer}`,
);
}
@@ -267,14 +273,14 @@ export default class Buffer extends Uint8Array {
return new DataView(
this.buffer,
this.byteOffset,
- this.byteLength
+ this.byteLength,
).getBigInt64(offset);
}
readBigInt64LE(offset = 0): bigint {
return new DataView(
this.buffer,
this.byteOffset,
- this.byteLength
+ this.byteLength,
).getBigInt64(offset, true);
}
@@ -282,14 +288,14 @@ export default class Buffer extends Uint8Array {
return new DataView(
this.buffer,
this.byteOffset,
- this.byteLength
+ this.byteLength,
).getBigUint64(offset);
}
readBigUInt64LE(offset = 0): bigint {
return new DataView(
this.buffer,
this.byteOffset,
- this.byteLength
+ this.byteLength,
).getBigUint64(offset, true);
}
@@ -297,14 +303,14 @@ export default class Buffer extends Uint8Array {
return new DataView(
this.buffer,
this.byteOffset,
- this.byteLength
+ this.byteLength,
).getFloat64(offset);
}
readDoubleLE(offset = 0): number {
return new DataView(
this.buffer,
this.byteOffset,
- this.byteLength
+ this.byteLength,
).getFloat64(offset, true);
}
@@ -312,50 +318,50 @@ export default class Buffer extends Uint8Array {
return new DataView(
this.buffer,
this.byteOffset,
- this.byteLength
+ this.byteLength,
).getFloat32(offset);
}
readFloatLE(offset = 0): number {
return new DataView(
this.buffer,
this.byteOffset,
- this.byteLength
+ this.byteLength,
).getFloat32(offset, true);
}
readInt8(offset = 0): number {
return new DataView(this.buffer, this.byteOffset, this.byteLength).getInt8(
- offset
+ offset,
);
}
readInt16BE(offset = 0): number {
return new DataView(this.buffer, this.byteOffset, this.byteLength).getInt16(
- offset
+ offset,
);
}
readInt16LE(offset = 0): number {
return new DataView(this.buffer, this.byteOffset, this.byteLength).getInt16(
offset,
- true
+ true,
);
}
readInt32BE(offset = 0): number {
return new DataView(this.buffer, this.byteOffset, this.byteLength).getInt32(
- offset
+ offset,
);
}
readInt32LE(offset = 0): number {
return new DataView(this.buffer, this.byteOffset, this.byteLength).getInt32(
offset,
- true
+ true,
);
}
readUInt8(offset = 0): number {
return new DataView(this.buffer, this.byteOffset, this.byteLength).getUint8(
- offset
+ offset,
);
}
@@ -363,14 +369,14 @@ export default class Buffer extends Uint8Array {
return new DataView(
this.buffer,
this.byteOffset,
- this.byteLength
+ this.byteLength,
).getUint16(offset);
}
readUInt16LE(offset = 0): number {
return new DataView(
this.buffer,
this.byteOffset,
- this.byteLength
+ this.byteLength,
).getUint16(offset, true);
}
@@ -378,14 +384,14 @@ export default class Buffer extends Uint8Array {
return new DataView(
this.buffer,
this.byteOffset,
- this.byteLength
+ this.byteLength,
).getUint32(offset);
}
readUInt32LE(offset = 0): number {
return new DataView(
this.buffer,
this.byteOffset,
- this.byteLength
+ this.byteLength,
).getUint32(offset, true);
}
@@ -429,14 +435,14 @@ export default class Buffer extends Uint8Array {
write(string: string, offset = 0, length = this.length): number {
return new TextEncoder().encodeInto(
string,
- this.subarray(offset, offset + length)
+ this.subarray(offset, offset + length),
).written;
}
writeBigInt64BE(value: bigint, offset = 0): number {
new DataView(this.buffer, this.byteOffset, this.byteLength).setBigInt64(
offset,
- value
+ value,
);
return offset + 4;
}
@@ -444,7 +450,7 @@ export default class Buffer extends Uint8Array {
new DataView(this.buffer, this.byteOffset, this.byteLength).setBigInt64(
offset,
value,
- true
+ true,
);
return offset + 4;
}
@@ -452,7 +458,7 @@ export default class Buffer extends Uint8Array {
writeBigUInt64BE(value: bigint, offset = 0): number {
new DataView(this.buffer, this.byteOffset, this.byteLength).setBigUint64(
offset,
- value
+ value,
);
return offset + 4;
}
@@ -460,7 +466,7 @@ export default class Buffer extends Uint8Array {
new DataView(this.buffer, this.byteOffset, this.byteLength).setBigUint64(
offset,
value,
- true
+ true,
);
return offset + 4;
}
@@ -468,7 +474,7 @@ export default class Buffer extends Uint8Array {
writeDoubleBE(value: number, offset = 0): number {
new DataView(this.buffer, this.byteOffset, this.byteLength).setFloat64(
offset,
- value
+ value,
);
return offset + 8;
}
@@ -476,7 +482,7 @@ export default class Buffer extends Uint8Array {
new DataView(this.buffer, this.byteOffset, this.byteLength).setFloat64(
offset,
value,
- true
+ true,
);
return offset + 8;
}
@@ -484,7 +490,7 @@ export default class Buffer extends Uint8Array {
writeFloatBE(value: number, offset = 0): number {
new DataView(this.buffer, this.byteOffset, this.byteLength).setFloat32(
offset,
- value
+ value,
);
return offset + 4;
}
@@ -492,7 +498,7 @@ export default class Buffer extends Uint8Array {
new DataView(this.buffer, this.byteOffset, this.byteLength).setFloat32(
offset,
value,
- true
+ true,
);
return offset + 4;
}
@@ -500,7 +506,7 @@ export default class Buffer extends Uint8Array {
writeInt8(value: number, offset = 0): number {
new DataView(this.buffer, this.byteOffset, this.byteLength).setInt8(
offset,
- value
+ value,
);
return offset + 1;
}
@@ -508,7 +514,7 @@ export default class Buffer extends Uint8Array {
writeInt16BE(value: number, offset = 0): number {
new DataView(this.buffer, this.byteOffset, this.byteLength).setInt16(
offset,
- value
+ value,
);
return offset + 2;
}
@@ -516,7 +522,7 @@ export default class Buffer extends Uint8Array {
new DataView(this.buffer, this.byteOffset, this.byteLength).setInt16(
offset,
value,
- true
+ true,
);
return offset + 2;
}
@@ -524,7 +530,7 @@ export default class Buffer extends Uint8Array {
writeInt32BE(value: number, offset = 0): number {
new DataView(this.buffer, this.byteOffset, this.byteLength).setUint32(
offset,
- value
+ value,
);
return offset + 4;
}
@@ -532,7 +538,7 @@ export default class Buffer extends Uint8Array {
new DataView(this.buffer, this.byteOffset, this.byteLength).setInt32(
offset,
value,
- true
+ true,
);
return offset + 4;
}
@@ -540,7 +546,7 @@ export default class Buffer extends Uint8Array {
writeUInt8(value: number, offset = 0): number {
new DataView(this.buffer, this.byteOffset, this.byteLength).setUint8(
offset,
- value
+ value,
);
return offset + 1;
}
@@ -548,7 +554,7 @@ export default class Buffer extends Uint8Array {
writeUInt16BE(value: number, offset = 0): number {
new DataView(this.buffer, this.byteOffset, this.byteLength).setUint16(
offset,
- value
+ value,
);
return offset + 2;
}
@@ -556,7 +562,7 @@ export default class Buffer extends Uint8Array {
new DataView(this.buffer, this.byteOffset, this.byteLength).setUint16(
offset,
value,
- true
+ true,
);
return offset + 2;
}
@@ -564,7 +570,7 @@ export default class Buffer extends Uint8Array {
writeUInt32BE(value: number, offset = 0): number {
new DataView(this.buffer, this.byteOffset, this.byteLength).setUint32(
offset,
- value
+ value,
);
return offset + 4;
}
@@ -572,7 +578,7 @@ export default class Buffer extends Uint8Array {
new DataView(this.buffer, this.byteOffset, this.byteLength).setUint32(
offset,
value,
- true
+ true,
);
return offset + 4;
}
diff --git a/std/node/buffer_test.ts b/std/node/buffer_test.ts
index f96fa8e4b..5d01a4b67 100644
--- a/std/node/buffer_test.ts
+++ b/std/node/buffer_test.ts
@@ -22,7 +22,7 @@ Deno.test({
},
RangeError,
"Invalid typed array length: -1",
- "should throw on negative numbers"
+ "should throw on negative numbers",
);
},
});
@@ -41,7 +41,7 @@ Deno.test({
},
TypeError,
`The "size" argument must be of type number. Received type ${typeof size}`,
- "should throw on non-number size"
+ "should throw on non-number size",
);
}
},
@@ -62,7 +62,7 @@ Deno.test({
},
TypeError,
`The argument "value" is invalid. Received ${value.constructor.name} []`,
- "should throw for empty Buffer/Uint8Array"
+ "should throw for empty Buffer/Uint8Array",
);
}
},
@@ -132,7 +132,7 @@ Deno.test({
fn() {
assertEquals(
Buffer.alloc(11, "aGVsbG8gd29ybGQ=", "base64"),
- new Uint8Array([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100])
+ new Uint8Array([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]),
);
},
});
@@ -142,7 +142,7 @@ Deno.test({
fn() {
assertEquals(
Buffer.alloc(4, "64656e6f", "hex"),
- new Uint8Array([100, 101, 110, 111])
+ new Uint8Array([100, 101, 110, 111]),
);
},
});
@@ -152,7 +152,7 @@ Deno.test({
fn() {
assertEquals(
Buffer.alloc(13, "64656e6f", "hex").toString(),
- "denodenodenod"
+ "denodenodenod",
);
},
});
@@ -162,11 +162,11 @@ Deno.test({
fn() {
assertEquals(
Buffer.alloc(7, new Uint8Array([100, 101])),
- new Uint8Array([100, 101, 100, 101, 100, 101, 100])
+ new Uint8Array([100, 101, 100, 101, 100, 101, 100]),
);
assertEquals(
Buffer.alloc(6, new Uint8Array([100, 101])),
- new Uint8Array([100, 101, 100, 101, 100, 101])
+ new Uint8Array([100, 101, 100, 101, 100, 101]),
);
},
});
@@ -176,7 +176,7 @@ Deno.test({
fn() {
assertEquals(
Buffer.alloc(1, new Uint8Array([100, 101])),
- new Uint8Array([100])
+ new Uint8Array([100]),
);
},
});
@@ -186,11 +186,11 @@ Deno.test({
fn() {
assertEquals(
Buffer.alloc(6, new Buffer([100, 101])),
- new Uint8Array([100, 101, 100, 101, 100, 101])
+ new Uint8Array([100, 101, 100, 101, 100, 101]),
);
assertEquals(
Buffer.alloc(7, new Buffer([100, 101])),
- new Uint8Array([100, 101, 100, 101, 100, 101, 100])
+ new Uint8Array([100, 101, 100, 101, 100, 101, 100]),
);
},
});
@@ -224,7 +224,7 @@ Deno.test({
assertEquals(Buffer.byteLength("aGkk", "base64"), 3);
assertEquals(
Buffer.byteLength("bHNrZGZsa3NqZmtsc2xrZmFqc2RsZmtqcw==", "base64"),
- 25
+ 25,
);
// special padding
assertEquals(Buffer.byteLength("aaa=", "base64"), 2);
@@ -253,7 +253,7 @@ Deno.test({
assertEquals(
Buffer.byteLength(Buffer.alloc(0)),
Buffer.alloc(0).byteLength,
- "Byte lenght differs on buffers"
+ "Byte lenght differs on buffers",
);
},
});
@@ -306,7 +306,7 @@ Deno.test({
},
RangeError,
"offset is out of bounds",
- "should throw on negative numbers"
+ "should throw on negative numbers",
);
},
});
@@ -319,7 +319,7 @@ Deno.test({
assertEquals(
buffer.toString(),
"test",
- "Buffer to string should recover the string"
+ "Buffer to string should recover the string",
);
},
});
@@ -330,13 +330,13 @@ Deno.test({
for (const encoding of ["hex", "HEX"]) {
const buffer: Buffer = Buffer.from(
"7468697320697320612074c3a97374",
- encoding
+ encoding,
);
assertEquals(buffer.length, 15, "Buffer length should be 15");
assertEquals(
buffer.toString(),
"this is a tést",
- "Buffer to string should recover the string"
+ "Buffer to string should recover the string",
);
}
},
@@ -351,7 +351,7 @@ Deno.test({
assertEquals(
buffer.toString(),
"this is a tést",
- "Buffer to string should recover the string"
+ "Buffer to string should recover the string",
);
}
},
@@ -365,7 +365,7 @@ Deno.test({
assertEquals(
buffer.toString(encoding),
"ZGVubyBsYW5k",
- "Buffer to string should recover the string in base64"
+ "Buffer to string should recover the string in base64",
);
}
const b64 = "dGhpcyBpcyBhIHTDqXN0";
@@ -381,7 +381,7 @@ Deno.test({
assertEquals(
buffer.toString(encoding),
"64656e6f206c616e64",
- "Buffer to string should recover the string"
+ "Buffer to string should recover the string",
);
}
const hex = "64656e6f206c616e64";
@@ -404,7 +404,7 @@ Deno.test({
},
TypeError,
`Unkown encoding: ${encoding}`,
- "Should throw on invalid encoding"
+ "Should throw on invalid encoding",
);
}
},
@@ -430,7 +430,7 @@ Deno.test({
Buffer.from("yes", encoding);
},
TypeError,
- `Unkown encoding: ${encoding}`
+ `Unkown encoding: ${encoding}`,
);
}
},
@@ -451,7 +451,7 @@ Deno.test({
},
Error,
`"${encoding}" encoding`,
- "Should throw on invalid encoding"
+ "Should throw on invalid encoding",
);
assertThrows(
@@ -462,7 +462,7 @@ Deno.test({
},
Error,
`"${encoding}" encoding`,
- "Should throw on invalid encoding"
+ "Should throw on invalid encoding",
);
}
},
@@ -476,7 +476,7 @@ Deno.test({
assertEquals(
buffer.toString(),
"test",
- "Buffer to string should recover the string"
+ "Buffer to string should recover the string",
);
},
});
@@ -501,7 +501,7 @@ Deno.test({
fn() {
assertEquals(
JSON.stringify(Buffer.from("deno")),
- '{"type":"Buffer","data":[100,101,110,111]}'
+ '{"type":"Buffer","data":[100,101,110,111]}',
);
},
});
@@ -578,7 +578,7 @@ Deno.test({
assertEquals(d.equals(d), true);
assertEquals(
d.equals(new Uint8Array([0x61, 0x62, 0x63, 0x64, 0x65])),
- true
+ true,
);
assertEquals(c.equals(d), false);
@@ -589,7 +589,7 @@ Deno.test({
// @ts-ignore
() => Buffer.alloc(1).equals("abc"),
TypeError,
- `The "otherBuffer" argument must be an instance of Buffer or Uint8Array. Received type string`
+ `The "otherBuffer" argument must be an instance of Buffer or Uint8Array. Received type string`,
);
},
});
diff --git a/std/node/events.ts b/std/node/events.ts
index ef547cc37..b267852aa 100644
--- a/std/node/events.ts
+++ b/std/node/events.ts
@@ -44,7 +44,7 @@ export default class EventEmitter {
private _addListener(
eventName: string | symbol,
listener: Function | WrappedFunction,
- prepend: boolean
+ prepend: boolean,
): this {
this.emit("newListener", eventName, listener);
if (this._events.has(eventName)) {
@@ -64,7 +64,7 @@ export default class EventEmitter {
const warning = new Error(
`Possible EventEmitter memory leak detected.
${this.listenerCount(eventName)} ${eventName.toString()} listeners.
- Use emitter.setMaxListeners() to increase limit`
+ Use emitter.setMaxListeners() to increase limit`,
);
warning.name = "MaxListenersExceededWarning";
console.warn(warning);
@@ -76,7 +76,7 @@ export default class EventEmitter {
/** Alias for emitter.on(eventName, listener). */
public addListener(
eventName: string | symbol,
- listener: Function | WrappedFunction
+ listener: Function | WrappedFunction,
): this {
return this._addListener(eventName, listener, false);
}
@@ -147,13 +147,13 @@ export default class EventEmitter {
private _listeners(
target: EventEmitter,
eventName: string | symbol,
- unwrap: boolean
+ unwrap: boolean,
): Function[] {
if (!target._events.has(eventName)) {
return [];
}
const eventListeners: Function[] = target._events.get(
- eventName
+ eventName,
) as Function[];
return unwrap
@@ -180,7 +180,7 @@ export default class EventEmitter {
* including any wrappers (such as those created by .once()).
*/
public rawListeners(
- eventName: string | symbol
+ eventName: string | symbol,
): Array<Function | WrappedFunction> {
return this._listeners(this, eventName, false);
}
@@ -199,7 +199,7 @@ export default class EventEmitter {
*/
public on(
eventName: string | symbol,
- listener: Function | WrappedFunction
+ listener: Function | WrappedFunction,
): this {
return this.addListener(eventName, listener);
}
@@ -217,7 +217,7 @@ export default class EventEmitter {
// Wrapped function that calls EventEmitter.removeListener(eventName, self) on execution.
private onceWrap(
eventName: string | symbol,
- listener: Function
+ listener: Function,
): WrappedFunction {
const wrapper = function (
this: {
@@ -239,7 +239,7 @@ export default class EventEmitter {
context: this,
};
const wrapped = (wrapper.bind(
- wrapperContext
+ wrapperContext,
) as unknown) as WrappedFunction;
wrapperContext.rawListener = wrapped;
wrapped.listener = listener;
@@ -255,7 +255,7 @@ export default class EventEmitter {
*/
public prependListener(
eventName: string | symbol,
- listener: Function | WrappedFunction
+ listener: Function | WrappedFunction,
): this {
return this._addListener(eventName, listener, true);
}
@@ -267,7 +267,7 @@ export default class EventEmitter {
*/
public prependOnceListener(
eventName: string | symbol,
- listener: Function
+ listener: Function,
): this {
const wrapped: WrappedFunction = this.onceWrap(eventName, listener);
this.prependListener(eventName, wrapped);
@@ -359,7 +359,7 @@ export { EventEmitter };
*/
export function once(
emitter: EventEmitter | EventTarget,
- name: string
+ name: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): Promise<any[]> {
return new Promise((resolve, reject) => {
@@ -371,7 +371,7 @@ export function once(
(...args) => {
resolve(args);
},
- { once: true, passive: false, capture: false }
+ { once: true, passive: false, capture: false },
);
return;
} else if (emitter instanceof EventEmitter) {
@@ -429,7 +429,7 @@ interface AsyncInterable {
*/
export function on(
emitter: EventEmitter,
- event: string | symbol
+ event: string | symbol,
): AsyncInterable {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const unconsumedEventValues: any[] = [];
diff --git a/std/node/events_test.ts b/std/node/events_test.ts
index 58025ce84..62b20594c 100644
--- a/std/node/events_test.ts
+++ b/std/node/events_test.ts
@@ -93,9 +93,9 @@ Deno.test({
"event",
(oneArg: string, twoArg: string, threeArg: string) => {
eventsFired.push(
- "event(" + oneArg + ", " + twoArg + ", " + threeArg + ")"
+ "event(" + oneArg + ", " + twoArg + ", " + threeArg + ")",
);
- }
+ },
);
testEmitter.emit("event", 1, 2, 3);
assertEquals(eventsFired, ["event(1)", "event(1, 2)", "event(1, 2, 3)"]);
@@ -346,7 +346,7 @@ Deno.test({
assertEquals(rawListenersForEvent[0], listenerA);
assertEquals(
(rawListenersForOnceEvent[0] as WrappedFunction).listener,
- listenerB
+ listenerB,
);
},
});
@@ -361,7 +361,8 @@ Deno.test({
testEmitter.once("once-event", listenerA);
const rawListenersForOnceEvent = testEmitter.rawListeners("once-event");
- const wrappedFn: WrappedFunction = rawListenersForOnceEvent[0] as WrappedFunction;
+ const wrappedFn: WrappedFunction =
+ rawListenersForOnceEvent[0] as WrappedFunction;
wrappedFn.listener();
wrappedFn.listener();
wrappedFn.listener();
@@ -411,14 +412,14 @@ Deno.test({
ee.setMaxListeners(-1);
},
Error,
- "must be >= 0"
+ "must be >= 0",
);
assertThrows(
() => {
ee.setMaxListeners(3.45);
},
Error,
- "must be 'an integer'"
+ "must be 'an integer'",
);
},
});
@@ -434,7 +435,7 @@ Deno.test({
ee.emit("error");
},
Error,
- "Unhandled error"
+ "Unhandled error",
);
ee.on(EventEmitter.errorMonitor, () => {
@@ -447,7 +448,7 @@ Deno.test({
ee.emit("error");
},
Error,
- "Unhandled error"
+ "Unhandled error",
);
assertEquals(events, ["errorMonitor event"]);
diff --git a/std/node/module.ts b/std/node/module.ts
index 8d13ff366..534fe88e4 100644
--- a/std/node/module.ts
+++ b/std/node/module.ts
@@ -71,7 +71,7 @@ function stat(filename: string): StatResult {
function updateChildren(
parent: Module | null,
child: Module,
- scan: boolean
+ scan: boolean,
): void {
const children = parent && parent.children;
if (children && !(scan && children.includes(child))) {
@@ -164,7 +164,7 @@ class Module {
require,
this,
filename,
- dirname
+ dirname,
);
if (requireDepth === 0) {
statCache = null;
@@ -177,7 +177,7 @@ class Module {
* */
static _resolveLookupPaths(
request: string,
- parent: Module | null
+ parent: Module | null,
): string[] | null {
if (
request.charAt(0) !== "." ||
@@ -208,7 +208,7 @@ class Module {
request: string,
parent: Module,
isMain: boolean,
- options?: { paths: string[] }
+ options?: { paths: string[] },
): string {
// Polyfills.
if (nativeModuleCanBeRequiredByUsers(request)) {
@@ -219,8 +219,7 @@ class Module {
if (typeof options === "object" && options !== null) {
if (Array.isArray(options.paths)) {
- const isRelative =
- request.startsWith("./") ||
+ const isRelative = request.startsWith("./") ||
request.startsWith("../") ||
(isWindows && request.startsWith(".\\")) ||
request.startsWith("..\\");
@@ -278,7 +277,7 @@ class Module {
static _findPath(
request: string,
paths: string[],
- isMain: boolean
+ isMain: boolean,
): string | boolean {
const absoluteRequest = path.isAbsolute(request);
if (absoluteRequest) {
@@ -287,16 +286,15 @@ class Module {
return false;
}
- const cacheKey =
- request + "\x00" + (paths.length === 1 ? paths[0] : paths.join("\x00"));
+ const cacheKey = request + "\x00" +
+ (paths.length === 1 ? paths[0] : paths.join("\x00"));
const entry = Module._pathCache[cacheKey];
if (entry) {
return entry;
}
let exts;
- let trailingSlash =
- request.length > 0 &&
+ let trailingSlash = request.length > 0 &&
request.charCodeAt(request.length - 1) === CHAR_FORWARD_SLASH;
if (!trailingSlash) {
trailingSlash = /(?:^|\/)\.?\.$/.test(request);
@@ -604,18 +602,18 @@ nativeModulePolyfill.set("os", createNativeModule("os", nodeOs));
nativeModulePolyfill.set("path", createNativeModule("path", nodePath));
nativeModulePolyfill.set(
"querystring",
- createNativeModule("querystring", nodeQueryString)
+ createNativeModule("querystring", nodeQueryString),
);
nativeModulePolyfill.set(
"string_decoder",
- createNativeModule("string_decoder", nodeStringDecoder)
+ createNativeModule("string_decoder", nodeStringDecoder),
);
nativeModulePolyfill.set("timers", createNativeModule("timers", nodeTimers));
nativeModulePolyfill.set("util", createNativeModule("util", nodeUtil));
function loadNativeModule(
_filename: string,
- request: string
+ request: string,
): Module | undefined {
return nativeModulePolyfill.get(request);
}
@@ -662,7 +660,7 @@ function readPackage(requestPath: string): PackageInfo | null {
let json: string | undefined;
try {
json = new TextDecoder().decode(
- Deno.readFileSync(path.toNamespacedPath(jsonPath))
+ Deno.readFileSync(path.toNamespacedPath(jsonPath)),
);
} catch {
// pass
@@ -691,7 +689,7 @@ function readPackage(requestPath: string): PackageInfo | null {
}
function readPackageScope(
- checkPath: string
+ checkPath: string,
): { path: string; data: PackageInfo } | false {
const rootSeparatorIndex = checkPath.indexOf(path.sep);
let separatorIndex;
@@ -726,7 +724,7 @@ function tryPackage(
requestPath: string,
exts: string[],
isMain: boolean,
- _originalPath: string
+ _originalPath: string,
): string | false {
const pkg = readPackageMain(requestPath);
@@ -735,8 +733,7 @@ function tryPackage(
}
const filename = path.resolve(requestPath, pkg);
- let actual =
- tryFile(filename, isMain) ||
+ let actual = tryFile(filename, isMain) ||
tryExtensions(filename, exts, isMain) ||
tryExtensions(path.resolve(filename, "index"), exts, isMain);
if (actual === false) {
@@ -744,7 +741,7 @@ function tryPackage(
if (!actual) {
const err = new Error(
`Cannot find module '${filename}'. ` +
- 'Please verify that the package.json has a valid "main" entry'
+ 'Please verify that the package.json has a valid "main" entry',
) as Error & { code: string };
err.code = "MODULE_NOT_FOUND";
throw err;
@@ -779,7 +776,7 @@ function toRealPath(requestPath: string): string {
function tryExtensions(
p: string,
exts: string[],
- isMain: boolean
+ isMain: boolean,
): string | false {
for (let i = 0; i < exts.length; i++) {
const filename = tryFile(p + exts[i], isMain);
@@ -826,7 +823,7 @@ function isConditionalDotExportSugar(exports: any, _basePath: string): boolean {
'"exports" cannot ' +
"contain some keys starting with '.' and some not. The exports " +
"object must either be an object of package subpath keys or an " +
- "object of main entry condition name keys only."
+ "object of main entry condition name keys only.",
);
}
}
@@ -853,7 +850,7 @@ function applyExports(basePath: string, expansion: string): string {
mapping,
"",
basePath,
- mappingKey
+ mappingKey,
);
}
@@ -879,7 +876,7 @@ function applyExports(basePath: string, expansion: string): string {
mapping,
subpath,
basePath,
- mappingKey
+ mappingKey,
);
}
}
@@ -888,7 +885,7 @@ function applyExports(basePath: string, expansion: string): string {
const e = new Error(
`Package exports for '${basePath}' do not define ` +
- `a '${mappingKey}' subpath`
+ `a '${mappingKey}' subpath`,
) as Error & { code?: string };
e.code = "MODULE_NOT_FOUND";
throw e;
@@ -901,7 +898,7 @@ const EXPORTS_PATTERN = /^((?:@[^/\\%]+\/)?[^./\\%][^/\\%]*)(\/.*)?$/;
function resolveExports(
nmPath: string,
request: string,
- absoluteRequest: boolean
+ absoluteRequest: boolean,
): string {
// The implementation's behavior is meant to mirror resolution in ESM.
if (!absoluteRequest) {
@@ -923,7 +920,7 @@ function resolveExportsTarget(
target: any,
subpath: string,
basePath: string,
- mappingKey: string
+ mappingKey: string,
): string {
if (typeof target === "string") {
if (
@@ -957,7 +954,7 @@ function resolveExportsTarget(
targetValue,
subpath,
basePath,
- mappingKey
+ mappingKey,
);
} catch (e) {
if (e.code !== "MODULE_NOT_FOUND") throw e;
@@ -972,7 +969,7 @@ function resolveExportsTarget(
target.default,
subpath,
basePath,
- mappingKey
+ mappingKey,
);
} catch (e) {
if (e.code !== "MODULE_NOT_FOUND") throw e;
@@ -983,7 +980,7 @@ function resolveExportsTarget(
if (mappingKey !== ".") {
e = new Error(
`Package exports for '${basePath}' do not define a ` +
- `valid '${mappingKey}' target${subpath ? " for " + subpath : ""}`
+ `valid '${mappingKey}' target${subpath ? " for " + subpath : ""}`,
);
} else {
e = new Error(`No valid exports main found for '${basePath}'`);
@@ -999,9 +996,9 @@ const nmLen = nmChars.length;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function emitCircularRequireWarning(prop: any): void {
console.error(
- `Accessing non-existent property '${String(
- prop
- )}' of module exports inside circular dependency`
+ `Accessing non-existent property '${
+ String(prop)
+ }' of module exports inside circular dependency`,
);
}
@@ -1024,7 +1021,7 @@ const CircularRequirePrototypeWarningProxy = new Proxy(
emitCircularRequireWarning(prop);
return undefined;
},
- }
+ },
);
// Object.prototype and ObjectProtoype refer to our 'primordials' versions
@@ -1056,7 +1053,7 @@ type RequireWrapper = (
require: any,
module: Module,
__filename: string,
- __dirname: string
+ __dirname: string,
) => void;
function wrapSafe(filename: string, content: string): RequireWrapper {
@@ -1099,8 +1096,8 @@ Module._extensions[".json"] = (module: Module, filename: string): void => {
function createRequireFromPath(filename: string): RequireFunction {
// Allow a directory to be passed as the filename
- const trailingSlash =
- filename.endsWith("/") || (isWindows && filename.endsWith("\\"));
+ const trailingSlash = filename.endsWith("/") ||
+ (isWindows && filename.endsWith("\\"));
const proxyPath = trailingSlash ? path.join(filename, "noop.js") : filename;
diff --git a/std/node/module_test.ts b/std/node/module_test.ts
index 30441a58d..bdc2f39d3 100644
--- a/std/node/module_test.ts
+++ b/std/node/module_test.ts
@@ -34,7 +34,7 @@ Deno.test("requireBuiltin", function () {
const { readFileSync, isNull, extname } = require("./tests/cjs/cjs_builtin");
assertEquals(
readFileSync("./node/_fs/testdata/hello.txt", { encoding: "utf8" }),
- "hello world"
+ "hello world",
);
assert(isNull(null));
assertEquals(extname("index.html"), ".html");
diff --git a/std/node/os.ts b/std/node/os.ts
index afb472629..c312ffe0c 100644
--- a/std/node/os.ts
+++ b/std/node/os.ts
@@ -203,7 +203,7 @@ export function uptime(): number {
/** Not yet implemented */
export function userInfo(
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
- options: UserInfoOptions = { encoding: "utf-8" }
+ options: UserInfoOptions = { encoding: "utf-8" },
): UserInfo {
notImplemented(SEE_GITHUB_ISSUE);
}
diff --git a/std/node/os_test.ts b/std/node/os_test.ts
index c5f39f635..34f8d0f87 100644
--- a/std/node/os_test.ts
+++ b/std/node/os_test.ts
@@ -54,14 +54,14 @@ Deno.test({
os.getPriority(3.15);
},
Error,
- "pid must be 'an integer'"
+ "pid must be 'an integer'",
);
assertThrows(
() => {
os.getPriority(9999999999);
},
Error,
- "must be >= -2147483648 && <= 2147483647"
+ "must be >= -2147483648 && <= 2147483647",
);
},
});
@@ -74,14 +74,14 @@ Deno.test({
os.setPriority(3.15, 0);
},
Error,
- "pid must be 'an integer'"
+ "pid must be 'an integer'",
);
assertThrows(
() => {
os.setPriority(9999999999, 0);
},
Error,
- "pid must be >= -2147483648 && <= 2147483647"
+ "pid must be >= -2147483648 && <= 2147483647",
);
},
});
@@ -94,28 +94,28 @@ Deno.test({
os.setPriority(0, 3.15);
},
Error,
- "priority must be 'an integer'"
+ "priority must be 'an integer'",
);
assertThrows(
() => {
os.setPriority(0, -21);
},
Error,
- "priority must be >= -20 && <= 19"
+ "priority must be >= -20 && <= 19",
);
assertThrows(
() => {
os.setPriority(0, 20);
},
Error,
- "priority must be >= -20 && <= 19"
+ "priority must be >= -20 && <= 19",
);
assertThrows(
() => {
os.setPriority(0, 9999999999);
},
Error,
- "priority must be >= -20 && <= 19"
+ "priority must be >= -20 && <= 19",
);
},
});
@@ -129,28 +129,28 @@ Deno.test({
os.setPriority(3.15);
},
Error,
- "priority must be 'an integer'"
+ "priority must be 'an integer'",
);
assertThrows(
() => {
os.setPriority(-21);
},
Error,
- "priority must be >= -20 && <= 19"
+ "priority must be >= -20 && <= 19",
);
assertThrows(
() => {
os.setPriority(20);
},
Error,
- "priority must be >= -20 && <= 19"
+ "priority must be >= -20 && <= 19",
);
assertThrows(
() => {
os.setPriority(9999999999);
},
Error,
- "priority must be >= -20 && <= 19"
+ "priority must be >= -20 && <= 19",
);
},
});
@@ -207,63 +207,63 @@ Deno.test({
os.cpus();
},
Error,
- "Not implemented"
+ "Not implemented",
);
assertThrows(
() => {
os.freemem();
},
Error,
- "Not implemented"
+ "Not implemented",
);
assertThrows(
() => {
os.getPriority();
},
Error,
- "Not implemented"
+ "Not implemented",
);
assertThrows(
() => {
os.networkInterfaces();
},
Error,
- "Not implemented"
+ "Not implemented",
);
assertThrows(
() => {
os.setPriority(0);
},
Error,
- "Not implemented"
+ "Not implemented",
);
assertThrows(
() => {
os.totalmem();
},
Error,
- "Not implemented"
+ "Not implemented",
);
assertThrows(
() => {
os.type();
},
Error,
- "Not implemented"
+ "Not implemented",
);
assertThrows(
() => {
os.uptime();
},
Error,
- "Not implemented"
+ "Not implemented",
);
assertThrows(
() => {
os.userInfo();
},
Error,
- "Not implemented"
+ "Not implemented",
);
},
});
diff --git a/std/node/process_test.ts b/std/node/process_test.ts
index c4332af33..2674b725f 100644
--- a/std/node/process_test.ts
+++ b/std/node/process_test.ts
@@ -44,7 +44,7 @@ Deno.test({
process.chdir("non-existent-directory-name");
},
Deno.errors.NotFound,
- "file"
+ "file",
// On every OS Deno returns: "No such file" except for Windows, where it's:
// "The system cannot find the file specified. (os error 2)" so "file" is
// the only common string here.
@@ -95,7 +95,7 @@ Deno.test({
process.on("uncaughtException", (_err: Error) => {});
},
Error,
- "implemented"
+ "implemented",
);
},
});
@@ -107,7 +107,7 @@ Deno.test({
assert(Array.isArray(argv));
assert(
process.argv[0].match(/[^/\\]*deno[^/\\]*$/),
- "deno included in the file name of argv[0]"
+ "deno included in the file name of argv[0]",
);
// we cannot test for anything else (we see test runner arguments here)
},
diff --git a/std/node/querystring.ts b/std/node/querystring.ts
index bed327337..4e3c728c1 100644
--- a/std/node/querystring.ts
+++ b/std/node/querystring.ts
@@ -5,14 +5,15 @@ interface ParseOptions {
maxKeys?: number;
}
export const hexTable = new Array(256);
-for (let i = 0; i < 256; ++i)
+for (let i = 0; i < 256; ++i) {
hexTable[i] = "%" + ((i < 16 ? "0" : "") + i.toString(16)).toUpperCase();
+}
export function parse(
str: string,
sep = "&",
eq = "=",
- { decodeURIComponent = unescape, maxKeys = 1000 }: ParseOptions = {}
+ { decodeURIComponent = unescape, maxKeys = 1000 }: ParseOptions = {},
): { [key: string]: string[] | string } {
const entries = str
.split(sep)
@@ -49,7 +50,7 @@ interface StringifyOptions {
export function encodeStr(
str: string,
noEscapeTable: number[],
- hexTable: string[]
+ hexTable: string[],
): string {
const len = str.length;
if (len === 0) return "";
@@ -78,8 +79,7 @@ export function encodeStr(
}
if (c < 0xd800 || c >= 0xe000) {
lastPos = i + 1;
- out +=
- hexTable[0xe0 | (c >> 12)] +
+ out += hexTable[0xe0 | (c >> 12)] +
hexTable[0x80 | ((c >> 6) & 0x3f)] +
hexTable[0x80 | (c & 0x3f)];
continue;
@@ -96,8 +96,7 @@ export function encodeStr(
lastPos = i + 1;
c = 0x10000 + (((c & 0x3ff) << 10) | c2);
- out +=
- hexTable[0xf0 | (c >> 18)] +
+ out += hexTable[0xf0 | (c >> 18)] +
hexTable[0x80 | ((c >> 12) & 0x3f)] +
hexTable[0x80 | ((c >> 6) & 0x3f)] +
hexTable[0x80 | (c & 0x3f)];
@@ -111,7 +110,7 @@ export function stringify(
obj: object,
sep = "&",
eq = "=",
- { encodeURIComponent = escape }: StringifyOptions = {}
+ { encodeURIComponent = escape }: StringifyOptions = {},
): string {
const final = [];
diff --git a/std/node/querystring_test.ts b/std/node/querystring_test.ts
index 63abf471b..6ce681ca5 100644
--- a/std/node/querystring_test.ts
+++ b/std/node/querystring_test.ts
@@ -11,7 +11,7 @@ Deno.test({
c: true,
d: ["foo", "bar"],
}),
- "a=hello&b=5&c=true&d=foo&d=bar"
+ "a=hello&b=5&c=true&d=foo&d=bar",
);
},
});
diff --git a/std/node/string_decoder.ts b/std/node/string_decoder.ts
index 7f167ad3c..ce7c19538 100644
--- a/std/node/string_decoder.ts
+++ b/std/node/string_decoder.ts
@@ -31,8 +31,9 @@ enum NotImplemented {
function normalizeEncoding(enc?: string): string {
const encoding = castEncoding(enc ?? null);
if (encoding && encoding in NotImplemented) notImplemented(encoding);
- if (!encoding && typeof enc === "string" && enc.toLowerCase() !== "raw")
+ if (!encoding && typeof enc === "string" && enc.toLowerCase() !== "raw") {
throw new Error(`Unknown encoding: ${enc}`);
+ }
return String(encoding);
}
/*
@@ -55,7 +56,7 @@ function utf8CheckByte(byte: number): number {
function utf8CheckIncomplete(
self: StringDecoderBase,
buf: Buffer,
- i: number
+ i: number,
): number {
let j = buf.length - 1;
if (j < i) return 0;
@@ -94,7 +95,7 @@ function utf8CheckIncomplete(
* */
function utf8CheckExtraBytes(
self: StringDecoderBase,
- buf: Buffer
+ buf: Buffer,
): string | undefined {
if ((buf[0] & 0xc0) !== 0x80) {
self.lastNeed = 0;
@@ -119,7 +120,7 @@ function utf8CheckExtraBytes(
* */
function utf8FillLastComplete(
this: StringDecoderBase,
- buf: Buffer
+ buf: Buffer,
): string | undefined {
const p = this.lastTotal - this.lastNeed;
const r = utf8CheckExtraBytes(this, buf);
@@ -137,7 +138,7 @@ function utf8FillLastComplete(
* */
function utf8FillLastIncomplete(
this: StringDecoderBase,
- buf: Buffer
+ buf: Buffer,
): string | undefined {
if (this.lastNeed <= buf.length) {
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
@@ -203,8 +204,9 @@ function base64Text(this: StringDecoderBase, buf: Buffer, i: number): string {
function base64End(this: Base64Decoder, buf?: Buffer): string {
const r = buf && buf.length ? this.write(buf) : "";
- if (this.lastNeed)
+ if (this.lastNeed) {
return r + this.lastChar.toString("base64", 0, 3 - this.lastNeed);
+ }
return r;
}
diff --git a/std/node/string_decoder_test.ts b/std/node/string_decoder_test.ts
index 69bb8402a..de32b6815 100644
--- a/std/node/string_decoder_test.ts
+++ b/std/node/string_decoder_test.ts
@@ -22,7 +22,7 @@ Deno.test({
decoder = new StringDecoder("utf8");
assertEquals(
decoder.write(Buffer.from("\ufffd\ufffd\ufffd")),
- "\ufffd\ufffd\ufffd"
+ "\ufffd\ufffd\ufffd",
);
assertEquals(decoder.end(), "");
@@ -60,7 +60,7 @@ Deno.test({
decoder = new StringDecoder("base64");
assertEquals(
decoder.write(Buffer.from("\ufffd\ufffd\ufffd")),
- "77+977+977+9"
+ "77+977+977+9",
);
assertEquals(decoder.end(), "");
@@ -98,7 +98,7 @@ Deno.test({
decoder = new StringDecoder("hex");
assertEquals(
decoder.write(Buffer.from("\ufffd\ufffd\ufffd")),
- "efbfbdefbfbdefbfbd"
+ "efbfbdefbfbdefbfbd",
);
assertEquals(decoder.end(), "");
diff --git a/std/node/url.ts b/std/node/url.ts
index b0034d02d..826a274f8 100644
--- a/std/node/url.ts
+++ b/std/node/url.ts
@@ -38,12 +38,14 @@ const tabRegEx = /\t/g;
export function fileURLToPath(path: string | URL): string {
if (typeof path === "string") path = new URL(path);
- else if (!(path instanceof URL))
+ else if (!(path instanceof URL)) {
throw new Deno.errors.InvalidData(
- "invalid argument path , must be a string or URL"
+ "invalid argument path , must be a string or URL",
);
- if (path.protocol !== "file:")
+ }
+ if (path.protocol !== "file:") {
throw new Deno.errors.InvalidData("invalid url scheme");
+ }
return isWindows ? getPathFromURLWin(path) : getPathFromURLPosix(path);
}
@@ -59,7 +61,7 @@ function getPathFromURLWin(url: URL): string {
) {
// 5c 5C \
throw new Deno.errors.InvalidData(
- "must not include encoded \\ or / characters"
+ "must not include encoded \\ or / characters",
);
}
}
@@ -95,7 +97,7 @@ function getPathFromURLPosix(url: URL): string {
const third = pathname.codePointAt(n + 2) || 0x20;
if (pathname[n + 1] === "2" && third === 102) {
throw new Deno.errors.InvalidData(
- "must not include encoded / characters"
+ "must not include encoded / characters",
);
}
}
@@ -111,16 +113,19 @@ export function pathToFileURL(filepath: string): URL {
(filePathLast === CHAR_FORWARD_SLASH ||
(isWindows && filePathLast === CHAR_BACKWARD_SLASH)) &&
resolved[resolved.length - 1] !== path.sep
- )
+ ) {
resolved += "/";
+ }
const outURL = new URL("file://");
if (resolved.includes("%")) resolved = resolved.replace(percentRegEx, "%25");
// In posix, "/" is a valid character in paths
- if (!isWindows && resolved.includes("\\"))
+ if (!isWindows && resolved.includes("\\")) {
resolved = resolved.replace(backslashRegEx, "%5C");
+ }
if (resolved.includes("\n")) resolved = resolved.replace(newlineRegEx, "%0A");
- if (resolved.includes("\r"))
+ if (resolved.includes("\r")) {
resolved = resolved.replace(carriageReturnRegEx, "%0D");
+ }
if (resolved.includes("\t")) resolved = resolved.replace(tabRegEx, "%09");
outURL.pathname = resolved;
return outURL;
diff --git a/std/node/util.ts b/std/node/util.ts
index e046aba9c..8e3c50b87 100644
--- a/std/node/util.ts
+++ b/std/node/util.ts
@@ -62,7 +62,7 @@ export function validateIntegerRange(
value: number,
name: string,
min = -2147483648,
- max = 2147483647
+ max = 2147483647,
): void {
// The defaults for min and max correspond to the limits of 32-bit integers.
if (!Number.isInteger(value)) {
@@ -70,7 +70,7 @@ export function validateIntegerRange(
}
if (value < min || value > max) {
throw new Error(
- `${name} must be >= ${min} && <= ${max}. Value was ${value}`
+ `${name} must be >= ${min} && <= ${max}. Value was ${value}`,
);
}
}
diff --git a/std/path/_globrex.ts b/std/path/_globrex.ts
index 6ad297d86..0cc5399fa 100644
--- a/std/path/_globrex.ts
+++ b/std/path/_globrex.ts
@@ -57,7 +57,7 @@ export function globrex(
strict = false,
filepath = false,
flags = "",
- }: GlobrexOptions = {}
+ }: GlobrexOptions = {},
): GlobrexResult {
const sepPattern = new RegExp(`^${SEP}${strict ? "" : "+"}$`);
let regex = "";
@@ -82,7 +82,7 @@ export function globrex(
// Helper function to build string and segments
function add(
str: string,
- options: AddOptions = { split: false, last: false, only: "" }
+ options: AddOptions = { split: false, last: false, only: "" },
): void {
const { split, last, only } = options;
if (only !== "path") regex += str;
@@ -279,8 +279,7 @@ export function globrex(
add(".*");
} else {
// globstar is enabled, so determine if this is a globstar segment
- const isGlobstar =
- starCount > 1 && // multiple "*"'s
+ const isGlobstar = starCount > 1 && // multiple "*"'s
// from the start of the segment
[SEP_RAW, "/", undefined].includes(prevChar) &&
// to the end of the segment
@@ -320,7 +319,7 @@ export function globrex(
segments: pathSegments,
globstar: new RegExp(
!flags.includes("g") ? `^${GLOBSTAR_SEGMENT}$` : GLOBSTAR_SEGMENT,
- flags
+ flags,
),
};
}
diff --git a/std/path/_globrex_test.ts b/std/path/_globrex_test.ts
index 67a58cc64..19eabc983 100644
--- a/std/path/_globrex_test.ts
+++ b/std/path/_globrex_test.ts
@@ -11,7 +11,7 @@ function match(
glob: string,
strUnix: string,
strWin?: string | object,
- opts: GlobrexOptions = {}
+ opts: GlobrexOptions = {},
): boolean {
if (typeof strWin === "object") {
opts = strWin;
@@ -48,19 +48,19 @@ Deno.test({
t.equal(
match("u*orn", "unicorn", { flags: "g" }),
true,
- "match the middle"
+ "match the middle",
);
t.equal(match("ico", "unicorn"), false, "do not match without g");
t.equal(
match("ico", "unicorn", { flags: "g" }),
true,
- 'match anywhere with RegExp "g"'
+ 'match anywhere with RegExp "g"',
);
t.equal(match("u*nicorn", "unicorn"), true, "match zero characters");
t.equal(
match("u*nicorn", "unicorn", { flags: "g" }),
true,
- "match zero characters"
+ "match zero characters",
);
},
});
@@ -73,34 +73,34 @@ Deno.test({
globstar: false,
}),
true,
- "complex match"
+ "complex match",
);
t.equal(
match("*.min.*", "http://example.com/jquery.min.js", { globstar: false }),
true,
- "complex match"
+ "complex match",
);
t.equal(
match("*/js/*.js", "http://example.com/js/jquery.min.js", {
globstar: false,
}),
true,
- "complex match"
+ "complex match",
);
t.equal(
match("*.min.*", "http://example.com/jquery.min.js", { flags: "g" }),
true,
- "complex match global"
+ "complex match global",
);
t.equal(
match("*.min.js", "http://example.com/jquery.min.js", { flags: "g" }),
true,
- "complex match global"
+ "complex match global",
);
t.equal(
match("*/js/*.js", "http://example.com/js/jquery.min.js", { flags: "g" }),
true,
- "complex match global"
+ "complex match global",
);
const str = "\\/$^+?.()=!|{},[].*";
@@ -108,70 +108,70 @@ Deno.test({
t.equal(
match(str, str, { flags: "g" }),
true,
- "battle test complex string - strict"
+ "battle test complex string - strict",
);
t.equal(
match(".min.", "http://example.com/jquery.min.js"),
false,
- 'matches without/with using RegExp "g"'
+ 'matches without/with using RegExp "g"',
);
t.equal(
match("*.min.*", "http://example.com/jquery.min.js"),
true,
- 'matches without/with using RegExp "g"'
+ 'matches without/with using RegExp "g"',
);
t.equal(
match(".min.", "http://example.com/jquery.min.js", { flags: "g" }),
true,
- 'matches without/with using RegExp "g"'
+ 'matches without/with using RegExp "g"',
);
t.equal(
match("http:", "http://example.com/jquery.min.js"),
false,
- 'matches without/with using RegExp "g"'
+ 'matches without/with using RegExp "g"',
);
t.equal(
match("http:*", "http://example.com/jquery.min.js"),
true,
- 'matches without/with using RegExp "g"'
+ 'matches without/with using RegExp "g"',
);
t.equal(
match("http:", "http://example.com/jquery.min.js", { flags: "g" }),
true,
- 'matches without/with using RegExp "g"'
+ 'matches without/with using RegExp "g"',
);
t.equal(
match("min.js", "http://example.com/jquery.min.js"),
false,
- 'matches without/with using RegExp "g"'
+ 'matches without/with using RegExp "g"',
);
t.equal(
match("*.min.js", "http://example.com/jquery.min.js"),
true,
- 'matches without/with using RegExp "g"'
+ 'matches without/with using RegExp "g"',
);
t.equal(
match("min.js", "http://example.com/jquery.min.js", { flags: "g" }),
true,
- 'matches without/with using RegExp "g"'
+ 'matches without/with using RegExp "g"',
);
t.equal(
match("min", "http://example.com/jquery.min.js", { flags: "g" }),
true,
- 'match anywhere (globally) using RegExp "g"'
+ 'match anywhere (globally) using RegExp "g"',
);
t.equal(
match("/js/", "http://example.com/js/jquery.min.js", { flags: "g" }),
true,
- 'match anywhere (globally) using RegExp "g"'
+ 'match anywhere (globally) using RegExp "g"',
);
t.equal(match("/js*jq*.js", "http://example.com/js/jquery.min.js"), false);
t.equal(
match("/js*jq*.js", "http://example.com/js/jquery.min.js", {
flags: "g",
}),
- true
+ true,
);
},
});
@@ -186,28 +186,28 @@ Deno.test({
const tester = (globstar: boolean): void => {
t.equal(
match("f?o", "foo", { extended: true, globstar, flags: "g" }),
- true
+ true,
);
t.equal(
match("f?o", "fooo", { extended: true, globstar, flags: "g" }),
- true
+ true,
);
t.equal(
match("f?o?", "fooo", { extended: true, globstar, flags: "g" }),
- true
+ true,
);
t.equal(
match("?fo", "fooo", { extended: true, globstar, flags: "g" }),
- false
+ false,
);
t.equal(
match("f?oo", "foo", { extended: true, globstar, flags: "g" }),
- false
+ false,
);
t.equal(
match("foo?", "foo", { extended: true, globstar, flags: "g" }),
- false
+ false,
);
};
@@ -230,15 +230,15 @@ Deno.test({
const tester = (globstar: boolean): void => {
t.equal(
match("fo[oz]", "foo", { extended: true, globstar, flags: "g" }),
- true
+ true,
);
t.equal(
match("fo[oz]", "foz", { extended: true, globstar, flags: "g" }),
- true
+ true,
);
t.equal(
match("fo[oz]", "fog", { extended: true, globstar, flags: "g" }),
- false
+ false,
);
};
@@ -252,55 +252,55 @@ Deno.test({
fn(): void {
t.equal(
match("[[:alnum:]]/bar.txt", "a/bar.txt", { extended: true }),
- true
+ true,
);
t.equal(
match("@([[:alnum:]abc]|11)/bar.txt", "11/bar.txt", { extended: true }),
- true
+ true,
);
t.equal(
match("@([[:alnum:]abc]|11)/bar.txt", "a/bar.txt", { extended: true }),
- true
+ true,
);
t.equal(
match("@([[:alnum:]abc]|11)/bar.txt", "b/bar.txt", { extended: true }),
- true
+ true,
);
t.equal(
match("@([[:alnum:]abc]|11)/bar.txt", "c/bar.txt", { extended: true }),
- true
+ true,
);
t.equal(
match("@([[:alnum:]abc]|11)/bar.txt", "abc/bar.txt", { extended: true }),
- false
+ false,
);
t.equal(
match("@([[:alnum:]abc]|11)/bar.txt", "3/bar.txt", { extended: true }),
- true
+ true,
);
t.equal(
match("[[:digit:]]/bar.txt", "1/bar.txt", { extended: true }),
- true
+ true,
);
t.equal(
match("[[:digit:]b]/bar.txt", "b/bar.txt", { extended: true }),
- true
+ true,
);
t.equal(
match("[![:digit:]b]/bar.txt", "a/bar.txt", { extended: true }),
- true
+ true,
);
t.equal(
match("[[:alnum:]]/bar.txt", "!/bar.txt", { extended: true }),
- false
+ false,
);
t.equal(
match("[[:digit:]]/bar.txt", "a/bar.txt", { extended: true }),
- false
+ false,
);
t.equal(
match("[[:digit:]b]/bar.txt", "a/bar.txt", { extended: true }),
- false
+ false,
);
},
});
@@ -320,7 +320,7 @@ Deno.test({
globstar,
flag: "g",
}),
- true
+ true,
);
t.equal(
match("foo{bar,baaz}", "foobar", {
@@ -328,7 +328,7 @@ Deno.test({
globstar,
flag: "g",
}),
- true
+ true,
);
t.equal(
match("foo{bar,baaz}", "foobuzz", {
@@ -336,7 +336,7 @@ Deno.test({
globstar,
flag: "g",
}),
- false
+ false,
);
t.equal(
match("foo{bar,b*z}", "foobuzz", {
@@ -344,7 +344,7 @@ Deno.test({
globstar,
flag: "g",
}),
- true
+ true,
);
};
@@ -360,41 +360,41 @@ Deno.test({
match(
"http://?o[oz].b*z.com/{*.js,*.html}",
"http://foo.baaz.com/jquery.min.js",
- { extended: true }
+ { extended: true },
),
- true
+ true,
);
t.equal(
match(
"http://?o[oz].b*z.com/{*.js,*.html}",
"http://moz.buzz.com/index.html",
- { extended: true }
+ { extended: true },
),
- true
+ true,
);
t.equal(
match(
"http://?o[oz].b*z.com/{*.js,*.html}",
"http://moz.buzz.com/index.htm",
- { extended: true }
+ { extended: true },
),
- false
+ false,
);
t.equal(
match(
"http://?o[oz].b*z.com/{*.js,*.html}",
"http://moz.bar.com/index.html",
- { extended: true }
+ { extended: true },
),
- false
+ false,
);
t.equal(
match(
"http://?o[oz].b*z.com/{*.js,*.html}",
"http://flozz.buzz.com/index.html",
- { extended: true }
+ { extended: true },
),
- false
+ false,
);
const tester = (globstar: boolean): void => {
@@ -402,41 +402,41 @@ Deno.test({
match(
"http://?o[oz].b*z.com/{*.js,*.html}",
"http://foo.baaz.com/jquery.min.js",
- { extended: true, globstar, flags: "g" }
+ { extended: true, globstar, flags: "g" },
),
- true
+ true,
);
t.equal(
match(
"http://?o[oz].b*z.com/{*.js,*.html}",
"http://moz.buzz.com/index.html",
- { extended: true, globstar, flags: "g" }
+ { extended: true, globstar, flags: "g" },
),
- true
+ true,
);
t.equal(
match(
"http://?o[oz].b*z.com/{*.js,*.html}",
"http://moz.buzz.com/index.htm",
- { extended: true, globstar, flags: "g" }
+ { extended: true, globstar, flags: "g" },
),
- false
+ false,
);
t.equal(
match(
"http://?o[oz].b*z.com/{*.js,*.html}",
"http://moz.bar.com/index.html",
- { extended: true, globstar, flags: "g" }
+ { extended: true, globstar, flags: "g" },
),
- false
+ false,
);
t.equal(
match(
"http://?o[oz].b*z.com/{*.js,*.html}",
"http://flozz.buzz.com/index.html",
- { extended: true, globstar, flags: "g" }
+ { extended: true, globstar, flags: "g" },
),
- false
+ false,
);
};
@@ -453,17 +453,17 @@ Deno.test({
match(
"http://foo.com/**/{*.js,*.html}",
"http://foo.com/bar/jquery.min.js",
- { extended: true, globstar, flags: "g" }
+ { extended: true, globstar, flags: "g" },
),
- true
+ true,
);
t.equal(
match(
"http://foo.com/**/{*.js,*.html}",
"http://foo.com/bar/baz/jquery.min.js",
- { extended: true, globstar, flags: "g" }
+ { extended: true, globstar, flags: "g" },
),
- true
+ true,
);
t.equal(
match("http://foo.com/**", "http://foo.com/bar/baz/jquery.min.js", {
@@ -471,7 +471,7 @@ Deno.test({
globstar,
flags: "g",
}),
- true
+ true,
);
};
@@ -488,7 +488,7 @@ Deno.test({
t.equal(match(testExtStr, testExtStr, { extended: true }), true);
t.equal(
match(testExtStr, testExtStr, { extended: true, globstar, flags: "g" }),
- true
+ true,
);
};
@@ -506,37 +506,37 @@ Deno.test({
t.equal(match("/foo/**", "/foo/bar/baz.txt", { globstar: true }), true);
t.equal(
match("/foo/*/*.txt", "/foo/bar/baz.txt", { globstar: true }),
- true
+ true,
);
t.equal(
match("/foo/**/*.txt", "/foo/bar/baz.txt", { globstar: true }),
- true
+ true,
);
t.equal(
match("/foo/**/*.txt", "/foo/bar/baz/qux.txt", { globstar: true }),
- true
+ true,
);
t.equal(match("/foo/**/bar.txt", "/foo/bar.txt", { globstar: true }), true);
t.equal(
match("/foo/**/**/bar.txt", "/foo/bar.txt", { globstar: true }),
- true
+ true,
);
t.equal(
match("/foo/**/*/baz.txt", "/foo/bar/baz.txt", { globstar: true }),
- true
+ true,
);
t.equal(match("/foo/**/*.txt", "/foo/bar.txt", { globstar: true }), true);
t.equal(
match("/foo/**/**/*.txt", "/foo/bar.txt", { globstar: true }),
- true
+ true,
);
t.equal(
match("/foo/**/*/*.txt", "/foo/bar/baz.txt", { globstar: true }),
- true
+ true,
);
t.equal(
match("**/*.txt", "/foo/bar/baz/qux.txt", { globstar: true }),
- true
+ true,
);
t.equal(match("**/foo.txt", "foo.txt", { globstar: true }), true);
t.equal(match("**/*.txt", "foo.txt", { globstar: true }), true);
@@ -544,29 +544,29 @@ Deno.test({
t.equal(match("/foo/*.txt", "/foo/bar/baz.txt", { globstar: true }), false);
t.equal(
match("/foo/*/*.txt", "/foo/bar/baz/qux.txt", { globstar: true }),
- false
+ false,
);
t.equal(match("/foo/*/bar.txt", "/foo/bar.txt", { globstar: true }), false);
t.equal(
match("/foo/*/*/baz.txt", "/foo/bar/baz.txt", { globstar: true }),
- false
+ false,
);
t.equal(
match("/foo/**.txt", "/foo/bar/baz/qux.txt", { globstar: true }),
- false
+ false,
);
t.equal(
match("/foo/bar**/*.txt", "/foo/bar/baz/qux.txt", { globstar: true }),
- false
+ false,
);
t.equal(match("/foo/bar**", "/foo/bar/baz.txt", { globstar: true }), false);
t.equal(
match("**/.txt", "/foo/bar/baz/qux.txt", { globstar: true }),
- false
+ false,
);
t.equal(
match("*/*.txt", "/foo/bar/baz/qux.txt", { globstar: true }),
- false
+ false,
);
t.equal(match("*/*.txt", "foo.txt", { globstar: true }), false);
t.equal(
@@ -574,65 +574,65 @@ Deno.test({
extended: true,
globstar: true,
}),
- false
+ false,
);
t.equal(
match("http://foo.com/*", "http://foo.com/bar/baz/jquery.min.js", {
globstar: true,
}),
- false
+ false,
);
t.equal(
match("http://foo.com/*", "http://foo.com/bar/baz/jquery.min.js", {
globstar: false,
}),
- true
+ true,
);
t.equal(
match("http://foo.com/**", "http://foo.com/bar/baz/jquery.min.js", {
globstar: true,
}),
- true
+ true,
);
t.equal(
match(
"http://foo.com/*/*/jquery.min.js",
"http://foo.com/bar/baz/jquery.min.js",
- { globstar: true }
+ { globstar: true },
),
- true
+ true,
);
t.equal(
match(
"http://foo.com/**/jquery.min.js",
"http://foo.com/bar/baz/jquery.min.js",
- { globstar: true }
+ { globstar: true },
),
- true
+ true,
);
t.equal(
match(
"http://foo.com/*/*/jquery.min.js",
"http://foo.com/bar/baz/jquery.min.js",
- { globstar: false }
+ { globstar: false },
),
- true
+ true,
);
t.equal(
match(
"http://foo.com/*/jquery.min.js",
"http://foo.com/bar/baz/jquery.min.js",
- { globstar: false }
+ { globstar: false },
),
- true
+ true,
);
t.equal(
match(
"http://foo.com/*/jquery.min.js",
"http://foo.com/bar/baz/jquery.min.js",
- { globstar: true }
+ { globstar: true },
),
- false
+ false,
);
},
});
@@ -646,46 +646,46 @@ Deno.test({
t.equal(match("?(foo|bar)baz.txt", "foobaz.txt", { extended: true }), true);
t.equal(
match("?(ba[zr]|qux)baz.txt", "bazbaz.txt", { extended: true }),
- true
+ true,
);
t.equal(
match("?(ba[zr]|qux)baz.txt", "barbaz.txt", { extended: true }),
- true
+ true,
);
t.equal(
match("?(ba[zr]|qux)baz.txt", "quxbaz.txt", { extended: true }),
- true
+ true,
);
t.equal(
match("?(ba[!zr]|qux)baz.txt", "batbaz.txt", { extended: true }),
- true
+ true,
);
t.equal(match("?(ba*|qux)baz.txt", "batbaz.txt", { extended: true }), true);
t.equal(
match("?(ba*|qux)baz.txt", "batttbaz.txt", { extended: true }),
- true
+ true,
);
t.equal(match("?(ba*|qux)baz.txt", "quxbaz.txt", { extended: true }), true);
t.equal(
match("?(ba?(z|r)|qux)baz.txt", "bazbaz.txt", { extended: true }),
- true
+ true,
);
t.equal(
match("?(ba?(z|?(r))|qux)baz.txt", "bazbaz.txt", { extended: true }),
- true
+ true,
);
t.equal(match("?(foo).txt", "foo.txt", { extended: false }), false);
t.equal(
match("?(foo|bar)baz.txt", "foobarbaz.txt", { extended: true }),
- false
+ false,
);
t.equal(
match("?(ba[zr]|qux)baz.txt", "bazquxbaz.txt", { extended: true }),
- false
+ false,
);
t.equal(
match("?(ba[!zr]|qux)baz.txt", "bazbaz.txt", { extended: true }),
- false
+ false,
);
},
});
@@ -708,21 +708,21 @@ Deno.test({
t.equal(match("*(foo|b*[rt]).txt", "tlat.txt", { extended: true }), false);
t.equal(
match("*(*).txt", "whatever.txt", { extended: true, globstar: true }),
- true
+ true,
);
t.equal(
match("*(foo|bar)/**/*.txt", "foo/hello/world/bar.txt", {
extended: true,
globstar: true,
}),
- true
+ true,
);
t.equal(
match("*(foo|bar)/**/*.txt", "foo/world/bar.txt", {
extended: true,
globstar: true,
}),
- true
+ true,
);
},
});
@@ -745,15 +745,15 @@ Deno.test({
t.equal(match("@(foo|baz)bar.txt", "foobar.txt", { extended: true }), true);
t.equal(
match("@(foo|baz)bar.txt", "foobazbar.txt", { extended: true }),
- false
+ false,
);
t.equal(
match("@(foo|baz)bar.txt", "foofoobar.txt", { extended: true }),
- false
+ false,
);
t.equal(
match("@(foo|baz)bar.txt", "toofoobar.txt", { extended: true }),
- false
+ false,
);
},
});
@@ -766,11 +766,11 @@ Deno.test({
t.equal(match("!bar.txt", "!bar.txt", { extended: true }), true);
t.equal(
match("!({foo,bar})baz.txt", "notbaz.txt", { extended: true }),
- true
+ true,
);
t.equal(
match("!({foo,bar})baz.txt", "foobaz.txt", { extended: true }),
- false
+ false,
);
},
});
@@ -791,35 +791,35 @@ Deno.test({
match("**/*/?yfile.{md,js,txt}", "foo/bar/baz/myfile.md", {
extended: true,
}),
- true
+ true,
);
t.equal(
match("**/*/?yfile.{md,js,txt}", "foo/baz/myfile.md", { extended: true }),
- true
+ true,
);
t.equal(
match("**/*/?yfile.{md,js,txt}", "foo/baz/tyfile.js", { extended: true }),
- true
+ true,
);
t.equal(
match("[[:digit:]_.]/file.js", "1/file.js", { extended: true }),
- true
+ true,
);
t.equal(
match("[[:digit:]_.]/file.js", "2/file.js", { extended: true }),
- true
+ true,
);
t.equal(
match("[[:digit:]_.]/file.js", "_/file.js", { extended: true }),
- true
+ true,
);
t.equal(
match("[[:digit:]_.]/file.js", "./file.js", { extended: true }),
- true
+ true,
);
t.equal(
match("[[:digit:]_.]/file.js", "z/file.js", { extended: true }),
- false
+ false,
);
},
});
diff --git a/std/path/_util.ts b/std/path/_util.ts
index 0c3253045..ead425a0b 100644
--- a/std/path/_util.ts
+++ b/std/path/_util.ts
@@ -16,7 +16,7 @@ import {
export function assertPath(path: string): void {
if (typeof path !== "string") {
throw new TypeError(
- `Path must be a string. Received ${JSON.stringify(path)}`
+ `Path must be a string. Received ${JSON.stringify(path)}`,
);
}
}
@@ -41,7 +41,7 @@ export function normalizeString(
path: string,
allowAboveRoot: boolean,
separator: string,
- isPathSeparator: (code: number) => boolean
+ isPathSeparator: (code: number) => boolean,
): string {
let res = "";
let lastSegmentLength = 0;
@@ -106,11 +106,11 @@ export function normalizeString(
export function _format(
sep: string,
- pathObject: FormatInputPathObject
+ pathObject: FormatInputPathObject,
): string {
const dir: string | undefined = pathObject.dir || pathObject.root;
- const base: string =
- pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
+ const base: string = pathObject.base ||
+ (pathObject.name || "") + (pathObject.ext || "");
if (!dir) return base;
if (dir === pathObject.root) return dir + base;
return dir + sep + base;
diff --git a/std/path/basename_test.ts b/std/path/basename_test.ts
index b0694de20..9e2265db9 100644
--- a/std/path/basename_test.ts
+++ b/std/path/basename_test.ts
@@ -32,7 +32,7 @@ Deno.test("basename", function () {
// On unix a backslash is just treated as any other character.
assertEquals(
path.posix.basename("\\dir\\basename.ext"),
- "\\dir\\basename.ext"
+ "\\dir\\basename.ext",
);
assertEquals(path.posix.basename("\\basename.ext"), "\\basename.ext");
assertEquals(path.posix.basename("basename.ext"), "basename.ext");
@@ -44,7 +44,7 @@ Deno.test("basename", function () {
const controlCharFilename = "Icon" + String.fromCharCode(13);
assertEquals(
path.posix.basename("/a/b/" + controlCharFilename),
- controlCharFilename
+ controlCharFilename,
);
});
diff --git a/std/path/common_test.ts b/std/path/common_test.ts
index 921cf1c99..7b7bd2ba3 100644
--- a/std/path/common_test.ts
+++ b/std/path/common_test.ts
@@ -11,7 +11,7 @@ Deno.test({
"file://deno/std/path/mod.ts",
"file://deno/cli/js/main.ts",
],
- "/"
+ "/",
);
assertEquals(actual, "file://deno/");
},
@@ -22,7 +22,7 @@ Deno.test({
fn() {
const actual = common(
["file://deno/cli/js/deno.ts", "https://deno.land/std/path/mod.ts"],
- "/"
+ "/",
);
assertEquals(actual, "");
},
@@ -37,7 +37,7 @@ Deno.test({
"c:\\deno\\std\\path\\mod.ts",
"c:\\deno\\cli\\js\\main.ts",
],
- "\\"
+ "\\",
);
assertEquals(actual, "c:\\deno\\");
},
diff --git a/std/path/dirname_test.ts b/std/path/dirname_test.ts
index bdf3391a9..210d3a9ec 100644
--- a/std/path/dirname_test.ts
+++ b/std/path/dirname_test.ts
@@ -40,15 +40,15 @@ Deno.test("dirnameWin32", function () {
assertEquals(path.win32.dirname("\\\\unc\\share\\foo\\"), "\\\\unc\\share\\");
assertEquals(
path.win32.dirname("\\\\unc\\share\\foo\\bar"),
- "\\\\unc\\share\\foo"
+ "\\\\unc\\share\\foo",
);
assertEquals(
path.win32.dirname("\\\\unc\\share\\foo\\bar\\"),
- "\\\\unc\\share\\foo"
+ "\\\\unc\\share\\foo",
);
assertEquals(
path.win32.dirname("\\\\unc\\share\\foo\\bar\\baz"),
- "\\\\unc\\share\\foo\\bar"
+ "\\\\unc\\share\\foo\\bar",
);
assertEquals(path.win32.dirname("/a/b/"), "/a");
assertEquals(path.win32.dirname("/a/b"), "/a");
diff --git a/std/path/glob.ts b/std/path/glob.ts
index 5288efda9..172587626 100644
--- a/std/path/glob.ts
+++ b/std/path/glob.ts
@@ -41,7 +41,7 @@ export interface GlobToRegExpOptions extends GlobOptions {
*/
export function globToRegExp(
glob: string,
- { extended = false, globstar = true }: GlobToRegExpOptions = {}
+ { extended = false, globstar = true }: GlobToRegExpOptions = {},
): RegExp {
const result = globrex(glob, {
extended,
@@ -57,7 +57,8 @@ export function globToRegExp(
export function isGlob(str: string): boolean {
const chars: Record<string, string> = { "{": "}", "(": ")", "[": "]" };
/* eslint-disable-next-line max-len */
- const regex = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/;
+ const regex =
+ /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/;
if (str === "") {
return false;
@@ -89,7 +90,7 @@ export function isGlob(str: string): boolean {
/** Like normalize(), but doesn't collapse "**\/.." when `globstar` is true. */
export function normalizeGlob(
glob: string,
- { globstar = false }: GlobOptions = {}
+ { globstar = false }: GlobOptions = {},
): string {
if (glob.match(/\0/g)) {
throw new Error(`Glob contains invalid characters: "${glob}"`);
@@ -100,7 +101,7 @@ export function normalizeGlob(
const s = SEP_PATTERN.source;
const badParentPattern = new RegExp(
`(?<=(${s}|^)\\*\\*${s})\\.\\.(?=${s}|$)`,
- "g"
+ "g",
);
return normalize(glob.replace(badParentPattern, "\0")).replace(/\0/g, "..");
}
@@ -108,7 +109,7 @@ export function normalizeGlob(
/** Like join(), but doesn't collapse "**\/.." when `globstar` is true. */
export function joinGlobs(
globs: string[],
- { extended = false, globstar = false }: GlobOptions = {}
+ { extended = false, globstar = false }: GlobOptions = {},
): string {
if (!globstar || globs.length == 0) {
return join(...globs);
diff --git a/std/path/glob_test.ts b/std/path/glob_test.ts
index 1c90e765a..dba79c302 100644
--- a/std/path/glob_test.ts
+++ b/std/path/glob_test.ts
@@ -13,33 +13,33 @@ Deno.test({
assertEquals(globToRegExp("*.ts").test("unicorn.js"), false);
assertEquals(
globToRegExp(join("unicorn", "**", "cathedral.ts")).test(
- join("unicorn", "in", "the", "cathedral.ts")
+ join("unicorn", "in", "the", "cathedral.ts"),
),
- true
+ true,
);
assertEquals(
globToRegExp(join("unicorn", "**", "cathedral.ts")).test(
- join("unicorn", "in", "the", "kitchen.ts")
+ join("unicorn", "in", "the", "kitchen.ts"),
),
- false
+ false,
);
assertEquals(
globToRegExp(join("unicorn", "**", "bathroom.*")).test(
- join("unicorn", "sleeping", "in", "bathroom.py")
+ join("unicorn", "sleeping", "in", "bathroom.py"),
),
- true
+ true,
);
assertEquals(
globToRegExp(join("unicorn", "!(sleeping)", "bathroom.ts"), {
extended: true,
}).test(join("unicorn", "flying", "bathroom.ts")),
- true
+ true,
);
assertEquals(
globToRegExp(join("unicorn", "(!sleeping)", "bathroom.ts"), {
extended: true,
}).test(join("unicorn", "sleeping", "bathroom.ts")),
- false
+ false,
);
},
});
@@ -59,7 +59,7 @@ testWalk(
assertEquals(arr.length, 2);
assertEquals(arr[0], "a/x.ts");
assertEquals(arr[1], "b/z.ts");
- }
+ },
);
testWalk(
@@ -79,7 +79,7 @@ testWalk(
});
assertEquals(arr.length, 1);
assertEquals(arr[0], "a/yo/x.ts");
- }
+ },
);
testWalk(
@@ -104,7 +104,7 @@ testWalk(
assertEquals(arr.length, 2);
assertEquals(arr[0], "a/deno/x.ts");
assertEquals(arr[1], "a/raptor/x.ts");
- }
+ },
);
testWalk(
@@ -120,7 +120,7 @@ testWalk(
assertEquals(arr.length, 2);
assertEquals(arr[0], "x.js");
assertEquals(arr[1], "x.ts");
- }
+ },
);
Deno.test({
diff --git a/std/path/posix.ts b/std/path/posix.ts
index 351ceb06e..03d07a84a 100644
--- a/std/path/posix.ts
+++ b/std/path/posix.ts
@@ -50,7 +50,7 @@ export function resolve(...pathSegments: string[]): string {
resolvedPath,
!resolvedAbsolute,
"/",
- isPosixPathSeparator
+ isPosixPathSeparator,
);
if (resolvedAbsolute) {
@@ -337,7 +337,7 @@ export function format(pathObject: FormatInputPathObject): string {
/* eslint-disable max-len */
if (pathObject === null || typeof pathObject !== "object") {
throw new TypeError(
- `The "pathObject" argument must be of type Object. Received type ${typeof pathObject}`
+ `The "pathObject" argument must be of type Object. Received type ${typeof pathObject}`,
);
}
return _format("/", pathObject);
diff --git a/std/path/win32.ts b/std/path/win32.ts
index 30482e453..66ed1ff14 100644
--- a/std/path/win32.ts
+++ b/std/path/win32.ts
@@ -167,7 +167,7 @@ export function resolve(...pathSegments: string[]): string {
resolvedTail,
!resolvedAbsolute,
"\\",
- isPathSeparator
+ isPathSeparator,
);
return resolvedDevice + (resolvedAbsolute ? "\\" : "") + resolvedTail || ".";
@@ -259,7 +259,7 @@ export function normalize(path: string): string {
path.slice(rootEnd),
!isAbsolute,
"\\",
- isPathSeparator
+ isPathSeparator,
);
} else {
tail = "";
@@ -750,7 +750,7 @@ export function format(pathObject: FormatInputPathObject): string {
/* eslint-disable max-len */
if (pathObject === null || typeof pathObject !== "object") {
throw new TypeError(
- `The "pathObject" argument must be of type Object. Received type ${typeof pathObject}`
+ `The "pathObject" argument must be of type Object. Received type ${typeof pathObject}`,
);
}
return _format("\\", pathObject);
diff --git a/std/permissions/mod.ts b/std/permissions/mod.ts
index b7f80117b..71c7e43ff 100644
--- a/std/permissions/mod.ts
+++ b/std/permissions/mod.ts
@@ -4,7 +4,8 @@ const { PermissionDenied } = Deno.errors;
function getPermissionString(descriptors: Deno.PermissionDescriptor[]): string {
return descriptors.length
- ? ` ${descriptors
+ ? ` ${
+ descriptors
.map((pd) => {
switch (pd.name) {
case "read":
@@ -20,7 +21,8 @@ function getPermissionString(descriptors: Deno.PermissionDescriptor[]): string {
return `--allow-${pd.name}`;
}
})
- .join("\n ")}`
+ .join("\n ")
+ }`
: "";
}
@@ -52,7 +54,7 @@ export async function grant(
* If one of the permissions requires a prompt, the function will attempt to
* prompt for it. The function resolves with all of the granted permissions. */
export async function grant(
- descriptors: Deno.PermissionDescriptor[]
+ descriptors: Deno.PermissionDescriptor[],
): Promise<void | Deno.PermissionDescriptor[]>;
export async function grant(
descriptor: Deno.PermissionDescriptor[] | Deno.PermissionDescriptor,
@@ -94,7 +96,7 @@ export async function grantOrThrow(
* the denied permissions. If all permissions are granted, the function will
* resolve. */
export async function grantOrThrow(
- descriptors: Deno.PermissionDescriptor[]
+ descriptors: Deno.PermissionDescriptor[],
): Promise<void>;
export async function grantOrThrow(
descriptor: Deno.PermissionDescriptor[] | Deno.PermissionDescriptor,
@@ -112,9 +114,11 @@ export async function grantOrThrow(
}
if (denied.length) {
throw new PermissionDenied(
- `The following permissions have not been granted:\n${getPermissionString(
- denied
- )}`
+ `The following permissions have not been granted:\n${
+ getPermissionString(
+ denied,
+ )
+ }`,
);
}
}
diff --git a/std/signal/mod.ts b/std/signal/mod.ts
index f09f76882..44ed24f13 100644
--- a/std/signal/mod.ts
+++ b/std/signal/mod.ts
@@ -27,7 +27,7 @@ export function signal(
if (signos.length < 1) {
throw new Error(
- "No signals are given. You need to specify at least one signal to create a signal stream."
+ "No signals are given. You need to specify at least one signal to create a signal stream.",
);
}
diff --git a/std/signal/test.ts b/std/signal/test.ts
index 4c8aa82e0..a21cc1d64 100644
--- a/std/signal/test.ts
+++ b/std/signal/test.ts
@@ -12,7 +12,7 @@ Deno.test({
(signal as any)();
},
Error,
- "No signals are given. You need to specify at least one signal to create a signal stream."
+ "No signals are given. You need to specify at least one signal to create a signal stream.",
);
},
});
@@ -28,7 +28,7 @@ Deno.test({
const sig = signal(
Deno.Signal.SIGUSR1,
Deno.Signal.SIGUSR2,
- Deno.Signal.SIGINT
+ Deno.Signal.SIGINT,
);
setTimeout(async () => {
diff --git a/std/testing/README.md b/std/testing/README.md
index 0e0ee14e7..bc9d8af33 100644
--- a/std/testing/README.md
+++ b/std/testing/README.md
@@ -90,7 +90,7 @@ Deno.test("doesThrow", function (): void {
throw new TypeError("hello world!");
},
TypeError,
- "hello"
+ "hello",
);
});
@@ -109,7 +109,7 @@ Deno.test("doesThrow", async function (): Promise<void> {
await assertThrowsAsync(
async (): Promise<void> => {
throw new TypeError("hello world!");
- }
+ },
);
await assertThrowsAsync(async (): Promise<void> => {
throw new TypeError("hello world!");
@@ -119,12 +119,12 @@ Deno.test("doesThrow", async function (): Promise<void> {
throw new TypeError("hello world!");
},
TypeError,
- "hello"
+ "hello",
);
await assertThrowsAsync(
async (): Promise<void> => {
return Promise.reject(new Error());
- }
+ },
);
});
@@ -133,7 +133,7 @@ Deno.test("fails", async function (): Promise<void> {
await assertThrowsAsync(
async (): Promise<void> => {
console.log("Hello world");
- }
+ },
);
});
```
@@ -214,7 +214,7 @@ runBenchmarks({ silent: true }, (p: BenchmarkRunProgress) => {
// initial progress data
if (p.state === ProgressState.BenchmarkingStart) {
console.log(
- `Starting benchmarking. Queued: ${p.queued.length}, filtered: ${p.filtered}`
+ `Starting benchmarking. Queued: ${p.queued.length}, filtered: ${p.filtered}`,
);
}
// ...
diff --git a/std/testing/asserts.ts b/std/testing/asserts.ts
index 2a1358143..4b9241e55 100644
--- a/std/testing/asserts.ts
+++ b/std/testing/asserts.ts
@@ -22,12 +22,12 @@ export class AssertionError extends Error {
export function _format(v: unknown): string {
let string = globalThis.Deno
? Deno.inspect(v, {
- depth: Infinity,
- sorted: true,
- trailingComma: true,
- compact: false,
- iterableLimit: Infinity,
- })
+ depth: Infinity,
+ sorted: true,
+ trailingComma: true,
+ compact: false,
+ iterableLimit: Infinity,
+ })
: String(v);
if (typeof v == "string") {
string = `"${string.replace(/(?=["\\])/g, "\\")}"`;
@@ -62,9 +62,9 @@ function buildMessage(diffResult: ReadonlyArray<DiffResult<string>>): string[] {
messages.push("");
messages.push("");
messages.push(
- ` ${gray(bold("[Diff]"))} ${red(bold("Actual"))} / ${green(
- bold("Expected")
- )}`
+ ` ${gray(bold("[Diff]"))} ${red(bold("Actual"))} / ${
+ green(bold("Expected"))
+ }`,
);
messages.push("");
messages.push("");
@@ -163,13 +163,13 @@ export function assert(expr: unknown, msg = ""): asserts expr {
export function assertEquals(
actual: unknown,
expected: unknown,
- msg?: string
+ msg?: string,
): void;
export function assertEquals<T>(actual: T, expected: T, msg?: string): void;
export function assertEquals(
actual: unknown,
expected: unknown,
- msg?: string
+ msg?: string,
): void {
if (equal(actual, expected)) {
return;
@@ -180,7 +180,7 @@ export function assertEquals(
try {
const diffResult = diff(
actualString.split("\n"),
- expectedString.split("\n")
+ expectedString.split("\n"),
);
const diffMsg = buildMessage(diffResult).join("\n");
message = `Values are not equal:\n${diffMsg}`;
@@ -206,13 +206,13 @@ export function assertEquals(
export function assertNotEquals(
actual: unknown,
expected: unknown,
- msg?: string
+ msg?: string,
): void;
export function assertNotEquals<T>(actual: T, expected: T, msg?: string): void;
export function assertNotEquals(
actual: unknown,
expected: unknown,
- msg?: string
+ msg?: string,
): void {
if (!equal(actual, expected)) {
return;
@@ -245,7 +245,7 @@ export function assertNotEquals(
export function assertStrictEquals<T>(
actual: T,
expected: T,
- msg?: string
+ msg?: string,
): void {
if (actual === expected) {
return;
@@ -264,14 +264,15 @@ export function assertStrictEquals<T>(
.split("\n")
.map((l) => ` ${l}`)
.join("\n");
- message = `Values have the same structure but are not reference-equal:\n\n${red(
- withOffset
- )}\n`;
+ message =
+ `Values have the same structure but are not reference-equal:\n\n${
+ red(withOffset)
+ }\n`;
} else {
try {
const diffResult = diff(
actualString.split("\n"),
- expectedString.split("\n")
+ expectedString.split("\n"),
);
const diffMsg = buildMessage(diffResult).join("\n");
message = `Values are not strictly equal:\n${diffMsg}`;
@@ -291,7 +292,7 @@ export function assertStrictEquals<T>(
export function assertStringContains(
actual: string,
expected: string,
- msg?: string
+ msg?: string,
): void {
if (!actual.includes(expected)) {
if (!msg) {
@@ -314,17 +315,17 @@ export function assertStringContains(
export function assertArrayContains(
actual: ArrayLike<unknown>,
expected: ArrayLike<unknown>,
- msg?: string
+ msg?: string,
): void;
export function assertArrayContains<T>(
actual: ArrayLike<T>,
expected: ArrayLike<T>,
- msg?: string
+ msg?: string,
): void;
export function assertArrayContains(
actual: ArrayLike<unknown>,
expected: ArrayLike<unknown>,
- msg?: string
+ msg?: string,
): void {
const missing: unknown[] = [];
for (let i = 0; i < expected.length; i++) {
@@ -343,9 +344,9 @@ export function assertArrayContains(
return;
}
if (!msg) {
- msg = `actual: "${_format(actual)}" expected to contain: "${_format(
- expected
- )}"\nmissing: ${_format(missing)}`;
+ msg = `actual: "${_format(actual)}" expected to contain: "${
+ _format(expected)
+ }"\nmissing: ${_format(missing)}`;
}
throw new AssertionError(msg);
}
@@ -357,7 +358,7 @@ export function assertArrayContains(
export function assertMatch(
actual: string,
expected: RegExp,
- msg?: string
+ msg?: string,
): void {
if (!expected.test(actual)) {
if (!msg) {
@@ -384,7 +385,7 @@ export function assertThrows<T = void>(
fn: () => T,
ErrorClass?: Constructor,
msgIncludes = "",
- msg?: string
+ msg?: string,
): Error {
let doesThrow = false;
let error = null;
@@ -395,18 +396,20 @@ export function assertThrows<T = void>(
throw new AssertionError("A non-Error object was thrown.");
}
if (ErrorClass && !(e instanceof ErrorClass)) {
- msg = `Expected error to be instance of "${ErrorClass.name}", but was "${
- e.constructor.name
- }"${msg ? `: ${msg}` : "."}`;
+ msg =
+ `Expected error to be instance of "${ErrorClass.name}", but was "${e.constructor.name}"${
+ msg ? `: ${msg}` : "."
+ }`;
throw new AssertionError(msg);
}
if (
msgIncludes &&
!stripColor(e.message).includes(stripColor(msgIncludes))
) {
- msg = `Expected error message to include "${msgIncludes}", but got "${
- e.message
- }"${msg ? `: ${msg}` : "."}`;
+ msg =
+ `Expected error message to include "${msgIncludes}", but got "${e.message}"${
+ msg ? `: ${msg}` : "."
+ }`;
throw new AssertionError(msg);
}
doesThrow = true;
@@ -428,7 +431,7 @@ export async function assertThrowsAsync<T = void>(
fn: () => Promise<T>,
ErrorClass?: Constructor,
msgIncludes = "",
- msg?: string
+ msg?: string,
): Promise<Error> {
let doesThrow = false;
let error = null;
@@ -439,18 +442,20 @@ export async function assertThrowsAsync<T = void>(
throw new AssertionError("A non-Error object was thrown or rejected.");
}
if (ErrorClass && !(e instanceof ErrorClass)) {
- msg = `Expected error to be instance of "${ErrorClass.name}", but got "${
- e.name
- }"${msg ? `: ${msg}` : "."}`;
+ msg =
+ `Expected error to be instance of "${ErrorClass.name}", but got "${e.name}"${
+ msg ? `: ${msg}` : "."
+ }`;
throw new AssertionError(msg);
}
if (
msgIncludes &&
!stripColor(e.message).includes(stripColor(msgIncludes))
) {
- msg = `Expected error message to include "${msgIncludes}", but got "${
- e.message
- }"${msg ? `: ${msg}` : "."}`;
+ msg =
+ `Expected error message to include "${msgIncludes}", but got "${e.message}"${
+ msg ? `: ${msg}` : "."
+ }`;
throw new AssertionError(msg);
}
doesThrow = true;
diff --git a/std/testing/asserts_test.ts b/std/testing/asserts_test.ts
index c3059ebac..7ea73b5c0 100644
--- a/std/testing/asserts_test.ts
+++ b/std/testing/asserts_test.ts
@@ -29,14 +29,14 @@ Deno.test("testingEqual", function (): void {
assert(
equal(
{ hello: "world", hi: { there: "everyone" } },
- { hello: "world", hi: { there: "everyone" } }
- )
+ { hello: "world", hi: { there: "everyone" } },
+ ),
);
assert(
!equal(
{ hello: "world", hi: { there: "everyone" } },
- { hello: "world", hi: { there: "everyone else" } }
- )
+ { hello: "world", hi: { there: "everyone else" } },
+ ),
);
assert(equal(/deno/, /deno/));
assert(!equal(/deno/, /node/));
@@ -45,8 +45,8 @@ Deno.test("testingEqual", function (): void {
assert(
!equal(
new Date(2019, 0, 3, 4, 20, 1, 10),
- new Date(2019, 0, 3, 4, 20, 1, 20)
- )
+ new Date(2019, 0, 3, 4, 20, 1, 20),
+ ),
);
assert(equal(new Set([1]), new Set([1])));
assert(!equal(new Set([1]), new Set([2])));
@@ -65,20 +65,20 @@ Deno.test("testingEqual", function (): void {
new Map([
["foo", "bar"],
["baz", "baz"],
- ])
- )
+ ]),
+ ),
);
assert(
equal(
new Map([["foo", new Map([["bar", "baz"]])]]),
- new Map([["foo", new Map([["bar", "baz"]])]])
- )
+ new Map([["foo", new Map([["bar", "baz"]])]]),
+ ),
);
assert(
equal(
new Map([["foo", { bar: "baz" }]]),
- new Map([["foo", { bar: "baz" }]])
- )
+ new Map([["foo", { bar: "baz" }]]),
+ ),
);
assert(
equal(
@@ -89,8 +89,8 @@ Deno.test("testingEqual", function (): void {
new Map([
["baz", "qux"],
["foo", "bar"],
- ])
- )
+ ]),
+ ),
);
assert(equal(new Map([["foo", ["bar"]]]), new Map([["foo", ["bar"]]])));
assert(!equal(new Map([["foo", "bar"]]), new Map([["bar", "baz"]])));
@@ -100,14 +100,14 @@ Deno.test("testingEqual", function (): void {
new Map([
["foo", "bar"],
["bar", "baz"],
- ])
- )
+ ]),
+ ),
);
assert(
!equal(
new Map([["foo", new Map([["bar", "baz"]])]]),
- new Map([["foo", new Map([["bar", "qux"]])]])
- )
+ new Map([["foo", new Map([["bar", "qux"]])]]),
+ ),
);
assert(equal(new Map([[{ x: 1 }, true]]), new Map([[{ x: 1 }, true]])));
assert(!equal(new Map([[{ x: 1 }, true]]), new Map([[{ x: 1 }, false]])));
@@ -120,13 +120,13 @@ Deno.test("testingEqual", function (): void {
assert(equal(new Uint8Array([1, 2, 3, 4]), new Uint8Array([1, 2, 3, 4])));
assert(!equal(new Uint8Array([1, 2, 3, 4]), new Uint8Array([2, 1, 4, 3])));
assert(
- equal(new URL("https://example.test"), new URL("https://example.test"))
+ equal(new URL("https://example.test"), new URL("https://example.test")),
);
assert(
!equal(
new URL("https://example.test"),
- new URL("https://example.test/with-path")
- )
+ new URL("https://example.test/with-path"),
+ ),
);
});
@@ -137,7 +137,7 @@ Deno.test("testingNotEquals", function (): void {
assertNotEquals("Denosaurus", "Tyrannosaurus");
assertNotEquals(
new Date(2019, 0, 3, 4, 20, 1, 10),
- new Date(2019, 0, 3, 4, 20, 1, 20)
+ new Date(2019, 0, 3, 4, 20, 1, 20),
);
let didThrow;
try {
@@ -172,7 +172,7 @@ Deno.test("testingArrayContains", function (): void {
assertArrayContains(fixtureObject, [{ deno: "luv" }]);
assertArrayContains(
Uint8Array.from([1, 2, 3, 4]),
- Uint8Array.from([1, 2, 3])
+ Uint8Array.from([1, 2, 3]),
);
assertThrows(
(): void => assertArrayContains(fixtureObject, [{ deno: "node" }]),
@@ -193,7 +193,7 @@ missing: [
{
deno: "node",
},
-]`
+]`,
);
});
@@ -204,7 +204,7 @@ Deno.test("testingAssertStringContainsThrow", function (): void {
} catch (e) {
assert(
e.message ===
- `actual: "Denosaurus from Jurassic" expected to contain: "Raptor"`
+ `actual: "Denosaurus from Jurassic" expected to contain: "Raptor"`,
);
assert(e instanceof AssertionError);
didThrow = true;
@@ -223,7 +223,7 @@ Deno.test("testingAssertStringMatchingThrows", function (): void {
} catch (e) {
assert(
e.message ===
- `actual: "Denosaurus from Jurassic" expected to match: "/Raptor/"`
+ `actual: "Denosaurus from Jurassic" expected to match: "/Raptor/"`,
);
assert(e instanceof AssertionError);
didThrow = true;
@@ -262,7 +262,7 @@ Deno.test("testingAssertFail", function (): void {
fail("foo");
},
AssertionError,
- "Failed assertion: foo"
+ "Failed assertion: foo",
);
});
@@ -276,11 +276,11 @@ Deno.test("testingAssertFailWithWrongErrorClass", function (): void {
fail("foo");
},
TypeError,
- "Failed assertion: foo"
+ "Failed assertion: foo",
);
},
AssertionError,
- `Expected error to be instance of "TypeError", but was "AssertionError"`
+ `Expected error to be instance of "TypeError", but was "AssertionError"`,
);
});
@@ -299,9 +299,9 @@ Deno.test("testingAssertThrowsAsyncWithReturnType", () => {
const createHeader = (): string[] => [
"",
"",
- ` ${gray(bold("[Diff]"))} ${red(bold("Actual"))} / ${green(
- bold("Expected")
- )}`,
+ ` ${gray(bold("[Diff]"))} ${red(bold("Actual"))} / ${
+ green(bold("Expected"))
+ }`,
"",
"",
];
@@ -332,7 +332,7 @@ Deno.test({
removed(`- ${yellow("1")}`),
added(`+ ${yellow("2")}`),
"",
- ].join("\n")
+ ].join("\n"),
);
},
});
@@ -348,7 +348,7 @@ Deno.test({
...createHeader(),
removed(`- ${yellow("1")}`),
added(`+ "1"`),
- ].join("\n")
+ ].join("\n"),
);
},
});
@@ -365,7 +365,7 @@ Deno.test({
+ "1",
"2",
3,
- ]`
+ ]`,
);
},
});
@@ -385,7 +385,7 @@ Deno.test({
+ ],
- b: "2",
- c: 3,
- }`
+ }`,
);
},
});
@@ -397,7 +397,7 @@ Deno.test({
(): void =>
assertEquals(
new Date(2019, 0, 3, 4, 20, 1, 10),
- new Date(2019, 0, 3, 4, 20, 1, 20)
+ new Date(2019, 0, 3, 4, 20, 1, 20),
),
AssertionError,
[
@@ -406,7 +406,7 @@ Deno.test({
removed(`- ${new Date(2019, 0, 3, 4, 20, 1, 10).toISOString()}`),
added(`+ ${new Date(2019, 0, 3, 4, 20, 1, 20).toISOString()}`),
"",
- ].join("\n")
+ ].join("\n"),
);
},
});
@@ -441,7 +441,7 @@ Deno.test({
+ 3,
+ ],
- b: 2,
- }`
+ }`,
);
},
});
@@ -457,7 +457,7 @@ Deno.test({
{
a: 1,
b: 2,
- }`
+ }`,
);
},
});
@@ -481,11 +481,11 @@ Deno.test("Assert Throws Non-Error Fail", () => {
throw "Panic!";
},
String,
- "Panic!"
+ "Panic!",
);
},
AssertionError,
- "A non-Error object was thrown."
+ "A non-Error object was thrown.",
);
assertThrows(
@@ -495,7 +495,7 @@ Deno.test("Assert Throws Non-Error Fail", () => {
});
},
AssertionError,
- "A non-Error object was thrown."
+ "A non-Error object was thrown.",
);
assertThrows(
@@ -505,7 +505,7 @@ Deno.test("Assert Throws Non-Error Fail", () => {
});
},
AssertionError,
- "A non-Error object was thrown."
+ "A non-Error object was thrown.",
);
});
@@ -517,11 +517,11 @@ Deno.test("Assert Throws Async Non-Error Fail", () => {
return Promise.reject("Panic!");
},
String,
- "Panic!"
+ "Panic!",
);
},
AssertionError,
- "A non-Error object was thrown or rejected."
+ "A non-Error object was thrown or rejected.",
);
assertThrowsAsync(
@@ -531,7 +531,7 @@ Deno.test("Assert Throws Async Non-Error Fail", () => {
});
},
AssertionError,
- "A non-Error object was thrown or rejected."
+ "A non-Error object was thrown or rejected.",
);
assertThrowsAsync(
@@ -541,7 +541,7 @@ Deno.test("Assert Throws Async Non-Error Fail", () => {
});
},
AssertionError,
- "A non-Error object was thrown or rejected."
+ "A non-Error object was thrown or rejected.",
);
assertThrowsAsync(
@@ -551,7 +551,7 @@ Deno.test("Assert Throws Async Non-Error Fail", () => {
});
},
AssertionError,
- "A non-Error object was thrown or rejected."
+ "A non-Error object was thrown or rejected.",
);
});
@@ -568,7 +568,7 @@ Deno.test("assertEquals diff for differently ordered objects", () => {
ccccccccccccccccccccccc: 1,
aaaaaaaaaaaaaaaaaaaaaaaa: 0,
bbbbbbbbbbbbbbbbbbbbbbbb: 0,
- }
+ },
);
},
AssertionError,
@@ -578,7 +578,7 @@ Deno.test("assertEquals diff for differently ordered objects", () => {
bbbbbbbbbbbbbbbbbbbbbbbb: 0,
- ccccccccccccccccccccccc: 0,
+ ccccccccccccccccccccccc: 1,
- }`
+ }`,
);
});
@@ -592,7 +592,7 @@ Deno.test("assert diff formatting", () => {
`{
a: 1,
b: 2,
-}`
+}`,
);
// Same for nested small objects.
@@ -609,7 +609,7 @@ Deno.test("assert diff formatting", () => {
"b",
],
},
-]`
+]`,
);
// Grouping is disabled.
@@ -623,7 +623,7 @@ Deno.test("assert diff formatting", () => {
"i",
"i",
"i",
-]`
+]`,
);
});
@@ -633,7 +633,7 @@ Deno.test("Assert Throws Parent Error", () => {
throw new AssertionError("Fail!");
},
Error,
- "Fail!"
+ "Fail!",
);
});
@@ -643,6 +643,6 @@ Deno.test("Assert Throws Async Parent Error", () => {
throw new AssertionError("Fail!");
},
Error,
- "Fail!"
+ "Fail!",
);
});
diff --git a/std/testing/bench.ts b/std/testing/bench.ts
index e6f4582b9..b8bf40a9b 100644
--- a/std/testing/bench.ts
+++ b/std/testing/bench.ts
@@ -112,17 +112,17 @@ function assertTiming(clock: BenchmarkClock): void {
if (!clock.stop) {
throw new BenchmarkRunError(
`Running benchmarks FAILED during benchmark named [${clock.for}]. The benchmark timer's stop method must be called`,
- clock.for
+ clock.for,
);
} else if (!clock.start) {
throw new BenchmarkRunError(
`Running benchmarks FAILED during benchmark named [${clock.for}]. The benchmark timer's start method must be called`,
- clock.for
+ clock.for,
);
} else if (clock.start > clock.stop) {
throw new BenchmarkRunError(
`Running benchmarks FAILED during benchmark named [${clock.for}]. The benchmark timer's start method must be called before its stop method`,
- clock.for
+ clock.for,
);
}
}
@@ -136,7 +136,7 @@ function createBenchmarkTimer(clock: BenchmarkClock): BenchmarkTimer {
if (isNaN(clock.start)) {
throw new BenchmarkRunError(
`Running benchmarks FAILED during benchmark named [${clock.for}]. The benchmark timer's start method must be called before its stop method`,
- clock.for
+ clock.for,
);
}
clock.stop = performance.now();
@@ -148,7 +148,7 @@ const candidates: BenchmarkDefinition[] = [];
/** Registers a benchmark as a candidate for the runBenchmarks executor. */
export function bench(
- benchmark: BenchmarkDefinition | BenchmarkFunction
+ benchmark: BenchmarkDefinition | BenchmarkFunction,
): void {
if (!benchmark.name) {
throw new Error("The benchmark function must not be anonymous");
@@ -171,7 +171,7 @@ export function clearBenchmarks({
skip = /$^/,
}: BenchmarkClearOptions = {}): void {
const keep = candidates.filter(
- ({ name }): boolean => !only.test(name) || skip.test(name)
+ ({ name }): boolean => !only.test(name) || skip.test(name),
);
candidates.splice(0, candidates.length);
candidates.push(...keep);
@@ -185,11 +185,11 @@ export function clearBenchmarks({
*/
export async function runBenchmarks(
{ only = /[^\s]/, skip = /^\s*$/, silent }: BenchmarkRunOptions = {},
- progressCb?: (progress: BenchmarkRunProgress) => void | Promise<void>
+ progressCb?: (progress: BenchmarkRunProgress) => void | Promise<void>,
): Promise<BenchmarkRunResult> {
// Filtering candidates by the "only" and "skip" constraint
const benchmarks: BenchmarkDefinition[] = candidates.filter(
- ({ name }): boolean => only.test(name) && !skip.test(name)
+ ({ name }): boolean => only.test(name) && !skip.test(name),
);
// Init main counters and error flag
const filtered = candidates.length - benchmarks.length;
@@ -217,7 +217,7 @@ export async function runBenchmarks(
console.log(
"running",
benchmarks.length,
- `benchmark${benchmarks.length === 1 ? " ..." : "s ..."}`
+ `benchmark${benchmarks.length === 1 ? " ..." : "s ..."}`,
);
}
@@ -233,7 +233,7 @@ export async function runBenchmarks(
// Remove benchmark from queued
const queueIndex = progress.queued.findIndex(
- (queued) => queued.name === name && queued.runsCount === runs
+ (queued) => queued.name === name && queued.runsCount === runs,
);
if (queueIndex != -1) {
progress.queued.splice(queueIndex, 1);
@@ -268,17 +268,16 @@ export async function runBenchmarks(
await publishProgress(
progress,
ProgressState.BenchPartialResult,
- progressCb
+ progressCb,
);
// Resetting the benchmark clock
clock.start = clock.stop = NaN;
// Once all ran
if (!--pendingRuns) {
- result =
- runs == 1
- ? `${totalMs}ms`
- : `${runs} runs avg: ${totalMs / runs}ms`;
+ result = runs == 1
+ ? `${totalMs}ms`
+ : `${runs} runs avg: ${totalMs / runs}ms`;
// Adding results
progress.results.push({
name,
@@ -293,7 +292,7 @@ export async function runBenchmarks(
await publishProgress(
progress,
ProgressState.BenchResult,
- progressCb
+ progressCb,
);
break;
}
@@ -329,7 +328,7 @@ export async function runBenchmarks(
// Closing results
console.log(
`benchmark result: ${failError ? red("FAIL") : blue("DONE")}. ` +
- `${progress.results.length} measured; ${filtered} filtered`
+ `${progress.results.length} measured; ${filtered} filtered`,
);
}
@@ -349,14 +348,14 @@ export async function runBenchmarks(
async function publishProgress(
progress: BenchmarkRunProgress,
state: ProgressState,
- progressCb?: (progress: BenchmarkRunProgress) => void | Promise<void>
+ progressCb?: (progress: BenchmarkRunProgress) => void | Promise<void>,
): Promise<void> {
progressCb && (await progressCb(cloneProgressWithState(progress, state)));
}
function cloneProgressWithState(
progress: BenchmarkRunProgress,
- state: ProgressState
+ state: ProgressState,
): BenchmarkRunProgress {
return deepAssign({}, progress, { state }) as BenchmarkRunProgress;
}
diff --git a/std/testing/bench_test.ts b/std/testing/bench_test.ts
index b6d64ab89..97a923ac2 100644
--- a/std/testing/bench_test.ts
+++ b/std/testing/bench_test.ts
@@ -46,8 +46,8 @@ Deno.test({
async (denoland: string): Promise<void> => {
const r = await fetch(denoland);
await r.text();
- }
- )
+ },
+ ),
);
b.stop();
});
@@ -73,7 +73,7 @@ Deno.test({
assertEquals(benchResult.results.length, 5);
const resultWithSingleRunsFiltered = benchResult.results.filter(
- ({ name }) => name === "forDecrementX1e9"
+ ({ name }) => name === "forDecrementX1e9",
);
assertEquals(resultWithSingleRunsFiltered.length, 1);
@@ -85,7 +85,7 @@ Deno.test({
assertEquals(resultWithSingleRuns.measuredRunsMs.length, 1);
const resultWithMultipleRunsFiltered = benchResult.results.filter(
- ({ name }) => name === "runs100ForIncrementX1e6"
+ ({ name }) => name === "runs100ForIncrementX1e6",
);
assertEquals(resultWithMultipleRunsFiltered.length, 1);
@@ -108,7 +108,7 @@ Deno.test({
bench(() => {});
},
Error,
- "The benchmark function must not be anonymous"
+ "The benchmark function must not be anonymous",
);
},
});
@@ -125,7 +125,7 @@ Deno.test({
await runBenchmarks({ only: /benchWithoutStop/, silent: true });
},
BenchmarkRunError,
- "The benchmark timer's stop method must be called"
+ "The benchmark timer's stop method must be called",
);
},
});
@@ -142,7 +142,7 @@ Deno.test({
await runBenchmarks({ only: /benchWithoutStart/, silent: true });
},
BenchmarkRunError,
- "The benchmark timer's start method must be called"
+ "The benchmark timer's start method must be called",
);
},
});
@@ -160,7 +160,7 @@ Deno.test({
await runBenchmarks({ only: /benchStopBeforeStart/, silent: true });
},
BenchmarkRunError,
- "The benchmark timer's start method must be called before its stop method"
+ "The benchmark timer's start method must be called before its stop method",
);
},
});
@@ -249,7 +249,7 @@ Deno.test({
{ skip: /skip/, silent: true },
(progress) => {
progressCallbacks.push(progress);
- }
+ },
);
let pc = 0;
@@ -322,7 +322,7 @@ Deno.test({
assertEquals(progress.results.length, 2);
assert(!!progress.results.find(({ name }) => name == "single"));
const resultOfMultiple = progress.results.filter(
- ({ name }) => name == "multiple"
+ ({ name }) => name == "multiple",
);
assertEquals(resultOfMultiple.length, 1);
assert(!!resultOfMultiple[0].measuredRunsMs);
diff --git a/std/testing/diff.ts b/std/testing/diff.ts
index da1e827ac..3a9eca4bb 100644
--- a/std/testing/diff.ts
+++ b/std/testing/diff.ts
@@ -41,7 +41,7 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
const suffixCommon = createCommon(
A.slice(prefixCommon.length),
B.slice(prefixCommon.length),
- true
+ true,
).reverse();
A = suffixCommon.length
? A.slice(prefixCommon.length, -suffixCommon.length)
@@ -57,16 +57,16 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
if (!N) {
return [
...prefixCommon.map(
- (c): DiffResult<typeof c> => ({ type: DiffType.common, value: c })
+ (c): DiffResult<typeof c> => ({ type: DiffType.common, value: c }),
),
...A.map(
(a): DiffResult<typeof a> => ({
type: swapped ? DiffType.added : DiffType.removed,
value: a,
- })
+ }),
),
...suffixCommon.map(
- (c): DiffResult<typeof c> => ({ type: DiffType.common, value: c })
+ (c): DiffResult<typeof c> => ({ type: DiffType.common, value: c }),
),
];
}
@@ -91,7 +91,7 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
A: T[],
B: T[],
current: FarthestPoint,
- swapped: boolean
+ swapped: boolean,
): Array<{
type: DiffType;
value: T;
@@ -133,7 +133,7 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
slide: FarthestPoint,
down: FarthestPoint,
k: number,
- M: number
+ M: number,
): FarthestPoint {
if (slide && slide.y === -1 && down && down.y === -1) {
return { y: 0, id: 0 };
@@ -163,7 +163,7 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
down: FarthestPoint,
_offset: number,
A: T[],
- B: T[]
+ B: T[],
): FarthestPoint {
const M = A.length;
const N = B.length;
@@ -189,7 +189,7 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
fp[k + 1 + offset],
offset,
A,
- B
+ B,
);
}
for (let k = delta + p; k > delta; --k) {
@@ -199,7 +199,7 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
fp[k + 1 + offset],
offset,
A,
- B
+ B,
);
}
fp[delta + offset] = snake(
@@ -208,16 +208,16 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
fp[delta + 1 + offset],
offset,
A,
- B
+ B,
);
}
return [
...prefixCommon.map(
- (c): DiffResult<typeof c> => ({ type: DiffType.common, value: c })
+ (c): DiffResult<typeof c> => ({ type: DiffType.common, value: c }),
),
...backTrace(A, B, fp[delta + offset], swapped),
...suffixCommon.map(
- (c): DiffResult<typeof c> => ({ type: DiffType.common, value: c })
+ (c): DiffResult<typeof c> => ({ type: DiffType.common, value: c }),
),
];
}
diff --git a/std/textproto/mod.ts b/std/textproto/mod.ts
index 1d0d22715..b23ccee19 100644
--- a/std/textproto/mod.ts
+++ b/std/textproto/mod.ts
@@ -71,7 +71,7 @@ export class TextProtoReader {
throw new Deno.errors.UnexpectedEof();
} else if (buf[0] == charCode(" ") || buf[0] == charCode("\t")) {
throw new Deno.errors.InvalidData(
- `malformed MIME header initial line: ${str(line)}`
+ `malformed MIME header initial line: ${str(line)}`,
);
}
@@ -84,7 +84,7 @@ export class TextProtoReader {
let i = kv.indexOf(charCode(":"));
if (i < 0) {
throw new Deno.errors.InvalidData(
- `malformed MIME header line: ${str(kv)}`
+ `malformed MIME header line: ${str(kv)}`,
);
}
@@ -110,7 +110,7 @@ export class TextProtoReader {
}
const value = str(kv.subarray(i)).replace(
invalidHeaderCharRegex,
- encodeURI
+ encodeURI,
);
// In case of invalid header we swallow the error
diff --git a/std/textproto/test.ts b/std/textproto/test.ts
index a7109410b..1d4bed50b 100644
--- a/std/textproto/test.ts
+++ b/std/textproto/test.ts
@@ -96,8 +96,7 @@ Deno.test({
Deno.test({
name: "[textproto] Reader : MIME Header Non compliant",
async fn(): Promise<void> {
- const input =
- "Foo: bar\r\n" +
+ const input = "Foo: bar\r\n" +
"Content-Language: en\r\n" +
"SID : 0\r\n" +
"Audio Mode : None\r\n" +
@@ -143,9 +142,7 @@ Deno.test({
Deno.test({
name: "[textproto] Reader : MIME Header Trim Continued",
async fn(): Promise<void> {
- const input =
- "" + // for code formatting purpose.
- "a:\n" +
+ const input = "a:\n" +
" 0 \r\n" +
"b:1 \t\r\n" +
"c: 2\r\n" +
@@ -185,7 +182,7 @@ Deno.test({
const input = "abcdefghijklmnopqrstuvwxyz";
const bufSize = 25;
const tp = new TextProtoReader(
- new BufReader(new StringReader(input), bufSize)
+ new BufReader(new StringReader(input), bufSize),
);
const line = await tp.readLine();
assertEquals(line, input);
diff --git a/std/uuid/v1.ts b/std/uuid/v1.ts
index cbfce576a..6e48fa55f 100644
--- a/std/uuid/v1.ts
+++ b/std/uuid/v1.ts
@@ -4,7 +4,7 @@ import { bytesToUuid } from "./_common.ts";
const UUID_RE = new RegExp(
"^[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
- "i"
+ "i",
);
export function validate(id: string): boolean {
@@ -29,7 +29,7 @@ type V1Options = {
export function generate(
options?: V1Options | null,
buf?: number[],
- offset?: number
+ offset?: number,
): string | number[] {
let i = (buf && offset) || 0;
const b = buf || [];
@@ -40,8 +40,7 @@ export function generate(
if (node == null || clockseq == null) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- const seedBytes: any =
- options.random ||
+ const seedBytes: any = options.random ||
options.rng ||
crypto.getRandomValues(new Uint8Array(16));
if (node == null) {
@@ -58,8 +57,9 @@ export function generate(
clockseq = _clockseq = ((seedBytes[6] << 8) | seedBytes[7]) & 0x3fff;
}
}
- let msecs =
- options.msecs !== undefined ? options.msecs : new Date().getTime();
+ let msecs = options.msecs !== undefined
+ ? options.msecs
+ : new Date().getTime();
let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;
diff --git a/std/uuid/v4.ts b/std/uuid/v4.ts
index 83fc6d86e..53fbc92e3 100644
--- a/std/uuid/v4.ts
+++ b/std/uuid/v4.ts
@@ -4,7 +4,7 @@ import { bytesToUuid } from "./_common.ts";
const UUID_RE = new RegExp(
"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
- "i"
+ "i",
);
export function validate(id: string): boolean {
diff --git a/std/uuid/v5.ts b/std/uuid/v5.ts
index f982d9745..6375e7bab 100644
--- a/std/uuid/v5.ts
+++ b/std/uuid/v5.ts
@@ -10,7 +10,8 @@ import { Sha1 } from "../hash/sha1.ts";
import { isString } from "../node/util.ts";
import { assert } from "../_util/assert.ts";
-const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
+const UUID_RE =
+ /^[0-9a-f]{8}-[0-9a-f]{4}-[5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
export function validate(id: string): boolean {
return UUID_RE.test(id);
@@ -24,7 +25,7 @@ interface V5Options {
export function generate(
options: V5Options,
buf?: number[],
- offset?: number
+ offset?: number,
): string | number[] {
const i = (buf && offset) || 0;
@@ -33,7 +34,7 @@ export function generate(
if (isString(namespace)) namespace = uuidToBytes(namespace as string);
assert(
namespace.length === 16,
- "namespace must be uuid string or an Array of 16 byte values"
+ "namespace must be uuid string or an Array of 16 byte values",
);
const content = (namespace as number[]).concat(value as number[]);
diff --git a/std/wasi/snapshot_preview1.ts b/std/wasi/snapshot_preview1.ts
index 5a526d408..37f8216ff 100644
--- a/std/wasi/snapshot_preview1.ts
+++ b/std/wasi/snapshot_preview1.ts
@@ -361,7 +361,7 @@ export default class Module {
args.reduce(function (acc, arg) {
return acc + text.encode(`${arg}\0`).length;
}, 0),
- true
+ true,
);
return ERRNO_SUCCESS;
@@ -387,7 +387,7 @@ export default class Module {
environ_sizes_get: (
environc_out: number,
- environ_buf_size_out: number
+ environ_buf_size_out: number,
): number => {
const entries = Object.entries(this.env);
const text = new TextEncoder();
@@ -399,7 +399,7 @@ export default class Module {
entries.reduce(function (acc, [key, value]) {
return acc + text.encode(`${key}=${value}\0`).length;
}, 0),
- true
+ true,
);
return ERRNO_SUCCESS;
@@ -435,7 +435,7 @@ export default class Module {
clock_time_get: (
id: number,
precision: bigint,
- time_out: number
+ time_out: number,
): number => {
const view = new DataView(this.memory.buffer);
@@ -467,7 +467,7 @@ export default class Module {
fd: number,
offset: bigint,
len: bigint,
- advice: number
+ advice: number,
): number => {
return ERRNO_NOSYS;
},
@@ -528,7 +528,7 @@ export default class Module {
fd_fdstat_set_rights: (
fd: number,
fs_rights_base: bigint,
- fs_rights_inheriting: bigint
+ fs_rights_inheriting: bigint,
): number => {
return ERRNO_NOSYS;
},
@@ -582,21 +582,21 @@ export default class Module {
view.setBigUint64(
buf_out,
BigInt(info.atime ? info.atime.getTime() * 1e6 : 0),
- true
+ true,
);
buf_out += 8;
view.setBigUint64(
buf_out,
BigInt(info.mtime ? info.mtime.getTime() * 1e6 : 0),
- true
+ true,
);
buf_out += 8;
view.setBigUint64(
buf_out,
BigInt(info.birthtime ? info.birthtime.getTime() * 1e6 : 0),
- true
+ true,
);
buf_out += 8;
} catch (err) {
@@ -625,7 +625,7 @@ export default class Module {
fd: number,
atim: bigint,
mtim: bigint,
- fst_flags: number
+ fst_flags: number,
): number => {
const entry = this.fds[fd];
if (!entry) {
@@ -658,7 +658,7 @@ export default class Module {
iovs_ptr: number,
iovs_len: number,
offset: bigint,
- nread_out: number
+ nread_out: number,
): number => {
const entry = this.fds[fd];
if (!entry) {
@@ -701,7 +701,7 @@ export default class Module {
view.setUint32(
buf_out + 4,
new TextEncoder().encode(entry.vpath).byteLength,
- true
+ true,
);
return ERRNO_SUCCESS;
@@ -710,7 +710,7 @@ export default class Module {
fd_prestat_dir_name: (
fd: number,
path_ptr: number,
- path_len: number
+ path_len: number,
): number => {
const entry = this.fds[fd];
if (!entry) {
@@ -732,7 +732,7 @@ export default class Module {
iovs_ptr: number,
iovs_len: number,
offset: bigint,
- nwritten_out: number
+ nwritten_out: number,
): number => {
const entry = this.fds[fd];
if (!entry) {
@@ -764,7 +764,7 @@ export default class Module {
fd: number,
iovs_ptr: number,
iovs_len: number,
- nread_out: number
+ nread_out: number,
): number => {
const entry = this.fds[fd];
if (!entry) {
@@ -795,7 +795,7 @@ export default class Module {
buf_ptr: number,
buf_len: number,
cookie: bigint,
- bufused_out: number
+ bufused_out: number,
): number => {
const entry = this.fds[fd];
if (!entry) {
@@ -813,7 +813,7 @@ export default class Module {
const name_data = new TextEncoder().encode(entries[i].name);
const entry_info = Deno.statSync(
- resolve(entry.path, entries[i].name)
+ resolve(entry.path, entries[i].name),
);
const entry_data = new Uint8Array(24 + name_data.byteLength);
const entry_view = new DataView(entry_data.buffer);
@@ -822,7 +822,7 @@ export default class Module {
entry_view.setBigUint64(
8,
BigInt(entry_info.ino ? entry_info.ino : 0),
- true
+ true,
);
entry_view.setUint32(16, name_data.byteLength, true);
@@ -849,7 +849,7 @@ export default class Module {
const data = entry_data.slice(
0,
- Math.min(entry_data.length, buf_len - bufused)
+ Math.min(entry_data.length, buf_len - bufused),
);
heap.set(data, buf_ptr + bufused);
bufused += data.byteLength;
@@ -883,7 +883,7 @@ export default class Module {
fd: number,
offset: bigint,
whence: number,
- newoffset_out: number
+ newoffset_out: number,
): number => {
const entry = this.fds[fd];
if (!entry) {
@@ -941,7 +941,7 @@ export default class Module {
fd: number,
iovs_ptr: number,
iovs_len: number,
- nwritten_out: number
+ nwritten_out: number,
): number => {
const entry = this.fds[fd];
if (!entry) {
@@ -959,7 +959,7 @@ export default class Module {
iovs_ptr += 4;
nwritten += entry.handle.writeSync(
- new Uint8Array(this.memory.buffer, data_ptr, data_len)
+ new Uint8Array(this.memory.buffer, data_ptr, data_len),
);
}
@@ -971,7 +971,7 @@ export default class Module {
path_create_directory: (
fd: number,
path_ptr: number,
- path_len: number
+ path_len: number,
): number => {
const entry = this.fds[fd];
if (!entry) {
@@ -1000,7 +1000,7 @@ export default class Module {
flags: number,
path_ptr: number,
path_len: number,
- buf_out: number
+ buf_out: number,
): number => {
const entry = this.fds[fd];
if (!entry) {
@@ -1018,10 +1018,9 @@ export default class Module {
const view = new DataView(this.memory.buffer);
try {
- const info =
- (flags & LOOKUPFLAGS_SYMLINK_FOLLOW) != 0
- ? Deno.statSync(path)
- : Deno.lstatSync(path);
+ const info = (flags & LOOKUPFLAGS_SYMLINK_FOLLOW) != 0
+ ? Deno.statSync(path)
+ : Deno.lstatSync(path);
view.setBigUint64(buf_out, BigInt(info.dev ? info.dev : 0), true);
buf_out += 8;
@@ -1060,21 +1059,21 @@ export default class Module {
view.setBigUint64(
buf_out,
BigInt(info.atime ? info.atime.getTime() * 1e6 : 0),
- true
+ true,
);
buf_out += 8;
view.setBigUint64(
buf_out,
BigInt(info.mtime ? info.mtime.getTime() * 1e6 : 0),
- true
+ true,
);
buf_out += 8;
view.setBigUint64(
buf_out,
BigInt(info.birthtime ? info.birthtime.getTime() * 1e6 : 0),
- true
+ true,
);
buf_out += 8;
} catch (err) {
@@ -1091,7 +1090,7 @@ export default class Module {
path_len: number,
atim: bigint,
mtim: bigint,
- fst_flags: number
+ fst_flags: number,
): number => {
const entry = this.fds[fd];
if (!entry) {
@@ -1130,7 +1129,7 @@ export default class Module {
old_path_len: number,
new_fd: number,
new_path_ptr: number,
- new_path_len: number
+ new_path_len: number,
): number => {
const old_entry = this.fds[old_fd];
const new_entry = this.fds[new_fd];
@@ -1146,13 +1145,13 @@ export default class Module {
const old_data = new Uint8Array(
this.memory.buffer,
old_path_ptr,
- old_path_len
+ old_path_len,
);
const old_path = resolve(old_entry.path, text.decode(old_data));
const new_data = new Uint8Array(
this.memory.buffer,
new_path_ptr,
- new_path_len
+ new_path_len,
);
const new_path = resolve(new_entry.path, text.decode(new_data));
@@ -1174,7 +1173,7 @@ export default class Module {
fs_rights_base: number | bigint,
fs_rights_inherting: number | bigint,
fdflags: number,
- opened_fd_out: number
+ opened_fd_out: number,
): number => {
const entry = this.fds[fd];
if (!entry) {
@@ -1196,11 +1195,10 @@ export default class Module {
// around it for now.
try {
const entries = Array.from(Deno.readDirSync(path));
- const opened_fd =
- this.fds.push({
- entries,
- path,
- }) - 1;
+ const opened_fd = this.fds.push({
+ entries,
+ path,
+ }) - 1;
const view = new DataView(this.memory.buffer);
view.setUint32(opened_fd_out, opened_fd, true);
@@ -1237,7 +1235,7 @@ export default class Module {
if (
(BigInt(fs_rights_base) &
BigInt(RIGHTS_FD_READ | RIGHTS_FD_READDIR)) !=
- 0n
+ 0n
) {
options.read = true;
}
@@ -1248,9 +1246,9 @@ export default class Module {
RIGHTS_FD_DATASYNC |
RIGHTS_FD_WRITE |
RIGHTS_FD_ALLOCATE |
- RIGHTS_FD_FILESTAT_SET_SIZE
+ RIGHTS_FD_FILESTAT_SET_SIZE,
)) !=
- 0n
+ 0n
) {
options.write = true;
}
@@ -1281,11 +1279,10 @@ export default class Module {
try {
const handle = Deno.openSync(path, options);
- const opened_fd =
- this.fds.push({
- handle,
- path,
- }) - 1;
+ const opened_fd = this.fds.push({
+ handle,
+ path,
+ }) - 1;
const view = new DataView(this.memory.buffer);
view.setUint32(opened_fd_out, opened_fd, true);
@@ -1302,7 +1299,7 @@ export default class Module {
path_len: number,
buf_ptr: number,
buf_len: number,
- bufused_out: number
+ bufused_out: number,
): number => {
const entry = this.fds[fd];
if (!entry) {
@@ -1336,7 +1333,7 @@ export default class Module {
path_remove_directory: (
fd: number,
path_ptr: number,
- path_len: number
+ path_len: number,
): number => {
const entry = this.fds[fd];
if (!entry) {
@@ -1370,7 +1367,7 @@ export default class Module {
old_path_len: number,
new_fd: number,
new_path_ptr: number,
- new_path_len: number
+ new_path_len: number,
): number => {
const old_entry = this.fds[fd];
const new_entry = this.fds[new_fd];
@@ -1386,13 +1383,13 @@ export default class Module {
const old_data = new Uint8Array(
this.memory.buffer,
old_path_ptr,
- old_path_len
+ old_path_len,
);
const old_path = resolve(old_entry.path, text.decode(old_data));
const new_data = new Uint8Array(
this.memory.buffer,
new_path_ptr,
- new_path_len
+ new_path_len,
);
const new_path = resolve(new_entry.path, text.decode(new_data));
@@ -1410,7 +1407,7 @@ export default class Module {
old_path_len: number,
fd: number,
new_path_ptr: number,
- new_path_len: number
+ new_path_len: number,
): number => {
const entry = this.fds[fd];
if (!entry) {
@@ -1425,13 +1422,13 @@ export default class Module {
const old_data = new Uint8Array(
this.memory.buffer,
old_path_ptr,
- old_path_len
+ old_path_len,
);
const old_path = text.decode(old_data);
const new_data = new Uint8Array(
this.memory.buffer,
new_path_ptr,
- new_path_len
+ new_path_len,
);
const new_path = resolve(entry.path, text.decode(new_data));
@@ -1447,7 +1444,7 @@ export default class Module {
path_unlink_file: (
fd: number,
path_ptr: number,
- path_len: number
+ path_len: number,
): number => {
const entry = this.fds[fd];
if (!entry) {
@@ -1475,7 +1472,7 @@ export default class Module {
in_ptr: number,
out_ptr: number,
nsubscriptions: number,
- nevents_out: number
+ nevents_out: number,
): number => {
return ERRNO_NOSYS;
},
@@ -1505,7 +1502,7 @@ export default class Module {
ri_data_len: number,
ri_flags: number,
ro_datalen_out: number,
- ro_flags_out: number
+ ro_flags_out: number,
): number => {
return ERRNO_NOSYS;
},
@@ -1515,7 +1512,7 @@ export default class Module {
si_data_ptr: number,
si_data_len: number,
si_flags: number,
- so_datalen_out: number
+ so_datalen_out: number,
): number => {
return ERRNO_NOSYS;
},
diff --git a/std/wasi/snapshot_preview1_test.ts b/std/wasi/snapshot_preview1_test.ts
index 262aa7f95..748ba7772 100644
--- a/std/wasi/snapshot_preview1_test.ts
+++ b/std/wasi/snapshot_preview1_test.ts
@@ -57,7 +57,7 @@ if (import.meta.main) {
const basename = entry.name.replace(/.rs$/, ".json");
await Deno.writeTextFile(
path.join(outdir, basename),
- prelude[0].slice(2)
+ prelude[0].slice(2),
);
}
}
diff --git a/std/ws/mod.ts b/std/ws/mod.ts
index e2151a53e..5f0219cfc 100644
--- a/std/ws/mod.ts
+++ b/std/ws/mod.ts
@@ -32,7 +32,7 @@ export interface WebSocketCloseEvent {
}
export function isWebSocketCloseEvent(
- a: WebSocketEvent
+ a: WebSocketEvent,
): a is WebSocketCloseEvent {
return hasOwnProperty(a, "code");
}
@@ -40,7 +40,7 @@ export function isWebSocketCloseEvent(
export type WebSocketPingEvent = ["ping", Uint8Array];
export function isWebSocketPingEvent(
- a: WebSocketEvent
+ a: WebSocketEvent,
): a is WebSocketPingEvent {
return Array.isArray(a) && a[0] === "ping" && a[1] instanceof Uint8Array;
}
@@ -48,7 +48,7 @@ export function isWebSocketPingEvent(
export type WebSocketPongEvent = ["pong", Uint8Array];
export function isWebSocketPongEvent(
- a: WebSocketEvent
+ a: WebSocketEvent,
): a is WebSocketPongEvent {
return Array.isArray(a) && a[0] === "pong" && a[1] instanceof Uint8Array;
}
@@ -105,14 +105,14 @@ export function unmask(payload: Uint8Array, mask?: Uint8Array): void {
/** Write websocket frame to given writer */
export async function writeFrame(
frame: WebSocketFrame,
- writer: Deno.Writer
+ writer: Deno.Writer,
): Promise<void> {
const payloadLength = frame.payload.byteLength;
let header: Uint8Array;
const hasMask = frame.mask ? 0x80 : 0;
if (frame.mask && frame.mask.byteLength !== 4) {
throw new Error(
- "invalid mask. mask must be 4 bytes: length=" + frame.mask.byteLength
+ "invalid mask. mask must be 4 bytes: length=" + frame.mask.byteLength,
);
}
if (payloadLength < 126) {
@@ -263,7 +263,7 @@ class WebSocketImpl implements WebSocket {
// [0x12, 0x34] -> 0x1234
const code = (frame.payload[0] << 8) | frame.payload[1];
const reason = decode(
- frame.payload.subarray(2, frame.payload.length)
+ frame.payload.subarray(2, frame.payload.length),
);
await this.close(code, reason);
yield { code, reason };
@@ -312,8 +312,9 @@ class WebSocketImpl implements WebSocket {
}
send(data: WebSocketMessage): Promise<void> {
- const opcode =
- typeof data === "string" ? OpCode.TextFrame : OpCode.BinaryFrame;
+ const opcode = typeof data === "string"
+ ? OpCode.TextFrame
+ : OpCode.BinaryFrame;
const payload = typeof data === "string" ? encode(data) : data;
const isLastFrame = true;
const frame = {
@@ -382,7 +383,7 @@ class WebSocketImpl implements WebSocket {
this.sendQueue = [];
rest.forEach((e) =>
e.d.reject(
- new Deno.errors.ConnectionReset("Socket has already been closed")
+ new Deno.errors.ConnectionReset("Socket has already been closed"),
)
);
}
@@ -457,7 +458,7 @@ export async function handshake(
url: URL,
headers: Headers,
bufReader: BufReader,
- bufWriter: BufWriter
+ bufWriter: BufWriter,
): Promise<void> {
const { hostname, pathname, search } = url;
const key = createSecKey();
@@ -494,7 +495,7 @@ export async function handshake(
if (version !== "HTTP/1.1" || statusCode !== "101") {
throw new Error(
`ws: server didn't accept handshake: ` +
- `version=${version}, statusCode=${statusCode}`
+ `version=${version}, statusCode=${statusCode}`,
);
}
@@ -508,7 +509,7 @@ export async function handshake(
if (secAccept !== expectedSecAccept) {
throw new Error(
`ws: unexpected sec-websocket-accept header: ` +
- `expected=${expectedSecAccept}, actual=${secAccept}`
+ `expected=${expectedSecAccept}, actual=${secAccept}`,
);
}
}
@@ -519,7 +520,7 @@ export async function handshake(
*/
export async function connectWebSocket(
endpoint: string,
- headers: Headers = new Headers()
+ headers: Headers = new Headers(),
): Promise<WebSocket> {
const url = new URL(endpoint);
const { hostname } = url;
diff --git a/std/ws/test.ts b/std/ws/test.ts
index ad6b6256c..87cf549ec 100644
--- a/std/ws/test.ts
+++ b/std/ws/test.ts
@@ -21,13 +21,13 @@ import { delay } from "../async/delay.ts";
Deno.test("[ws] read unmasked text frame", async () => {
// unmasked single text frame with payload "Hello"
const buf = new BufReader(
- new Deno.Buffer(new Uint8Array([0x81, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f]))
+ new Deno.Buffer(new Uint8Array([0x81, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f])),
);
const frame = await readFrame(buf);
assertEquals(frame.opcode, OpCode.TextFrame);
assertEquals(frame.mask, undefined);
const actual = new TextDecoder().decode(
- new Deno.Buffer(frame.payload).bytes()
+ new Deno.Buffer(frame.payload).bytes(),
);
assertEquals(actual, "Hello");
assertEquals(frame.isLastFrame, true);
@@ -49,14 +49,14 @@ Deno.test("[ws] read masked text frame", async () => {
0x4d,
0x51,
0x58,
- ])
- )
+ ]),
+ ),
);
const frame = await readFrame(buf);
assertEquals(frame.opcode, OpCode.TextFrame);
unmask(frame.payload, frame.mask);
const actual = new TextDecoder().decode(
- new Deno.Buffer(frame.payload).bytes()
+ new Deno.Buffer(frame.payload).bytes(),
);
assertEquals(actual, "Hello");
assertEquals(frame.isLastFrame, true);
@@ -64,10 +64,10 @@ Deno.test("[ws] read masked text frame", async () => {
Deno.test("[ws] read unmasked split text frames", async () => {
const buf1 = new BufReader(
- new Deno.Buffer(new Uint8Array([0x01, 0x03, 0x48, 0x65, 0x6c]))
+ new Deno.Buffer(new Uint8Array([0x01, 0x03, 0x48, 0x65, 0x6c])),
);
const buf2 = new BufReader(
- new Deno.Buffer(new Uint8Array([0x80, 0x02, 0x6c, 0x6f]))
+ new Deno.Buffer(new Uint8Array([0x80, 0x02, 0x6c, 0x6f])),
);
const [f1, f2] = await Promise.all([readFrame(buf1), readFrame(buf2)]);
assertEquals(f1.isLastFrame, false);
@@ -86,15 +86,15 @@ Deno.test("[ws] read unmasked split text frames", async () => {
Deno.test("[ws] read unmasked ping / pong frame", async () => {
// unmasked ping with payload "Hello"
const buf = new BufReader(
- new Deno.Buffer(new Uint8Array([0x89, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f]))
+ new Deno.Buffer(new Uint8Array([0x89, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f])),
);
const ping = await readFrame(buf);
assertEquals(ping.opcode, OpCode.Ping);
const actual1 = new TextDecoder().decode(
- new Deno.Buffer(ping.payload).bytes()
+ new Deno.Buffer(ping.payload).bytes(),
);
assertEquals(actual1, "Hello");
- // prettier-ignore
+ // deno-fmt-ignore
const pongFrame= [0x8a, 0x85, 0x37, 0xfa, 0x21, 0x3d, 0x7f, 0x9f, 0x4d, 0x51, 0x58]
const buf2 = new BufReader(new Deno.Buffer(new Uint8Array(pongFrame)));
const pong = await readFrame(buf2);
@@ -102,7 +102,7 @@ Deno.test("[ws] read unmasked ping / pong frame", async () => {
assert(pong.mask !== undefined);
unmask(pong.payload, pong.mask);
const actual2 = new TextDecoder().decode(
- new Deno.Buffer(pong.payload).bytes()
+ new Deno.Buffer(pong.payload).bytes(),
);
assertEquals(actual2, "Hello");
});
@@ -163,7 +163,7 @@ Deno.test("[ws] acceptable", () => {
["sec-websocket-version", "13"],
["upgrade", "WebSocket"],
]),
- })
+ }),
);
});
@@ -172,25 +172,25 @@ Deno.test("[ws] acceptable should return false when headers invalid", () => {
acceptable({
headers: new Headers({ "sec-websocket-key": "aaa" }),
}),
- false
+ false,
);
assertEquals(
acceptable({
headers: new Headers({ upgrade: "websocket" }),
}),
- false
+ false,
);
assertEquals(
acceptable({
headers: new Headers({ upgrade: "invalid", "sec-websocket-key": "aaa" }),
}),
- false
+ false,
);
assertEquals(
acceptable({
headers: new Headers({ upgrade: "websocket", "sec-websocket-ky": "" }),
}),
- false
+ false,
);
});
@@ -200,9 +200,9 @@ Deno.test(
await assertThrowsAsync(
async (): Promise<void> => {
await connectWebSocket("file://hoge/hoge");
- }
+ },
);
- }
+ },
);
Deno.test("[ws] write and read masked frame", async () => {
@@ -217,7 +217,7 @@ Deno.test("[ws] write and read masked frame", async () => {
opcode: OpCode.TextFrame,
payload: encode(msg),
},
- buf
+ buf,
);
const frame = await readFrame(r);
assertEquals(frame.opcode, OpCode.TextFrame);
@@ -237,9 +237,9 @@ Deno.test("[ws] handshake should not send search when it's empty", async () => {
new URL("ws://example.com"),
new Headers(),
new BufReader(reader),
- new BufWriter(writer)
+ new BufWriter(writer),
);
- }
+ },
);
const tpReader = new TextProtoReader(new BufReader(writer));
@@ -260,16 +260,16 @@ Deno.test(
new URL("ws://example.com?a=1"),
new Headers(),
new BufReader(reader),
- new BufWriter(writer)
+ new BufWriter(writer),
);
- }
+ },
);
const tpReader = new TextProtoReader(new BufReader(writer));
const statusLine = await tpReader.readLine();
assertEquals(statusLine, "GET /?a=1 HTTP/1.1");
- }
+ },
);
Deno.test("[ws] ws.close() should use 1000 as close code", async () => {
@@ -356,11 +356,11 @@ Deno.test(
sock.closeForce();
await assertThrowsAsync(
() => sock.send("hello"),
- Deno.errors.ConnectionReset
+ Deno.errors.ConnectionReset,
);
await assertThrowsAsync(() => sock.ping(), Deno.errors.ConnectionReset);
await assertThrowsAsync(() => sock.close(0), Deno.errors.ConnectionReset);
- }
+ },
);
Deno.test(
@@ -378,7 +378,7 @@ Deno.test(
const { value, done } = await it.next();
assertEquals(value, undefined);
assertEquals(done, true);
- }
+ },
);
Deno.test({