steno

Specialized fast async file writer

MIT 24 个版本
安装
npm install steno
yarn add steno
pnpm add steno
bun add steno
README

Steno Node.js CI

Specialized fast async file writer

Steno makes writing to the same file often/concurrently fast and safe.

Used in lowdb.

https://en.wikipedia.org/wiki/Stenotype

Features

  • ⚡ Fast (see benchmark)
  • 🐦 Lightweight (~6kb)
  • 👍 ⚛️ Safe: No partial writes (writes are atomic)
  • 👍 🏁 Safe: No race conditions (writes are ordered even if they're async)

Usage

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  :    1ms

Write 1MB data to the same file x 1000
  fs     : 2300ms
  steno  :    5ms

Steno uses a smart queue and avoids unnecessary writes.

License

MIT - Typicode

版本列表
4.0.2 2023-12-26
4.0.1 2023-12-26
4.0.0 2023-12-26
3.2.0 2023-12-26
3.1.1 2023-10-23
3.1.0 2023-10-07
3.0.0 2022-10-17
2.1.0 2021-08-17
2.0.0 2021-06-06
1.0.0 2021-03-11
0.5.0 2020-03-18
0.4.4 2016-03-09
0.4.3 2016-02-13
0.4.2 2015-06-25
0.4.1 2015-06-02
0.4.0 2015-06-02
0.3.2 2014-12-08
0.3.1 2014-11-28
0.3.0 2014-11-27
0.2.1 2014-11-06
0.2.0 2014-11-06
0.1.2 2014-10-23
0.1.1 2014-10-23
0.1.0 2014-10-21