0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

fix(cli): use rid getter for stdio (#8014)

This changes the rid of Deno.stdin, Deno.stdout, Deno.stderr from a
mutable property into a getter to match the rid semantics of Deno.File.
This commit is contained in:
Casper Beyer 2020-10-20 19:20:17 +08:00 committed by GitHub
parent 9141c76b25
commit d9ae74019e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View file

@ -710,11 +710,11 @@ declare namespace Deno {
}
/** A handle for `stdin`. */
export const stdin: Reader & ReaderSync & Closer & { rid: number };
export const stdin: Reader & ReaderSync & Closer & { readonly rid: number };
/** A handle for `stdout`. */
export const stdout: Writer & WriterSync & Closer & { rid: number };
export const stdout: Writer & WriterSync & Closer & { readonly rid: number };
/** A handle for `stderr`. */
export const stderr: Writer & WriterSync & Closer & { rid: number };
export const stderr: Writer & WriterSync & Closer & { readonly rid: number };
export interface OpenOptions {
/** Sets the option for read access. This option, when `true`, means that the

View file

@ -109,7 +109,10 @@
class Stdin {
constructor() {
this.rid = 0;
}
get rid() {
return 0;
}
read(p) {
@ -127,7 +130,10 @@
class Stdout {
constructor() {
this.rid = 1;
}
get rid() {
return 1;
}
write(p) {
@ -145,7 +151,10 @@
class Stderr {
constructor() {
this.rid = 2;
}
get rid() {
return 2;
}
write(p) {