index.js 584 B

1234567891011121314151617181920
  1. 'use strict';
  2. var gzipSize = require('gzip-size');
  3. var prettyBytes = require('pretty-bytes');
  4. var chalk = require('chalk');
  5. var figures = require('figures');
  6. var arrow = ' ' + figures.arrowRight + ' ';
  7. function format(size) {
  8. return chalk.green(prettyBytes(size));
  9. }
  10. module.exports = function (max, min, useGzip) {
  11. var ret = format(typeof max === 'number' ? max : max.length) + arrow + format(typeof min === 'number' ? min : min.length);
  12. if (useGzip === true && typeof min !== 'number') {
  13. ret += arrow + format(gzipSize.sync(min)) + chalk.gray(' (gzip)');
  14. }
  15. return ret;
  16. };