@naturalcycles/nodejs-lib 15.92.1 → 15.93.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/zip/zip.util.d.ts +3 -0
- package/dist/zip/zip.util.js +10 -0
- package/package.json +1 -1
- package/src/zip/zip.util.ts +16 -0
package/dist/zip/zip.util.d.ts
CHANGED
|
@@ -31,8 +31,11 @@ export declare function gunzipBuffer(buf: Buffer, options?: ZlibOptions): Promis
|
|
|
31
31
|
export declare function gzipString(s: string, options?: ZlibOptions): Promise<Buffer<ArrayBuffer>>;
|
|
32
32
|
export declare function gunzipToString(buf: Buffer, options?: ZlibOptions): Promise<string>;
|
|
33
33
|
export declare function zstdCompress(input: Buffer | string, level?: Integer, options?: ZstdOptions): Promise<Buffer<ArrayBuffer>>;
|
|
34
|
+
export declare function zstdCompressSync(input: Buffer | string, level?: Integer, options?: ZstdOptions): Buffer<ArrayBuffer>;
|
|
34
35
|
export declare function zstdLevelToOptions(level: Integer | undefined, opt?: ZstdOptions): ZstdOptions;
|
|
35
36
|
export declare function zstdDecompressToString(input: Buffer, options?: ZstdOptions): Promise<string>;
|
|
36
37
|
export declare function zstdDecompress(input: Buffer, options?: ZstdOptions): Promise<Buffer<ArrayBuffer>>;
|
|
38
|
+
export declare function zstdDecompressToStringSync(input: Buffer, options?: ZstdOptions): string;
|
|
39
|
+
export declare function zstdDecompressSync(input: Buffer, options?: ZstdOptions): Buffer<ArrayBuffer>;
|
|
37
40
|
export declare function isZstdBuffer(input: Buffer): boolean;
|
|
38
41
|
export declare function isGzipBuffer(input: Buffer): boolean;
|
package/dist/zip/zip.util.js
CHANGED
|
@@ -63,6 +63,10 @@ export async function zstdCompress(input, level, // defaults to 3
|
|
|
63
63
|
options = {}) {
|
|
64
64
|
return await zstdCompressAsync(input, zstdLevelToOptions(level, options));
|
|
65
65
|
}
|
|
66
|
+
export function zstdCompressSync(input, level, // defaults to 3
|
|
67
|
+
options = {}) {
|
|
68
|
+
return zlib.zstdCompressSync(input, zstdLevelToOptions(level, options));
|
|
69
|
+
}
|
|
66
70
|
export function zstdLevelToOptions(level, opt = {}) {
|
|
67
71
|
if (!level)
|
|
68
72
|
return opt;
|
|
@@ -80,6 +84,12 @@ export async function zstdDecompressToString(input, options = {}) {
|
|
|
80
84
|
export async function zstdDecompress(input, options = {}) {
|
|
81
85
|
return await zstdDecompressAsync(input, options);
|
|
82
86
|
}
|
|
87
|
+
export function zstdDecompressToStringSync(input, options = {}) {
|
|
88
|
+
return zlib.zstdDecompressSync(input, options).toString();
|
|
89
|
+
}
|
|
90
|
+
export function zstdDecompressSync(input, options = {}) {
|
|
91
|
+
return zlib.zstdDecompressSync(input, options);
|
|
92
|
+
}
|
|
83
93
|
const ZSTD_MAGIC_NUMBER = 0xfd2fb528;
|
|
84
94
|
export function isZstdBuffer(input) {
|
|
85
95
|
return input.readUInt32LE(0) === ZSTD_MAGIC_NUMBER;
|
package/package.json
CHANGED
package/src/zip/zip.util.ts
CHANGED
|
@@ -96,6 +96,14 @@ export async function zstdCompress(
|
|
|
96
96
|
return await zstdCompressAsync(input, zstdLevelToOptions(level, options))
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
export function zstdCompressSync(
|
|
100
|
+
input: Buffer | string,
|
|
101
|
+
level?: Integer, // defaults to 3
|
|
102
|
+
options: ZstdOptions = {},
|
|
103
|
+
): Buffer<ArrayBuffer> {
|
|
104
|
+
return zlib.zstdCompressSync(input, zstdLevelToOptions(level, options))
|
|
105
|
+
}
|
|
106
|
+
|
|
99
107
|
export function zstdLevelToOptions(level: Integer | undefined, opt: ZstdOptions = {}): ZstdOptions {
|
|
100
108
|
if (!level) return opt
|
|
101
109
|
|
|
@@ -122,6 +130,14 @@ export async function zstdDecompress(
|
|
|
122
130
|
return await zstdDecompressAsync(input, options)
|
|
123
131
|
}
|
|
124
132
|
|
|
133
|
+
export function zstdDecompressToStringSync(input: Buffer, options: ZstdOptions = {}): string {
|
|
134
|
+
return zlib.zstdDecompressSync(input, options).toString()
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function zstdDecompressSync(input: Buffer, options: ZstdOptions = {}): Buffer<ArrayBuffer> {
|
|
138
|
+
return zlib.zstdDecompressSync(input, options)
|
|
139
|
+
}
|
|
140
|
+
|
|
125
141
|
const ZSTD_MAGIC_NUMBER = 0xfd2fb528
|
|
126
142
|
|
|
127
143
|
export function isZstdBuffer(input: Buffer): boolean {
|