@capillarytech/cap-ui-utils 2.0.8 → 2.0.9

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": "@capillarytech/cap-ui-utils",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
4
4
  "description": "Utility functions shared accross all the modules",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,13 +9,13 @@
9
9
  "author": "Rajshekar",
10
10
  "dependencies": {
11
11
  "base64-js": "1.5.1",
12
+ "handlebars": "4.0.11",
13
+ "lodash": "4.17.11",
14
+ "moment-timezone": "^0.5.25",
15
+ "pako": "^2.1.0",
12
16
  "react": "^16.13.0",
13
17
  "react-ga": "^2.7.0",
14
- "tti-polyfill": "^0.2.2",
15
- "moment-timezone": "^0.5.25",
16
18
  "react-intl": "2.7.2",
17
- "lodash": "4.17.11",
18
- "handlebars": "4.0.11",
19
- "zlib": "1.0.5"
19
+ "tti-polyfill": "^0.2.2"
20
20
  }
21
21
  }
@@ -1,14 +1,9 @@
1
- import zlib from 'zlib';
2
- import base64 from 'base64-js';
1
+ import pako from "pako";
2
+ import base64 from "base64-js";
3
3
 
4
- const decompressData = (data) => new Promise((resolve, reject) => {
5
- zlib.gunzip(data, (err, buffer) => {
6
- if (err) {
7
- return reject(err);
8
- }
9
- resolve(buffer);
10
- });
11
- });
4
+ const decompressData = (data) => {
5
+ return pako.ungzip(data, { to: "string" });
6
+ };
12
7
 
13
8
  // Function to decode base64 to buffer
14
9
  function decodeBase64(base64String) {
@@ -16,23 +11,17 @@ function decodeBase64(base64String) {
16
11
  }
17
12
 
18
13
  // Function to decompress base64-encoded compressed JSON string
19
- const decompressJsonObject = async (base64Compressed) => {
20
- try {
21
- // Decode the base64 string to buffer
22
- if (base64Compressed && typeof base64Compressed === 'string') {
23
- const compressedBuffer = decodeBase64(base64Compressed);
24
- // Decompress the buffer
25
- const decompressedBuffer = await decompressData(compressedBuffer);
26
- // Convert buffer to string
27
- const jsonString = decompressedBuffer.toString();
28
- // Parse JSON string to object
29
- const jsonObject = JSON.parse(jsonString);
30
- return jsonObject;
31
- }
32
- return base64Compressed;
33
- } catch (error) {
34
- throw error;
14
+ const decompressJsonObject = (base64Compressed) => {
15
+ // Decode the base64 string to buffer
16
+ if (base64Compressed && typeof base64Compressed === "string") {
17
+ const compressedBuffer = decodeBase64(base64Compressed);
18
+ // Decompress the buffer
19
+ const decompressedBuffer = decompressData(compressedBuffer);
20
+ // Parse decompressedBuffer to object
21
+ const jsonObject = JSON.parse(decompressedBuffer);
22
+ return jsonObject;
35
23
  }
24
+ return base64Compressed;
36
25
  };
37
26
 
38
27
  export default decompressJsonObject;