How to use the gzip-size.fileSync function in gzip-size

To help you get started, we’ve selected a few gzip-size examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ngnjs / NGN / test / common / integration / 01-size.js View on Github external
test('Distribution File Sizes', function (t) {
  let filepath = require('path').resolve('./test/lib/ngn.min.js')
  let stats = require('fs').statSync(filepath)
  let uncompressedSize = (stats.size / 1000).toFixed(2)

  t.ok(uncompressedSize < 100, 'Uncompressed distributable file is under 100kb (' + (stats.size / 1000) + 'kb).')

  let compressedSize = (gzip.fileSync(filepath, { level: 9 }) / 1000).toFixed(2)
  t.ok(compressedSize < 30, 'Compressed (minified) distributable is under 30kb (' + compressedSize + 'kb)')

  t.end()
})
github mazipan / vue-currency-filter / check-size.js View on Github external
readDirs(path.resolve('./lib-out/'), async (filepath, filename) => {
    try {
      console.log(chalk.greenBright(`> ${filename}: ${bytes(gzipSize.fileSync(filepath))}`))
    } catch (err) {
      console.error(err)
    }
  }, (err) => {
    console.error(err)
github wagerfield / onno / stats.js View on Github external
return glob.sync(pattern).reduce((total, path) => {
    return total + gzipSize.fileSync(path)
  }, 0)
}
github gilbarbara / styled-minimal / tools / sizer.js View on Github external
    .reduce((acc, file) => acc + fileSync(resolve(path, file)), 0);
}
github auth0 / auth0-spa-js / scripts / print-bundle-size.js View on Github external
.forEach(f => {
    const path = `./dist/${f}`;
    table.push([
      f,
      toKb(fs.statSync(path).size),
      toKb(gzipSize.fileSync(path))
    ]);
  });
github Automattic / wp-calypso / bin / icfy-analyze.js View on Github external
function analyzeStylesheet( inputCSSFile, outputJSONFile ) {
	if ( ! existsSync( inputCSSFile ) ) {
		return;
	}
	const parsedSize = statSync( inputCSSFile ).size;
	const gzipSize = gzip.fileSync( inputCSSFile );
	const hash = hashFile( inputCSSFile );
	const styleStats = { statSize: parsedSize, parsedSize, gzipSize, hash };
	writeFileSync( outputJSONFile, JSON.stringify( styleStats, null, 2 ) );
}
github chialab / rna-cli / lib / File.js View on Github external
get size() {
        let sizes = {
            size: new Number(statSync(this.path).size),
            zipped: new Number(gzipSize.fileSync(this.path)),
        };

        function bytesToString() {
            let value = parseInt(Number.prototype.toString.call(this));
            return prettyBytes(value);
        }

        sizes.size.toString = bytesToString;
        sizes.zipped.toString = bytesToString;

        return sizes;
    }
github chialab / rna-cli / lib / file-size.js View on Github external
module.exports = function fileSize(file) {
    let stats = fs.statSync(file);
    if (stats.isDirectory()) {
        return fs.readdirSync(file)
            .map((child) => path.join(file, child))
            .filter((child) => fs.statSync(child).isFile())
            .map((child) => fileSize(child))
            .join('\n');
    }
    let size = fs.statSync(file).size;
    let gzip = gzipSize.fileSync(file);
    return `${path.relative(process.cwd(), file)} ${colors.grey(`(${prettyByte(size)}, ${prettyByte(gzip)} zipped)`)}`;
};

gzip-size

Get the gzipped size of a string or buffer

MIT
Latest version published 3 years ago

Package Health Score

73 / 100
Full package analysis