UNPKG

1.23 kBMarkdownView Raw
1# Steno [![](http://img.shields.io/npm/dm/steno.svg?style=flat)](https://www.npmjs.org/package/steno) [![Node.js CI](https://github.com/typicode/steno/actions/workflows/node.js.yml/badge.svg)](https://github.com/typicode/steno/actions/workflows/node.js.yml)
2
3> Specialized fast async file writer
4
5**Steno** makes writing to the same file often/concurrently fast and safe.
6
7Used in [lowdb](https://github.com/typicode/lowdb).
8
9_https://en.wikipedia.org/wiki/Stenotype_
10
11## Features
12
13- ⚡ Fast (see benchmark)
14- 🐦 Lightweight (~6kb)
15- 👍 ⚛️ Safe: No partial writes (writes are atomic)
16- 👍 🏁 Safe: No race conditions (writes are ordered even if they're async)
17
18## Usage
19
20```javascript
21import { Writer } from 'steno'
22
23// Create a singleton writer
24const file = new Writer('file.txt')
25
26// Use it in the rest of your code
27async function save() {
28 await file.write('some data')
29}
30```
31
32## Benchmark
33
34`npm run benchmark` (see `src/benchmark.ts`)
35
36```
37Write 1KB data to the same file x 1000
38 fs : 62ms
39 steno : 1ms
40
41Write 1MB data to the same file x 1000
42 fs : 2300ms
43 steno : 5ms
44```
45
46_Steno uses a smart queue and avoids unnecessary writes._
47
48## License
49
50MIT - [Typicode](https://github.com/typicode)