A dead simple read time estimation
npm install lesetid/leːsətiːd/, Norwegian: "lesetid"
- ESM Support
- Tree Shakeable
- Using CPM (Characters Per Minute) to estimate for CJK languages
- Streaming support
- Implements Medium's reading time algorithm.
``sh`
npm install lesetid
`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);
});
``
I would like to thank ngryman for his work on reading-time which inspired me to create this package.
Published under MIT License.