vite-plugin-singlefile-compression 2.0.6 → 2.0.7
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/compress.js +8 -5
- package/package.json +1 -1
package/dist/compress.js
CHANGED
|
@@ -17,12 +17,15 @@ const compressors = {
|
|
|
17
17
|
zstd: zlib.zstdCompressSync,
|
|
18
18
|
};
|
|
19
19
|
function switchCompressor(format) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
throw Error(`Could not get compressor:
|
|
24
|
-
|
|
20
|
+
if (!Object.prototype.hasOwnProperty.call(compressors, format)) {
|
|
21
|
+
const f = zlib[format + 'CompressSync'];
|
|
22
|
+
if (!f)
|
|
23
|
+
throw Error(`Could not get compressor: Unknown compress format '${format}', please set your compressor function.`);
|
|
24
|
+
return f;
|
|
25
25
|
}
|
|
26
|
+
const f = compressors[format];
|
|
27
|
+
if (!f)
|
|
28
|
+
throw Error(`Could not get compressor: Please upgrade node.js or set your compressor function.`);
|
|
26
29
|
return f;
|
|
27
30
|
}
|
|
28
31
|
export function compress(format, buf, useBase128, compressor) {
|