@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 +6 -6
- package/utils/zlibDataDecompress.js +15 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capillarytech/cap-ui-utils",
|
|
3
|
-
"version": "2.0.
|
|
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
|
-
"
|
|
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
|
|
2
|
-
import base64 from
|
|
1
|
+
import pako from "pako";
|
|
2
|
+
import base64 from "base64-js";
|
|
3
3
|
|
|
4
|
-
const decompressData = (data) =>
|
|
5
|
-
|
|
6
|
-
|
|
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 =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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;
|