@capillarytech/cap-ui-utils 3.0.2 → 3.0.4-alpha.0
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/index.js +1 -0
- package/package.json +8 -5
- package/utils/zlibDataDecompress.js +28 -0
package/index.js
CHANGED
|
@@ -9,3 +9,4 @@ export { default as loadable, FORCE_REFRESH_NOTIFIER, FORCE_REFRESH_SECONDS } fr
|
|
|
9
9
|
export { default as GTMTracker } from './utils/gtmTracker';
|
|
10
10
|
export { default as compileHandlebars } from './utils/compileHandlebars';
|
|
11
11
|
export { default as sanitizeTemplateWithRegexp } from "./utils/contentSanitizationHelper";
|
|
12
|
+
export { default as decompressJsonObject } from "./utils/zlibDataDecompress";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capillarytech/cap-ui-utils",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4-alpha.0",
|
|
4
4
|
"description": "Utility functions shared accross all the modules",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,12 +8,15 @@
|
|
|
8
8
|
},
|
|
9
9
|
"author": "Rajshekar",
|
|
10
10
|
"dependencies": {
|
|
11
|
+
"base64-js": "1.5.1",
|
|
12
|
+
"buffer": "^6.0.3",
|
|
13
|
+
"handlebars": "4.0.11",
|
|
14
|
+
"lodash": "4.17.11",
|
|
15
|
+
"moment-timezone": "^0.5.25",
|
|
16
|
+
"pako": "^2.1.0",
|
|
11
17
|
"react": "^18.2.0",
|
|
12
18
|
"react-ga": "^3.3.1",
|
|
13
|
-
"tti-polyfill": "^0.2.2",
|
|
14
|
-
"moment-timezone": "^0.5.25",
|
|
15
19
|
"react-intl": "6.6.6",
|
|
16
|
-
"
|
|
17
|
-
"handlebars": "4.0.11"
|
|
20
|
+
"tti-polyfill": "^0.2.2"
|
|
18
21
|
}
|
|
19
22
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import pako from "pako";
|
|
2
|
+
import base64 from "base64-js";
|
|
3
|
+
import { Buffer } from "buffer";
|
|
4
|
+
|
|
5
|
+
const decompressData = (data) => {
|
|
6
|
+
return pako.ungzip(data, { to: "string" });
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
// Function to decode base64 to buffer
|
|
10
|
+
function decodeBase64(base64String) {
|
|
11
|
+
return Buffer.from(base64.toByteArray(base64String));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Function to decompress base64-encoded compressed JSON string
|
|
15
|
+
const decompressJsonObject = (base64Compressed) => {
|
|
16
|
+
// Decode the base64 string to buffer
|
|
17
|
+
if (base64Compressed && typeof base64Compressed === "string") {
|
|
18
|
+
const compressedBuffer = decodeBase64(base64Compressed);
|
|
19
|
+
// Decompress the buffer
|
|
20
|
+
const decompressedBuffer = decompressData(compressedBuffer);
|
|
21
|
+
// Parse decompressedBuffer to object
|
|
22
|
+
const jsonObject = JSON.parse(decompressedBuffer);
|
|
23
|
+
return jsonObject;
|
|
24
|
+
}
|
|
25
|
+
return base64Compressed;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default decompressJsonObject;
|