liudong
2023-05-29 340f156319b863525e50e900c58e59b86ecb3d5e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
'use strict';
const gzipSize = require('gzip-size');
const prettyBytes = require('pretty-bytes');
const chalk = require('chalk');
const figures = require('figures');
const arrow = ' ' + figures.arrowRight + ' ';
 
const format = size => chalk.green(prettyBytes(size));
 
module.exports = function (max, min, useGzip = false) {
    const maxString = format(typeof max === 'number' ? max : max.length);
    const minString = format(typeof min === 'number' ? min : min.length);
    let returnValue = maxString + arrow + minString;
 
    if (useGzip && typeof min !== 'number') {
        returnValue += arrow + format(gzipSize.sync(min)) + chalk.gray(' (gzip)');
    }
 
    return returnValue;
};