UseWriteFile
katanakit-js / useWriteFile
Function: useWriteFile()
Section titled “Function: useWriteFile()”function useWriteFile( path, data, options?): Promise<FilesystemResult<string>>;Defined in: infrastructure/filesystem/filesystem.service.ts:231
Writes (or overwrites) a file, creating it when missing.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
path |
string |
Destination file path. |
data |
string | Uint8Array<ArrayBufferLike> |
Text or bytes to write. |
options? |
{ encoding?: | "utf-8" | "utf8" | "ascii" | "base64" | "base64url" | "hex" | "latin1" | "binary" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le"; flag?: string; mode?: number; } |
Encoding, mode and flag overrides. |
options.encoding? |
| "utf-8" | "utf8" | "ascii" | "base64" | "base64url" | "hex" | "latin1" | "binary" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" |
- |
options.flag? |
string |
- |
options.mode? |
number |
- |
Returns
Section titled “Returns”Promise<FilesystemResult<string>>
Safe Result with the written path.
Example
Section titled “Example”const result = await useWriteFile("logs/app.log", "started\n");