Нет описания

123456789101112131415161718192021222324
  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. if (max == null || min == null) {
  12. throw new Error('`max` and `min` required');
  13. }
  14. var ret = format(typeof max === 'number' ? max : max.length) + arrow + format(typeof min === 'number' ? min : min.length);
  15. if (useGzip === true && typeof min !== 'number') {
  16. ret += arrow + format(gzipSize.sync(min)) + chalk.gray(' (gzip)');
  17. }
  18. return ret;
  19. };