@contrail/util 1.1.9-alpha-1 → 1.1.9-alpha-2

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.
@@ -4,12 +4,20 @@ exports.decompressFromString = exports.compressIntoString = void 0;
4
4
  const fflate_1 = require("fflate");
5
5
  function compressIntoString(obj) {
6
6
  const jsonStr = JSON.stringify(obj === undefined ? null : obj);
7
+ if (typeof Buffer === 'undefined') {
8
+ console.warn('Buffer is not available. Compression will be skipped.');
9
+ return jsonStr;
10
+ }
7
11
  const buffer = new TextEncoder().encode(jsonStr);
8
12
  const compressed = (0, fflate_1.compressSync)(buffer);
9
13
  return Buffer.from(compressed).toString('base64');
10
14
  }
11
15
  exports.compressIntoString = compressIntoString;
12
16
  function decompressFromString(str) {
17
+ if (typeof Buffer === 'undefined') {
18
+ console.warn('Buffer is not available. Decompression will be skipped. Returning original string.');
19
+ return str;
20
+ }
13
21
  const compressed = Buffer.from(str, 'base64');
14
22
  const decompressed = (0, fflate_1.decompressSync)(compressed);
15
23
  const originalText = new TextDecoder().decode(decompressed);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/util",
3
- "version": "1.1.9-alpha-1",
3
+ "version": "1.1.9-alpha-2",
4
4
  "description": "General javascript utilities",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -39,6 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@contrail/types": "^3.0.95",
42
+ "@contrail/util": "^1.1.9-alpha-1",
42
43
  "fflate": "^0.8.2",
43
44
  "lodash": "^4.17.21"
44
45
  }