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

@itrocks/summary

v0.1.1

Published

Generic action-based object summary in JSON

Readme

npm version npm downloads GitHub issues discord

summary

Generic action-based objects summary in HTML or JSON.

This documentation was written by an artificial intelligence and may contain errors or approximations. It has not yet been fully reviewed by a human. If anything seems unclear or incomplete, please feel free to contact the author of this package.

Installation

npm i @itrocks/summary

@itrocks/summary is designed to be used together with the other it.rocks backend packages such as @itrocks/action, @itrocks/action-request, @itrocks/route, and @itrocks/storage.

What it returns

A summary is a list of tuples:

export type SummaryRecord = [Identifier, string]

Example JSON payload:

[
  [1, "Alice"],
  [2, "Bob"],
  [3, "Charlie"]
]

Identifier 0 is reserved internally and never represents a persisted entity.

Usage

@itrocks/summary exposes a single action class, Summary.

Minimal example

@Route('/summary/users')
export class SummaryUsers extends Summary<User> {}

const summaryUsers = new SummaryUsers()

export async function summaryUsersJson(request: Request<User>) {
  return summaryUsers.json(request)
}

HTML output

The action also supports an HTML variant:

export async function summaryUsersHtml(request: Request<User>) {
  return summaryUsers.html(request)
}

The produced HTML is:

<ul>
  <li data-id="1">Alice</li>
  <li data-id="2">Bob</li>
  <li data-id="3">Charlie</li>
</ul>

The label content is generated from representativeValueOf(object). If representative values may contain user-provided content, proper HTML escaping must be ensured by the surrounding framework.

Query parameters (filtering and paging)

export interface SummaryRequest {
  limit?:      number
  offset?:     number
  page?:       number
  startsWith?: string
}

startsWith

Filters results to objects whose representative property begins with the given prefix.

The filtering is delegated to the underlying search(...) implementation. Case sensitivity and collation therefore depend on the configured storage layer.

limit, offset, page

  • limit - maximum number of records returned.
  • offset - zero‑based index of the first record to return.
  • page - alternative to offset, computed as: offset = page * limit

Precedence rules:

  • If not paging parameter limit is provided, offset and page are ignored, no implicit limit is applied, and all matching records are returned.
  • If limit is provided as an empty string, a default limit of 1000 is applied.
  • If both offset and page are provided, only offset is used.
  • Otherwise, if page is provided, offset = page * limit.

Truncation marker

When paging and/or filtering is used and additional matching records exist beyond the returned slice, a pseudo‑record is appended:

  [0, "..."]

This record signals that the result set is incomplete. It is always appended at the end of the result array.

API

export class Summary<T extends object = object> extends Action<T> {
  html(request: Request<T>): Promise<HtmlResponse>
  json(request: Request<T>): Promise<JsonResponse>
}
  • json() returns SummaryRecord[].
  • html() returns an HTML <ul> containing <li data-id="…">…</li> entries.

Internally, Summary:

  • Retrieves entities via dataSource().search(...)
  • Aplies sorting through the storage layer
  • Applies optional paging (limit, offset, page)
  • Computes each label via representativeValueOf(object)

Typical use cases

  • Select boxes / drop‑downs
  • Autocomplete with progressive narrowing
  • Lightweight navigation lists