summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2019-03-08 09:25:16 +0900
committerRyan Dahl <ry@tinyclouds.org>2019-03-07 19:25:16 -0500
commitf90f62fa52eccd020026b6899de1b3c7ae0288b6 (patch)
tree6c8b67a43e353b01671179182a5b4c25f95ef416
parentfd74b38d361db4a251621d486b69473a4cc13f24 (diff)
Use Deno global var instead of built-in "deno" module (denoland/deno_std#247)
Original: https://github.com/denoland/deno_std/commit/395392912d69fe320d74c1f95a27be8e4adc0fa6
-rw-r--r--examples/cat.ts8
-rw-r--r--fs/glob.ts1
-rw-r--r--fs/glob_test.ts2
-rw-r--r--fs/walk.ts2
-rw-r--r--fs/walk_test.ts2
-rwxr-xr-xhttp/file_server.ts5
-rw-r--r--http/http_bench.ts3
-rw-r--r--http/server.ts4
-rw-r--r--io/bufio.ts4
-rw-r--r--io/bufio_test.ts3
-rw-r--r--io/iotest.ts4
-rw-r--r--io/ioutil.ts3
-rw-r--r--io/ioutil_test.ts3
-rw-r--r--io/readers.ts3
-rw-r--r--io/util.ts3
-rw-r--r--io/writers.ts2
-rw-r--r--log/handlers.ts3
-rw-r--r--multipart/multipart.ts5
-rw-r--r--ws/mod.ts3
19 files changed, 36 insertions, 27 deletions
diff --git a/examples/cat.ts b/examples/cat.ts
index 38fdbb2cc..ba8b42bdf 100644
--- a/examples/cat.ts
+++ b/examples/cat.ts
@@ -1,12 +1,10 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as deno from "deno";
-
async function cat(filenames: string[]): Promise<void> {
for (let filename of filenames) {
- let file = await deno.open(filename);
- await deno.copy(deno.stdout, file);
+ let file = await Deno.open(filename);
+ await Deno.copy(Deno.stdout, file);
file.close();
}
}
-cat(deno.args.slice(1));
+cat(Deno.args.slice(1));
diff --git a/fs/glob.ts b/fs/glob.ts
index 8c64c45b3..4d4ccc7ce 100644
--- a/fs/glob.ts
+++ b/fs/glob.ts
@@ -1,4 +1,3 @@
-import { FileInfo } from "deno";
import { globrex } from "./globrex.ts";
export interface GlobOptions {
diff --git a/fs/glob_test.ts b/fs/glob_test.ts
index 8691d2c33..2dc509dee 100644
--- a/fs/glob_test.ts
+++ b/fs/glob_test.ts
@@ -1,5 +1,5 @@
const { mkdir, open } = Deno;
-import { FileInfo } from "deno";
+type FileInfo = Deno.FileInfo;
import { test } from "../testing/mod.ts";
import { assertEquals } from "../testing/asserts.ts";
import { glob } from "./glob.ts";
diff --git a/fs/walk.ts b/fs/walk.ts
index c76803a2e..24c800e59 100644
--- a/fs/walk.ts
+++ b/fs/walk.ts
@@ -1,5 +1,5 @@
const { readDir, readDirSync, readlink, readlinkSync, stat, statSync } = Deno;
-import { FileInfo } from "deno";
+type FileInfo = Deno.FileInfo;
export interface WalkOptions {
maxDepth?: number;
diff --git a/fs/walk_test.ts b/fs/walk_test.ts
index 7e6384a60..93073c620 100644
--- a/fs/walk_test.ts
+++ b/fs/walk_test.ts
@@ -1,5 +1,5 @@
const { cwd, chdir, makeTempDir, mkdir, open, build, remove, symlink } = Deno;
-import { FileInfo } from "deno";
+type FileInfo = Deno.FileInfo;
import { walk, walkSync, WalkOptions } from "./walk.ts";
import { test, TestFunction } from "../testing/mod.ts";
import { assert, assertEquals } from "../testing/asserts.ts";
diff --git a/http/file_server.ts b/http/file_server.ts
index 20ad45be6..19a94c6aa 100755
--- a/http/file_server.ts
+++ b/http/file_server.ts
@@ -7,7 +7,6 @@
// https://github.com/indexzero/http-server/blob/master/test/http-server-test.js
const { ErrorKind, cwd, args, stat, readDir, open } = Deno;
-import { DenoError } from "deno";
import {
listenAndServe,
ServerRequest,
@@ -181,8 +180,8 @@ async function serveFile(req: ServerRequest, filename: string) {
async function serveFallback(req: ServerRequest, e: Error) {
if (
- e instanceof DenoError &&
- (e as DenoError<any>).kind === ErrorKind.NotFound
+ e instanceof Deno.DenoError &&
+ (e as Deno.DenoError<any>).kind === ErrorKind.NotFound
) {
return {
status: 404,
diff --git a/http/http_bench.ts b/http/http_bench.ts
index c7c2bdf2d..fa7d40bbc 100644
--- a/http/http_bench.ts
+++ b/http/http_bench.ts
@@ -1,8 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import * as deno from "deno";
import { serve } from "./server.ts";
-const addr = deno.args[1] || "127.0.0.1:4500";
+const addr = Deno.args[1] || "127.0.0.1:4500";
const server = serve(addr);
const body = new TextEncoder().encode("Hello World");
diff --git a/http/server.ts b/http/server.ts
index d39173045..f3b92ee90 100644
--- a/http/server.ts
+++ b/http/server.ts
@@ -1,6 +1,8 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { listen, toAsyncIterator, copy } = Deno;
-import { Conn, Reader, Writer } from "deno";
+type Conn = Deno.Conn;
+type Reader = Deno.Reader;
+type Writer = Deno.Writer;
import { BufReader, BufState, BufWriter } from "../io/bufio.ts";
import { TextProtoReader } from "../textproto/mod.ts";
import { STATUS_TEXT } from "./http_status.ts";
diff --git a/io/bufio.ts b/io/bufio.ts
index f583a2ff9..f057952fe 100644
--- a/io/bufio.ts
+++ b/io/bufio.ts
@@ -3,7 +3,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-import { Reader, ReadResult, Writer } from "deno";
+type Reader = Deno.Reader;
+type ReadResult = Deno.ReadResult;
+type Writer = Deno.Writer;
import { charCode, copyBytes } from "./util.ts";
import { assert } from "../testing/asserts.ts";
diff --git a/io/bufio_test.ts b/io/bufio_test.ts
index aed58d9ed..1351b7e37 100644
--- a/io/bufio_test.ts
+++ b/io/bufio_test.ts
@@ -4,7 +4,8 @@
// license that can be found in the LICENSE file.
const { Buffer } = Deno;
-import { Reader, ReadResult } from "deno";
+type Reader = Deno.Reader;
+type ReadResult = Deno.ReadResult;
import { test } from "../testing/mod.ts";
import { assert, assertEquals } from "../testing/asserts.ts";
import { BufReader, BufWriter } from "./bufio.ts";
diff --git a/io/iotest.ts b/io/iotest.ts
index e3a42f58a..9973562a7 100644
--- a/io/iotest.ts
+++ b/io/iotest.ts
@@ -2,8 +2,8 @@
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-
-import { Reader, ReadResult } from "deno";
+type Reader = Deno.Reader;
+type ReadResult = Deno.ReadResult;
/** OneByteReader returns a Reader that implements
* each non-empty Read by reading one byte from r.
diff --git a/io/ioutil.ts b/io/ioutil.ts
index 2d189620d..484aba281 100644
--- a/io/ioutil.ts
+++ b/io/ioutil.ts
@@ -1,6 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { BufReader } from "./bufio.ts";
-import { Reader, Writer } from "deno";
+type Reader = Deno.Reader;
+type Writer = Deno.Writer;
import { assert } from "../testing/asserts.ts";
/** copy N size at the most. If read size is lesser than N, then returns nread */
diff --git a/io/ioutil_test.ts b/io/ioutil_test.ts
index 72adfcec2..c6980ebb9 100644
--- a/io/ioutil_test.ts
+++ b/io/ioutil_test.ts
@@ -1,6 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { Buffer } = Deno;
-import { Reader, ReadResult } from "deno";
+type Reader = Deno.Reader;
+type ReadResult = Deno.ReadResult;
import { test } from "../testing/mod.ts";
import { assertEquals } from "../testing/asserts.ts";
import {
diff --git a/io/readers.ts b/io/readers.ts
index df0299356..915d73e6c 100644
--- a/io/readers.ts
+++ b/io/readers.ts
@@ -1,5 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import { Reader, ReadResult } from "deno";
+type Reader = Deno.Reader;
+type ReadResult = Deno.ReadResult;
import { encode } from "../strings/strings.ts";
/** Reader utility for strings */
diff --git a/io/util.ts b/io/util.ts
index d87776ee5..30df2a0e1 100644
--- a/io/util.ts
+++ b/io/util.ts
@@ -1,6 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { Buffer, mkdir, open } = Deno;
-import { File, Reader } from "deno";
+type File = Deno.File;
+type Reader = Deno.Reader;
import { encode } from "../strings/strings.ts";
import * as path from "../fs/path.ts";
// `off` is the offset into `dst` where it will at which to begin writing values
diff --git a/io/writers.ts b/io/writers.ts
index 15c2628ac..07c5743ad 100644
--- a/io/writers.ts
+++ b/io/writers.ts
@@ -1,5 +1,5 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import { Writer } from "deno";
+type Writer = Deno.Writer;
import { decode, encode } from "../strings/strings.ts";
/** Writer utility for buffering string chunks */
diff --git a/log/handlers.ts b/log/handlers.ts
index c1f664cc0..666a8aa48 100644
--- a/log/handlers.ts
+++ b/log/handlers.ts
@@ -1,6 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { open } = Deno;
-import { File, Writer } from "deno";
+type File = Deno.File;
+type Writer = Deno.Writer;
import { getLevelByName, LogLevel } from "./levels.ts";
import { LogRecord } from "./logger.ts";
import { red, yellow, blue, bold } from "../colors/mod.ts";
diff --git a/multipart/multipart.ts b/multipart/multipart.ts
index 68785c7c6..9b3f1ceb0 100644
--- a/multipart/multipart.ts
+++ b/multipart/multipart.ts
@@ -1,7 +1,10 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { Buffer, copy, remove } = Deno;
-import { Closer, Reader, ReadResult, Writer } from "deno";
+type Closer = Deno.Closer;
+type Reader = Deno.Reader;
+type ReadResult = Deno.ReadResult;
+type Writer = Deno.Writer;
import { FormFile } from "./formfile.ts";
import {
bytesFindIndex,
diff --git a/ws/mod.ts b/ws/mod.ts
index 6c827802b..b68f3ad4a 100644
--- a/ws/mod.ts
+++ b/ws/mod.ts
@@ -1,6 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { Buffer } = Deno;
-import { Writer, Conn } from "deno";
+type Conn = Deno.Conn;
+type Writer = Deno.Writer;
import { BufReader, BufWriter } from "../io/bufio.ts";
import { readLong, readShort, sliceLongToBytes } from "../io/ioutil.ts";
import { Sha1 } from "./sha1.ts";