From ff9b368f1e77edc627218b6eb52394831804ea42 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Fri, 19 Feb 2021 09:06:55 +0100 Subject: [PATCH] add jsdoc --- examples/echo_server.ts | 1 + examples/hello.ts | 14 ++++++++++++-- index.ts | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/echo_server.ts b/examples/echo_server.ts index 8457134..4c2afb0 100644 --- a/examples/echo_server.ts +++ b/examples/echo_server.ts @@ -10,5 +10,6 @@ const listener = Deno.listen({ hostname, port }); console.log(`Listen on ${hostname}:${port}`); for await (const conn of listener) { + console.log("Connection initiated"); Deno.copy(conn, conn); } diff --git a/examples/hello.ts b/examples/hello.ts index f7566af..4051f22 100644 --- a/examples/hello.ts +++ b/examples/hello.ts @@ -1,6 +1,16 @@ // Library exporting `sayHello` function -const capitalize = (word: string) => +/** + * Title case the given word. First character uppercase and the rest lowercase. + * @param {string} word + * @returns {string} Capitalized word. + */ +const capitalize = (word: string): string => `${word.charAt(0).toUpperCase()}${word.toLowerCase().slice(1)}`; -export const sayHello = (name: string) => `Hello ${capitalize(name)}`; +/** + * Greets the named user after name capitalization + * @param {string} name + * @returns {string} Greeting to the user + */ +export const sayHello = (name: string): string => `Hello ${capitalize(name)}`; diff --git a/index.ts b/index.ts index 87fdbba..d525446 100644 --- a/index.ts +++ b/index.ts @@ -3,6 +3,7 @@ import { serve } from "https://deno.land/std@0.87.0/http/server.ts"; const s = serve({ port: 8000 }); console.log("http://localhost:8000/"); + for await (const req of s) { req.respond({ body: "Hello, World\n" }); }