1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-27 01:29:14 -05:00

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. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import * as deno from "deno";
async function cat(filenames: string[]): Promise<void> { async function cat(filenames: string[]): Promise<void> {
for (let filename of filenames) { for (let filename of filenames) {
let file = await deno.open(filename); let file = await Deno.open(filename);
await deno.copy(deno.stdout, file); await Deno.copy(Deno.stdout, file);
file.close(); 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"; import { globrex } from "./globrex.ts";
export interface GlobOptions { export interface GlobOptions {

View file

@ -1,5 +1,5 @@
const { mkdir, open } = Deno; const { mkdir, open } = Deno;
import { FileInfo } from "deno"; type FileInfo = Deno.FileInfo;
import { test } from "../testing/mod.ts"; import { test } from "../testing/mod.ts";
import { assertEquals } from "../testing/asserts.ts"; import { assertEquals } from "../testing/asserts.ts";
import { glob } from "./glob.ts"; import { glob } from "./glob.ts";

View file

@ -1,5 +1,5 @@
const { readDir, readDirSync, readlink, readlinkSync, stat, statSync } = Deno; const { readDir, readDirSync, readlink, readlinkSync, stat, statSync } = Deno;
import { FileInfo } from "deno"; type FileInfo = Deno.FileInfo;
export interface WalkOptions { export interface WalkOptions {
maxDepth?: number; maxDepth?: number;

View file

@ -1,5 +1,5 @@
const { cwd, chdir, makeTempDir, mkdir, open, build, remove, symlink } = Deno; 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 { walk, walkSync, WalkOptions } from "./walk.ts";
import { test, TestFunction } from "../testing/mod.ts"; import { test, TestFunction } from "../testing/mod.ts";
import { assert, assertEquals } from "../testing/asserts.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 // https://github.com/indexzero/http-server/blob/master/test/http-server-test.js
const { ErrorKind, cwd, args, stat, readDir, open } = Deno; const { ErrorKind, cwd, args, stat, readDir, open } = Deno;
import { DenoError } from "deno";
import { import {
listenAndServe, listenAndServe,
ServerRequest, ServerRequest,
@ -181,8 +180,8 @@ async function serveFile(req: ServerRequest, filename: string) {
async function serveFallback(req: ServerRequest, e: Error) { async function serveFallback(req: ServerRequest, e: Error) {
if ( if (
e instanceof DenoError && e instanceof Deno.DenoError &&
(e as DenoError<any>).kind === ErrorKind.NotFound (e as Deno.DenoError<any>).kind === ErrorKind.NotFound
) { ) {
return { return {
status: 404, status: 404,

View file

@ -1,8 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import * as deno from "deno";
import { serve } from "./server.ts"; 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 server = serve(addr);
const body = new TextEncoder().encode("Hello World"); const body = new TextEncoder().encode("Hello World");

View file

@ -1,6 +1,8 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { listen, toAsyncIterator, copy } = Deno; 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 { BufReader, BufState, BufWriter } from "../io/bufio.ts";
import { TextProtoReader } from "../textproto/mod.ts"; import { TextProtoReader } from "../textproto/mod.ts";
import { STATUS_TEXT } from "./http_status.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 // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 { charCode, copyBytes } from "./util.ts";
import { assert } from "../testing/asserts.ts"; import { assert } from "../testing/asserts.ts";

View file

@ -4,7 +4,8 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
const { Buffer } = Deno; const { Buffer } = Deno;
import { Reader, ReadResult } from "deno"; type Reader = Deno.Reader;
type ReadResult = Deno.ReadResult;
import { test } from "../testing/mod.ts"; import { test } from "../testing/mod.ts";
import { assert, assertEquals } from "../testing/asserts.ts"; import { assert, assertEquals } from "../testing/asserts.ts";
import { BufReader, BufWriter } from "./bufio.ts"; import { BufReader, BufWriter } from "./bufio.ts";

View file

@ -2,8 +2,8 @@
// Copyright 2009 The Go Authors. All rights reserved. // Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
type Reader = Deno.Reader;
import { Reader, ReadResult } from "deno"; type ReadResult = Deno.ReadResult;
/** OneByteReader returns a Reader that implements /** OneByteReader returns a Reader that implements
* each non-empty Read by reading one byte from r. * 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. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { BufReader } from "./bufio.ts"; import { BufReader } from "./bufio.ts";
import { Reader, Writer } from "deno"; type Reader = Deno.Reader;
type Writer = Deno.Writer;
import { assert } from "../testing/asserts.ts"; import { assert } from "../testing/asserts.ts";
/** copy N size at the most. If read size is lesser than N, then returns nread */ /** 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. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { Buffer } = Deno; const { Buffer } = Deno;
import { Reader, ReadResult } from "deno"; type Reader = Deno.Reader;
type ReadResult = Deno.ReadResult;
import { test } from "../testing/mod.ts"; import { test } from "../testing/mod.ts";
import { assertEquals } from "../testing/asserts.ts"; import { assertEquals } from "../testing/asserts.ts";
import { import {

View file

@ -1,5 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // 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"; import { encode } from "../strings/strings.ts";
/** Reader utility for strings */ /** Reader utility for strings */

View file

@ -1,6 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { Buffer, mkdir, open } = Deno; 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 { encode } from "../strings/strings.ts";
import * as path from "../fs/path.ts"; import * as path from "../fs/path.ts";
// `off` is the offset into `dst` where it will at which to begin writing values // `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. // 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"; import { decode, encode } from "../strings/strings.ts";
/** Writer utility for buffering string chunks */ /** Writer utility for buffering string chunks */

View file

@ -1,6 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { open } = Deno; const { open } = Deno;
import { File, Writer } from "deno"; type File = Deno.File;
type Writer = Deno.Writer;
import { getLevelByName, LogLevel } from "./levels.ts"; import { getLevelByName, LogLevel } from "./levels.ts";
import { LogRecord } from "./logger.ts"; import { LogRecord } from "./logger.ts";
import { red, yellow, blue, bold } from "../colors/mod.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. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { Buffer, copy, remove } = Deno; 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 { FormFile } from "./formfile.ts";
import { import {
bytesFindIndex, bytesFindIndex,

View file

@ -1,6 +1,7 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { Buffer } = Deno; const { Buffer } = Deno;
import { Writer, Conn } from "deno"; type Conn = Deno.Conn;
type Writer = Deno.Writer;
import { BufReader, BufWriter } from "../io/bufio.ts"; import { BufReader, BufWriter } from "../io/bufio.ts";
import { readLong, readShort, sliceLongToBytes } from "../io/ioutil.ts"; import { readLong, readShort, sliceLongToBytes } from "../io/ioutil.ts";
import { Sha1 } from "./sha1.ts"; import { Sha1 } from "./sha1.ts";