lambda-compression 0.2.25 → 0.2.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lambda-compression",
3
- "version": "0.2.25",
3
+ "version": "0.2.26",
4
4
  "description": "HTTP payload compression for AWS Lambda functions",
5
5
  "keywords": [
6
6
  "lambda",
@@ -1,3 +0,0 @@
1
- import type { APIGatewayProxyEventV2, APIGatewayProxyStructuredResultV2 } from 'aws-lambda';
2
- export declare const compress: (event: APIGatewayProxyEventV2, result: APIGatewayProxyStructuredResultV2) => APIGatewayProxyStructuredResultV2;
3
- //# sourceMappingURL=lambdaCompression.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lambdaCompression.d.ts","sourceRoot":"","sources":["../../src/lambdaCompression.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAI5F,eAAO,MAAM,QAAQ,GACnB,OAAO,sBAAsB,EAC7B,QAAQ,iCAAiC,KACxC,iCA0CF,CAAC"}
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.compress = void 0;
7
- const zlib_1 = __importDefault(require("zlib"));
8
- const compress = (event, result) => {
9
- // when there is no body, there is nothing to compress
10
- if (!result.body) {
11
- return result;
12
- }
13
- const acceptEncodingHeader = event.headers['accept-encoding'];
14
- // determine accepted encodings
15
- const encodings = new Set();
16
- if (acceptEncodingHeader) {
17
- acceptEncodingHeader.split(',').forEach((encoding) => {
18
- encodings.add(encoding.toLowerCase().trim());
19
- });
20
- }
21
- if (!result.headers) {
22
- result.headers = {};
23
- }
24
- if (encodings.has('br')) {
25
- result.headers['content-encoding'] = 'br';
26
- result.isBase64Encoded = true;
27
- result.body = zlib_1.default.brotliCompressSync(result.body).toString('base64');
28
- return result;
29
- }
30
- if (encodings.has('gzip')) {
31
- result.headers['content-encoding'] = 'gzip';
32
- result.isBase64Encoded = true;
33
- result.body = zlib_1.default.gzipSync(result.body).toString('base64');
34
- return result;
35
- }
36
- if (encodings.has('deflate')) {
37
- result.headers['content-encoding'] = 'deflate ';
38
- result.isBase64Encoded = true;
39
- result.body = zlib_1.default.deflateSync(result.body).toString('base64');
40
- return result;
41
- }
42
- // if there are no supported encodings, return unencoded message
43
- return result;
44
- };
45
- exports.compress = compress;
46
- //# sourceMappingURL=lambdaCompression.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lambdaCompression.js","sourceRoot":"","sources":["../../src/lambdaCompression.ts"],"names":[],"mappings":";;;;;;AAEA,gDAAwB;AAEjB,MAAM,QAAQ,GAAG,CACtB,KAA6B,EAC7B,MAAyC,EACN,EAAE;IACrC,sDAAsD;IACtD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACjB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAE9D,+BAA+B;IAC/B,MAAM,SAAS,GAAgB,IAAI,GAAG,EAAE,CAAC;IACzC,IAAI,oBAAoB,EAAE,CAAC;QACzB,oBAAoB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YACnD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;IACtB,CAAC;IACD,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAAM,CAAC,O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