Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 3x 3x 3x 3x 5x 5x 5x 3x 3x 3x 3x 3x 9x 10x 9x 1x 8x 7x 6x 5x 4x 3x 3x 3x 3x 3x 3x | const c = require('chalk'); const _ = require('lodash/fp'); const bytes = require('bytes'); const syntheticView = stat => { const size = bytes(stat.size); const gzip = bytes(stat.gzip); return `${c.bold.underline(stat.name)} (${c.grey.dim(stat.version)}) has ${c.blue.bold( stat.dependencyCount )} dependencies for a weight of ${c.cyan.bold(size)} (${c.dim.bold(gzip)} gzipped)`; }; // TODO: later dynamic color + kilo printing + plural const jsonView = JSON.stringify; const sizeView = stat => stat.size; const gzipsizeView = stat => stat.gzip; const dependenciesView = stat => stat.dependencyCount; const getView = (argv = {}) => { const viewOpts = _.intersection( _.keys(argv).filter(key => argv[key]), ['json', 'gzip-size', 'size', 'dependencies'] ); if (_.size(viewOpts) > 1) throw new Error(`Can't use in the same time options ${[...viewOpts].sort().join(', ')}`); if (argv.json) return jsonView; if (argv['gzip-size']) return gzipsizeView; if (argv.size) return sizeView; if (argv.dependencies) return dependenciesView; return syntheticView; }; module.exports.syntheticView = syntheticView; module.exports.jsonView = jsonView; module.exports.sizeView = sizeView; module.exports.gzipsizeView = gzipsizeView; module.exports.dependenciesView = dependenciesView; module.exports.getView = getView; |