summaryrefslogtreecommitdiff
path: root/std/node
diff options
context:
space:
mode:
Diffstat (limited to 'std/node')
-rw-r--r--std/node/_fs/_fs_appendFile.ts2
-rw-r--r--std/node/_fs/_fs_appendFile_test.ts30
-rw-r--r--std/node/_fs/_fs_chmod.ts2
-rw-r--r--std/node/_fs/_fs_chmod_test.ts6
-rw-r--r--std/node/_fs/_fs_chown.ts2
-rw-r--r--std/node/_fs/_fs_chown_test.ts6
-rw-r--r--std/node/_fs/_fs_close.ts2
-rw-r--r--std/node/_fs/_fs_close_test.ts6
-rw-r--r--std/node/_fs/_fs_dir.ts4
-rw-r--r--std/node/_fs/_fs_dir_test.ts16
-rw-r--r--std/node/_fs/_fs_dirent_test.ts14
-rw-r--r--std/node/_fs/_fs_readFile.ts2
-rw-r--r--std/node/_fs/_fs_readlink.ts2
-rw-r--r--std/node/_fs/_fs_readlink_test.ts8
-rw-r--r--std/node/_utils.ts8
-rw-r--r--std/node/events.ts8
-rw-r--r--std/node/events_test.ts78
-rwxr-xr-xstd/node/fs.ts2
-rw-r--r--std/node/module.ts46
-rw-r--r--std/node/os.ts2
-rw-r--r--std/node/os_test.ts32
-rw-r--r--std/node/process.ts4
-rw-r--r--std/node/process_test.ts18
-rw-r--r--std/node/querystring.ts2
-rw-r--r--std/node/querystring_test.ts8
-rw-r--r--std/node/tests/cjs/cjs_builtin.js2
-rw-r--r--std/node/tests/node_modules/left-pad/index.js34
-rw-r--r--std/node/util_test.ts26
28 files changed, 193 insertions, 179 deletions
diff --git a/std/node/_fs/_fs_appendFile.ts b/std/node/_fs/_fs_appendFile.ts
index 49a4fc29f..f3b44dd7b 100644
--- a/std/node/_fs/_fs_appendFile.ts
+++ b/std/node/_fs/_fs_appendFile.ts
@@ -55,7 +55,7 @@ export function appendFile(
closeRidIfNecessary(typeof pathOrRid === "string", rid);
callbackFn();
})
- .catch(err => {
+ .catch((err) => {
closeRidIfNecessary(typeof pathOrRid === "string", rid);
callbackFn(err);
});
diff --git a/std/node/_fs/_fs_appendFile_test.ts b/std/node/_fs/_fs_appendFile_test.ts
index 47d552740..ca48dc5d3 100644
--- a/std/node/_fs/_fs_appendFile_test.ts
+++ b/std/node/_fs/_fs_appendFile_test.ts
@@ -15,7 +15,7 @@ test({
Error,
"No callback function supplied"
);
- }
+ },
});
test({
@@ -48,12 +48,12 @@ test({
assertThrows(
() =>
appendFileSync("some/path", "some data", {
- encoding: "made-up-encoding"
+ encoding: "made-up-encoding",
}),
Error,
"Only 'utf8' encoding is currently supported"
);
- }
+ },
});
test({
@@ -63,10 +63,10 @@ test({
const file: Deno.File = await Deno.open(tempFile, {
create: true,
write: true,
- read: true
+ read: true,
});
await new Promise((resolve, reject) => {
- appendFile(file.rid, "hello world", err => {
+ appendFile(file.rid, "hello world", (err) => {
if (err) reject();
else resolve();
});
@@ -82,7 +82,7 @@ test({
Deno.close(file.rid);
await Deno.remove(tempFile);
});
- }
+ },
});
test({
@@ -90,7 +90,7 @@ test({
async fn() {
const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources();
await new Promise((resolve, reject) => {
- appendFile("_fs_appendFile_test_file.txt", "hello world", err => {
+ appendFile("_fs_appendFile_test_file.txt", "hello world", (err) => {
if (err) reject(err);
else resolve();
});
@@ -100,13 +100,13 @@ test({
const data = await Deno.readFile("_fs_appendFile_test_file.txt");
assertEquals(decoder.decode(data), "hello world");
})
- .catch(err => {
+ .catch((err) => {
fail("No error was expected: " + err);
})
.finally(async () => {
await Deno.remove("_fs_appendFile_test_file.txt");
});
- }
+ },
});
test({
@@ -116,7 +116,7 @@ test({
const openResourcesBeforeAppend: Deno.ResourceMap = Deno.resources();
const tempFile: string = await Deno.makeTempFile();
await new Promise((resolve, reject) => {
- appendFile(tempFile, "hello world", { flag: "ax" }, err => {
+ appendFile(tempFile, "hello world", { flag: "ax" }, (err) => {
if (err) reject(err);
else resolve();
});
@@ -130,7 +130,7 @@ test({
.finally(async () => {
await Deno.remove(tempFile);
});
- }
+ },
});
test({
@@ -140,14 +140,14 @@ test({
const file: Deno.File = Deno.openSync(tempFile, {
create: true,
write: true,
- read: true
+ read: true,
});
appendFileSync(file.rid, "hello world");
Deno.close(file.rid);
const data = Deno.readFileSync(tempFile);
assertEquals(decoder.decode(data), "hello world");
Deno.removeSync(tempFile);
- }
+ },
});
test({
@@ -159,7 +159,7 @@ test({
const data = Deno.readFileSync("_fs_appendFile_test_file_sync.txt");
assertEquals(decoder.decode(data), "hello world");
Deno.removeSync("_fs_appendFile_test_file_sync.txt");
- }
+ },
});
test({
@@ -175,5 +175,5 @@ test({
);
assertEquals(Deno.resources(), openResourcesBeforeAppend);
Deno.removeSync(tempFile);
- }
+ },
});
diff --git a/std/node/_fs/_fs_chmod.ts b/std/node/_fs/_fs_chmod.ts
index cecb878ec..0eb01a8a6 100644
--- a/std/node/_fs/_fs_chmod.ts
+++ b/std/node/_fs/_fs_chmod.ts
@@ -24,7 +24,7 @@ export function chmod(
.then(() => {
callback();
})
- .catch(err => {
+ .catch((err) => {
callback(err);
});
}
diff --git a/std/node/_fs/_fs_chmod_test.ts b/std/node/_fs/_fs_chmod_test.ts
index 8d420b3be..a3d814b51 100644
--- a/std/node/_fs/_fs_chmod_test.ts
+++ b/std/node/_fs/_fs_chmod_test.ts
@@ -10,7 +10,7 @@ test({
const tempFile: string = await Deno.makeTempFile();
const originalFileMode: number | null = (await Deno.lstat(tempFile)).mode;
await new Promise((resolve, reject) => {
- chmod(tempFile, 0o777, err => {
+ chmod(tempFile, 0o777, (err) => {
if (err) reject(err);
else resolve();
});
@@ -26,7 +26,7 @@ test({
.finally(() => {
Deno.removeSync(tempFile);
});
- }
+ },
});
test({
@@ -41,5 +41,5 @@ test({
assert(newFileMode && originalFileMode);
assert(newFileMode === 33279 && newFileMode > originalFileMode);
Deno.removeSync(tempFile);
- }
+ },
});
diff --git a/std/node/_fs/_fs_chown.ts b/std/node/_fs/_fs_chown.ts
index 008b30c47..94b7401d0 100644
--- a/std/node/_fs/_fs_chown.ts
+++ b/std/node/_fs/_fs_chown.ts
@@ -23,7 +23,7 @@ export function chown(
.then(() => {
callback();
})
- .catch(err => {
+ .catch((err) => {
callback(err);
});
}
diff --git a/std/node/_fs/_fs_chown_test.ts b/std/node/_fs/_fs_chown_test.ts
index bdf2ae09a..fd31a8c62 100644
--- a/std/node/_fs/_fs_chown_test.ts
+++ b/std/node/_fs/_fs_chown_test.ts
@@ -14,7 +14,7 @@ test({
const originalUserId: number | null = (await Deno.lstat(tempFile)).uid;
const originalGroupId: number | null = (await Deno.lstat(tempFile)).gid;
await new Promise((resolve, reject) => {
- chown(tempFile, originalUserId!, originalGroupId!, err => {
+ chown(tempFile, originalUserId!, originalGroupId!, (err) => {
if (err) reject(err);
else resolve();
});
@@ -31,7 +31,7 @@ test({
.finally(() => {
Deno.removeSync(tempFile);
});
- }
+ },
});
test({
@@ -48,5 +48,5 @@ test({
assertEquals(newUserId, originalUserId);
assertEquals(newGroupId, originalGroupId);
Deno.removeSync(tempFile);
- }
+ },
});
diff --git a/std/node/_fs/_fs_close.ts b/std/node/_fs/_fs_close.ts
index 4ec10eefb..469bdc77b 100644
--- a/std/node/_fs/_fs_close.ts
+++ b/std/node/_fs/_fs_close.ts
@@ -14,7 +14,7 @@ export function close(fd: number, callback: CallbackWithError): void {
.then(() => {
callback();
})
- .catch(err => {
+ .catch((err) => {
callback(err);
});
}
diff --git a/std/node/_fs/_fs_close_test.ts b/std/node/_fs/_fs_close_test.ts
index 7c6dd684c..8bcd662c9 100644
--- a/std/node/_fs/_fs_close_test.ts
+++ b/std/node/_fs/_fs_close_test.ts
@@ -11,7 +11,7 @@ test({
assert(Deno.resources()[file.rid]);
await new Promise((resolve, reject) => {
- close(file.rid, err => {
+ close(file.rid, (err) => {
if (err) reject();
else resolve();
});
@@ -25,7 +25,7 @@ test({
.finally(async () => {
await Deno.remove(tempFile);
});
- }
+ },
});
test({
@@ -38,5 +38,5 @@ test({
closeSync(file.rid);
assert(!Deno.resources()[file.rid]);
Deno.removeSync(tempFile);
- }
+ },
});
diff --git a/std/node/_fs/_fs_dir.ts b/std/node/_fs/_fs_dir.ts
index e3830bb31..c5bb368c9 100644
--- a/std/node/_fs/_fs_dir.ts
+++ b/std/node/_fs/_fs_dir.ts
@@ -30,7 +30,7 @@ export default class Dir {
try {
if (this.initializationOfDirectoryFilesIsRequired()) {
const denoFiles: Deno.FileInfo[] = await Deno.readdir(this.path);
- this.files = denoFiles.map(file => new Dirent(file));
+ this.files = denoFiles.map((file) => new Dirent(file));
}
const nextFile = this.files.pop();
if (nextFile) {
@@ -55,7 +55,7 @@ export default class Dir {
readSync(): Dirent | null {
if (this.initializationOfDirectoryFilesIsRequired()) {
this.files.push(
- ...Deno.readdirSync(this.path).map(file => new Dirent(file))
+ ...Deno.readdirSync(this.path).map((file) => new Dirent(file))
);
}
const dirent: Dirent | undefined = this.files.pop();
diff --git a/std/node/_fs/_fs_dir_test.ts b/std/node/_fs/_fs_dir_test.ts
index be276887b..6ee044391 100644
--- a/std/node/_fs/_fs_dir_test.ts
+++ b/std/node/_fs/_fs_dir_test.ts
@@ -13,21 +13,21 @@ test({
calledBack = true;
});
assert(calledBack);
- }
+ },
});
test({
name: "Closing current directory without callback returns void Promise",
async fn() {
await new Dir(".").close();
- }
+ },
});
test({
name: "Closing current directory synchronously works",
fn() {
new Dir(".").closeSync();
- }
+ },
});
test({
@@ -37,7 +37,7 @@ test({
const enc: Uint8Array = new TextEncoder().encode("std/node");
assertEquals(new Dir(enc).path, "std/node");
- }
+ },
});
test({
@@ -64,7 +64,7 @@ test({
} finally {
Deno.removeSync(testDir);
}
- }
+ },
});
test({
@@ -103,7 +103,7 @@ test({
} finally {
Deno.removeSync(testDir, { recursive: true });
}
- }
+ },
});
test({
@@ -132,7 +132,7 @@ test({
} finally {
Deno.removeSync(testDir, { recursive: true });
}
- }
+ },
});
test({
@@ -158,5 +158,5 @@ test({
} finally {
Deno.removeSync(testDir, { recursive: true });
}
- }
+ },
});
diff --git a/std/node/_fs/_fs_dirent_test.ts b/std/node/_fs/_fs_dirent_test.ts
index 36091d3e1..1b1d38d38 100644
--- a/std/node/_fs/_fs_dirent_test.ts
+++ b/std/node/_fs/_fs_dirent_test.ts
@@ -40,7 +40,7 @@ test({
fileInfo.blocks = 5;
assert(new Dirent(fileInfo).isBlockDevice());
assert(!new Dirent(fileInfo).isCharacterDevice());
- }
+ },
});
test({
@@ -50,7 +50,7 @@ test({
fileInfo.blocks = null;
assert(new Dirent(fileInfo).isCharacterDevice());
assert(!new Dirent(fileInfo).isBlockDevice());
- }
+ },
});
test({
@@ -63,7 +63,7 @@ test({
assert(new Dirent(fileInfo).isDirectory());
assert(!new Dirent(fileInfo).isFile());
assert(!new Dirent(fileInfo).isSymbolicLink());
- }
+ },
});
test({
@@ -76,7 +76,7 @@ test({
assert(!new Dirent(fileInfo).isDirectory());
assert(new Dirent(fileInfo).isFile());
assert(!new Dirent(fileInfo).isSymbolicLink());
- }
+ },
});
test({
@@ -89,7 +89,7 @@ test({
assert(!new Dirent(fileInfo).isDirectory());
assert(!new Dirent(fileInfo).isFile());
assert(new Dirent(fileInfo).isSymbolicLink());
- }
+ },
});
test({
@@ -98,7 +98,7 @@ test({
const fileInfo: FileInfoMock = new FileInfoMock();
fileInfo.name = "my_file";
assertEquals(new Dirent(fileInfo).name, "my_file");
- }
+ },
});
test({
@@ -119,5 +119,5 @@ test({
Error,
"does not yet support"
);
- }
+ },
});
diff --git a/std/node/_fs/_fs_readFile.ts b/std/node/_fs/_fs_readFile.ts
index 05bad6f3d..13e82bfe1 100644
--- a/std/node/_fs/_fs_readFile.ts
+++ b/std/node/_fs/_fs_readFile.ts
@@ -3,7 +3,7 @@
import {
notImplemented,
intoCallbackAPIWithIntercept,
- MaybeEmpty
+ MaybeEmpty,
} from "../_utils.ts";
const { readFile: denoReadFile, readFileSync: denoReadFileSync } = Deno;
diff --git a/std/node/_fs/_fs_readlink.ts b/std/node/_fs/_fs_readlink.ts
index d1cb69f51..1fd7e3c14 100644
--- a/std/node/_fs/_fs_readlink.ts
+++ b/std/node/_fs/_fs_readlink.ts
@@ -2,7 +2,7 @@
import {
intoCallbackAPIWithIntercept,
MaybeEmpty,
- notImplemented
+ notImplemented,
} from "../_utils.ts";
const { readlink: denoReadlink, readlinkSync: denoReadlinkSync } = Deno;
diff --git a/std/node/_fs/_fs_readlink_test.ts b/std/node/_fs/_fs_readlink_test.ts
index 653d1a598..151d3f782 100644
--- a/std/node/_fs/_fs_readlink_test.ts
+++ b/std/node/_fs/_fs_readlink_test.ts
@@ -25,7 +25,7 @@ test({
assertEquals(typeof data, "string");
assertEquals(data as string, oldname);
- }
+ },
});
test({
@@ -43,7 +43,7 @@ test({
assert(data instanceof Uint8Array);
assertEquals(new TextDecoder().decode(data as Uint8Array), oldname);
- }
+ },
});
test({
@@ -53,7 +53,7 @@ test({
const data = readlinkSync(newname);
assertEquals(typeof data, "string");
assertEquals(data as string, oldname);
- }
+ },
});
test({
@@ -63,5 +63,5 @@ test({
const data = readlinkSync(newname, { encoding: "buffer" });
assert(data instanceof Uint8Array);
assertEquals(new TextDecoder().decode(data as Uint8Array), oldname);
- }
+ },
});
diff --git a/std/node/_utils.ts b/std/node/_utils.ts
index f0808e82b..ec89d11a8 100644
--- a/std/node/_utils.ts
+++ b/std/node/_utils.ts
@@ -17,8 +17,8 @@ export function intoCallbackAPI<T>(
...args: any[]
): void {
func(...args)
- .then(value => cb && cb(null, value))
- .catch(err => cb && cb(err, null));
+ .then((value) => cb && cb(null, value))
+ .catch((err) => cb && cb(err, null));
}
export function intoCallbackAPIWithIntercept<T1, T2>(
@@ -30,6 +30,6 @@ export function intoCallbackAPIWithIntercept<T1, T2>(
...args: any[]
): void {
func(...args)
- .then(value => cb && cb(null, interceptor(value)))
- .catch(err => cb && cb(err, null));
+ .then((value) => cb && cb(null, interceptor(value)))
+ .catch((err) => cb && cb(err, null));
}
diff --git a/std/node/events.ts b/std/node/events.ts
index b2f1d6026..aa62e4d43 100644
--- a/std/node/events.ts
+++ b/std/node/events.ts
@@ -219,7 +219,7 @@ export default class EventEmitter {
eventName: string | symbol,
listener: Function
): WrappedFunction {
- const wrapper = function(
+ const wrapper = function (
this: {
eventName: string | symbol;
listener: Function;
@@ -235,7 +235,7 @@ export default class EventEmitter {
eventName: eventName,
listener: listener,
rawListener: (wrapper as unknown) as WrappedFunction,
- context: this
+ context: this,
};
const wrapped = (wrapper.bind(
wrapperContext
@@ -462,7 +462,7 @@ export function on(
}
// Wait until an event happens
- return new Promise(function(resolve, reject) {
+ return new Promise(function (resolve, reject) {
unconsumedPromises.push({ resolve, reject });
});
},
@@ -489,7 +489,7 @@ export function on(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[Symbol.asyncIterator](): any {
return this;
- }
+ },
};
emitter.on(event, eventHandler);
diff --git a/std/node/events_test.ts b/std/node/events_test.ts
index b0b74e499..5960290af 100644
--- a/std/node/events_test.ts
+++ b/std/node/events_test.ts
@@ -3,7 +3,7 @@ import {
assert,
assertEquals,
fail,
- assertThrows
+ assertThrows,
} from "../testing/asserts.ts";
import EventEmitter, { WrappedFunction, once, on } from "./events.ts";
@@ -29,7 +29,7 @@ test({
eventsFired = [];
testEmitter.emit("event");
assertEquals(eventsFired, ["event"]);
- }
+ },
});
test({
@@ -41,7 +41,7 @@ test({
testEmitter.on("removeListener", () => {
eventsFired.push("removeListener");
});
- const eventFunction = function(): void {
+ const eventFunction = function (): void {
eventsFired.push("event");
};
testEmitter.on("event", eventFunction);
@@ -49,7 +49,7 @@ test({
assertEquals(eventsFired, []);
testEmitter.removeListener("event", eventFunction);
assertEquals(eventsFired, ["removeListener"]);
- }
+ },
});
test({
@@ -62,7 +62,7 @@ test({
EventEmitter.defaultMaxListeners = 20;
assertEquals(EventEmitter.defaultMaxListeners, 20);
EventEmitter.defaultMaxListeners = 10; //reset back to original value
- }
+ },
});
test({
@@ -73,7 +73,7 @@ test({
assertEquals(1, testEmitter.listenerCount("event"));
testEmitter.on("event", shouldNeverBeEmitted);
assertEquals(2, testEmitter.listenerCount("event"));
- }
+ },
});
test({
@@ -100,7 +100,7 @@ test({
);
testEmitter.emit("event", 1, 2, 3);
assertEquals(eventsFired, ["event(1)", "event(1, 2)", "event(1, 2, 3)"]);
- }
+ },
});
test({
@@ -112,7 +112,7 @@ test({
const sym = Symbol("symbol");
testEmitter.on(sym, shouldNeverBeEmitted);
assertEquals(testEmitter.eventNames(), ["event", sym]);
- }
+ },
});
test({
@@ -122,7 +122,7 @@ test({
assertEquals(testEmitter.getMaxListeners(), 10);
testEmitter.setMaxListeners(20);
assertEquals(testEmitter.getMaxListeners(), 20);
- }
+ },
});
test({
@@ -135,9 +135,9 @@ test({
testEmitter.on("event", testFunction);
assertEquals(testEmitter.listeners("event"), [
shouldNeverBeEmitted,
- testFunction
+ testFunction,
]);
- }
+ },
});
test({
@@ -148,7 +148,7 @@ test({
assertEquals(testEmitter.listenerCount("event"), 1);
testEmitter.off("event", shouldNeverBeEmitted);
assertEquals(testEmitter.listenerCount("event"), 0);
- }
+ },
});
test({
@@ -159,7 +159,7 @@ test({
.on("event", shouldNeverBeEmitted)
.on("event", shouldNeverBeEmitted);
assertEquals(testEmitter.listenerCount("event"), 2);
- }
+ },
});
test({
@@ -183,7 +183,7 @@ test({
testEmitter.emit("single event");
testEmitter.emit("single event");
assertEquals(eventsFired, ["single event"]);
- }
+ },
});
test({
@@ -203,7 +203,7 @@ test({
});
testEmitter.emit("event");
assertEquals(eventsFired, ["third", "first", "second"]);
- }
+ },
});
test({
@@ -223,7 +223,7 @@ test({
testEmitter.emit("event");
testEmitter.emit("event");
assertEquals(eventsFired, ["third", "first", "second", "first", "second"]);
- }
+ },
});
test({
@@ -242,7 +242,7 @@ test({
assertEquals(testEmitter.listenerCount("event"), 0);
assertEquals(testEmitter.listenerCount("other event"), 0);
- }
+ },
});
test({
@@ -265,7 +265,7 @@ test({
assertEquals(testEmitter.listenerCount("event"), 0);
assertEquals(testEmitter.listenerCount("other event"), 0);
- }
+ },
});
test({
@@ -284,7 +284,7 @@ test({
testEmitter.removeListener("non-existant event", madeUpEvent);
assertEquals(testEmitter.listenerCount("event"), 1);
- }
+ },
});
test({
@@ -307,7 +307,7 @@ test({
eventsProcessed = [];
testEmitter.emit("event");
assertEquals(eventsProcessed, ["A"]);
- }
+ },
});
test({
@@ -330,7 +330,7 @@ test({
(rawListenersForOnceEvent[0] as WrappedFunction).listener,
listenerB
);
- }
+ },
});
test({
@@ -353,7 +353,7 @@ test({
wrappedFn(); // executing the wrapped listener function will remove it from the event
assertEquals(eventsProcessed, ["A"]);
assertEquals(testEmitter.listeners("once-event").length, 0);
- }
+ },
});
test({
@@ -366,7 +366,7 @@ test({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const valueArr: any[] = await once(ee, "event");
assertEquals(valueArr, [42, "foo"]);
- }
+ },
});
test({
@@ -380,7 +380,7 @@ test({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const eventObj: any[] = await once(et, "event");
assert(!eventObj[0].isTrusted);
- }
+ },
});
test({
@@ -402,7 +402,7 @@ test({
Error,
"must be 'an integer'"
);
- }
+ },
});
test({
@@ -440,7 +440,7 @@ test({
});
ee.emit("error");
assertEquals(events, ["errorMonitor event", "error"]);
- }
+ },
});
test({
@@ -468,7 +468,7 @@ test({
}
assertEquals(ee.listenerCount("foo"), 0);
assertEquals(ee.listenerCount("error"), 0);
- }
+ },
});
test({
@@ -493,7 +493,7 @@ test({
assertEquals(err, _err);
}
assertEquals(thrown, true);
- }
+ },
});
test({
@@ -522,7 +522,7 @@ test({
assertEquals(thrown, true);
assertEquals(ee.listenerCount("foo"), 0);
assertEquals(ee.listenerCount("error"), 0);
- }
+ },
});
test({
@@ -548,7 +548,7 @@ test({
assertEquals(ee.listenerCount("foo"), 0);
assertEquals(ee.listenerCount("error"), 0);
- }
+ },
});
test({
@@ -557,7 +557,7 @@ test({
const ee = new EventEmitter();
const iterable = on(ee, "foo");
- setTimeout(function() {
+ setTimeout(function () {
ee.emit("foo", "bar");
ee.emit("foo", 42);
iterable.return();
@@ -566,29 +566,29 @@ test({
const results = await Promise.all([
iterable.next(),
iterable.next(),
- iterable.next()
+ iterable.next(),
]);
assertEquals(results, [
{
value: ["bar"],
- done: false
+ done: false,
},
{
value: [42],
- done: false
+ done: false,
},
{
value: undefined,
- done: true
- }
+ done: true,
+ },
]);
assertEquals(await iterable.next(), {
value: undefined,
- done: true
+ done: true,
});
- }
+ },
});
test({
@@ -620,5 +620,5 @@ test({
assertEquals(expected.length, 0);
assertEquals(ee.listenerCount("foo"), 0);
assertEquals(ee.listenerCount("error"), 0);
- }
+ },
});
diff --git a/std/node/fs.ts b/std/node/fs.ts
index 9135441bb..0681ee5a1 100755
--- a/std/node/fs.ts
+++ b/std/node/fs.ts
@@ -24,5 +24,5 @@ export {
readFile,
readFileSync,
readlink,
- readlinkSync
+ readlinkSync,
};
diff --git a/std/node/module.ts b/std/node/module.ts
index 21992f743..522eaec7e 100644
--- a/std/node/module.ts
+++ b/std/node/module.ts
@@ -108,7 +108,7 @@ class Module {
// Proxy related code removed.
static wrapper = [
"(function (exports, require, module, __filename, __dirname) { ",
- "\n});"
+ "\n});",
];
// Loads a module at the given file path. Returns that module's
@@ -235,7 +235,9 @@ class Module {
const lookupPaths = Module._resolveLookupPaths(request, fakeParent);
for (let j = 0; j < lookupPaths!.length; j++) {
- if (!paths.includes(lookupPaths![j])) paths.push(lookupPaths![j]);
+ if (!paths.includes(lookupPaths![j])) {
+ paths.push(lookupPaths![j]);
+ }
}
}
}
@@ -357,8 +359,9 @@ class Module {
const cachedModule = Module._cache[filename];
if (cachedModule !== undefined) {
updateChildren(parent, cachedModule, true);
- if (!cachedModule.loaded)
+ if (!cachedModule.loaded) {
return getExportsForCircularRequire(cachedModule);
+ }
return cachedModule.exports;
}
delete relativeResolveCache[relResolveCacheIdentifier];
@@ -370,8 +373,9 @@ class Module {
const cachedModule = Module._cache[filename];
if (cachedModule !== undefined) {
updateChildren(parent, cachedModule, true);
- if (!cachedModule.loaded)
+ if (!cachedModule.loaded) {
return getExportsForCircularRequire(cachedModule);
+ }
return cachedModule.exports;
}
@@ -436,8 +440,9 @@ class Module {
if (
from.charCodeAt(from.length - 1) === CHAR_BACKWARD_SLASH &&
from.charCodeAt(from.length - 2) === CHAR_COLON
- )
+ ) {
return [from + "node_modules"];
+ }
const paths = [];
for (let i = from.length - 1, p = 0, last = from.length; i >= 0; --i) {
@@ -663,7 +668,7 @@ function readPackage(requestPath: string): PackageInfo | null {
name: parsed.name,
main: parsed.main,
exports: parsed.exports,
- type: parsed.type
+ type: parsed.type,
};
packageJsonCache.set(jsonPath, filtered);
return filtered;
@@ -685,11 +690,12 @@ function readPackageScope(
checkPath = checkPath.slice(0, separatorIndex);
if (checkPath.endsWith(path.sep + "node_modules")) return false;
const pjson = readPackage(checkPath);
- if (pjson)
+ if (pjson) {
return {
path: checkPath,
- data: pjson
+ data: pjson,
};
+ }
}
return false;
}
@@ -822,11 +828,13 @@ function applyExports(basePath: string, expansion: string): string {
const mappingKey = `.${expansion}`;
let pkgExports = readPackageExports(basePath);
- if (pkgExports === undefined || pkgExports === null)
+ if (pkgExports === undefined || pkgExports === null) {
return path.resolve(basePath, mappingKey);
+ }
- if (isConditionalDotExportSugar(pkgExports, basePath))
+ if (isConditionalDotExportSugar(pkgExports, basePath)) {
pkgExports = { ".": pkgExports };
+ }
if (typeof pkgExports === "object") {
if (pkgExports.hasOwnProperty(mappingKey)) {
@@ -1005,11 +1013,12 @@ const CircularRequirePrototypeWarningProxy = new Proxy(
},
getOwnPropertyDescriptor(target, prop): PropertyDescriptor | undefined {
- if (target.hasOwnProperty(prop))
+ if (target.hasOwnProperty(prop)) {
return Object.getOwnPropertyDescriptor(target, prop);
+ }
emitCircularRequireWarning(prop);
return undefined;
- }
+ },
}
);
@@ -1230,16 +1239,21 @@ 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("\n")) {
+ resolved = resolved.replace(newlineRegEx, "%0A");
+ }
+ 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/os.ts b/std/node/os.ts
index 4bc70d1ff..7c61e910b 100644
--- a/std/node/os.ts
+++ b/std/node/os.ts
@@ -219,7 +219,7 @@ export const constants = {
signals: Deno.Signal,
priority: {
// see https://nodejs.org/docs/latest-v12.x/api/os.html#os_priority_constants
- }
+ },
};
export const EOL = Deno.build.os == "win" ? fsEOL.CRLF : fsEOL.LF;
diff --git a/std/node/os_test.ts b/std/node/os_test.ts
index a73a2d4e9..f0b9ca79d 100644
--- a/std/node/os_test.ts
+++ b/std/node/os_test.ts
@@ -6,42 +6,42 @@ test({
name: "build architecture is a string",
fn() {
assertEquals(typeof os.arch(), "string");
- }
+ },
});
test({
name: "home directory is a string",
fn() {
assertEquals(typeof os.homedir(), "string");
- }
+ },
});
test({
name: "tmp directory is a string",
fn() {
assertEquals(typeof os.tmpdir(), "string");
- }
+ },
});
test({
name: "hostname is a string",
fn() {
assertEquals(typeof os.hostname(), "string");
- }
+ },
});
test({
name: "platform is a string",
fn() {
assertEquals(typeof os.platform(), "string");
- }
+ },
});
test({
name: "release is a string",
fn() {
assertEquals(typeof os.release(), "string");
- }
+ },
});
test({
@@ -61,7 +61,7 @@ test({
Error,
"must be >= -2147483648 && <= 2147483647"
);
- }
+ },
});
test({
@@ -81,7 +81,7 @@ test({
Error,
"pid must be >= -2147483648 && <= 2147483647"
);
- }
+ },
});
test({
@@ -115,7 +115,7 @@ test({
Error,
"priority must be >= -20 && <= 19"
);
- }
+ },
});
test({
@@ -150,7 +150,7 @@ test({
Error,
"priority must be >= -20 && <= 19"
);
- }
+ },
});
test({
@@ -160,21 +160,21 @@ test({
assertEquals(os.constants.signals.SIGKILL, Deno.Signal.SIGKILL);
assertEquals(os.constants.signals.SIGCONT, Deno.Signal.SIGCONT);
assertEquals(os.constants.signals.SIGXFSZ, Deno.Signal.SIGXFSZ);
- }
+ },
});
test({
name: "EOL is as expected",
fn() {
assert(os.EOL == "\r\n" || os.EOL == "\n");
- }
+ },
});
test({
name: "Endianness is determined",
fn() {
assert(["LE", "BE"].includes(os.endianness()));
- }
+ },
});
test({
@@ -185,7 +185,7 @@ test({
assertEquals(typeof result[0], "number");
assertEquals(typeof result[1], "number");
assertEquals(typeof result[2], "number");
- }
+ },
});
test({
@@ -196,7 +196,7 @@ test({
assertEquals(`${os.homedir}`, os.homedir());
assertEquals(`${os.hostname}`, os.hostname());
assertEquals(`${os.platform}`, os.platform());
- }
+ },
});
test({
@@ -265,5 +265,5 @@ test({
Error,
"Not implemented"
);
- }
+ },
});
diff --git a/std/node/process.ts b/std/node/process.ts
index 35de23b88..89d383e8e 100644
--- a/std/node/process.ts
+++ b/std/node/process.ts
@@ -4,7 +4,7 @@ const version = `v${Deno.version.deno}`;
const versions = {
node: Deno.version.deno,
- ...Deno.version
+ ...Deno.version,
};
const osToPlatform = (os: Deno.OperatingSystem): string =>
@@ -38,5 +38,5 @@ export const process = {
get argv(): string[] {
// Deno.execPath() also requires --allow-env
return [Deno.execPath(), ...Deno.args];
- }
+ },
};
diff --git a/std/node/process_test.ts b/std/node/process_test.ts
index f44143acb..b9d5388ea 100644
--- a/std/node/process_test.ts
+++ b/std/node/process_test.ts
@@ -14,7 +14,7 @@ test({
assert(process.cwd().match(/\Wnode$/));
process.chdir("..");
assert(process.cwd().match(/\Wstd$/));
- }
+ },
});
test({
@@ -30,7 +30,7 @@ test({
// "The system cannot find the file specified. (os error 2)" so "file" is
// the only common string here.
);
- }
+ },
});
test({
@@ -40,14 +40,14 @@ test({
assertEquals(typeof process.version, "string");
assertEquals(typeof process.versions, "object");
assertEquals(typeof process.versions.node, "string");
- }
+ },
});
test({
name: "process.platform",
fn() {
assertEquals(typeof process.platform, "string");
- }
+ },
});
test({
@@ -56,7 +56,7 @@ test({
assertEquals(typeof process.arch, "string");
// TODO(rsp): make sure that the arch strings should be the same in Node and Deno:
assertEquals(process.arch, Deno.build.arch);
- }
+ },
});
test({
@@ -64,7 +64,7 @@ test({
fn() {
assertEquals(typeof process.pid, "number");
assertEquals(process.pid, Deno.pid);
- }
+ },
});
test({
@@ -78,7 +78,7 @@ test({
Error,
"implemented"
);
- }
+ },
});
test({
@@ -90,12 +90,12 @@ test({
"deno included in the file name of argv[0]"
);
// we cannot test for anything else (we see test runner arguments here)
- }
+ },
});
test({
name: "process.env",
fn() {
assertEquals(typeof process.env.PATH, "string");
- }
+ },
});
diff --git a/std/node/querystring.ts b/std/node/querystring.ts
index fc5a00a13..427183bf0 100644
--- a/std/node/querystring.ts
+++ b/std/node/querystring.ts
@@ -13,7 +13,7 @@ export function parse(
): { [key: string]: string[] | string } {
const entries = str
.split(sep)
- .map(entry => entry.split(eq).map(decodeURIComponent));
+ .map((entry) => entry.split(eq).map(decodeURIComponent));
const final: { [key: string]: string[] | string } = {};
let i = 0;
diff --git a/std/node/querystring_test.ts b/std/node/querystring_test.ts
index d8cb1ec35..0a37eee6b 100644
--- a/std/node/querystring_test.ts
+++ b/std/node/querystring_test.ts
@@ -10,11 +10,11 @@ test({
a: "hello",
b: 5,
c: true,
- d: ["foo", "bar"]
+ d: ["foo", "bar"],
}),
"a=hello&b=5&c=true&d=foo&d=bar"
);
- }
+ },
});
test({
@@ -24,7 +24,7 @@ test({
a: "hello",
b: "5",
c: "true",
- d: ["foo", "bar"]
+ d: ["foo", "bar"],
});
- }
+ },
});
diff --git a/std/node/tests/cjs/cjs_builtin.js b/std/node/tests/cjs/cjs_builtin.js
index 3d182981a..d821d2558 100644
--- a/std/node/tests/cjs/cjs_builtin.js
+++ b/std/node/tests/cjs/cjs_builtin.js
@@ -6,5 +6,5 @@ const path = require("path");
module.exports = {
readFileSync: fs.readFileSync,
isNull: util.isNull,
- extname: path.extname
+ extname: path.extname,
};
diff --git a/std/node/tests/node_modules/left-pad/index.js b/std/node/tests/node_modules/left-pad/index.js
index e90aec35d..8501bca1b 100644
--- a/std/node/tests/node_modules/left-pad/index.js
+++ b/std/node/tests/node_modules/left-pad/index.js
@@ -3,37 +3,37 @@
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://www.wtfpl.net/ for more details. */
-'use strict';
+"use strict";
module.exports = leftPad;
var cache = [
- '',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' ',
- ' '
+ "",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " "
];
-function leftPad (str, len, ch) {
+function leftPad(str, len, ch) {
// convert `str` to a `string`
- str = str + '';
+ str = str + "";
// `len` is the `pad`'s length now
len = len - str.length;
// doesn't need to pad
if (len <= 0) return str;
// `ch` defaults to `' '`
- if (!ch && ch !== 0) ch = ' ';
+ if (!ch && ch !== 0) ch = " ";
// convert `ch` to a `string` cuz it could be a number
- ch = ch + '';
+ ch = ch + "";
// cache common use cases
- if (ch === ' ' && len < 10) return cache[len] + str;
+ if (ch === " " && len < 10) return cache[len] + str;
// `pad` starts with an empty string
- var pad = '';
+ var pad = "";
// loop
while (true) {
// add `ch` to `pad` if `len` is odd
diff --git a/std/node/util_test.ts b/std/node/util_test.ts
index 751dba57e..05cec15df 100644
--- a/std/node/util_test.ts
+++ b/std/node/util_test.ts
@@ -11,7 +11,7 @@ test({
assert(util.isBoolean(false));
assert(!util.isBoolean("deno"));
assert(!util.isBoolean("true"));
- }
+ },
});
test({
@@ -22,7 +22,7 @@ test({
assert(!util.isNull(n));
assert(!util.isNull(0));
assert(!util.isNull({}));
- }
+ },
});
test({
@@ -33,7 +33,7 @@ test({
assert(util.isNullOrUndefined(n));
assert(!util.isNullOrUndefined({}));
assert(!util.isNullOrUndefined("undefined"));
- }
+ },
});
test({
@@ -43,7 +43,7 @@ test({
assert(util.isNumber(new Number(666)));
assert(!util.isNumber("999"));
assert(!util.isNumber(null));
- }
+ },
});
test({
@@ -52,7 +52,7 @@ test({
assert(util.isString("deno"));
assert(util.isString(new String("DIO")));
assert(!util.isString(1337));
- }
+ },
});
test({
@@ -61,7 +61,7 @@ test({
assert(util.isSymbol(Symbol()));
assert(!util.isSymbol(123));
assert(!util.isSymbol("string"));
- }
+ },
});
test({
@@ -71,7 +71,7 @@ test({
assert(util.isUndefined(t));
assert(!util.isUndefined("undefined"));
assert(!util.isUndefined({}));
- }
+ },
});
test({
@@ -81,7 +81,7 @@ test({
assert(util.isObject(dio));
assert(util.isObject(new RegExp(/Toki Wo Tomare/)));
assert(!util.isObject("Jotaro"));
- }
+ },
});
test({
@@ -93,17 +93,17 @@ test({
assert(util.isError(java));
assert(util.isError(nodejs));
assert(!util.isError(deno));
- }
+ },
});
test({
name: "[util] isFunction",
fn() {
- const f = function(): void {};
+ const f = function (): void {};
assert(util.isFunction(f));
assert(!util.isFunction({}));
assert(!util.isFunction(new RegExp(/f/)));
- }
+ },
});
test({
@@ -113,7 +113,7 @@ test({
assert(util.isRegExp(/fuManchu/));
assert(!util.isRegExp({ evil: "eye" }));
assert(!util.isRegExp(null));
- }
+ },
});
test({
@@ -122,5 +122,5 @@ test({
assert(util.isArray([]));
assert(!util.isArray({ yaNo: "array" }));
assert(!util.isArray(null));
- }
+ },
});