lesetid
Version:
A dead simple read time estimation
55 lines (38 loc) β’ 1.19 kB
Markdown
# π lesetid
`/leΛsΙtiΛd/`, Norwegian: "lesetid"
## β¨ Features
- ESM Support
- Tree Shakeable
- Using `CPM` (Characters Per Minute) to estimate for CJK languages
- Streaming support
- Implements [Medium's reading time algorithm](https://help.medium.com/hc/en-us/articles/214991667-Read-time).
## π¦ Installation
```sh
npm install lesetid
```
## π Usage
```ts
import { estimate } from "lesetid";
const {
minutes,
rawMinutes,
words
} = estimate("Hello World!");
```
or you can use the streaming approach
```ts
import { Readable } from "node:stream";
import { createReadingTimeStream } from "lesetid/stream";
const readingTimeStream = await fetch("https://next.luxass.dev/projects/eslint-config/raw")
.then((res) => Readable.from(res.body, {
encoding: "utf-8",
}))
.then((body) => body.pipe(createReadingTimeStream()));
readingTimeStream.on("data", (data) => {
console.info(data);
});
```
## π Acknowledgements
I would like to thank [ngryman](https://github.com/ngryman) for his work on [reading-time](https://github.com/ngryman/reading-time) which inspired me to create this package.
## π License
Published under [MIT License](./LICENSE).