aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/lib/utils/gunzip-maybe.js
diff options
context:
space:
mode:
authorKat Marchán <kzm@sykosomatic.org>2017-02-14 15:12:22 -0800
committerJeremiah Senkpiel <fishrock123@rocketmail.com>2017-03-22 18:27:31 -0400
commite1834ff5da0117457a14fe76a097ed7763cfb61f (patch)
tree15ae7076df1333fb02cb20d5fafb542f0d526874 /deps/npm/lib/utils/gunzip-maybe.js
parentcaf9ae748b1324c34284b324f2951b91368ca840 (diff)
downloadandroid-node-v8-e1834ff5da0117457a14fe76a097ed7763cfb61f.tar.gz
android-node-v8-e1834ff5da0117457a14fe76a097ed7763cfb61f.tar.bz2
android-node-v8-e1834ff5da0117457a14fe76a097ed7763cfb61f.zip
deps: upgrade npm to 4.2.0
PR-URL: https://github.com/nodejs/node/pull/11389 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'deps/npm/lib/utils/gunzip-maybe.js')
-rw-r--r--deps/npm/lib/utils/gunzip-maybe.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/deps/npm/lib/utils/gunzip-maybe.js b/deps/npm/lib/utils/gunzip-maybe.js
new file mode 100644
index 0000000000..db75f06017
--- /dev/null
+++ b/deps/npm/lib/utils/gunzip-maybe.js
@@ -0,0 +1,22 @@
+var duplex = require('mississippi').duplex
+var through = require('mississippi').through
+var zlib = require('zlib')
+
+function hasGzipHeader (c) {
+ return c[0] === 0x1F && c[1] === 0x8B && c[2] === 0x08
+}
+
+module.exports = gunzip
+function gunzip () {
+ var stream = duplex()
+ var peeker = through(function (chunk, enc, cb) {
+ var newStream = hasGzipHeader(chunk)
+ ? zlib.createGunzip()
+ : through()
+ stream.setReadable(newStream)
+ stream.setWritable(newStream)
+ stream.write(chunk)
+ })
+ stream.setWritable(peeker)
+ return stream
+}