25.0.0-beta.3 • Published 5 months ago
@contextjs/io v25.0.0-beta.3
@contextjs/io
File system utilities for reading, writing, and inspecting files, directories, and paths — with clean APIs and exception-based error handling.
✨ Features
- Create, rename, and delete files and directories
- Automatic parent directory creation for files
- Path utilities:
isFile
,isDirectory
,exists
- Clear and consistent exceptions
- Null-safe input validation
- Zero dependencies
Installation
npm i @contextjs/io
Usage
import { File, Directory, Path } from '@contextjs/io';
if (!Directory.exists("logs"))
Directory.create("logs");
File.save("logs/app.log", "Application started", true);
const log = File.read("logs/app.log");
File.save("logs/app.log", log + "\nSecond line", true);
File.rename("logs/app.log", "logs/app-archived.log");
if (Path.isFile("logs/app-archived.log"))
File.delete("logs/app-archived.log");
if (Directory.exists("logs"))
Directory.delete("logs");
These custom exceptions are thrown by the File
and Directory
APIs:
Exception | Thrown When |
---|---|
FileExistsException | File already exists and overwrite = false |
FileNotFoundException | File does not exist during read/rename/delete |
DirectoryExistsException | Directory already exists on rename |
PathNotFoundException | Path does not exist for directory/file operations |
NullReferenceException | Input path is null or whitespace (from system) |
API Reference
For detailed API documentation, please refer to the API Reference.
25.0.0-beta.3
5 months ago
25.0.0-beta.2
5 months ago
25.0.0-beta.1
5 months ago
0.5.3-alpha.1
5 months ago
0.5.2-alpha.1
5 months ago
0.5.1-alpha.1
5 months ago
0.5.0-alpha.1
5 months ago
0.4.8
6 months ago
0.4.7
6 months ago
0.4.6
7 months ago
0.4.5
7 months ago
0.4.4
7 months ago
0.4.3
7 months ago
0.4.2
7 months ago
0.4.1
7 months ago
0.4.0
7 months ago
0.3.0
7 months ago
0.2.3
7 months ago
0.2.2
7 months ago
0.1.2
7 months ago
0.1.1
7 months ago
0.1.0
7 months ago