You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.8 KiB

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