summaryrefslogtreecommitdiff
path: root/std/examples
diff options
context:
space:
mode:
Diffstat (limited to 'std/examples')
-rw-r--r--std/examples/chat/server.ts20
-rw-r--r--std/examples/chat/server_test.ts6
-rwxr-xr-xstd/examples/gist.ts6
-rw-r--r--std/examples/test.ts4
-rw-r--r--std/examples/tests/cat_test.ts4
-rw-r--r--std/examples/tests/catj_test.ts6
-rw-r--r--std/examples/tests/colors_test.ts2
-rw-r--r--std/examples/tests/curl_test.ts4
-rw-r--r--std/examples/tests/echo_server_test.ts2
-rw-r--r--std/examples/tests/welcome_test.ts2
-rw-r--r--std/examples/tests/xeval_test.ts12
-rw-r--r--std/examples/xeval.ts8
12 files changed, 38 insertions, 38 deletions
diff --git a/std/examples/chat/server.ts b/std/examples/chat/server.ts
index 08aede05b..eb5b2f7d4 100644
--- a/std/examples/chat/server.ts
+++ b/std/examples/chat/server.ts
@@ -3,7 +3,7 @@ import {
acceptWebSocket,
acceptable,
WebSocket,
- isWebSocketCloseEvent
+ isWebSocketCloseEvent,
} from "../../ws/mod.ts";
const clients = new Map<number, WebSocket>();
@@ -29,19 +29,19 @@ async function wsHandler(ws: WebSocket): Promise<void> {
}
}
-listenAndServe({ port: 8080 }, async req => {
+listenAndServe({ port: 8080 }, async (req) => {
if (req.method === "GET" && req.url === "/") {
//Serve with hack
const u = new URL("./index.html", import.meta.url);
if (u.protocol.startsWith("http")) {
// server launched by deno run http(s)://.../server.ts,
- fetch(u.href).then(resp => {
+ fetch(u.href).then((resp) => {
return req.respond({
status: resp.status,
headers: new Headers({
- "content-type": "text/html"
+ "content-type": "text/html",
}),
- body: resp.body
+ body: resp.body,
});
});
} else {
@@ -50,9 +50,9 @@ listenAndServe({ port: 8080 }, async req => {
req.respond({
status: 200,
headers: new Headers({
- "content-type": "text/html"
+ "content-type": "text/html",
}),
- body: file
+ body: file,
});
}
}
@@ -60,8 +60,8 @@ listenAndServe({ port: 8080 }, async req => {
req.respond({
status: 302,
headers: new Headers({
- location: "https://deno.land/favicon.ico"
- })
+ location: "https://deno.land/favicon.ico",
+ }),
});
}
if (req.method === "GET" && req.url === "/ws") {
@@ -70,7 +70,7 @@ listenAndServe({ port: 8080 }, async req => {
conn: req.conn,
bufReader: req.r,
bufWriter: req.w,
- headers: req.headers
+ headers: req.headers,
}).then(wsHandler);
}
}
diff --git a/std/examples/chat/server_test.ts b/std/examples/chat/server_test.ts
index 13a5c337c..673b61174 100644
--- a/std/examples/chat/server_test.ts
+++ b/std/examples/chat/server_test.ts
@@ -11,7 +11,7 @@ async function startServer(): Promise<Deno.Process> {
const server = Deno.run({
cmd: [Deno.execPath(), "--allow-net", "--allow-read", "server.ts"],
cwd: "examples/chat",
- stdout: "piped"
+ stdout: "piped",
});
try {
assert(server.stdout != null);
@@ -45,7 +45,7 @@ test({
server.stdout!.close();
}
await delay(10);
- }
+ },
});
test({
@@ -65,5 +65,5 @@ test({
server.stdout!.close();
ws!.conn.close();
}
- }
+ },
});
diff --git a/std/examples/gist.ts b/std/examples/gist.ts
index 15f00ff5d..a11a92383 100755
--- a/std/examples/gist.ts
+++ b/std/examples/gist.ts
@@ -35,7 +35,7 @@ for (const filename of parsedArgs._) {
const content = {
description: parsedArgs.title || parsedArgs.t || "Example",
public: false,
- files: files
+ files: files,
};
const body = JSON.stringify(content);
@@ -44,9 +44,9 @@ const res = await fetch("https://api.github.com/gists", {
headers: [
["Content-Type", "application/json"],
["User-Agent", "Deno-Gist"],
- ["Authorization", `token ${token}`]
+ ["Authorization", `token ${token}`],
],
- body
+ body,
});
if (res.ok) {
diff --git a/std/examples/test.ts b/std/examples/test.ts
index d5dd8bedc..6e26407fb 100644
--- a/std/examples/test.ts
+++ b/std/examples/test.ts
@@ -19,10 +19,10 @@ Deno.test(async function catSmoke(): Promise<void> {
"run",
"--allow-read",
"examples/cat.ts",
- "README.md"
+ "README.md",
],
stdout: "null",
- stderr: "null"
+ stderr: "null",
});
const s = await p.status();
assertEquals(s.code, 0);
diff --git a/std/examples/tests/cat_test.ts b/std/examples/tests/cat_test.ts
index 0f17b798d..b12a6916f 100644
--- a/std/examples/tests/cat_test.ts
+++ b/std/examples/tests/cat_test.ts
@@ -9,10 +9,10 @@ Deno.test("[examples/cat] print multiple files", async () => {
"--allow-read",
"cat.ts",
"testdata/cat/hello.txt",
- "testdata/cat/world.txt"
+ "testdata/cat/world.txt",
],
cwd: "examples",
- stdout: "piped"
+ stdout: "piped",
});
try {
diff --git a/std/examples/tests/catj_test.ts b/std/examples/tests/catj_test.ts
index 3f246a65f..53b36bef8 100644
--- a/std/examples/tests/catj_test.ts
+++ b/std/examples/tests/catj_test.ts
@@ -12,7 +12,7 @@ Deno.test("[examples/catj] print an array", async () => {
".[1] = 100",
'.[2].key = "value"',
'.[2].array[0] = "foo"',
- '.[2].array[1] = "bar"'
+ '.[2].array[1] = "bar"',
].join("\n");
assertStrictEq(actual, expected);
@@ -31,7 +31,7 @@ Deno.test("[examples/catj] print an object", async () => {
const expected = [
'.string = "foobar"',
".number = 123",
- '.array[0].message = "hello"'
+ '.array[0].message = "hello"',
].join("\n");
assertStrictEq(actual, expected);
@@ -81,6 +81,6 @@ function catj(...files: string[]): Deno.Process {
cwd: "examples",
stdin: "piped",
stdout: "piped",
- env: { NO_COLOR: "true" }
+ env: { NO_COLOR: "true" },
});
}
diff --git a/std/examples/tests/colors_test.ts b/std/examples/tests/colors_test.ts
index 7c01cd8d6..ac779adb8 100644
--- a/std/examples/tests/colors_test.ts
+++ b/std/examples/tests/colors_test.ts
@@ -6,7 +6,7 @@ Deno.test("[examples/colors] print a colored text", async () => {
const process = Deno.run({
cmd: [Deno.execPath(), "colors.ts"],
cwd: "examples",
- stdout: "piped"
+ stdout: "piped",
});
try {
const output = await process.output();
diff --git a/std/examples/tests/curl_test.ts b/std/examples/tests/curl_test.ts
index 8d7634525..9b2870216 100644
--- a/std/examples/tests/curl_test.ts
+++ b/std/examples/tests/curl_test.ts
@@ -16,7 +16,7 @@ Deno.test({
const process = Deno.run({
cmd: [Deno.execPath(), "--allow-net", "curl.ts", "http://localhost:8081"],
cwd: "examples",
- stdout: "piped"
+ stdout: "piped",
});
try {
@@ -30,5 +30,5 @@ Deno.test({
process.close();
await serverPromise;
}
- }
+ },
});
diff --git a/std/examples/tests/echo_server_test.ts b/std/examples/tests/echo_server_test.ts
index dd7336023..fecc7d6a6 100644
--- a/std/examples/tests/echo_server_test.ts
+++ b/std/examples/tests/echo_server_test.ts
@@ -8,7 +8,7 @@ Deno.test("[examples/echo_server]", async () => {
const process = Deno.run({
cmd: [Deno.execPath(), "--allow-net", "echo_server.ts"],
cwd: "examples",
- stdout: "piped"
+ stdout: "piped",
});
let conn: Deno.Conn | undefined;
diff --git a/std/examples/tests/welcome_test.ts b/std/examples/tests/welcome_test.ts
index 60c55dc0b..cacb77ab9 100644
--- a/std/examples/tests/welcome_test.ts
+++ b/std/examples/tests/welcome_test.ts
@@ -6,7 +6,7 @@ Deno.test("[examples/welcome] print a welcome message", async () => {
const process = Deno.run({
cmd: [Deno.execPath(), "welcome.ts"],
cwd: "examples",
- stdout: "piped"
+ stdout: "piped",
});
try {
const output = await process.output();
diff --git a/std/examples/tests/xeval_test.ts b/std/examples/tests/xeval_test.ts
index 92e9e1bfe..25f99c9f0 100644
--- a/std/examples/tests/xeval_test.ts
+++ b/std/examples/tests/xeval_test.ts
@@ -5,7 +5,7 @@ import { decode, encode } from "../../strings/mod.ts";
import {
assertEquals,
assertStrContains,
- assert
+ assert,
} from "../../testing/asserts.ts";
const { execPath, run } = Deno;
@@ -18,7 +18,7 @@ Deno.test(async function xevalSuccess(): Promise<void> {
Deno.test(async function xevalDelimiter(): Promise<void> {
const chunks: string[] = [];
await xeval(stringsReader("!MADMADAMADAM!"), ($): number => chunks.push($), {
- delimiter: "MADAM"
+ delimiter: "MADAM",
});
assertEquals(chunks, ["!MAD", "ADAM!"]);
});
@@ -27,12 +27,12 @@ const xevalPath = "examples/xeval.ts";
Deno.test({
name: "xevalCliReplvar",
- fn: async function(): Promise<void> {
+ fn: async function (): Promise<void> {
const p = run({
cmd: [execPath(), xevalPath, "--replvar=abc", "console.log(abc)"],
stdin: "piped",
stdout: "piped",
- stderr: "null"
+ stderr: "null",
});
assert(p.stdin != null);
await p.stdin.write(encode("hello"));
@@ -40,7 +40,7 @@ Deno.test({
assertEquals(await p.status(), { code: 0, success: true });
assertEquals(decode(await p.output()).trimEnd(), "hello");
p.close();
- }
+ },
});
Deno.test(async function xevalCliSyntaxError(): Promise<void> {
@@ -48,7 +48,7 @@ Deno.test(async function xevalCliSyntaxError(): Promise<void> {
cmd: [execPath(), xevalPath, "("],
stdin: "null",
stdout: "piped",
- stderr: "piped"
+ stderr: "piped",
});
assertEquals(await p.status(), { code: 1, success: false });
assertEquals(decode(await p.output()), "");
diff --git a/std/examples/xeval.ts b/std/examples/xeval.ts
index 16ce37fb4..6589fec16 100644
--- a/std/examples/xeval.ts
+++ b/std/examples/xeval.ts
@@ -5,7 +5,7 @@ type Reader = Deno.Reader;
/* eslint-disable-next-line max-len */
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction.
-const AsyncFunction = Object.getPrototypeOf(async function(): Promise<void> {})
+const AsyncFunction = Object.getPrototypeOf(async function (): Promise<void> {})
.constructor;
/* eslint-disable max-len */
@@ -59,12 +59,12 @@ async function main(): Promise<void> {
alias: {
delim: ["d"],
replvar: ["I"],
- help: ["h"]
+ help: ["h"],
},
default: {
delim: DEFAULT_DELIMITER,
- replvar: "$"
- }
+ replvar: "$",
+ },
});
if (parsedArgs._.length != 1) {
console.error(HELP_MSG);