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

@dominic.mayers/last-of-readme

v0.1.27

Published

Resolve README to last relevant commit based on npm version

Readme

Last of README

npm version

By default, a package version is expected to contain its correct documentation, but in practice there is no guarantee that documentation is complete or even correct at release time.

Last of Readme helps maintainers make more realistic guarantees about their documentation.


🔗 How it works

Last of Readme connects:

  • a package version
  • a repository state (commit)

This connection is established through a README link.

The system relies on:

  • tags (explicit signals from maintainers)
  • repository structure (implicit signals)
  • a resolver that applies these rules

At each version, a link is inserted into the README. This link points to a resolver, which redirects to the repository state that satisfies the maintainer’s guarantees.


📐 Resolution strategy (last-of contract)

Different contracts are planned for future versions of Last of Readme. This implementation offers the last-of contract:

A more complete and possibly corrected documentation for the package will appear after the version is released.

Resolution order:

  1. vX.Y.Z-last-doc tag → explicitly designated last valid documentation
  2. vX.Y.Z-next-doc tag → same as last-doc, but automatically asserted by a newer version
  3. A unique branch contains the version → use its HEAD
  4. Multiple branches contain the version → present options
  5. No branch contains the version → fall back to the version itself
  6. Otherwise → not found

⚙️ Setup

Insert the placeholder, copy the update script, hook into version, install the documentation tag script, copy the resolver page, and push tags.

1. Add the placeholder to your README

Add the following placeholder in your README:

<!-- DOC-LINK-START --><!-- DOC-LINK-END -->

Place it where you want the documentation link to appear, before any further occurence of the placeholder. Only the first occurence is processed by the update script.


2. Add the update script and run it

A. Copy scripts/update-readme-link.cjs from this repository and place it at the same location in your repository.

B. Add the repository info in package.json (replace <your-github-username> and <your-repo>):

{
    "repository": {
        "type": "git",
        "url": "git+https://github.com/<your-github-username>/<your-repo>"
    }
}

C. Run the script

node scripts/update-readme-link.cjs

This script:

  • reads metadata from package.json
  • generates a documentation badge and a resolver link for the current version
  • inserts the badge into the placeholder

The link is resolved later by readme-resolver.html.


3. Hook into version

Add to package.json

{
    "scripts": {
        "version": "node scripts/update-readme-link.cjs && git add README.md",
    }
}

This will run the update script and stage the updated README.md whenever the package version is updated.


4. Install the documentation tag script

A. Copy scripts/tag-last-doc.cjs from this repository.

B. Place it in your project (e.g. scripts/tag-last-doc.cjs).

C. Add to package.json:

{
    "scripts": {
        "version": "node scripts/update-readme-link.cjs && git add README.md",
        "tag:last-doc": "node scripts/tag-last-doc.cjs"
    }
}

The command to execute the script:

npm run tag:last-doc

D. When to use the script

This script:

  • reads the current version from package.json
  • creates a tag of the form vX.Y.Z-last-doc pointing to the current commit
  • pushes the tag to the remote repository

The script should be executed when the README starts to diverge from the current version of the package. The created tag marks the last commit whose README still matches version X.Y.Z.

If no last-doc tag is present, the resolver falls back to the next version tag (or to the main branch if none exists).


5. Copy the resolver page

A. Copy docs/readme-resolver.html from this repository.

B. Place it in your project (e.g. docs/readme-resolver.html).

C. Enable GitHub Pages for that folder.

The page will:

  • read the requested version from the URL.
  • check for a corresponding documentation tag (vX.Y.Z-last-doc).
  • otherwise query the npm registry.
  • redirect to the appropriate repository state on GitHub, where the README is displayed.

6. Push tags

  • After every npm version ..., push commits and tags:

       git push --follow-tags
  • You should consider automating it with postversion. For example:

      {
          "scripts": {
              "version": "node scripts/update-readme-link.cjs && git add README.md",
              "tag:last-doc": "node scripts/tag-last-doc.cjs"
              "postversion": "git push --follow-tags"
          }
      }

This also pushes any documentation tags (such as vX.Y.Z-last-doc) that point to commits on the current branch.


📄 License

MIT