@contrail/util 1.1.5-alpha-compression-1 → 1.1.5-alpha.1
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.
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.decompressBuffer = exports.convertBase64ToBuffer = exports.convertBufferToBase64 = exports.compressObjectIntoBuffer = exports.decompressFromBase64 = exports.compressToBase64 = void 0;
|
|
13
|
-
const
|
|
13
|
+
const zlib = require('zlib');
|
|
14
14
|
function compressToBase64(obj) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
return compressObjectIntoBuffer(obj).then((buffer) => convertBufferToBase64(buffer));
|
|
@@ -27,7 +27,7 @@ exports.decompressFromBase64 = decompressFromBase64;
|
|
|
27
27
|
function compressObjectIntoBuffer(obj) {
|
|
28
28
|
const json = obj === undefined ? JSON.stringify(null) : JSON.stringify(obj);
|
|
29
29
|
return new Promise((resolve, reject) => {
|
|
30
|
-
|
|
30
|
+
zlib.gzip(json, (err, buffer) => {
|
|
31
31
|
if (err)
|
|
32
32
|
reject(err);
|
|
33
33
|
else
|
|
@@ -46,7 +46,7 @@ function convertBase64ToBuffer(base64) {
|
|
|
46
46
|
exports.convertBase64ToBuffer = convertBase64ToBuffer;
|
|
47
47
|
function decompressBuffer(buffer) {
|
|
48
48
|
return new Promise((resolve, reject) => {
|
|
49
|
-
|
|
49
|
+
zlib.gunzip(buffer, (err, result) => {
|
|
50
50
|
if (err)
|
|
51
51
|
reject(err);
|
|
52
52
|
else
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrail/util",
|
|
3
|
-
"version": "1.1.5-alpha
|
|
3
|
+
"version": "1.1.5-alpha.1",
|
|
4
4
|
"description": "General javascript utilities",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"testEnvironment": "node"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@contrail/types": "^3.0.
|
|
41
|
+
"@contrail/types": "^3.0.95",
|
|
42
42
|
"lodash": "^4.17.21"
|
|
43
43
|
}
|
|
44
44
|
}
|