diff --git a/.editorconfig b/.editorconfig
index 98a761d..1c6314a 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -7,6 +7,6 @@ charset = utf-8
 trim_trailing_whitespace = true
 insert_final_newline = true
 
-[{package.json,*.yml}]
+[*.yml]
 indent_style = space
 indent_size = 2
diff --git a/.gitattributes b/.gitattributes
index 391f0a4..6313b56 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1 @@
-* text=auto
-*.js text eol=lf
+* text=auto eol=lf
diff --git a/.github/funding.yml b/.github/funding.yml
new file mode 100644
index 0000000..89f2f3b
--- /dev/null
+++ b/.github/funding.yml
@@ -0,0 +1,4 @@
+github: sindresorhus
+open_collective: sindresorhus
+tidelift: npm/unzip-response
+custom: https://sindresorhus.com/donate
diff --git a/.github/security.md b/.github/security.md
new file mode 100644
index 0000000..5358dc5
--- /dev/null
+++ b/.github/security.md
@@ -0,0 +1,3 @@
+# Security Policy
+
+To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
diff --git a/.gitignore b/.gitignore
index 3c3629e..239ecff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 node_modules
+yarn.lock
diff --git a/.npmrc b/.npmrc
new file mode 100644
index 0000000..43c97e7
--- /dev/null
+++ b/.npmrc
@@ -0,0 +1 @@
+package-lock=false
diff --git a/.travis.yml b/.travis.yml
index 97519af..f98fed0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,5 @@
 language: node_js
 node_js:
