summaryrefslogtreecommitdiff
path: root/cli/js/lib.deno.ns.d.ts
diff options
context:
space:
mode:
authorRiver <22485304+actual-size@users.noreply.github.com>2020-06-12 02:36:20 +1000
committerGitHub <noreply@github.com>2020-06-11 12:36:20 -0400
commit818a8010928cb8cef0b7043bd881c8cdce9b6efc (patch)
tree1502e74c9eb01901df8da118257d60d4f962b0e4 /cli/js/lib.deno.ns.d.ts
parent813210d4337bf6e174f1da1f1a6c6fb9b073afa2 (diff)
feat: URL support in Deno filesystem methods (#5990)
Diffstat (limited to 'cli/js/lib.deno.ns.d.ts')
-rw-r--r--cli/js/lib.deno.ns.d.ts78
1 files changed, 50 insertions, 28 deletions
diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts
index 972405680..c50c71d46 100644
--- a/cli/js/lib.deno.ns.d.ts
+++ b/cli/js/lib.deno.ns.d.ts
@@ -419,7 +419,7 @@ declare namespace Deno {
*
* Requires `allow-read` and/or `allow-write` permissions depending on options.
*/
- export function openSync(path: string, options?: OpenOptions): File;
+ export function openSync(path: string | URL, options?: OpenOptions): 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`
@@ -434,7 +434,10 @@ declare namespace Deno {
*
* Requires `allow-read` and/or `allow-write` permissions depending on options.
*/
- export function open(path: string, options?: OpenOptions): Promise<File>;
+ export function open(
+ path: string | URL,
+ options?: OpenOptions
+ ): Promise<File>;
/** Creates a file if none exists or truncates an existing file and returns
* an instance of `Deno.File`.
@@ -445,7 +448,7 @@ declare namespace Deno {
*
* Requires `allow-read` and `allow-write` permissions.
*/
- export function createSync(path: string): File;
+ export function createSync(path: string | URL): File;
/** Creates a file if none exists or truncates an existing file and resolves to
* an instance of `Deno.File`.
@@ -456,7 +459,7 @@ declare namespace Deno {
*
* Requires `allow-read` and `allow-write` permissions.
*/
- export function create(path: string): Promise<File>;
+ export function create(path: string | URL): Promise<File>;
/** Synchronously read from a resource ID (`rid`) into an array buffer (`buffer`).
*
@@ -890,7 +893,7 @@ declare namespace Deno {
* Defaults to throwing error if the directory already exists.
*
* Requires `allow-write` permission. */
- export function mkdirSync(path: string, options?: MkdirOptions): void;
+ export function mkdirSync(path: string | URL, options?: MkdirOptions): void;
/** Creates a new directory with the specified path.
*
@@ -903,7 +906,10 @@ declare namespace Deno {
* Defaults to throwing error if the directory already exists.
*
* Requires `allow-write` permission. */
- export function mkdir(path: string, options?: MkdirOptions): Promise<void>;
+ export function mkdir(
+ path: string | URL,
+ options?: MkdirOptions
+ ): Promise<void>;
export interface MakeTempOptions {
/** Directory where the temporary directory should be created (defaults to
@@ -1011,7 +1017,7 @@ declare namespace Deno {
* NOTE: This API currently throws on Windows
*
* Requires `allow-write` permission. */
- export function chmodSync(path: string, mode: number): void;
+ export function chmodSync(path: string | URL, mode: number): void;
/** Changes the permission of a specific file/directory of specified path.
* Ignores the process's umask.
@@ -1041,7 +1047,7 @@ declare namespace Deno {
* NOTE: This API currently throws on Windows
*
* Requires `allow-write` permission. */
- export function chmod(path: string, mode: number): Promise<void>;
+ export function chmod(path: string | URL, mode: number): Promise<void>;
/** Synchronously change owner of a regular file or directory. This functionality
* is not available on Windows.
@@ -1058,7 +1064,7 @@ declare namespace Deno {
* @param uid user id (UID) of the new owner
* @param gid group id (GID) of the new owner
*/
- export function chownSync(path: string, uid: number, gid: number): void;
+ export function chownSync(path: string | URL, uid: number, gid: number): void;
/** Change owner of a regular file or directory. This functionality
* is not available on Windows.
@@ -1075,7 +1081,11 @@ declare namespace Deno {
* @param uid user id (UID) of the new owner
* @param gid group id (GID) of the new owner
*/
- export function chown(path: string, uid: number, gid: number): Promise<void>;
+ export function chown(
+ path: string | URL,
+ uid: number,
+ gid: number
+ ): Promise<void>;
export interface RemoveOptions {
/** Defaults to `false`. If set to `true`, path will be removed even if
@@ -1094,7 +1104,7 @@ declare namespace Deno {
* directory and the `recursive` option isn't set to `true`.
*
* Requires `allow-write` permission. */
- export function removeSync(path: string, options?: RemoveOptions): void;
+ export function removeSync(path: string | URL, options?: RemoveOptions): void;
/** Removes the named file or directory.
*
@@ -1107,7 +1117,10 @@ declare namespace Deno {
* directory and the `recursive` option isn't set to `true`.
*
* Requires `allow-write` permission. */
- export function remove(path: string, options?: RemoveOptions): Promise<void>;
+ export function remove(
+ path: string | URL,
+ options?: RemoveOptions
+ ): Promise<void>;
/** Synchronously renames (moves) `oldpath` to `newpath`. Paths may be files or
* directories. If `newpath` already exists and is not a directory,
@@ -1152,7 +1165,7 @@ declare namespace Deno {
* ```
*
* Requires `allow-read` permission. */
- export function readTextFileSync(path: string): string;
+ export function readTextFileSync(path: string | URL): string;
/** Asynchronously reads and returns the entire contents of a file as a utf8
* encoded string. Reading a directory returns an empty data array.
@@ -1163,7 +1176,7 @@ declare namespace Deno {
* ```
*
* Requires `allow-read` permission. */
- export function readTextFile(path: string): Promise<string>;
+ export function readTextFile(path: string | URL): Promise<string>;
/** Synchronously reads and returns the entire contents of a file as an array
* of bytes. `TextDecoder` can be used to transform the bytes to string if
@@ -1176,7 +1189,7 @@ declare namespace Deno {
* ```
*
* Requires `allow-read` permission. */
- export function readFileSync(path: string): Uint8Array;
+ export function readFileSync(path: string | URL): Uint8Array;
/** Reads and resolves to the entire contents of a file as an array of bytes.
* `TextDecoder` can be used to transform the bytes to string if required.
@@ -1189,7 +1202,7 @@ declare namespace Deno {
* ```
*
* Requires `allow-read` permission. */
- export function readFile(path: string): Promise<Uint8Array>;
+ export function readFile(path: string | URL): Promise<Uint8Array>;
/** A FileInfo describes a file and is returned by `stat`, `lstat`,
* `statSync`, `lstatSync`. */
@@ -1307,7 +1320,7 @@ declare namespace Deno {
* Throws error if `path` is not a directory.
*
* Requires `allow-read` permission. */
- export function readDirSync(path: string): Iterable<DirEntry>;
+ export function readDirSync(path: string | URL): Iterable<DirEntry>;
/** Reads the directory given by `path` and returns an async iterable of
* `Deno.DirEntry`.
@@ -1321,7 +1334,7 @@ declare namespace Deno {
* Throws error if `path` is not a directory.
*
* Requires `allow-read` permission. */
- export function readDir(path: string): AsyncIterable<DirEntry>;
+ export function readDir(path: string | URL): AsyncIterable<DirEntry>;
/** Synchronously copies the contents and permissions of one file to another
* specified path, by default creating a new file if needed, else overwriting.
@@ -1333,7 +1346,10 @@ declare namespace Deno {
*
* Requires `allow-read` permission on fromPath.
* Requires `allow-write` permission on toPath. */
- export function copyFileSync(fromPath: string, toPath: string): void;
+ export function copyFileSync(
+ fromPath: string | URL,
+ toPath: string | URL
+ ): void;
/** Copies the contents and permissions of one file to another specified path,
* by default creating a new file if needed, else overwriting. Fails if target
@@ -1345,7 +1361,10 @@ declare namespace Deno {
*
* Requires `allow-read` permission on fromPath.
* Requires `allow-write` permission on toPath. */
- export function copyFile(fromPath: string, toPath: string): Promise<void>;
+ export function copyFile(
+ fromPath: string | URL,
+ toPath: string | URL
+ ): Promise<void>;
/** Returns the full path destination of the named symbolic link.
*
@@ -1382,7 +1401,7 @@ declare namespace Deno {
* ```
*
* Requires `allow-read` permission. */
- export function lstat(path: string): Promise<FileInfo>;
+ export function lstat(path: string | URL): Promise<FileInfo>;
/** Synchronously returns a `Deno.FileInfo` for the specified `path`. If
* `path` is a symlink, information for the symlink will be returned instead of
@@ -1394,7 +1413,7 @@ declare namespace Deno {
* ```
*
* Requires `allow-read` permission. */
- export function lstatSync(path: string): FileInfo;
+ export function lstatSync(path: string | URL): FileInfo;
/** Resolves to a `Deno.FileInfo` for the specified `path`. Will always
* follow symlinks.
@@ -1406,7 +1425,7 @@ declare namespace Deno {
* ```
*
* Requires `allow-read` permission. */
- export function stat(path: string): Promise<FileInfo>;
+ export function stat(path: string | URL): Promise<FileInfo>;
/** Synchronously returns a `Deno.FileInfo` for the specified `path`. Will
* always follow symlinks.
@@ -1418,7 +1437,7 @@ declare namespace Deno {
* ```
*
* Requires `allow-read` permission. */
- export function statSync(path: string): FileInfo;
+ export function statSync(path: string | URL): FileInfo;
/** Options for writing to a file. */
export interface WriteFileOptions {
@@ -1448,7 +1467,7 @@ declare namespace Deno {
* `false`.
*/
export function writeFileSync(
- path: string,
+ path: string | URL,
data: Uint8Array,
options?: WriteFileOptions
): void;
@@ -1468,7 +1487,7 @@ declare namespace Deno {
* Requires `allow-write` permission, and `allow-read` if `options.create` is `false`.
*/
export function writeFile(
- path: string,
+ path: string | URL,
data: Uint8Array,
options?: WriteFileOptions
): Promise<void>;
@@ -1482,7 +1501,7 @@ declare namespace Deno {
*
* Requires `allow-write` permission, and `allow-read` if `options.create` is `false`.
*/
- export function writeTextFileSync(path: string, data: string): void;
+ export function writeTextFileSync(path: string | URL, data: string): void;
/** Asynchronously write string `data` to the given `path`, by default creating a new file if needed,
* else overwriting.
@@ -1493,7 +1512,10 @@ declare namespace Deno {
*
* Requires `allow-write` permission, and `allow-read` if `options.create` is `false`.
*/
- export function writeTextFile(path: string, data: string): Promise<void>;
+ export function writeTextFile(
+ path: string | URL,
+ data: string
+ ): Promise<void>;
/** Synchronously truncates or extends the specified file, to reach the
* specified `len`. If `len` is not specified then the entire file contents