backoffice/node_modules/maxmin/index.js

23 lines
505 B
JavaScript
Raw Normal View History

2020-02-06 10:09:39 +00:00
'use strict';
var gzipSize = require('gzip-size');
var prettyBytes = require('pretty-bytes');
var chalk = require('chalk');
function format(size) {
return chalk.green(prettyBytes(size));
}
module.exports = function (max, min, useGzip) {
if (max == null || min == null) {
throw new Error('`max` and `min` required');
}
var ret = format(max.length) + ' → ' + format(min.length);
if (useGzip === true) {
ret += ' → ' + format(gzipSize.sync(min)) + chalk.gray(' (gzip)');
}
return ret;
};