appendFile
Append data to a file, creating the file if it does not exist.
Basic usage
import { appendFile } from '@rush-fs/core'
await appendFile('./log.txt', 'new line\n')
await appendFile('./log.txt', buffer, { encoding: 'utf8', mode: 0o644 })Methods
appendFile(path, data, options?)
Async. Returns Promise<void>.
| Argument | Type | Description |
|---|---|---|
path | string | File path. |
data | string | Buffer | Data to append. |
options | object | Optional: encoding, mode, flag. |
appendFileSync(path, data, options?)
Sync. Same arguments; throws on error.
Performance
From repo benchmarks (pnpm build && pnpm bench):
| Scenario | Node.js | Rush-FS | Ratio |
|---|---|---|---|
| appendFile | 30 µs | 27 µs | 0.9x |
On par with Node.js; single-file append is an atomic syscall.
Notes
- Encodings: utf8, ascii, latin1, base64, base64url, hex. Same semantics as Node.js.
Last updated on