diff --git a/std/fs/README.md b/std/fs/README.md index 612b1393fd..dd1692524d 100644 --- a/std/fs/README.md +++ b/std/fs/README.md @@ -183,20 +183,6 @@ readFileStr("./target.dat", { encoding: "utf8" }); // returns a promise readFileStrSync("./target.dat", { encoding: "utf8" }); // string ``` -### writeFileStr - -Write the string to file. - -```ts -import { - writeFileStr, - writeFileStrSync, -} from "https://deno.land/std/fs/mod.ts"; - -writeFileStr("./target.dat", "file content"); // returns a promise -writeFileStrSync("./target.dat", "file content"); // void -``` - ### expandGlob Expand the glob string from the specified `root` directory and yield each result diff --git a/std/fs/write_file_str.ts b/std/fs/write_file_str.ts deleted file mode 100644 index bf972f2040..0000000000 --- a/std/fs/write_file_str.ts +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. - -/** - * Write the string to file synchronously. - * - * @param filename File to write - * @param content The content write to file - * @returns void - */ -export function writeFileStrSync(filename: string, content: string): void { - const encoder = new TextEncoder(); - Deno.writeFileSync(filename, encoder.encode(content)); -} - -/** - * Write the string to file. - * - * @param filename File to write - * @param content The content write to file - * @returns Promise - */ -export async function writeFileStr( - filename: string, - content: string, -): Promise { - const encoder = new TextEncoder(); - await Deno.writeFile(filename, encoder.encode(content)); -} diff --git a/std/fs/write_file_str_test.ts b/std/fs/write_file_str_test.ts deleted file mode 100644 index 42119c8fbb..0000000000 --- a/std/fs/write_file_str_test.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { assertEquals } from "../testing/asserts.ts"; -import * as path from "../path/mod.ts"; -import { writeFileStr, writeFileStrSync } from "./write_file_str.ts"; - -const testdataDir = path.resolve("fs", "testdata"); - -Deno.test("testReadFileSync", function (): void { - const jsonFile = path.join(testdataDir, "write_file_1.json"); - const content = "write_file_str_test"; - writeFileStrSync(jsonFile, content); - - // make sure file have been create. - Deno.statSync(jsonFile); - - const result = new TextDecoder().decode(Deno.readFileSync(jsonFile)); - - // remove test file - Deno.removeSync(jsonFile); - - assertEquals(content, result); -}); - -Deno.test("testReadFile", async function (): Promise { - const jsonFile = path.join(testdataDir, "write_file_2.json"); - const content = "write_file_str_test"; - await writeFileStr(jsonFile, content); - - // make sure file have been create. - await Deno.stat(jsonFile); - - const result = new TextDecoder().decode(await Deno.readFile(jsonFile)); - - // remove test file - await Deno.remove(jsonFile); - - assertEquals(content, result); -});