mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-09-24 04:53:31 +08:00
编排分类调整
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
const quickcomposer = {
|
||||
text: require("./quickcomposer/text"),
|
||||
data: require("./quickcomposer/data"),
|
||||
simulate: require("./quickcomposer/simulate"),
|
||||
file: require("./quickcomposer/file"),
|
||||
system: require("./quickcomposer/system"),
|
||||
network: require("./quickcomposer/network"),
|
||||
developer: require("./quickcomposer/developer"),
|
||||
};
|
||||
|
||||
module.exports = quickcomposer;
|
||||
|
@@ -2,10 +2,14 @@ const encoder = require("./encoder");
|
||||
const hash = require("./hash");
|
||||
const string = require("./string");
|
||||
const crypto = require("./crypto");
|
||||
const buffer = require("./buffer");
|
||||
const zlib = require("./zlib");
|
||||
|
||||
module.exports = {
|
||||
...encoder,
|
||||
...hash,
|
||||
...string,
|
||||
...crypto,
|
||||
buffer,
|
||||
zlib,
|
||||
};
|
@@ -1,3 +0,0 @@
|
||||
module.exports = {
|
||||
buffer: require("./buffer"),
|
||||
};
|
@@ -1,7 +1,5 @@
|
||||
const operation = require("./operation");
|
||||
const zlib = require("./zlib");
|
||||
|
||||
module.exports = {
|
||||
operation: operation.operation,
|
||||
zlib: zlib,
|
||||
};
|
||||
|
@@ -1,75 +0,0 @@
|
||||
const zlib = require("zlib");
|
||||
const { promisify } = require("util");
|
||||
|
||||
// 压缩方法
|
||||
const gzip = promisify(zlib.gzip);
|
||||
const deflate = promisify(zlib.deflate);
|
||||
const brotliCompress = promisify(zlib.brotliCompress);
|
||||
|
||||
// 解压方法
|
||||
const gunzip = promisify(zlib.gunzip);
|
||||
const inflate = promisify(zlib.inflate);
|
||||
const brotliDecompress = promisify(zlib.brotliDecompress);
|
||||
|
||||
// 压缩选项
|
||||
const defaultGzipOptions = {
|
||||
level: zlib.constants.Z_DEFAULT_COMPRESSION,
|
||||
memLevel: zlib.constants.Z_DEFAULT_MEMLEVEL,
|
||||
strategy: zlib.constants.Z_DEFAULT_STRATEGY,
|
||||
};
|
||||
|
||||
const defaultBrotliOptions = {
|
||||
params: {
|
||||
[zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_GENERIC,
|
||||
[zlib.constants.BROTLI_PARAM_QUALITY]:
|
||||
zlib.constants.BROTLI_DEFAULT_QUALITY,
|
||||
[zlib.constants.BROTLI_PARAM_SIZE_HINT]: 0,
|
||||
},
|
||||
};
|
||||
|
||||
// 异步压缩函数
|
||||
async function compressData(data, method, options = {}) {
|
||||
try {
|
||||
const buffer = Buffer.from(data);
|
||||
switch (method) {
|
||||
case "gzip":
|
||||
return await gzip(buffer, { ...defaultGzipOptions, ...options });
|
||||
case "deflate":
|
||||
return await deflate(buffer, { ...defaultGzipOptions, ...options });
|
||||
case "brotli":
|
||||
return await brotliCompress(buffer, {
|
||||
...defaultBrotliOptions,
|
||||
...options,
|
||||
});
|
||||
default:
|
||||
throw new Error("不支持的压缩方法");
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error(`压缩失败: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// 异步解压函数
|
||||
async function decompressData(data, method, options = {}) {
|
||||
try {
|
||||
const buffer = Buffer.from(data);
|
||||
switch (method) {
|
||||
case "gzip":
|
||||
return await gunzip(buffer, options);
|
||||
case "deflate":
|
||||
return await inflate(buffer, options);
|
||||
case "brotli":
|
||||
return await brotliDecompress(buffer, options);
|
||||
default:
|
||||
throw new Error("不支持的解压方法");
|
||||
}
|
||||
} catch (error) {
|
||||
throw new Error(`解压失败: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
compressData,
|
||||
decompressData,
|
||||
constants: zlib.constants,
|
||||
};
|
@@ -1 +0,0 @@
|
||||
module.exports = require("../file/zlib");
|
Reference in New Issue
Block a user