summaryrefslogtreecommitdiff
path: root/cli/js/lib.deno.ns.d.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/lib.deno.ns.d.ts')
-rw-r--r--cli/js/lib.deno.ns.d.ts37
1 files changed, 37 insertions, 0 deletions
diff --git a/cli/js/lib.deno.ns.d.ts b/cli/js/lib.deno.ns.d.ts
index d33fde844..6d354d034 100644
--- a/cli/js/lib.deno.ns.d.ts
+++ b/cli/js/lib.deno.ns.d.ts
@@ -1276,6 +1276,25 @@ declare namespace Deno {
* Requires `allow-read` and `allow-write` permission. */
export function rename(oldpath: string, newpath: string): Promise<void>;
+ /** Synchronously reads and returns the entire contents of a file as utf8 encoded string
+ * encoded string. Reading a directory returns an empty string.
+ *
+ * const data = Deno.readTextFileSync("hello.txt");
+ * console.log(data);
+ *
+ * Requires `allow-read` permission. */
+ export function readTextFileSync(path: string): string;
+
+ /** Asynchronously reads and returns the entire contents of a file as a utf8
+ * encoded string. Reading a directory returns an empty data array.
+ *
+ * const decoder = new TextDecoder("utf-8");
+ * const data = Deno.readFileSync("hello.txt");
+ * console.log(decoder.decode(data));
+ *
+ * Requires `allow-read` permission. */
+ export function readTextFile(path: string): 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
* required. Reading a directory returns an empty data array.
@@ -1598,6 +1617,24 @@ declare namespace Deno {
options?: WriteFileOptions
): Promise<void>;
+ /** Synchronously write string `data` to the given `path`, by default creating a new file if needed,
+ * else overwriting.
+ *
+ * await Deno.writeTextFileSync("hello1.txt", "Hello world\n"); // overwrite "hello1.txt" or create it
+ *
+ * Requires `allow-write` permission, and `allow-read` if `options.create` is `false`.
+ */
+ export function writeTextFileSync(path: string, data: string): void;
+
+ /** Asynchronously write string `data` to the given `path`, by default creating a new file if needed,
+ * else overwriting.
+ *
+ * await Deno.writeTextFile("hello1.txt", "Hello world\n"); // overwrite "hello1.txt" or create it
+ *
+ * Requires `allow-write` permission, and `allow-read` if `options.create` is `false`.
+ */
+ export function writeTextFile(path: string, data: string): Promise<void>;
+
/** **UNSTABLE**: Should not have same name as `window.location` type. */
interface Location {
/** The full url for the module, e.g. `file://some/file.ts` or