Use Deno global var instead of built-in "deno" module (#247)

This commit is contained in:
Yoshiya Hinosawa 2019-03-08 09:25:16 +09:00 committed by Ryan Dahl
parent 899ab67cea
commit 395392912d
19 changed files with 36 additions and 27 deletions

View File

@ -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));

View File

@ -1,4 +1,3 @@
import { FileInfo } from "deno";
import { globrex } from "./globrex.ts";
export interface GlobOptions {

View File

@ -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";

View File

@ -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;

View File

@ -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";

View File

@ -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,

View File

@ -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");

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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.

View File

@ -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 */

View File

@ -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 {

View File

@ -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 */

View File

@ -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

View File

@ -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 */

View File

@ -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";

View File

@ -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,

View File

@ -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";