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

@cendor/squeeze

v0.2.8

Published

Shrink long prompts to hit a token budget and expand them back exactly — the same input always produces the same output.

Readme

@cendor/squeeze

npm version License: Apache 2.0

Shrink long prompts to hit a token budget and expand them back exactly — the same input always produces the same output, with no LLM and no model download. Compression returns a handle; the original is always restorable, byte-for-byte. The TypeScript port of cendor-squeeze.

The TypeScript port of cendor-squeeze. Satisfies @cendor/core's Compressor protocol by shape, so context tooling can use it without importing it.

Using an AI coding assistant? npx @cendor/init (TS) / uvx cendor-init (Python) wires it up — or point it at cendor.ai/docs/for-ai-assistants.

import { compress, decompress } from '@cendor/squeeze';

const [small, handle] = compress(hugeJson, { kind: 'auto' });                    // detect + route
const [small2] = compress(sourceCode, { kind: 'code', fidelity: 'aggressive' });
const [small3] = compress(logs, { kind: 'logs', targetTokens: 400 });           // compress to a budget
const original = handle.expand();                                               // restore, byte-for-byte
decompress(handle) === handle.expand();                                          // true

Surface

| Symbol | What it does | |---|---| | compress(content, opts?) | [small, handle]. opts: kind ("auto" detects), targetTokens (never exceeded), model ("gpt-4o"), fidelity ("lossless" \| "balanced" \| "aggressive"). Accepts a string or a JSON-serializable object. | | decompress(handle) | handle.expand() — the exact original. | | detect(content) | "json" \| "logs" \| "code" \| "prose". | | Handle | .expand(), .technique, .toDict(), Handle.fromDict(), .id, .kind, .originalRef, .restoreMap. | | SqueezeCompressor | Object form matching core's Compressor protocol. | | useStore(store) | Swap the content-addressed store (CCR) backend; returns the previous one. | | MemoryStore(maxItems?) · SQLiteStore(path) | CCR backends (also at @cendor/squeeze/store). MemoryStore is LRU-capped; SQLiteStore persists (via optional better-sqlite3). |

  • Four compressors — JSON (minify + drop nulls; budget-shrink drops keys/elements structurally, staying valid JSON), logs (normalize timestamps/UUIDs/IPs/hex/integers + dedup repeats into (×N), chronological), code (string-aware comment stripping — a // or # inside a literal stays put; keeps preprocessor & shebang), prose (extractive, abbreviation-aware sentence splitting).
  • Compress to a budgettargetTokens is never exceeded.
  • 100% reversible — a content-addressed store (deduped by sha256) keeps every original; handle.expand() restores it no matter how hard you squeeze. The deterministic handle id is the first 32 hex of sha256(ref:technique).

Parity note

Faithful port of the Python package: same public symbols, defaults, string-literal values (kind, fidelity, technique strings, the × dedup marker U+00D7), algorithms, and error names (KeyError, invalid-fidelity throws). Python snake_case keyword args become a trailing options object; content_ref/restore_map stay snake_case inside toDict() for cross-language persistence.

One deliberate difference: token counts. @cendor/core bundles js-tiktoken, so tokens.count returns real tiktoken numbers for gpt-4o (not Python's forced ceil(len/4) test heuristic). The compressors call the same counter their budget checks do, so every guarantee — targetTokens never exceeded, reversibility, ordering — holds identically; only exact token counts differ from the Python test fixtures.