# @eggjs/compressible

> Compressible Content-Type / mime checking. Forked for TypeScript and keep mime-db as same version as mime-types

Latest version **3.0.0** (published 2025-03-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @eggjs/compressible
pnpm add @eggjs/compressible
yarn add @eggjs/compressible
bun add @eggjs/compressible
```

## Health

**Score 45/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2025-03-12 |
| First published | 2025-03-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 18.19.0 |
| Dependencies | 1 |
| Unpacked size | 11.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2 |
| Maintainers | gxkl, eggjs-admin, fengmk2, atian25, dead_horse, wanghx, hyj1991, killagu, coolme200, mansonchor.zzw, hubcarl, gemwuu, akitasummer |
| Keywords | compress, gzip, mime, content-type |

## Links

- npm: https://www.npmjs.com/package/@eggjs/compressible
- Repository: https://github.com/eggjs/compressible
- Homepage: https://github.com/eggjs/compressible#readme
- Issues: https://github.com/eggjs/compressible/issues
- npm.io page: https://npm.io/package/@eggjs/compressible

## Dependencies (1)

- [mime-db](https://npm.io/package/mime-db.md) 1.52.0

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 3.0.0 (latest) — 2025-03-12

## README

# @eggjs/compressible

[![NPM version][npm-image]][npm-url]
[![Node.js CI](https://github.com/eggjs/compressible/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/compressible/actions/workflows/nodejs.yml)
[![Test coverage][codecov-image]][codecov-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![npm download][download-image]][download-url]
[![Node.js Version](https://img.shields.io/node/v/@eggjs/compressible.svg?style=flat)](https://nodejs.org/en/download/)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/eggjs/compressible)

[npm-image]: https://img.shields.io/npm/v/@eggjs/compressible.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@eggjs/compressible
[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/compressible.svg?style=flat-square
[codecov-url]: https://codecov.io/github/eggjs/compressible?branch=master
[snyk-image]: https://snyk.io/test/npm/@eggjs/compressible/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/@eggjs/compressible
[download-image]: https://img.shields.io/npm/dm/@eggjs/compressible.svg?style=flat-square
[download-url]: https://npmjs.org/package/@eggjs/compressible

Compressible `Content-Type` / `mime` checking.

Forked [compressible](https://github.com/jshttp/compressible) for TypeScript and keep mime-db as same version as mime-types.

## Installation

```sh
npm install @eggjs/compressible
```

## API

```ts
import { compressible } from '@eggjs/compressible';
```

### compressible(type)

Checks if the given `Content-Type` is compressible. The `type` argument is expected
to be a value MIME type or `Content-Type` string, though no validation is performed.

The MIME is looked up in the [`mime-db`](https://www.npmjs.com/package/mime-db) and
if there is compressible information in the database entry, that is returned. Otherwise,
this module will fallback to `true` for the following types:

* `text/*`
* `*/*+json`
* `*/*+text`
* `*/*+xml`

If this module is not sure if a type is specifically compressible or specifically
uncompressible, `undefined` is returned.

```ts
compressible('text/html') // => true
compressible('image/png') // => false
```

## License

[MIT](LICENSE)

## Contributors

[![Contributors](https://contrib.rocks/image?repo=eggjs/compressible)](https://github.com/eggjs/compressible/graphs/contributors)

Made with [contributors-img](https://contrib.rocks).

---
_Source: https://npm.io/package/@eggjs/compressible · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
