zlib: lint

pull/23362/head
isaacs 2011-09-17 23:03:36 -07:00
parent d104bfd5a6
commit f90264d246
1 changed files with 35 additions and 15 deletions

View File

@ -59,13 +59,33 @@ exports.DeflateRaw = DeflateRaw;
exports.InflateRaw = InflateRaw; exports.InflateRaw = InflateRaw;
exports.Unzip = Unzip; exports.Unzip = Unzip;
exports.createDeflate = function (o) { return new Deflate(o); }; exports.createDeflate = function(o) {
exports.createInflate = function (o) { return new Inflate(o); }; return new Deflate(o);
exports.createDeflateRaw = function (o) { return new DeflateRaw(o); }; };
exports.createInflateRaw = function (o) { return new InflateRaw(o); };
exports.createGzip = function (o) { return new Gzip(o); }; exports.createInflate = function(o) {
exports.createGunzip = function (o) { return new Gunzip(o); }; return new Inflate(o);
exports.createUnzip = function (o) { return new Unzip(o); }; };
exports.createDeflateRaw = function(o) {
return new DeflateRaw(o);
};
exports.createInflateRaw = function(o) {
return new InflateRaw(o);
};
exports.createGzip = function(o) {
return new Gzip(o);
};
exports.createGunzip = function(o) {
return new Gunzip(o);
};
exports.createUnzip = function(o) {
return new Unzip(o);
};
@ -132,28 +152,28 @@ function Zlib(opts, Binding) {
if (opts.chunkSize) { if (opts.chunkSize) {
if (opts.chunkSize < exports.Z_MIN_CHUNK || if (opts.chunkSize < exports.Z_MIN_CHUNK ||
opts.chunkSize > exports.Z_MAX_CHUNK) { opts.chunkSize > exports.Z_MAX_CHUNK) {
throw new Error("Invalid chunk size: "+opts.chunkSize); throw new Error('Invalid chunk size: ' + opts.chunkSize);
} }
} }
if (opts.windowBits) { if (opts.windowBits) {
if (opts.windowBits < exports.Z_MIN_WINDOWBITS || if (opts.windowBits < exports.Z_MIN_WINDOWBITS ||
opts.windowBits > exports.Z_MAX_WINDOWBITS) { opts.windowBits > exports.Z_MAX_WINDOWBITS) {
throw new Error("Invalid windowBits: "+opts.windowBits); throw new Error('Invalid windowBits: ' + opts.windowBits);
} }
} }
if (opts.level) { if (opts.level) {
if (opts.level < exports.Z_MIN_LEVEL || if (opts.level < exports.Z_MIN_LEVEL ||
opts.level > exports.Z_MAX_LEVEL) { opts.level > exports.Z_MAX_LEVEL) {
throw new Error("Invalid compression level: "+opts.level); throw new Error('Invalid compression level: ' + opts.level);
} }
} }
if (opts.memLevel) { if (opts.memLevel) {
if (opts.memLevel < exports.Z_MIN_MEMLEVEL || if (opts.memLevel < exports.Z_MIN_MEMLEVEL ||
opts.memLevel > exports.Z_MAX_MEMLEVEL) { opts.memLevel > exports.Z_MAX_MEMLEVEL) {
throw new Error("Invalid memLevel: "+opts.memLevel); throw new Error('Invalid memLevel: ' + opts.memLevel);
} }
} }
@ -163,15 +183,15 @@ function Zlib(opts, Binding) {
opts.strategy != exports.Z_RLE && opts.strategy != exports.Z_RLE &&
opts.strategy != exports.Z_FIXED && opts.strategy != exports.Z_FIXED &&
opts.strategy != exports.Z_DEFAULT_STRATEGY) { opts.strategy != exports.Z_DEFAULT_STRATEGY) {
throw new Error("Invalid strategy: "+opts.strategy); throw new Error('Invalid strategy: ' + opts.strategy);
} }
} }
this._binding = new Binding(); this._binding = new Binding();
this._binding.init(opts.windowBits || exports.Z_DEFAULT_WINDOWBITS, this._binding.init(opts.windowBits || exports.Z_DEFAULT_WINDOWBITS,
opts.level || exports.Z_DEFAULT_COMPRESSION, opts.level || exports.Z_DEFAULT_COMPRESSION,
opts.memLevel || exports.Z_DEFAULT_MEMLEVEL, opts.memLevel || exports.Z_DEFAULT_MEMLEVEL,
opts.strategy || exports.Z_DEFAULT_STRATEGY); opts.strategy || exports.Z_DEFAULT_STRATEGY);
this._chunkSize = opts.chunkSize || exports.Z_DEFAULT_CHUNK; this._chunkSize = opts.chunkSize || exports.Z_DEFAULT_CHUNK;
this._buffer = new Buffer(this._chunkSize); this._buffer = new Buffer(this._chunkSize);