https://github.com/typicode/steno
Super fast async file writer with atomic write ⚡
https://github.com/typicode/steno
atomic file fs race-condition-prevention safe writer
Last synced: 13 days ago
JSON representation
Super fast async file writer with atomic write ⚡
- Host: GitHub
- URL: https://github.com/typicode/steno
- Owner: typicode
- License: mit
- Created: 2014-10-20T23:48:27.000Z (over 10 years ago)
- Default Branch: main
- Last Pushed: 2024-06-16T19:14:56.000Z (12 months ago)
- Last Synced: 2025-04-02T02:09:48.816Z (about 2 months ago)
- Topics: atomic, file, fs, race-condition-prevention, safe, writer
- Language: JavaScript
- Homepage:
- Size: 315 KB
- Stars: 683
- Watchers: 6
- Forks: 41
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Steno [](https://www.npmjs.org/package/steno) [](https://github.com/typicode/steno/actions/workflows/node.js.yml)
> Super fast async file writer with atomic write
**Steno** makes writing concurrently fast and safe.
Battle-tested in [lowdb](https://github.com/typicode/lowdb).
## Features
- ⚡ Fast (see benchmark)
- 🐦 Lightweight (~6kb)
- 🩵 Written in TypeScript
- 🖊️ Writes are atomic (no partial writes)
- 🏎️ Writes are ordered even if they're async (no race conditions)
- ♻️ Automatic retry## Usage
```javascript
import { Writer } from 'steno'// Create a singleton writer
const file = new Writer('file.txt')// Use it in the rest of your code
async function save() {
await file.write('some data')
}
```## Benchmark
`npm run benchmark` (see `src/benchmark.ts`)
```
Write 1KB data to the same file x 1000
fs : 62ms
steno : 1msWrite 1MB data to the same file x 1000
fs : 2300ms
steno : 5ms
```_Steno uses a smart queue and avoids unnecessary writes._
## Name
https://en.wikipedia.org/wiki/Stenotype
## License
MIT - [Typicode](https://github.com/typicode)