Skip to Content
APIaccess

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).

ArgumentTypeDescription
pathstringFile path.
modenumberOptional. 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):

ScenarioNode.jsVooya FSSpeedup
access R_OK (directory)4.18 µs1.55 µs2.7x
ScenarioNode.jsVooya FSNote
accessSync F_OK456 ns1.46 µsNode.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_OK from node: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, and syscall fields yet.
  • Unsupported Node path inputs: Buffer paths and URL paths are not part of the current Vooya FS access surface.

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