reading-time 0.1.0

Estimate the reading time of a text (word count + minutes), with CJK support. A faithful port of the reading-time npm package. Zero deps, no_std.
Documentation
  • Coverage
  • 100%
    8 out of 8 items documented2 out of 4 items with examples
  • Size
  • Source code size: 26.89 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 333.63 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • trananhtung/reading-time
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • trananhtung

reading-time

All Contributors

crates.io docs.rs CI license

Estimate how long a text takes to read.

Counts the words in a text and estimates reading time, with sensible handling of CJK characters (each counts as a word, and trailing punctuation is absorbed). A faithful Rust port of the widely-used reading-time npm package — handy for blogs, CMSs, and feeds.

  • Zero dependencies
  • Word count, minutes, milliseconds, and a "N min read" summary
  • CJK / Hiragana / Hangul aware
  • Differential-tested against the reference reading-time implementation (60k cases)

Install

[dependencies]
reading-time = "0.1"

Usage

use reading_time::{reading_time, reading_time_with};

let result = reading_time("Hello world, this is a test.");
assert_eq!(result.words, 6);
assert_eq!(result.text, "1 min read");

// Custom words-per-minute (default 200):
let slow = reading_time_with(&"word ".repeat(300), 200);
assert_eq!(slow.minutes, 1.5);
assert_eq!(slow.text, "2 min read");

The returned [ReadingTime] exposes text, minutes (fractional), time (milliseconds), and words.

Contributors ✨

This project follows the all-contributors specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the emoji key for how each contribution is recognized, and open a PR or issue to get involved.

Thanks goes to these wonderful people:

License

Licensed under either of MIT or Apache-2.0 at your option.