私はJsZipとexceljsパッケージを使用しています。 ExcelJsはexcel docをnode.jsストリームに書き込むことができ、jszipはストリームからファイルを読み込み、アーカイブに追加することができます。私はどのようにそれとの間でストリーム転送を行うことができますそれとの便利な作業のために?私は、このソリューションを作るが、私はその悪い松葉杖...node.jsで転送ストリームを作成するにはどうすればよいですか?
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);
});
});