summaryrefslogtreecommitdiff
path: root/lib/zlib.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2015-01-28 20:05:53 -0500
committercjihrig <cjihrig@gmail.com>2015-01-31 23:47:29 -0500
commit6ac8bdc0aba5f60f4b4f2da5abd36d664062aa40 (patch)
tree29a3b1ce92cfad3ae5d41a4ba7451846beace950 /lib/zlib.js
parentbce7a2608eb198eee6ecd7991062efd6daeeb440 (diff)
downloadandroid-node-v8-6ac8bdc0aba5f60f4b4f2da5abd36d664062aa40.tar.gz
android-node-v8-6ac8bdc0aba5f60f4b4f2da5abd36d664062aa40.tar.bz2
android-node-v8-6ac8bdc0aba5f60f4b4f2da5abd36d664062aa40.zip
lib: reduce util.is*() usage
Many of the util.is*() methods used to check data types simply compare against a single value or the result of typeof. This commit replaces calls to these methods with equivalent checks. This commit does not touch calls to the more complex methods (isRegExp(), isDate(), etc.). Fixes: https://github.com/iojs/io.js/issues/607 PR-URL: https://github.com/iojs/io.js/pull/647 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'lib/zlib.js')
-rw-r--r--lib/zlib.js30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/zlib.js b/lib/zlib.js
index 53e8eb66fd..14ccf8f959 100644
--- a/lib/zlib.js
+++ b/lib/zlib.js
@@ -92,7 +92,7 @@ exports.createUnzip = function(o) {
// Convenience methods.
// compress/decompress a string or buffer in one step.
exports.deflate = function(buffer, opts, callback) {
- if (util.isFunction(opts)) {
+ if (typeof opts === 'function') {
callback = opts;
opts = {};
}
@@ -104,7 +104,7 @@ exports.deflateSync = function(buffer, opts) {
};
exports.gzip = function(buffer, opts, callback) {
- if (util.isFunction(opts)) {
+ if (typeof opts === 'function') {
callback = opts;
opts = {};
}
@@ -116,7 +116,7 @@ exports.gzipSync = function(buffer, opts) {
};
exports.deflateRaw = function(buffer, opts, callback) {
- if (util.isFunction(opts)) {
+ if (typeof opts === 'function') {
callback = opts;
opts = {};
}
@@ -128,7 +128,7 @@ exports.deflateRawSync = function(buffer, opts) {
};
exports.unzip = function(buffer, opts, callback) {
- if (util.isFunction(opts)) {
+ if (typeof opts === 'function') {
callback = opts;
opts = {};
}
@@ -140,7 +140,7 @@ exports.unzipSync = function(buffer, opts) {
};
exports.inflate = function(buffer, opts, callback) {
- if (util.isFunction(opts)) {
+ if (typeof opts === 'function') {
callback = opts;
opts = {};
}
@@ -152,7 +152,7 @@ exports.inflateSync = function(buffer, opts) {
};
exports.gunzip = function(buffer, opts, callback) {
- if (util.isFunction(opts)) {
+ if (typeof opts === 'function') {
callback = opts;
opts = {};
}
@@ -164,7 +164,7 @@ exports.gunzipSync = function(buffer, opts) {
};
exports.inflateRaw = function(buffer, opts, callback) {
- if (util.isFunction(opts)) {
+ if (typeof opts === 'function') {
callback = opts;
opts = {};
}
@@ -209,9 +209,9 @@ function zlibBuffer(engine, buffer, callback) {
}
function zlibBufferSync(engine, buffer) {
- if (util.isString(buffer))
+ if (typeof buffer === 'string')
buffer = new Buffer(buffer);
- if (!util.isBuffer(buffer))
+ if (!(buffer instanceof Buffer))
throw new TypeError('Not a string or buffer');
var flushFlag = binding.Z_FINISH;
@@ -327,7 +327,7 @@ function Zlib(opts, mode) {
}
if (opts.dictionary) {
- if (!util.isBuffer(opts.dictionary)) {
+ if (!(opts.dictionary instanceof Buffer)) {
throw new Error('Invalid dictionary: it should be a Buffer instance');
}
}
@@ -349,10 +349,10 @@ function Zlib(opts, mode) {
};
var level = exports.Z_DEFAULT_COMPRESSION;
- if (util.isNumber(opts.level)) level = opts.level;
+ if (typeof opts.level === 'number') level = opts.level;
var strategy = exports.Z_DEFAULT_STRATEGY;
- if (util.isNumber(opts.strategy)) strategy = opts.strategy;
+ if (typeof opts.strategy === 'number') strategy = opts.strategy;
this._handle.init(opts.windowBits || exports.Z_DEFAULT_WINDOWBITS,
level,
@@ -414,7 +414,7 @@ Zlib.prototype._flush = function(callback) {
Zlib.prototype.flush = function(kind, callback) {
var ws = this._writableState;
- if (util.isFunction(kind) || (util.isUndefined(kind) && !callback)) {
+ if (typeof kind === 'function' || (kind === undefined && !callback)) {
callback = kind;
kind = binding.Z_FULL_FLUSH;
}
@@ -459,7 +459,7 @@ Zlib.prototype._transform = function(chunk, encoding, cb) {
var ending = ws.ending || ws.ended;
var last = ending && (!chunk || ws.length === chunk.length);
- if (!util.isNull(chunk) && !util.isBuffer(chunk))
+ if (chunk !== null && !(chunk instanceof Buffer))
return cb(new Error('invalid input'));
if (this._closed)
@@ -490,7 +490,7 @@ Zlib.prototype._processChunk = function(chunk, flushFlag, cb) {
var self = this;
- var async = util.isFunction(cb);
+ var async = typeof cb === 'function';
if (!async) {
var buffers = [];