Skip to content

Commit

Permalink
✨ [feature] 添加默认排序根据base version大小降序
Browse files Browse the repository at this point in the history
  • Loading branch information
lanjingling0510 committed May 19, 2017
1 parent cf08b79 commit ec9afd5
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions src/azer-compare.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,26 @@ async function analyzeBundles() {
value => value.thunk + value.ext,
);

const analyzeList = allKeys.map(key => {
const base = groupBaseBundle[key] || [];
const compare = groupCompareBundle[key] || [];
const baseSize = base.reduce((a, b) => a + b.size, 0);
const compareSize = compare.reduce((a, b) => a + b.size, 0);
const gzipBaseSize = base.reduce((a, b) => a + b.gzipSize, 0);
const gzipCompareSize = compare.reduce((a, b) => a + b.gzipSize, 0);
return {
key,
base,
compare,
baseSize,
compareSize,
rankSize: baseSize - compareSize,
gzipBaseSize: gzipBaseSize,
gzipRankSize: gzipBaseSize - gzipCompareSize,
};
});
const analyzeList = _.chain(allKeys)
.map(key => {
const base = groupBaseBundle[key] || [];
const compare = groupCompareBundle[key] || [];
const baseSize = base.reduce((a, b) => a + b.size, 0);
const compareSize = compare.reduce((a, b) => a + b.size, 0);
const gzipBaseSize = base.reduce((a, b) => a + b.gzipSize, 0);
const gzipCompareSize = compare.reduce((a, b) => a + b.gzipSize, 0);
return {
key,
base,
compare,
baseSize,
compareSize,
rankSize: baseSize - compareSize,
gzipBaseSize: gzipBaseSize,
gzipRankSize: gzipBaseSize - gzipCompareSize,
};
})
.sortBy(item => - item.baseSize);

return analyzeList;
}
Expand Down

0 comments on commit ec9afd5

Please sign in to comment.