UNPKG

648 BJavaScriptView Raw
1/*
2 Copyright 2018 Google LLC
3
4 Use of this source code is governed by an MIT-style
5 license that can be found in the LICENSE file or at
6 https://opensource.org/licenses/MIT.
7*/
8
9const crypto = require('crypto');
10
11module.exports = (compositeURL, dependencyDetails) => {
12 let totalSize = 0;
13 let compositeHash = '';
14
15 for (let fileDetails of dependencyDetails) {
16 totalSize += fileDetails.size;
17 compositeHash += fileDetails.hash;
18 }
19
20 const md5 = crypto.createHash('md5');
21 md5.update(compositeHash);
22 const hashOfHashes = md5.digest('hex');
23
24 return {
25 file: compositeURL,
26 hash: hashOfHashes,
27 size: totalSize,
28 };
29};