etcher-sdk
Version:
30 lines • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.cleanupParts = exports.getGzipSizeFromParts = exports.createGzipStreamFromParts = void 0;
const gzip_stream_1 = require("gzip-stream");
const node_stream_1 = require("node:stream");
const createGzipStreamFromParts = (parts) => {
if (parts.length !== 1) {
throw new Error('Using gzip is only supported for sources with a single part');
}
return (0, gzip_stream_1.createGzipFromParts)(parts[0].parts);
};
exports.createGzipStreamFromParts = createGzipStreamFromParts;
const getGzipSizeFromParts = (parts) => {
if (parts.length !== 1) {
throw new Error('Using gzip is only supported for sources with a single part');
}
return (0, gzip_stream_1.getGzipSizeFromParts)(parts[0].parts);
};
exports.getGzipSizeFromParts = getGzipSizeFromParts;
const cleanupParts = function (partsByImage) {
for (const part of partsByImage) {
for (const { stream } of part.parts) {
if (stream instanceof node_stream_1.Stream && !stream.destroyed) {
stream.destroy();
}
}
}
};
exports.cleanupParts = cleanupParts;
//# sourceMappingURL=compressed-source-utils.js.map