mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
refactor: remove combined io interface like ReadCloser (#4944)
This commit removes "combined" interfaces from cli/js/io.ts; in the like of "ReadCloser", "WriteCloser" in favor of using intersections of concrete interfaces.
This commit is contained in:
parent
dea3ca39ba
commit
b508e84567
5 changed files with 9 additions and 40 deletions
|
@ -51,13 +51,6 @@ export {
|
||||||
SyncWriter,
|
SyncWriter,
|
||||||
Closer,
|
Closer,
|
||||||
Seeker,
|
Seeker,
|
||||||
SyncSeeker,
|
|
||||||
ReadCloser,
|
|
||||||
WriteCloser,
|
|
||||||
ReadSeeker,
|
|
||||||
WriteSeeker,
|
|
||||||
ReadWriteCloser,
|
|
||||||
ReadWriteSeeker,
|
|
||||||
} from "./io.ts";
|
} from "./io.ts";
|
||||||
export { linkSync, link } from "./ops/fs/link.ts";
|
export { linkSync, link } from "./ops/fs/link.ts";
|
||||||
export {
|
export {
|
||||||
|
|
18
cli/js/io.ts
18
cli/js/io.ts
|
@ -52,24 +52,6 @@ export interface SyncSeeker {
|
||||||
seekSync(offset: number, whence: SeekMode): number;
|
seekSync(offset: number, whence: SeekMode): number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://golang.org/pkg/io/#ReadCloser
|
|
||||||
export interface ReadCloser extends Reader, Closer {}
|
|
||||||
|
|
||||||
// https://golang.org/pkg/io/#WriteCloser
|
|
||||||
export interface WriteCloser extends Writer, Closer {}
|
|
||||||
|
|
||||||
// https://golang.org/pkg/io/#ReadSeeker
|
|
||||||
export interface ReadSeeker extends Reader, Seeker {}
|
|
||||||
|
|
||||||
// https://golang.org/pkg/io/#WriteSeeker
|
|
||||||
export interface WriteSeeker extends Writer, Seeker {}
|
|
||||||
|
|
||||||
// https://golang.org/pkg/io/#ReadWriteCloser
|
|
||||||
export interface ReadWriteCloser extends Reader, Writer, Closer {}
|
|
||||||
|
|
||||||
// https://golang.org/pkg/io/#ReadWriteSeeker
|
|
||||||
export interface ReadWriteSeeker extends Reader, Writer, Seeker {}
|
|
||||||
|
|
||||||
export async function copy(
|
export async function copy(
|
||||||
src: Reader,
|
src: Reader,
|
||||||
dst: Writer,
|
dst: Writer,
|
||||||
|
|
13
cli/js/lib.deno.ns.d.ts
vendored
13
cli/js/lib.deno.ns.d.ts
vendored
|
@ -495,13 +495,6 @@ declare namespace Deno {
|
||||||
seekSync(offset: number, whence: SeekMode): number;
|
seekSync(offset: number, whence: SeekMode): number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ReadCloser extends Reader, Closer {}
|
|
||||||
export interface WriteCloser extends Writer, Closer {}
|
|
||||||
export interface ReadSeeker extends Reader, Seeker {}
|
|
||||||
export interface WriteSeeker extends Writer, Seeker {}
|
|
||||||
export interface ReadWriteCloser extends Reader, Writer, Closer {}
|
|
||||||
export interface ReadWriteSeeker extends Reader, Writer, Seeker {}
|
|
||||||
|
|
||||||
/** Copies from `src` to `dst` until either `EOF` is reached on `src` or an
|
/** Copies from `src` to `dst` until either `EOF` is reached on `src` or an
|
||||||
* error occurs. It resolves to the number of bytes copied or rejects with
|
* error occurs. It resolves to the number of bytes copied or rejects with
|
||||||
* the first error encountered while copying.
|
* the first error encountered while copying.
|
||||||
|
@ -2195,9 +2188,9 @@ declare namespace Deno {
|
||||||
export class Process {
|
export class Process {
|
||||||
readonly rid: number;
|
readonly rid: number;
|
||||||
readonly pid: number;
|
readonly pid: number;
|
||||||
readonly stdin?: WriteCloser;
|
readonly stdin?: Writer & Closer;
|
||||||
readonly stdout?: ReadCloser;
|
readonly stdout?: Reader & Closer;
|
||||||
readonly stderr?: ReadCloser;
|
readonly stderr?: Reader & Closer;
|
||||||
/** Resolves to the current status of the process. */
|
/** Resolves to the current status of the process. */
|
||||||
status(): Promise<ProcessStatus>;
|
status(): Promise<ProcessStatus>;
|
||||||
/** Buffer the stdout and return it as `Uint8Array` after `Deno.EOF`.
|
/** Buffer the stdout and return it as `Uint8Array` after `Deno.EOF`.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||||
import { File } from "./files.ts";
|
import { File } from "./files.ts";
|
||||||
import { close } from "./ops/resources.ts";
|
import { close } from "./ops/resources.ts";
|
||||||
import { ReadCloser, WriteCloser } from "./io.ts";
|
import { Closer, Reader, Writer } from "./io.ts";
|
||||||
import { readAll } from "./buffer.ts";
|
import { readAll } from "./buffer.ts";
|
||||||
import { kill, runStatus as runStatusOp, run as runOp } from "./ops/process.ts";
|
import { kill, runStatus as runStatusOp, run as runOp } from "./ops/process.ts";
|
||||||
|
|
||||||
|
@ -33,9 +33,9 @@ async function runStatus(rid: number): Promise<ProcessStatus> {
|
||||||
export class Process {
|
export class Process {
|
||||||
readonly rid: number;
|
readonly rid: number;
|
||||||
readonly pid: number;
|
readonly pid: number;
|
||||||
readonly stdin?: WriteCloser;
|
readonly stdin?: Writer & Closer;
|
||||||
readonly stdout?: ReadCloser;
|
readonly stdout?: Reader & Closer;
|
||||||
readonly stderr?: ReadCloser;
|
readonly stderr?: Reader & Closer;
|
||||||
|
|
||||||
// @internal
|
// @internal
|
||||||
constructor(res: RunResponse) {
|
constructor(res: RunResponse) {
|
||||||
|
|
|
@ -28,7 +28,8 @@ function hasHeaderValueOf(s: string, value: string): boolean {
|
||||||
return new RegExp(`^${value}[\t\s]*;?`).test(s);
|
return new RegExp(`^${value}[\t\s]*;?`).test(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Body implements domTypes.Body, ReadableStream<Uint8Array>, io.ReadCloser {
|
class Body
|
||||||
|
implements domTypes.Body, ReadableStream<Uint8Array>, io.Reader, io.Closer {
|
||||||
#bodyUsed = false;
|
#bodyUsed = false;
|
||||||
#bodyPromise: Promise<ArrayBuffer> | null = null;
|
#bodyPromise: Promise<ArrayBuffer> | null = null;
|
||||||
#data: ArrayBuffer | null = null;
|
#data: ArrayBuffer | null = null;
|
||||||
|
|
Loading…
Reference in a new issue