{"id":13469723,"url":"https://github.com/ngryman/reading-time","last_synced_at":"2025-05-14T11:08:51.213Z","repository":{"id":15238384,"uuid":"17967200","full_name":"ngryman/reading-time","owner":"ngryman","description":":books: Medium's like reading time estimation.","archived":false,"fork":false,"pushed_at":"2025-04-22T20:41:27.000Z","size":547,"stargazers_count":1397,"open_issues_count":9,"forks_count":49,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-22T21:34:02.666Z","etag":null,"topics":["estimate","medium","reading-time"],"latest_commit_sha":null,"homepage":"https://ngryman.sh","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ngryman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"ngryman","patreon":"ngryman","ko_fi":"ngryman"}},"created_at":"2014-03-21T03:33:01.000Z","updated_at":"2025-04-22T20:41:32.000Z","dependencies_parsed_at":"2023-01-13T18:19:39.990Z","dependency_job_id":"84927631-a9a7-438d-8ae6-24dba0e43b5f","html_url":"https://github.com/ngryman/reading-time","commit_stats":{"total_commits":66,"total_committers":12,"mean_commits":5.5,"dds":0.3484848484848485,"last_synced_commit":"5f9f6fb2382a7238f89de401f8057c5a26087bd9"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngryman%2Freading-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngryman%2Freading-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngryman%2Freading-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngryman%2Freading-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ngryman","download_url":"https://codeload.github.com/ngryman/reading-time/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254129482,"owners_count":22019628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["estimate","medium","reading-time"],"created_at":"2024-07-31T15:01:52.910Z","updated_at":"2025-05-14T11:08:51.168Z","avatar_url":"https://github.com/ngryman.png","language":"TypeScript","funding_links":["https://github.com/sponsors/ngryman","https://patreon.com/ngryman","https://ko-fi.com/ngryman"],"categories":["TypeScript","others"],"sub_categories":[],"readme":"# reading-time\n\n[![NPM](http://img.shields.io/npm/v/reading-time.svg)](https://www.npmjs.org/package/reading-time) [![Build Status](http://img.shields.io/travis/ngryman/reading-time.svg)](https://travis-ci.org/ngryman/reading-time)\n\n\u003cbr\u003e\n\n[Medium]'s like reading time estimation.\n\n`reading-time` helps you estimate how long an article will take to read.\nIt works perfectly with plain text, but also with `markdown` or `html`.\n\nNote that it's focused on performance and simplicity, so the number of words it will extract from other formats than plain text can vary a little. But this is an estimation right?\n\n[medium]: https://medium.com\n\n## Installation\n\n```sh\nnpm install reading-time --production\n```\n\n## Usage\n\n### Classic\n\n```javascript\n// In Node.js\nconst readingTime = require('reading-time');\n// In the browser\nconst readingTime = require('reading-time/lib/reading-time');\n\nconst stats = readingTime(text);\n// -\u003e\n// stats: {\n//   minutes: 1,\n//   time: 60000,\n//   words: {total: 200}\n// }\nconsole.log(`The reading time is: ${stats.minutes} min`);\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e🙋‍♂️ Why different imports for Node.js and the browser?\u003c/b\u003e\u003c/summary\u003e\u003cbr\u003e\n  \nThis library is primarily for Node.js. The entrypoint also exports a `ReadingTimeStream` class which is, without polyfills, not supported in browsers. A simple workaround is to import the underlying `lib/reading-time` module.\n\n**Note that in the upcoming `2.0.0` version, this won't be necessary anymore.**\n\n\u003c/details\u003e\n\n### Stream\n\n```javascript\nconst {ReadingTimeStream, readingTimeWithCount} = require('reading-time');\n\nconst analyzer = new ReadingTimeStream();\nfs.createReadStream('foo')\n  .pipe(analyzer)\n  .on('data', (count) =\u003e {\n    console.log(`The reading time is: ${readingTimeWithCount(count).minutes} min`);\n  });\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003e🙋‍♂️ Can I use this in the browser?\u003c/b\u003e\u003c/summary\u003e\u003cbr\u003e\n  \nYes. You need to provide the appropriate polyfills. Please refer to your bundler's documentation.\n\n\u003c/details\u003e\n\n## API\n\n### `readingTime(text, options?)`\n\nReturns an object with `minutes`, `time` (in milliseconds), and `words`.\n\n```ts\ntype ReadingTimeResults = {\n  minutes: number;\n  time: number;\n  words: WordCountStats;\n};\n```\n\n- `text`: the text to analyze\n- options (optional)\n  - `options.wordsPerMinute`: (optional) the words per minute an average reader can read (default: 200)\n  - `options.wordBound`: (optional) a function that returns a boolean value depending on if a character is considered as a word bound (default: spaces, new lines and tabs)\n\n### `countWords(text, options?)`\n\nReturns an object representing the word count stats:\n\n```ts\ntype WordCountStats = {\n  total: number;\n};\n```\n\n- `text`: the text to analyze\n- options (optional)\n  - `options.wordBound`: (optional) a function that returns a boolean value depending on if a character is considered as a word bound (default: spaces, new lines and tabs)\n\n### `readingTimeWithCount(words, options?)`\n\nReturns an object with `minutes` (rounded minute stats) and `time` (exact time in milliseconds).\n\n- `words`: the word count stats\n- options (optional)\n  - `options.wordsPerMinute`: (optional) the words per minute an average reader can read (default: 200)\n\nNote that `readingTime(text, options) === readingTimeWithCount(countWords(text, options), options)`.\n\n## Help wanted!\n\nThis library has been optimized for alphabetical languages and CJK languages, but may not behave correctly for other languages that don't use spaces for word bounds. If you find the behavior of this library to deviate significantly from your expectation, issues or contributions are welcomed!\n\n## Other projects\n\n- [Fauda](https://github.com/ngryman/fauda): configuration made simple.\n- [Badge Size](https://github.com/ngryman/badge-size): Displays the size of a given file in your repository.\n- [Commitizen Emoji](https://github.com/ngryman/cz-emoji): Commitizen adapter formatting commit messages using emojis.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngryman%2Freading-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fngryman%2Freading-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngryman%2Freading-time/lists"}