I use JsZip and exceljs packages. ExcelJs can write excel doc to node.js stream, jszip can read file from stream and add it to archive. How I can make stream-transfer between it for convenient working with it? I make this solution, but I think its bad crutch...
const stream2 = new Writable();
stream2.result = [];
stream2._write = function (chunk, enc, next) {
this.result.push(chunk);
next();
};
const stream1 = new Readable();
stream1._read = function () {
stream1.push(stream2.result.shift() || null);
};
let promise = new Promise((resolve, reject) => {
excelDoc.write(stream2).then(() => {
zip.file('excelDoc.xlsx', stream1);
resolve(true);
});
});