From 99a2e4efdc616c790a853ec9d73aabc67944fc35 Mon Sep 17 00:00:00 2001 From: Vitaly Puzrin Date: Wed, 17 Feb 2016 10:26:37 +0300 Subject: [PATCH] Allow create Deflate/Inflate instances without `new` --- lib/deflate.js | 1 + lib/inflate.js | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/deflate.js b/lib/deflate.js index feb65ac..60ccdda 100644 --- a/lib/deflate.js +++ b/lib/deflate.js @@ -117,6 +117,7 @@ var Z_DEFLATED = 8; * ``` **/ function Deflate(options) { + if (!(this instanceof Deflate)) return new Deflate(options); this.options = utils.assign({ level: Z_DEFAULT_COMPRESSION, diff --git a/lib/inflate.js b/lib/inflate.js index 70ab3b7..95610a8 100644 --- a/lib/inflate.js +++ b/lib/inflate.js @@ -90,6 +90,7 @@ var toString = Object.prototype.toString; * ``` **/ function Inflate(options) { + if (!(this instanceof Inflate)) return new Inflate(options); this.options = utils.assign({ chunkSize: 16384,