-  - '6'
-  - '4'
+  - '12'
+  - '10'
+  - '8'
diff --git a/debian/changelog b/debian/changelog
index ee8d7b2..7b5b22a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+node-decompress-response (4.2.1-1) UNRELEASED; urgency=medium
+
+  * New upstream release.
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Mon, 23 Sep 2019 16:08:12 +0000
+
 node-decompress-response (3.3.0-1) unstable; urgency=low
 
   * Initial release (Closes: #876960)
diff --git a/index.d.ts b/index.d.ts
new file mode 100644
index 0000000..18918fa
--- /dev/null
+++ b/index.d.ts
@@ -0,0 +1,29 @@
+/// <reference types="node"/>
+import {IncomingMessage} from 'http';
+
+declare const decompressResponse: {
+	/**
+	Decompress a HTTP response if needed.
+
+	@param response - The HTTP incoming stream with compressed data.
+	@returns The decompressed HTTP response stream.
+
+	@example
+	```
+	import {http} from 'http';
+	import decompressResponse = require('decompress-response');
+
+	http.get('https://sindresorhus.com', response => {
+		response = decompressResponse(response);
+	});
+	```
+	*/
+	(response: IncomingMessage): IncomingMessage;
+
+	// TODO: remove this in the next major version, refactor the whole definition to:
+	// declare function decompressResponse(response: IncomingMessage): IncomingMessage;
+	// export = decompressResponse;
+	default: typeof decompressResponse;
+};
+
+export = decompressResponse;
diff --git a/index.js b/index.js
index d8acd4a..0379dc5 100644
--- a/index.js
+++ b/index.js
@@ -1,29 +1,40 @@
 'use strict';
-const PassThrough = require('stream').PassThrough;
+const {PassThrough: PassThroughStream} = require('stream');
 const zlib = require('zlib');
 const mimicResponse = require('mimic-response');
 
-module.exports = response => {
-	// TODO: Use Array#includes when targeting Node.js 6
-	if (['gzip', 'deflate'].indexOf(response.headers['content-encoding']) === -1) {
+const decompressResponse = response => {
+	const contentEncoding = (response.headers['content-encoding'] || '').toLowerCase();
+
+	if (!['gzip', 'deflate', 'br'].includes(contentEncoding)) {
 		return response;
 	}
 
-	const unzip = zlib.createUnzip();
-	const stream = new PassThrough();
+	const isBrotli = contentEncoding === 'br';
+	if (isBrotli && typeof zlib.createBrotliDecompress !== 'function') {
+		return response;
+	}
+
+	const decompress = isBrotli ? zlib.createBrotliDecompress() : zlib.createUnzip();
+	const stream = new PassThroughStream();
 
 	mimicResponse(response, stream);
 
-	unzip.on('error', err => {
-		if (err.code === 'Z_BUF_ERROR') {
+	decompress.on('error', error => {
+		// Ignore empty response
+		if (error.code === 'Z_BUF_ERROR') {
 			stream.end();
 			return;
 		}
 
-		stream.emit('error', err);
+		stream.emit('error', error);
 	});
 
-	response.pipe(unzip).pipe(stream);
+	response.pipe(decompress).pipe(stream);
 
 	return stream;
 };
+
+module.exports = decompressResponse;
+// TODO: remove this in the next major version
+module.exports.default = decompressResponse;
diff --git a/index.test-d.ts b/index.test-d.ts
new file mode 100644
index 0000000..5166a2f
--- /dev/null
+++ b/index.test-d.ts
@@ -0,0 +1,7 @@
+import * as http from 'http';
+import {expectType} from 'tsd';
+import decompressResponse = require('.');
+
+http.get('localhost', response => {
+	expectType<http.IncomingMessage>(decompressResponse(response));
+});
diff --git a/license b/license
index 32a16ce..e7af2f7 100644
--- a/license
+++ b/license
@@ -1,21 +1,9 @@
-`The MIT License (MIT)
+MIT License
 
 Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
 
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/package.json b/package.json
index 3574dc2..d152101 100644
--- a/package.json
+++ b/package.json
@@ -1,53 +1,50 @@
 {
-  "name": "decompress-response",
-  "version": "3.3.0",
-  "description": "Decompress a HTTP response if needed",
-  "license": "MIT",
-  "repository": "sindresorhus/decompress-response",
-  "maintainers": [
-    {
-      "name": "Sindre Sorhus",
-      "email": "sindresorhus@gmail.com",
-      "url": "sindresorhus.com"
-    },
-    {
-      "name": "Vsevolod Strukchinsky",
-      "email": "floatdrop@gmail.com",
-      "url": "github.com/floatdrop"
-    }
-  ],
-  "engines": {
-    "node": ">=4"
-  },
-  "scripts": {
-    "test": "xo && ava"
-  },
-  "files": [
-    "index.js"
-  ],
-  "keywords": [
-    "decompress",
-    "response",
-    "http",
-    "https",
-    "zlib",
-    "gzip",
-    "zip",
-    "deflate",
-    "unzip",
-    "ungzip",
-    "incoming",
-    "message",
-    "stream",
-    "compressed"
-  ],
-  "dependencies": {
-    "mimic-response": "^1.0.0"
-  },
-  "devDependencies": {
-    "ava": "*",
-    "get-stream": "^3.0.0",
-    "pify": "^3.0.0",
-    "xo": "*"
-  }
+	"name": "decompress-response",
+	"version": "4.2.1",
+	"description": "Decompress a HTTP response if needed",
+	"license": "MIT",
+	"repository": "sindresorhus/decompress-response",
+	"author": {
+		"name": "Sindre Sorhus",
+		"email": "sindresorhus@gmail.com",
+		"url": "sindresorhus.com"
+	},
+	"engines": {
+		"node": ">=8"
+	},
+	"scripts": {
+		"test": "xo && ava && tsd"
+	},
+	"files": [
+		"index.js",
+		"index.d.ts"
+	],
+	"keywords": [
+		"decompress",
+		"response",
+		"http",
+		"https",
+		"zlib",
+		"gzip",
+		"zip",
+		"deflate",
+		"unzip",
+		"ungzip",
+		"incoming",
+		"message",
+		"stream",
+		"compressed",
+		"brotli"
+	],
+	"dependencies": {
+		"mimic-response": "^2.0.0"
+	},
+	"devDependencies": {
+		"@types/node": "^12.7.1",
+		"ava": "^2.2.0",
+		"get-stream": "^5.0.0",
+		"pify": "^4.0.1",
+		"tsd": "^0.7.1",
+		"xo": "^0.24.0"
+	}
 }
diff --git a/readme.md b/readme.md
index 1b98767..c87431a 100644
--- a/readme.md
+++ b/readme.md
@@ -2,7 +2,7 @@
 
 > Decompress a HTTP response if needed
 
-Decompresses the [response](https://nodejs.org/api/http.html#http_class_http_incomingmessage) from [`http.request`](https://nodejs.org/api/http.html#http_http_request_options_callback) if it's gzipped or deflated, otherwise just passes it through.
+Decompresses the [response](https://nodejs.org/api/http.html#http_class_http_incomingmessage) from [`http.request`](https://nodejs.org/api/http.html#http_http_request_options_callback) if it's gzipped, deflated or compressed with Brotli, otherwise just passes it through.
 
 Used by [`got`](https://github.com/sindresorhus/got).
 
@@ -20,12 +20,33 @@ $ npm install decompress-response
 const http = require('http');
 const decompressResponse = require('decompress-response');
 
-http.get('http://sindresorhus.com', response => {
+http.get('https://sindresorhus.com', response => {
 	response = decompressResponse(response);
 });
 ```
 
 
-## License
+## API
 
-MIT © [Sindre Sorhus](https://sindresorhus.com)
+### decompressResponse(response)
+
+Returns the decompressed HTTP response stream.
+
+#### response
+
+Type: [`http.IncomingMessage`](https://nodejs.org/api/http.html#http_class_http_incomingmessage)
+
+The HTTP incoming stream with compressed data.
+
+
+---
+
+<div align="center">
+	<b>
+		<a href="https://tidelift.com/subscription/pkg/npm-unzip-response?utm_source=npm-unzip-response&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
+	</b>
+	<br>
+	<sub>
+		Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
+	</sub>
+</div>
diff --git a/test/helpers/server.js b/test/_server.js
similarity index 100%
rename from test/helpers/server.js
rename to test/_server.js
diff --git a/test/test.js b/test/test.js
index aef5cda..a9fa7ab 100644
--- a/test/test.js
+++ b/test/test.js
@@ -3,8 +3,8 @@ import zlib from 'zlib';
 import test from 'ava';
 import getStream from 'get-stream';
 import pify from 'pify';
-import m from '..';
-import {createServer} from './helpers/server';
+import {createServer} from './_server';
+import decompressResponse from '..';
 
 const zlibP = pify(zlib);
 const httpGetP = pify(http.get, {errorFirst: false});
@@ -15,25 +15,32 @@ let s;
 test.before('setup', async () => {
 	s = createServer();
 
-	s.on('/', async (req, res) => {
-		res.statusCode = 200;
-		res.setHeader('content-type', 'text/plain');
-		res.setHeader('content-encoding', 'gzip');
-		res.end(await zlibP.gzip(fixture));
+	s.on('/', async (request, response) => {
+		response.statusCode = 200;
+		response.setHeader('content-type', 'text/plain');
+		response.setHeader('content-encoding', 'gzip');
+		response.end(await zlibP.gzip(fixture));
 	});
 
-	s.on('/deflate', async (req, res) => {
-		res.statusCode = 200;
-		res.setHeader('content-encoding-type', 'text/plain');
-		res.setHeader('content-encoding', 'deflate');
-		res.end(await zlibP.deflate(fixture));
+	s.on('/deflate', async (request, response) => {
+		response.statusCode = 200;
+		response.setHeader('content-encoding-type', 'text/plain');
+		response.setHeader('content-encoding', 'deflate');
+		response.end(await zlibP.deflate(fixture));
 	});
 
-	s.on('/missing-data', async (req, res) => {
-		res.statusCode = 200;
-		res.setHeader('content-encoding-type', 'text/plain');
-		res.setHeader('content-encoding', 'gzip');
-		res.end((await zlibP.gzip(fixture)).slice(0, -1));
+	s.on('/brotli', async (request, response) => {
+		response.statusCode = 200;
+		response.setHeader('content-type', 'text/plain');
+		response.setHeader('content-encoding', 'br');
+		response.end(await zlibP.brotliCompress(fixture));
+	});
+
+	s.on('/missing-data', async (request, response) => {
+		response.statusCode = 200;
+		response.setHeader('content-encoding-type', 'text/plain');
+		response.setHeader('content-encoding', 'gzip');
+		response.end((await zlibP.gzip(fixture)).slice(0, -1));
 	});
 
 	await s.listen(s.port);
@@ -44,54 +51,67 @@ test.after('cleanup', async () => {
 });
 
 test('decompress gzipped content', async t => {
-	const res = m(await httpGetP(s.url));
-
-	t.truthy(res.destroy);
-	t.truthy(res.setTimeout);
-	t.truthy(res.socket);
-	t.truthy(res.headers);
-	t.truthy(res.trailers);
-	t.truthy(res.rawHeaders);
-	t.truthy(res.statusCode);
-	t.truthy(res.httpVersion);
-	t.truthy(res.httpVersionMinor);
-	t.truthy(res.httpVersionMajor);
-	t.truthy(res.rawTrailers);
-	t.truthy(res.statusMessage);
-
-	res.setEncoding('utf8');
-
-	t.is(await getStream(res), fixture);
+	const response = decompressResponse(await httpGetP(s.url));
+
+	t.truthy(response.destroy);
+	t.truthy(response.setTimeout);
+	t.truthy(response.socket);
+	t.truthy(response.headers);
+	t.truthy(response.trailers);
+	t.truthy(response.rawHeaders);
+	t.truthy(response.statusCode);
+	t.truthy(response.httpVersion);
+	t.truthy(response.httpVersionMinor);
+	t.truthy(response.httpVersionMajor);
+	t.truthy(response.rawTrailers);
+	t.truthy(response.statusMessage);
+
+	response.setEncoding('utf8');
+
+	t.is(await getStream(response), fixture);
 });
 
 test('decompress deflated content', async t => {
-	const res = m(await httpGetP(`${s.url}/deflate`));
+	const response = decompressResponse(await httpGetP(`${s.url}/deflate`));
 
-	t.is(typeof res.httpVersion, 'string');
-	t.truthy(res.headers);
+	t.is(typeof response.httpVersion, 'string');
+	t.truthy(response.headers);
 
-	res.setEncoding('utf8');
+	response.setEncoding('utf8');
 
-	t.is(await getStream(res), fixture);
+	t.is(await getStream(response), fixture);
 });
 
+if (typeof zlib.brotliCompress === 'function') {
+	test('decompress brotli content', async t => {
+		const response = decompressResponse(await httpGetP(`${s.url}/brotli`));
+
+		t.is(typeof response.httpVersion, 'string');
+		t.truthy(response.headers);
+
+		response.setEncoding('utf8');
+
+		t.is(await getStream(response), fixture);
+	});
+}
+
 test('ignore missing data', async t => {
-	const res = m(await httpGetP(`${s.url}/missing-data`));
+	const response = decompressResponse(await httpGetP(`${s.url}/missing-data`));
 
-	t.is(typeof res.httpVersion, 'string');
-	t.truthy(res.headers);
+	t.is(typeof response.httpVersion, 'string');
+	t.truthy(response.headers);
 
-	res.setEncoding('utf8');
+	response.setEncoding('utf8');
 
-	t.is(await getStream(res), fixture);
+	t.is(await getStream(response), fixture);
 });
 
 test('preserves custom properties on the stream', async t => {
-	let res = await httpGetP(s.url);
-	res.customProp = '🦄';
-	res = m(res);
+	let response = await httpGetP(s.url);
+	response.customProp = '🦄';
+	response = decompressResponse(response);
 
-	t.is(res.customProp, '🦄');
+	t.is(response.customProp, '🦄');
 
-	res.destroy();
+	response.destroy();
 });