Refactored manifest creation to use Object.entries

This commit is contained in:
Alexander Cerutti
2021-06-19 20:14:41 +02:00
parent 202e227b3d
commit 8366c63c8c

View File

@@ -268,15 +268,17 @@ export class Pass {
* and returning the compiled manifest * and returning the compiled manifest
*/ */
const archive = new ZipFile(); const archive = new ZipFile();
const manifest = Object.keys(finalBundle).reduce<Schemas.Manifest>( const manifest = Object.entries(finalBundle).reduce<Schemas.Manifest>(
(acc, current) => { (acc, [fileName, buffer]) => {
let hashFlow = forge.md.sha1.create(); let hashFlow = forge.md.sha1.create();
hashFlow.update(finalBundle[current].toString("binary")); hashFlow.update(buffer.toString("binary"));
archive.addBuffer(finalBundle[current], current); archive.addBuffer(buffer, fileName);
acc[current] = hashFlow.digest().toHex();
return acc; return {
...acc,
[fileName]: hashFlow.digest().toHex(),
};
}, },
{}, {},
); );