Inflation is a focused utility that automatically decompresses HTTP streams using Node.js's built-in zlib module. It supports common compression algorithms like gzip, deflate, and brotli. Currently at version 2.1.0, the package demonstrates a stable, low-maintenance release cadence, with its last publish two years ago. It's widely adopted, with over 1.5 million dependents, indicating its reliability for its specific function. Its key differentiator is its simplicity and direct integration with Node.js streams for handling `Content-Encoding` headers, aiming to simplify the process of consuming compressed HTTP request bodies or responses without needing to manually detect the compression type. While robust for its core purpose, users should be aware of specific Node.js version requirements, especially for Brotli support.
npm install inflationVerified import paths — ran on the pinned version, not inferred.
This quickstart sets up a basic HTTP server that listens for incoming requests. It uses `inflation` to automatically decompress the request body based on the `Content-Encoding` header, then reads the raw content and logs it to the console. This demonstrates how to integrate `inflation` into an HTTP request processing pipeline for handling compressed data. Note that `raw-body` is used here for convenience in reading the stream, but is not a dependency of `inflation` itself.
Ensure your Node.js runtime is v11.7.0 or higher if Brotli decompression is required. For older Node.js versions, only gzip and deflate are reliably supported.
For ESM projects, use `import { createRequire } from 'module'; const require = createRequire(import.meta.url); const inflate = require('inflation');` or configure your build system to transpile CJS modules.Always explicitly pass the `encoding` option to `inflate(stream, { encoding: 'gzip' })` if the input stream is not an `http.IncomingMessage` or similar object with a `headers` property.Upgrade your Node.js runtime to v11.7.0 or newer to support Brotli decompression.
Pass the `encoding` option explicitly: `inflate(myStream, { encoding: 'gzip' })` or ensure the `stream` object has a `headers` property containing `content-encoding`.Use `import { createRequire } from 'module'; const require = createRequire(import.meta.url); const inflate = require('inflation');` for ESM projects to import this CJS-only package.No dependency data recorded yet.