@naturalcycles/nodejs-lib 12.61.0 → 12.62.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/dist/util/zip.util.d.ts +9 -9
- package/dist/util/zip.util.js +21 -23
- package/package.json +1 -1
- package/src/util/zip.util.ts +19 -21
package/dist/util/zip.util.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ZlibOptions } from 'zlib';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* deflateBuffer uses `deflate`.
|
|
5
5
|
* It's 9 bytes shorter than `gzip`.
|
|
6
6
|
*/
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function deflateBuffer(buf: Buffer, options?: ZlibOptions): Promise<Buffer>;
|
|
8
|
+
export declare function inflateBuffer(buf: Buffer, options?: ZlibOptions): Promise<Buffer>;
|
|
9
|
+
/**
|
|
10
|
+
* deflateString uses `deflate`.
|
|
11
|
+
* It's 9 bytes shorter than `gzip`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function deflateString(s: string, options?: ZlibOptions): Promise<Buffer>;
|
|
14
|
+
export declare function inflateToString(buf: Buffer, options?: ZlibOptions): Promise<string>;
|
|
8
15
|
/**
|
|
9
16
|
* gzipBuffer uses `gzip`
|
|
10
17
|
* It's 9 bytes longer than `deflate`.
|
|
11
18
|
*/
|
|
12
19
|
export declare function gzipBuffer(buf: Buffer, options?: ZlibOptions): Promise<Buffer>;
|
|
13
|
-
export declare function unzipBuffer(buf: Buffer, options?: ZlibOptions): Promise<Buffer>;
|
|
14
20
|
export declare function gunzipBuffer(buf: Buffer, options?: ZlibOptions): Promise<Buffer>;
|
|
15
|
-
/**
|
|
16
|
-
* zipString uses `deflate`.
|
|
17
|
-
* It's 9 bytes shorter than `gzip`.
|
|
18
|
-
*/
|
|
19
|
-
export declare function zipString(s: string, options?: ZlibOptions): Promise<Buffer>;
|
|
20
21
|
/**
|
|
21
22
|
* gzipString uses `gzip`.
|
|
22
23
|
* It's 9 bytes longer than `deflate`.
|
|
23
24
|
*/
|
|
24
25
|
export declare function gzipString(s: string, options?: ZlibOptions): Promise<Buffer>;
|
|
25
|
-
export declare function unzipToString(buf: Buffer, options?: ZlibOptions): Promise<string>;
|
|
26
26
|
export declare function gunzipToString(buf: Buffer, options?: ZlibOptions): Promise<string>;
|
package/dist/util/zip.util.js
CHANGED
|
@@ -1,21 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gunzipToString = exports.
|
|
3
|
+
exports.gunzipToString = exports.gzipString = exports.gunzipBuffer = exports.gzipBuffer = exports.inflateToString = exports.deflateString = exports.inflateBuffer = exports.deflateBuffer = void 0;
|
|
4
4
|
const util_1 = require("util");
|
|
5
5
|
const zlib = require("zlib");
|
|
6
6
|
const deflate = (0, util_1.promisify)(zlib.deflate.bind(zlib));
|
|
7
7
|
const inflate = (0, util_1.promisify)(zlib.inflate.bind(zlib));
|
|
8
8
|
const gzip = (0, util_1.promisify)(zlib.gzip.bind(zlib));
|
|
9
9
|
const gunzip = (0, util_1.promisify)(zlib.gunzip.bind(zlib));
|
|
10
|
-
// string >
|
|
10
|
+
// string > compressed buffer
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* deflateBuffer uses `deflate`.
|
|
13
13
|
* It's 9 bytes shorter than `gzip`.
|
|
14
14
|
*/
|
|
15
|
-
async function
|
|
15
|
+
async function deflateBuffer(buf, options = {}) {
|
|
16
16
|
return await deflate(buf, options);
|
|
17
17
|
}
|
|
18
|
-
exports.
|
|
18
|
+
exports.deflateBuffer = deflateBuffer;
|
|
19
|
+
async function inflateBuffer(buf, options = {}) {
|
|
20
|
+
return await inflate(buf, options);
|
|
21
|
+
}
|
|
22
|
+
exports.inflateBuffer = inflateBuffer;
|
|
23
|
+
/**
|
|
24
|
+
* deflateString uses `deflate`.
|
|
25
|
+
* It's 9 bytes shorter than `gzip`.
|
|
26
|
+
*/
|
|
27
|
+
async function deflateString(s, options) {
|
|
28
|
+
return await deflateBuffer(Buffer.from(s), options);
|
|
29
|
+
}
|
|
30
|
+
exports.deflateString = deflateString;
|
|
31
|
+
async function inflateToString(buf, options) {
|
|
32
|
+
return (await inflateBuffer(buf, options)).toString();
|
|
33
|
+
}
|
|
34
|
+
exports.inflateToString = inflateToString;
|
|
19
35
|
/**
|
|
20
36
|
* gzipBuffer uses `gzip`
|
|
21
37
|
* It's 9 bytes longer than `deflate`.
|
|
@@ -24,23 +40,10 @@ async function gzipBuffer(buf, options = {}) {
|
|
|
24
40
|
return await gzip(buf, options);
|
|
25
41
|
}
|
|
26
42
|
exports.gzipBuffer = gzipBuffer;
|
|
27
|
-
// zip > buffer
|
|
28
|
-
async function unzipBuffer(buf, options = {}) {
|
|
29
|
-
return await inflate(buf, options);
|
|
30
|
-
}
|
|
31
|
-
exports.unzipBuffer = unzipBuffer;
|
|
32
43
|
async function gunzipBuffer(buf, options = {}) {
|
|
33
44
|
return await gunzip(buf, options);
|
|
34
45
|
}
|
|
35
46
|
exports.gunzipBuffer = gunzipBuffer;
|
|
36
|
-
/**
|
|
37
|
-
* zipString uses `deflate`.
|
|
38
|
-
* It's 9 bytes shorter than `gzip`.
|
|
39
|
-
*/
|
|
40
|
-
async function zipString(s, options) {
|
|
41
|
-
return await zipBuffer(Buffer.from(s), options);
|
|
42
|
-
}
|
|
43
|
-
exports.zipString = zipString;
|
|
44
47
|
/**
|
|
45
48
|
* gzipString uses `gzip`.
|
|
46
49
|
* It's 9 bytes longer than `deflate`.
|
|
@@ -49,11 +52,6 @@ async function gzipString(s, options) {
|
|
|
49
52
|
return await gzipBuffer(Buffer.from(s), options);
|
|
50
53
|
}
|
|
51
54
|
exports.gzipString = gzipString;
|
|
52
|
-
// convenience
|
|
53
|
-
async function unzipToString(buf, options) {
|
|
54
|
-
return (await unzipBuffer(buf, options)).toString();
|
|
55
|
-
}
|
|
56
|
-
exports.unzipToString = unzipToString;
|
|
57
55
|
async function gunzipToString(buf, options) {
|
|
58
56
|
return (await gunzipBuffer(buf, options)).toString();
|
|
59
57
|
}
|
package/package.json
CHANGED
package/src/util/zip.util.ts
CHANGED
|
@@ -7,16 +7,32 @@ const inflate = promisify(zlib.inflate.bind(zlib))
|
|
|
7
7
|
const gzip = promisify(zlib.gzip.bind(zlib))
|
|
8
8
|
const gunzip = promisify(zlib.gunzip.bind(zlib))
|
|
9
9
|
|
|
10
|
-
// string >
|
|
10
|
+
// string > compressed buffer
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* deflateBuffer uses `deflate`.
|
|
14
14
|
* It's 9 bytes shorter than `gzip`.
|
|
15
15
|
*/
|
|
16
|
-
export async function
|
|
16
|
+
export async function deflateBuffer(buf: Buffer, options: ZlibOptions = {}): Promise<Buffer> {
|
|
17
17
|
return await deflate(buf, options)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
export async function inflateBuffer(buf: Buffer, options: ZlibOptions = {}): Promise<Buffer> {
|
|
21
|
+
return await inflate(buf, options)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* deflateString uses `deflate`.
|
|
26
|
+
* It's 9 bytes shorter than `gzip`.
|
|
27
|
+
*/
|
|
28
|
+
export async function deflateString(s: string, options?: ZlibOptions): Promise<Buffer> {
|
|
29
|
+
return await deflateBuffer(Buffer.from(s), options)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function inflateToString(buf: Buffer, options?: ZlibOptions): Promise<string> {
|
|
33
|
+
return (await inflateBuffer(buf, options)).toString()
|
|
34
|
+
}
|
|
35
|
+
|
|
20
36
|
/**
|
|
21
37
|
* gzipBuffer uses `gzip`
|
|
22
38
|
* It's 9 bytes longer than `deflate`.
|
|
@@ -25,23 +41,10 @@ export async function gzipBuffer(buf: Buffer, options: ZlibOptions = {}): Promis
|
|
|
25
41
|
return await gzip(buf, options)
|
|
26
42
|
}
|
|
27
43
|
|
|
28
|
-
// zip > buffer
|
|
29
|
-
export async function unzipBuffer(buf: Buffer, options: ZlibOptions = {}): Promise<Buffer> {
|
|
30
|
-
return await inflate(buf, options)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
44
|
export async function gunzipBuffer(buf: Buffer, options: ZlibOptions = {}): Promise<Buffer> {
|
|
34
45
|
return await gunzip(buf, options)
|
|
35
46
|
}
|
|
36
47
|
|
|
37
|
-
/**
|
|
38
|
-
* zipString uses `deflate`.
|
|
39
|
-
* It's 9 bytes shorter than `gzip`.
|
|
40
|
-
*/
|
|
41
|
-
export async function zipString(s: string, options?: ZlibOptions): Promise<Buffer> {
|
|
42
|
-
return await zipBuffer(Buffer.from(s), options)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
48
|
/**
|
|
46
49
|
* gzipString uses `gzip`.
|
|
47
50
|
* It's 9 bytes longer than `deflate`.
|
|
@@ -50,11 +53,6 @@ export async function gzipString(s: string, options?: ZlibOptions): Promise<Buff
|
|
|
50
53
|
return await gzipBuffer(Buffer.from(s), options)
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
// convenience
|
|
54
|
-
export async function unzipToString(buf: Buffer, options?: ZlibOptions): Promise<string> {
|
|
55
|
-
return (await unzipBuffer(buf, options)).toString()
|
|
56
|
-
}
|
|
57
|
-
|
|
58
56
|
export async function gunzipToString(buf: Buffer, options?: ZlibOptions): Promise<string> {
|
|
59
57
|
return (await gunzipBuffer(buf, options)).toString()
|
|
60
58
|
}
|