access
Check whether the process can access a file with the given mode (F_OK, R_OK, W_OK, X_OK). Rejects if access is denied.
Basic usage
import { access } from '@vooya/fs'
import { constants } from 'node:fs'
await access('./file.txt') // F_OK default
await access('./file.txt', constants.R_OK)
await access('./script.sh', constants.X_OK)Methods
access(path, mode?)
Async. Returns Promise<void> (rejects on access denied).
| Argument | Type | Description |
|---|---|---|
path | string | File path. |
mode | number | Optional. F_OK, R_OK, W_OK, X_OK (from fs.constants). |
accessSync(path, mode?)
Sync. Same arguments; throws on access denied.
Performance
From repo benchmarks (pnpm build && pnpm bench):
| Scenario | Node.js | Vooya FS | Speedup |
|---|---|---|---|
| access R_OK (directory) | 4.18 µs | 1.55 µs | 2.7x |
| Scenario | Node.js | Vooya FS | Note |
|---|---|---|---|
| accessSync F_OK | 456 ns | 1.46 µs | Node.js fast path |
Vooya FS is faster for typical access checks; for F_OK-only sync checks Node.js can be faster due to internal fast path.
Notes
- Prefer exists: If you only need “file exists”,
exists(path)is simpler;access(path, F_OK)is the lower-level API. - Constants: Use
constants.F_OK,R_OK,W_OK,X_OKfromnode:fs(or the numeric values). - Known gap: Missing-path and permission errors currently have Node-like messages, but do not expose Node-style
code,path, andsyscallfields yet. - Unsupported Node path inputs:
Bufferpaths andURLpaths are not part of the current Vooya FSaccesssurface.
Competitor measurements
See the full access comparison table for Node 22/24, peer libraries, sync/Promise modes, small and batch workloads, execution routes and measurement limits.
Last updated on