npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

postkit-reading-time

v1.0.0

Published

Estimate how long a post takes to read

Readme

[ACS 3310] Postkit: Reading Time

Estimate how long a post takes to read based on word count. Words are character sequences separated by whitespace, and include punctuation

Installation

API

wordCount count the number of words in a given text

Takes in a string and returns a number representing the word count

wordCount(str: string): number

readingTime estimate the reading time of a given text

Takes in a string and returns a number representing the estimated reading time in minutes

readingTime(str: string): number

formatTime format time for display

Takes in a number of minutes and returns a readable label

formatTime(minutes: number): string
  • < 1 min: Less than a minute
  • 1–9 min: exact minutes (3 minutes)
  • 10–58 min: rounded to 5min (15 minutes)
  • 59–89 min: 1 hour
  • 90–179 min: rounded to half hour (1.5 hours, 2 hours)
  • 180+ min: A few hours

Usage

import { wordCount, readingTime, formatTime } from "postkit-reading-time";

const text = "A fish jumped over something super tall. Wow!";

const count = wordCount(text);
console.log(count); // 8

const time = readingTime(text);
console.log(time); // 0.04

const formattedTime = formatTime(time);
console.log(formattedTime); // "Less than a minute"

Edge Cases

  • Empty text: returns 0 words, 0 minutes, and "Less than a minute"
  • Negative numbers or 0: formats to "Less than a minute"

Design Notes

  • A reading speed of 250 words per minute is used to calculate reading time. Calculated as total word count divided by WPM equals reading time in minutes
  • Reading time is returned as is, rather than rounding, in case someone wants to use it for something other than display (like sorting posts by reading time)
  • 0 words and Less than a minute will be treated as the "floor". This way, unrealistic input (like empty text or negative numbers) can be handled gracefully rather than erroring