diff options
Diffstat (limited to 'http/racing_server.ts')
-rw-r--r-- | http/racing_server.ts | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/http/racing_server.ts b/http/racing_server.ts index 0053fa428..9d118dc6d 100644 --- a/http/racing_server.ts +++ b/http/racing_server.ts @@ -1,5 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import { serve, ServerRequest } from "./server.ts"; +import { delay } from "../util/async.ts"; const addr = Deno.args[1] || "127.0.0.1:4501"; const server = serve(addr); @@ -7,12 +8,8 @@ const server = serve(addr); const body = new TextEncoder().encode("Hello 1\n"); const body4 = new TextEncoder().encode("World 4\n"); -function sleep(ms: number): Promise<void> { - return new Promise((res): number => setTimeout(res, ms)); -} - async function delayedRespond(request: ServerRequest): Promise<void> { - await sleep(3000); + await delay(3000); await request.respond({ status: 200, body }); } |