25.0.0-beta.3 • Published 6 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/ioUsage
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
6 months ago
25.0.0-beta.2
6 months ago
25.0.0-beta.1
6 months ago
0.5.3-alpha.1
6 months ago
0.5.2-alpha.1
6 months ago
0.5.1-alpha.1
7 months ago
0.5.0-alpha.1
7 months ago
0.4.8
7 months ago
0.4.7
8 months ago
0.4.6
8 months ago
0.4.5
8 months ago
0.4.4
8 months ago
0.4.3
8 months ago
0.4.2
8 months ago
0.4.1
8 months ago
0.4.0
8 months ago
0.3.0
8 months ago
0.2.3
8 months ago
0.2.2
8 months ago
0.1.2
8 months ago
0.1.1
8 months ago
0.1.0
8 months ago