How to use the gzip-size.stream 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 sindresorhus / gzip-size-cli / cli.js View on Github external
const [input] = cli.input;

if (!input && process.stdin.isTTY) {
	console.error('Specify a file path');
	process.exit(1);
}

const source = input ? fs.createReadStream(input) : process.stdin;

const options = {};
if (cli.flags.level) {
	options.level = Number(cli.flags.level);
}

source.pipe(gzipSize.stream(options)).on('gzip-size', size => {
	console.log(cli.flags.raw ? size : prettyBytes(size));
});
github srod / node-minify / packages / utils / src / utils.js View on Github external
return new Promise(resolve => {
    const source = fs.createReadStream(file);
    source.pipe(gzipSize.stream()).on('gzip-size', size => {
      resolve(utils.prettyBytes(size));
    });
  });
};
github sindresorhus / gulp-size / index.js View on Github external
return;
			}

			totalSize += size;

			if (options.showFiles === true && size > 0) {
				log(chalk.blue(file.relative), size);
			}

			fileCount++;
			callback(null, file);
		};

		if (file.isStream()) {
			if (options.gzip) {
				file.contents.pipe(gzipSize.stream())
					.on('error', finish)
					.on('end', function () {
						finish(null, this.gzipSize);
					});
			} else {
				file.contents.pipe(new StreamCounter())
					.on('error', finish)
					.on('finish', function () {
						finish(null, this.bytes);
					});
			}

			return;
		}

		if (options.gzip) {

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