Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

zlib: lint

  • Loading branch information...
isaacs committed Sep 18, 2011
1 parent d104bfd commit f90264d2462e0e24b9a4479b23443c518d24ef0d
Showing with 35 additions and 15 deletions.
  1. +35 −15 lib/zlib.js
@@ -59,13 +59,33 @@ exports.DeflateRaw = DeflateRaw;
exports.InflateRaw = InflateRaw;
exports.Unzip = Unzip;

exports.createDeflate = function (o) { return new Deflate(o); };
exports.createInflate = function (o) { return new Inflate(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); };
exports.createDeflate = function(o) {
return new Deflate(o);
};

exports.createInflate = function(o) {
return new Inflate(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 < exports.Z_MIN_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 < exports.Z_MIN_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 < exports.Z_MIN_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 < exports.Z_MIN_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_FIXED &&
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.init(opts.windowBits || exports.Z_DEFAULT_WINDOWBITS,
opts.level || exports.Z_DEFAULT_COMPRESSION,
opts.memLevel || exports.Z_DEFAULT_MEMLEVEL,
opts.strategy || exports.Z_DEFAULT_STRATEGY);
opts.level || exports.Z_DEFAULT_COMPRESSION,
opts.memLevel || exports.Z_DEFAULT_MEMLEVEL,
opts.strategy || exports.Z_DEFAULT_STRATEGY);

this._chunkSize = opts.chunkSize || exports.Z_DEFAULT_CHUNK;
this._buffer = new Buffer(this._chunkSize);

0 comments on commit f90264d

Please sign in to comment.
You can’t perform that action at this time.