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

xypriss-compressible

v2.0.19

Published

Compressible Content-Type / mime checking (XyPriss Hardened)

Readme

XyPriss Compressible Check — xypriss-compressible

[!NOTE] Internalized Fork: This module is a strictly typed TypeScript port of the original compressible library. It has been internalized into the XyPriss ecosystem to reduce external dependency surfaces and ensure architectural consistency within XyPriss framework plugins.


Overview

xypriss-compressible determines whether a given Content-Type or MIME type string is worth compressing before sending to the client. It combines an explicit database lookup (mime-db) with a convention-based fallback for types not covered by the database.


Installation

xfpm install xypriss-compressible

Usage

Basic

import compressible from "xypriss-compressible";

compressible("text/html"); // → true
compressible("image/png"); // → false
compressible("application/x-custom"); // → undefined

With a full Content-Type header value

Parameters like charset are automatically stripped before the lookup.

compressible("text/html; charset=utf-8"); // → true
compressible("application/json; charset=utf-8"); // → true

In middleware

import vary from "xypriss-vary";
import compressible from "xypriss-compressible";

function compressionMiddleware(req, res, next) {
  const type = res.getHeader("Content-Type") as string;

  if (type && compressible(type) === true) {
    vary(res, "Accept-Encoding");
    // … apply compression stream …
  }

  next();
}

API

compressible(type)

| Parameter | Type | Description | | --------- | -------- | ------------------------------------------------ | | type | string | A MIME type or full Content-Type header value. |

Returns boolean | undefined:

| Return value | Meaning | | ------------ | ----------------------------------------------------------------------- | | true | The type is compressible. | | false | The type is explicitly not compressible, or type is not a string. | | undefined | Compressibility is unknown — treat as "maybe" in your middleware logic. |

The function never throws. Non-string inputs return false; malformed strings return undefined.


Resolution Order

  1. mime-db lookup — if the database entry carries an explicit compressible flag, that value is returned as-is.
  2. Convention-based fallback — if the type is absent from the database (or has no compressible flag), the following patterns return true:
    • text/*
    • *+json
    • *+text
    • *+xml
  3. Unknown — if neither rule matches, undefined is returned.

Common Values

| MIME type | Result | | -------------------------- | ----------- | | text/html | true | | text/plain | true | | application/json | true | | application/vnd.api+json | true | | application/xml | true | | image/png | false | | image/jpeg | false | | application/octet-stream | false | | video/mp4 | false | | application/x-custom | undefined |


Technical Implementation

  • Strict TypeScript port — no runtime dependencies beyond mime-db; full compile-time safety.
  • Never throws — non-string inputs return false; malformed strings return undefined. Safe to use as a filter predicate without try/catch.
  • Typed mime-db access — the internal MimeDbEntry interface makes the database shape explicit and prevents silent property access on unknown.
  • Clear resolution order — db lookup → regexp fallback → undefined; each step is isolated and commented.

History

See HISTORY.md for full release details.


License

Copyright © 2013 Jonathan Ong
Copyright © 2014 Jeremiah Senkpiel
Copyright © 2015 Douglas Christopher Wilson
Copyright © 2026 Nehonix Team
Released under the MIT License.