Skip to content

Commit d3d3575

Browse files
committed
Add deflateRaw method
1 parent 683116d commit d3d3575

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ This library also exports consistent async methods to compress and decompress ea
4747
* `gzip`
4848
* `gunzip`
4949
* `deflate`
50+
* `deflateRaw`
5051
* `inflate`
5152
* `inflateRaw`
5253
* `brotliCompress`

‎src/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export type SUPPORTED_ENCODING =
1919
export const gzip = promisify(zlib.gzip);
2020
export const gunzip = promisify(zlib.gunzip);
2121
export const deflate = promisify(zlib.deflate);
22+
export const deflateRaw = promisify(zlib.deflateRaw);
2223
export const inflate = promisify(zlib.inflate);
2324
export const inflateRaw = promisify(zlib.inflateRaw);
2425

‎test/encode.spec.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import chaiAsPromised = require("chai-as-promised");
77
chai.use(chaiAsPromised);
88
const expect = chai.expect;
99

10-
import { encodeBuffer } from '../src/index';
10+
import { encodeBuffer, deflateRaw } from '../src/index';
1111

1212
function bufferToArrayBuffer(buffer: Buffer): ArrayBuffer {
1313
return buffer.buffer.slice(buffer.byteOffset, buffer.byteLength + buffer.byteOffset)
@@ -57,6 +57,11 @@ describe("Encode", () => {
5757
expect(zlib.inflateSync(body).toString()).to.equal('Response to deflate');
5858
});
5959

60+
it('should encode raw deflate bodies', async () => {
61+
const body = await deflateRaw(Buffer.from('Response to raw deflate'), { level: 1 });
62+
expect(zlib.inflateRawSync(body).toString()).to.equal('Response to raw deflate');
63+
});
64+
6065
it('should encode brotli bodies', async () => {
6166
const body = await encodeBuffer(Buffer.from('Response to brotlify brotlify'), 'br');
6267
expect(Buffer.from(

0 commit comments

Comments
 (0)