maxcso
Version:
💿 maxcso binaries and wrapper for Node.js.
54 lines • 2.75 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import MaxcsoBin from './maxcsoBin.js';
import MaxcsoInfo from './maxcsoInfo.js';
export var CompressFormat;
(function (CompressFormat) {
CompressFormat["CSO_V1"] = "cso1";
CompressFormat["CSO_V2"] = "cso2";
CompressFormat["ZSO"] = "zso";
CompressFormat["DAX"] = "dax";
})(CompressFormat || (CompressFormat = {}));
export var CompressMethod;
(function (CompressMethod) {
CompressMethod["ZLIB"] = "zlib";
CompressMethod["ZOPFLI"] = "zopfli";
CompressMethod["7ZDEFLATE"] = "7zdeflate";
CompressMethod["LZ4"] = "lz4";
CompressMethod["LZ4_BRUTE"] = "lz4brute";
CompressMethod["LIBDEFLATE"] = "libdeflate";
})(CompressMethod || (CompressMethod = {}));
export default {
compress(options) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
yield MaxcsoBin.run([
...(options.threads === undefined ? [] : [`--threads=${options.threads}`]),
...(options.fast === true ? ['--fast'] : []),
...(options.blockSize === undefined ? [] : [`--block=${options.blockSize}`]),
...(options.format === undefined ? [] : [`--format=${options.format}`]),
...((_a = options.tryMethods) !== null && _a !== void 0 ? _a : []).map((m) => `--use-${m}`),
...(options.method === undefined ? [] : [`--only-${options.method}`]),
...((_b = options.disableMethods) !== null && _b !== void 0 ? _b : []).map((m) => `--no-${m}`),
...(options.lz4Cost === undefined ? [] : [`--lz4-cost=${options.lz4Cost}`]),
...(options.originalCost === undefined ? [] : [`--orig-cost=${options.originalCost}`]),
options.inputFilename,
'-o', options.outputFilename,
], options);
try {
yield MaxcsoInfo.header(options.outputFilename);
}
catch (error) {
throw new Error(`created CSO is invalid: ${error}`);
}
});
},
};
//# sourceMappingURL=maxcsoCompress.js.map