Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gzipper

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gzipper - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

43

Gzipper.js

@@ -43,6 +43,16 @@ const zlib = require('zlib')

this.compressionMechanism = zlib.createGzip({
level: this.options.gzipLevel || DEFAULT_GZIP_LEVEL,
memLevel: this.options.gzipMemoryLevel || DEFAULT_GZIP_MEMORY_LEVEL,
strategy: this.options.gzipStrategy || DEFAULT_GZIP_STRATEGY,
level:
this.options.gzipLevel !== undefined
? this.options.gzipLevel
: DEFAULT_GZIP_LEVEL,
memLevel:
this.options.gzipMemoryLevel !== undefined
? this.options.gzipMemoryLevel
: DEFAULT_GZIP_MEMORY_LEVEL,
strategy:
this.options.gzipStrategy !== undefined
? this.options.gzipStrategy
: DEFAULT_GZIP_STRATEGY,
})
this.selectCompressionMechanismLog()
}

@@ -126,6 +136,4 @@

if (callback) {
output.on(
'finish',
callback.bind(
this,
output.on('finish', () =>
callback(
fs.statSync(inputPath).size / 1024,

@@ -147,4 +155,25 @@ fs.statSync(outputPath).size / 1024

}
/**
* Show message with compression params.
*
* @memberof Gzipper
*/
selectCompressionMechanismLog() {
let compressionType,
optionsStr = '',
options = new Map([['level', '_level'], ['strategy', '_strategy']])
if (this.compressionMechanism instanceof zlib.Gzip) {
compressionType = 'GZIP'
}
for (const [key, value] of options) {
optionsStr += `${key}: ${this.compressionMechanism[value]}, `
}
this.logger.warn(`${compressionType} -> ${optionsStr.slice(0, -2)}`)
}
}
module.exports = Gzipper

@@ -12,11 +12,11 @@ #!/usr/bin/env node

.option(
'-gl, --gzip-level',
'-gl, --gzip-level [level]',
'gzip compression level 0 (no compression) - 9 (best compression)'
)
.option(
'-gm, --gzip-memory-level',
'-gm, --gzip-memory-level [memoryLevel]',
'amount of memory which will be allocated for compression 1 (minimum memory) - 9 (maximum memory)'
)
.option(
'-gs, --gzip-strategy',
'-gs, --gzip-strategy [strategy]',
'compression strategy 1 (filtered) - 2 (huffman only) - 3 (RLE) - 4 (fixed)'

@@ -27,2 +27,19 @@ )

const [target, outputPath] = program.args
new Gzipper(target, outputPath, program).compress()
const options = {
verbose: program.verbose,
gzipLevel: program.gzipLevel,
gzipMemoryLevel: program.gzipMemoryLevel,
gzipStrategy: program.gzipStrategy,
}
Object.keys(options).forEach(
key => options[key] === undefined && delete options[key]
)
Object.keys(options).forEach(key => {
if (!isNaN(+options[key])) {
options[key] = +options[key]
}
})
new Gzipper(target, outputPath, options).compress()

3

Logger.js

@@ -47,4 +47,3 @@ const logger = Symbol('logger')

return (message, force) =>
(this.verbose || force) &&
console.log(colorfulMessage.replace('%s', message))
(this.verbose || force) && console.log(colorfulMessage, message)
}

@@ -51,0 +50,0 @@

{
"name": "gzipper",
"version": "2.0.2",
"version": "2.0.3",
"description": "CLI for gzipping files.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc