1 | # compressible
|
2 |
|
3 | [![NPM Version][npm-version-image]][npm-url]
|
4 | [![NPM Downloads][npm-downloads-image]][npm-url]
|
5 | [![Node.js Version][node-version-image]][node-version-url]
|
6 | [![Build Status][travis-image]][travis-url]
|
7 | [![Test Coverage][coveralls-image]][coveralls-url]
|
8 |
|
9 | Compressible `Content-Type` / `mime` checking.
|
10 |
|
11 | ## Installation
|
12 |
|
13 | ```sh
|
14 | $ npm install compressible
|
15 | ```
|
16 |
|
17 | ## API
|
18 |
|
19 |
|
20 |
|
21 | ```js
|
22 | var compressible = require('compressible')
|
23 | ```
|
24 |
|
25 | ### compressible(type)
|
26 |
|
27 | Checks if the given `Content-Type` is compressible. The `type` argument is expected
|
28 | to be a value MIME type or `Content-Type` string, though no validation is performed.
|
29 |
|
30 | The MIME is looked up in the [`mime-db`](https://www.npmjs.com/package/mime-db) and
|
31 | if there is compressible information in the database entry, that is returned. Otherwise,
|
32 | this module will fallback to `true` for the following types:
|
33 |
|
34 | * `text/*`
|
35 | * `*/*+json`
|
36 | * `*/*+text`
|
37 | * `*/*+xml`
|
38 |
|
39 | If this module is not sure if a type is specifically compressible or specifically
|
40 | uncompressible, `undefined` is returned.
|
41 |
|
42 |
|
43 |
|
44 | ```js
|
45 | compressible('text/html') // => true
|
46 | compressible('image/png') // => false
|
47 | ```
|
48 |
|
49 | ## License
|
50 |
|
51 | [MIT](LICENSE)
|
52 |
|
53 | [coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/compressible/master
|
54 | [coveralls-url]: https://coveralls.io/r/jshttp/compressible?branch=master
|
55 | [node-version-image]: https://badgen.net/npm/node/compressible
|
56 | [node-version-url]: https://nodejs.org/en/download
|
57 | [npm-downloads-image]: https://badgen.net/npm/dm/compressible
|
58 | [npm-url]: https://npmjs.org/package/compressible
|
59 | [npm-version-image]: https://badgen.net/npm/v/compressible
|
60 | [travis-image]: https://badgen.net/travis/jshttp/compressible/master
|
61 | [travis-url]: https://travis-ci.org/jshttp/compressible
|