rm
This page describes
@vooya/fs@0.1.1. See Node compatibility and execution policy for native fast paths, Node routes and verified limits.
Remove files and directories. Supports recursive removal with optional concurrency (Vooya FS extension) for tuning recursive deletion.
Basic usage
import { rm } from '@vooya/fs'
// Remove a file
await rm('./tmp.txt')
// Remove a directory recursively
await rm('./temp-dir', { recursive: true })
// Force (ignore errors when path does not exist) + retries
await rm('./maybe-missing', { recursive: true, force: true, maxRetries: 3 })
// Recursive with explicit concurrency (measure for your workload)
await rm('./large-tree', { recursive: true, force: true, concurrency: 4 })Methods
rm(path, options?)
Async. Returns Promise<void>.
| Argument | Type | Description |
|---|---|---|
path | string / Buffer / URL | Path to file or directory. |
options | object | Optional. See below. |
Options:
| Option | Type | Default | Description |
|---|---|---|---|
force | boolean | false | If true, ignore ENOENT (path not found). |
maxRetries | number | 0 | Retry on transient errors (e.g. Windows locking). |
recursive | boolean | false | If true, remove directory and its contents. |
retryDelay | number | 100 | Base delay in ms; retry n waits n * retryDelay, matching Node’s linear backoff. |
concurrency | number | 1 | (Vooya FS) Max concurrent delete operations in recursive mode. |
rmSync(path, options?)
Sync. Same Node arguments; calls Node directly and throws on error. The
concurrency extension is validated but does not affect synchronous execution.
Performance
- Recursive: Removal speed is workload-dependent. The current evidence does not establish a reliable advantage for every scale; increasing concurrency can hurt.
- Single file: The public entry calls Node directly.
See Batch API evidence for the current measurements and their limits.
Local scale report
Generated from local performance reports. Do not edit this block by hand.
- Runtime: v22.22.0 on darwin/arm64
- Samples: 2 warmup runs, 10 measured runs
- Aggregation: trimmed mean for wall-clock time; average per-run memory delta for RSS
| Scale | Fixture | Node.js | Vooya FS | Ratio | Node RSS | Vooya FS RSS |
|---|---|---|---|---|---|---|
| tiny | 8 files / 2 dirs | 0.42 ms | 0.41 ms | 1.04x faster | 0 B | 0 B |
| small | 104 files / 13 dirs | 2.47 ms | 2.63 ms | 1.06x slower | 0 B | 0 B |
| medium | 2728 files / 341 dirs | 75.23 ms | 68.29 ms | 1.10x faster | 12.8 KB | 0 B |
Notes
- Recursive: When
recursive: true, Vooya FS uses rayon for parallel deletion. Defaultconcurrencyis 1; values 0 and 1 are serial. Measure before increasing it. - Windows:
maxRetriesandretryDelayhelp with transient “access denied” or locking issues. Same semantics as Node.js. - Symlinks: Recursive removal does not follow symlinks; valid and broken links are removed without touching their targets.
An empty directory still requires recursive: true; force does not change that
rule. Retry delays apply only to recursive removal and eligible error codes. The
public entry uses Node for non-recursive calls, Windows removal and all rmSync
calls, preserving runtime-specific synchronous errors.
Competitor measurements
See the full rm comparison table for Node 22/24, peer libraries, sync/Promise modes, small and batch workloads, execution routes and measurement limits.