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

@molecule/api-web-content-readability

v1.1.3

Published

Mozilla Readability web content provider for molecule.dev — fetch a page or extract readable content in this process

Readme

@molecule/api-web-content-readability

Mozilla Readability web content provider for molecule.dev — fetch a page or extract readable content in this process

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Type

provider

Installation

npm install @molecule/api-web-content-readability @molecule/api-web-content @mozilla/readability jsdom turndown turndown-plugin-gfm
npm install -D @types/jsdom @types/turndown

API

Interfaces

ExtractedContent

What extractReadable produces (everything but the fetch metadata).

interface ExtractedContent {
  title?: string
  description?: string
  content: string
  format: WebContentFormat
  links?: WebContentLink[]
  truncated: boolean
}

ReadabilityWebContentConfig

Options for createProvider().

interface ReadabilityWebContentConfig {
  /**
   * Per-fetch timeout in milliseconds (`fetch` only; `extract` never touches
   * the network). Defaults to `30_000`.
   */
  timeoutMs?: number

  /**
   * Largest response body a fetch reads, in bytes. Defaults to 3 MB — a
   * bigger body is refused rather than read into memory. `extract` is bounded
   * by the caller's own HTML size instead.
   */
  maxFetchBytes?: number

  /**
   * The `User-Agent` sent on fetches. Defaults to
   * `molecule-web-content/1.0 (+https://www.molecule.dev)` — an honest
   * product string, not a browser disguise.
   */
  userAgent?: string
}

Functions

extractReadable(html, options)

Extracts readable content from one HTML document.

The article (Readability) is preferred; when the page is not an article — an app shell, a fragments-only home page, a plain text dump — the whole document's squeezed text is the content instead, so the caller always gets the page's words rather than an empty result. about:blank (no baseUrl) is legal: relative links are simply dropped.

Readability is handed a CLONE of the document (parse mutates what it is given), so the fallback text and the links both still read the original.

function extractReadable(
  html: string,
  options?: {
    baseUrl?: string
    format?: WebContentFormat
    includeLinks?: boolean
    maxContentChars?: number
  },
): ExtractedContent
  • html — The HTML to read (a full document or a fragment).
  • options — Format, links, base URL, and the content cap (tests override it).

Returns: Title, description and the readable content.

createProvider(config)

Creates a Readability-backed web content provider.

function createProvider(config?: ReadabilityWebContentConfig): WebContentProvider
  • config — Optional provider configuration (timeout, byte cap, UA).

Returns: A WebContentProvider backed by Mozilla Readability in this process.

Constants

WEB_CONTENT_LIMITS

Extraction bounds — the same numbers every bond and the hosted handler document.

const WEB_CONTENT_LIMITS: {
  readonly maxContentChars: 500000
  readonly maxLinks: 200
  readonly maxLinkTextChars: 200
  readonly maxHtmlChars: 2000000
}

FETCH_LIMITS

Per-fetch limits, enforced before any network work.

const FETCH_LIMITS: {
  readonly maxUrlChars: 2048
  readonly maxFetchBytes: number
  readonly maxRedirects: 20
}

provider

The provider implementation, lazily initialized with default config.

const provider: WebContentProvider

Core Interface

Implements @molecule/api-web-content interface.

Bond Wiring

Setup function to register this provider with the core interface:

import { setProvider } from '@molecule/api-web-content'
import { provider } from '@molecule/api-web-content-readability'

export function setupWebContentReadability(): void {
  setProvider(provider)
}

Injection Notes

Requirements

Peer dependencies:

  • @molecule/api-web-content >=1.0.0

Runtime Dependencies

  • @molecule/api-web-content
  • @mozilla/readability
  • jsdom
  • turndown
  • turndown-plugin-gfm