I want to access 'newEtag' variable value out of the scope of 'tap.on()' callback. I have tried it but it gives 'undefined'.
const gzip = zlib.createGzip();
const options = { partSize: 8 * 1024 * 1024, partCount: 4 };
const tap = createTapStream(options);
let newEtag;
tap.on('finish', async () => {
newEtag = tap.calculate();
});
stream.pipe(gzip).pipe(tap);
const uniqueItem = await this.uniqueDataTable.getItem({ Etag: newEtag });
if (uniqueItem !== undefined) {
return {
key,
versionId: uniqueItem.Etag,
};
}