decompress-tarbz2
Advanced tools
Comparing version 4.0.0 to 4.1.0
16
index.js
'use strict'; | ||
const decompressTar = require('decompress-tar'); | ||
const fileType = require('file-type'); | ||
const isStream = require('is-stream'); | ||
const seekBzip = require('seek-bzip'); | ||
const unbzip2Stream = require('unbzip2-stream'); | ||
module.exports = () => buf => { | ||
if (!Buffer.isBuffer(buf)) { | ||
return Promise.reject(new TypeError(`Expected a Buffer, got ${typeof buf}`)); | ||
module.exports = () => input => { | ||
if (!Buffer.isBuffer(input) && !isStream(input)) { | ||
return Promise.reject(new TypeError(`Expected a Buffer or Stream, got ${typeof input}`)); | ||
} | ||
if (!fileType(buf) || fileType(buf).ext !== 'bz2') { | ||
if (Buffer.isBuffer(input) && (!fileType(input) || fileType(input).ext !== 'bz2')) { | ||
return Promise.resolve([]); | ||
} | ||
return decompressTar()(seekBzip.decode(buf)); | ||
if (Buffer.isBuffer(input)) { | ||
return decompressTar()(seekBzip.decode(input)); | ||
} | ||
return decompressTar()(input.pipe(unbzip2Stream())); | ||
}; |
{ | ||
"name": "decompress-tarbz2", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "decompress tar.bz2 plugin", | ||
@@ -31,6 +31,8 @@ "license": "MIT", | ||
"dependencies": { | ||
"decompress-tar": "^4.0.0", | ||
"decompress-tar": "^4.1.0", | ||
"file-type": "^3.8.0", | ||
"is-stream": "^1.1.0", | ||
"pify": "^2.3.0", | ||
"seek-bzip": "^1.0.5" | ||
"seek-bzip": "^1.0.5", | ||
"unbzip2-stream": "^1.0.9" | ||
}, | ||
@@ -37,0 +39,0 @@ "devDependencies": { |
@@ -33,5 +33,7 @@ # decompress-tarbz2 [![Build Status](https://travis-ci.org/kevva/decompress-tarbz2.svg?branch=master)](https://travis-ci.org/kevva/decompress-tarbz2) | ||
Returns both a Promise for a Buffer and a [Duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex). | ||
#### buf | ||
Type: `Buffer` | ||
Type: `Buffer` `Stream` | ||
@@ -38,0 +40,0 @@ Buffer to decompress. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3402
18
45
6
+ Addedis-stream@^1.1.0
+ Addedunbzip2-stream@^1.0.9
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedunbzip2-stream@1.4.3(transitive)
Updateddecompress-tar@^4.1.0