writeTextFileSync

import { writeTextFileSync } from "jsr:@ende/fs/unstable-write-text-file";

function · experimental · requires --allow-read, --allow-write

function writeTextFileSync(path: string | URL, data: string, options?: WriteFileOptions): void

Synchronously write string data to the given path, by default creating a new file if needed, else overwriting.

Requires allow-write permission, and allow-read if options.create is false.

path: string | URL

The path of the file that data is written to.

data: string

A UTF-8 string.

options?: WriteFileOptions

Options for writing files. See WriteFileOptions.

Example: Usage

import { writeTextFileSync } from "@ende/fs/unstable-write-text-file";
writeTextFileSync("hello1.txt", "Hello world\n");  // overwrite "hello1.txt" or create it

Source