BREAKING CHANGE: remove Deno.OpenMode (#4884)

This commit removes Deno.OpenMode along with overloaded variants
of Deno.open() and Deno.openSync() that used OpenMode.
This commit is contained in:
Bartek Iwańczuk 2020-04-25 00:45:55 +02:00 committed by GitHub
parent 0cb1bb98cc
commit 4a8d25646a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 113 additions and 198 deletions

View file

@ -653,18 +653,6 @@ declare namespace Deno {
*/
export function openSync(path: string, options?: OpenOptions): File;
/** Synchronously open a file and return an instance of `Deno.File`. The file
* may be created depending on the mode passed in. It is the callers responsibility
* to close the file when finished with it.
*
* const file = Deno.openSync("/foo/bar.txt", "r");
* // Do work with file
* Deno.close(file.rid);
*
* Requires `allow-read` and/or `allow-write` permissions depending on openMode.
*/
export function openSync(path: string, openMode?: OpenMode): File;
/** Open a file and resolve to an instance of `Deno.File`. The
* file does not need to previously exist if using the `create` or `createNew`
* open options. It is the callers responsibility to close the file when finished
@ -678,18 +666,6 @@ declare namespace Deno {
*/
export function open(path: string, options?: OpenOptions): Promise<File>;
/** Open a file and resolve to an instance of `Deno.File`. The file may be
* created depending on the mode passed in. It is the callers responsibility
* to close the file when finished with it.
*
* const file = await Deno.open("/foo/bar.txt", "w+");
* // Do work with file
* Deno.close(file.rid);
*
* Requires `allow-read` and/or `allow-write` permissions depending on openMode.
*/
export function open(path: string, openMode?: OpenMode): Promise<File>;
/** Creates a file if none exists or truncates an existing file and returns
* an instance of `Deno.File`.
*
@ -890,21 +866,6 @@ declare namespace Deno {
mode?: number;
}
/** A set of string literals which specify how to open a file.
*
* |Value |Description |
* |------|--------------------------------------------------------------------------------------------------|
* |`"r"` |Read-only. Default. Starts at beginning of file. |
* |`"r+"`|Read-write. Start at beginning of file. |
* |`"w"` |Write-only. Opens and truncates existing file or creates new one for writing only. |
* |`"w+"`|Read-write. Opens and truncates existing file or creates new one for writing and reading. |
* |`"a"` |Write-only. Opens existing file or creates new one. Each write appends content to the end of file.|
* |`"a+"`|Read-write. Behaves like `"a"` and allows to read from file. |
* |`"x"` |Write-only. Exclusive create - creates new file only if one doesn't exist already. |
* |`"x+"`|Read-write. Behaves like `x` and allows reading from file. |
*/
export type OpenMode = "r" | "r+" | "w" | "w+" | "a" | "a+" | "x" | "x+";
/** **UNSTABLE**: new API, yet to be vetted
*
* Check if a given resource id (`rid`) is a TTY.