Gathering detailed insights and metrics for @zeeko/compressing
Gathering detailed insights and metrics for @zeeko/compressing
npm install @zeeko/compressing
Typescript
Module System
Min. Node Version
Node Version
NPM Version
70.1
Supply Chain
97.2
Quality
72.6
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
686
Last Day
2
Last Week
4
Last Month
11
Last Year
58
443 Stars
61 Commits
34 Forks
18 Watching
2 Branches
32 Contributors
Minified
Minified + Gzipped
Latest Version
1.6.1-patch.1
Package Id
@zeeko/compressing@1.6.1-patch.1
Unpacked Size
49.16 kB
Size
10.93 kB
File Count
23
NPM Version
8.11.0
Node Version
16.15.1
Cumulative downloads
Total Downloads
Last day
0%
2
Compared to previous day
Last week
33.3%
4
Compared to previous week
Last month
266.7%
11
Compared to previous month
Last year
-47.3%
58
Compared to previous year
The missing compressing and uncompressing lib for node.
Currently supported:
1npm install compressing
Use gzip as an example, tar, tgz and zip is same as gzip.
promise style
1const compressing = require('compressing');
2
3// compress a file
4compressing.gzip.compressFile('file/path/to/compress', 'path/to/destination.gz')
5.then(compressDone)
6.catch(handleError);
7
8// compress a file buffer
9compressing.gzip.compressFile(buffer, 'path/to/destination.gz')
10.then(compressDone)
11.catch(handleError);
12
13// compress a stream
14compressing.gzip.compressFile(stream, 'path/to/destination.gz')
15.then(compressDone)
16.catch(handleError);
stream style
1const compressing = require('compressing'); 2 3new compressing.gzip.FileStream({ source: 'file/path/to/compress' }) 4 .on('error', handleError) 5 .pipe(fs.createWriteStream('path/to/destination.gz')) 6 .on('error', handleError); 7 8// It's a transform stream, so you can pipe to it 9fs.createReadStream('file/path/to/compress') 10 .on('error', handleError) 11 .pipe(new compressing.gzip.FileStream()) 12 .on('error', handleError) 13 .pipe(fs.createWriteStream('path/to/destination.gz')) 14 .on('error', handleError); 15 16// You should take care of stream errors in caution, use pump to handle error in one place 17const pump = require('pump';) 18const sourceStream = fs.createReadStream('file/path/to/compress') 19const gzipStream = new compressing.gzip.FileStream(); 20const destStream = fs.createWriteStream('path/to/destination.gz'); 21pump(sourceStream, gzipStream, destStream, handleError);
Use tar as an example, tgz and zip is same as gzip.
Gzip only support compressing a single file. if you want to compress a dir with gzip, then you may need tgz instead.
promise style
1const compressing = require('compressing'); 2compressing.tar.compressDir('dir/path/to/compress', 'path/to/destination.tar') 3.then(compressDone) 4.catch(handleError);
stream style
1const compressing = require('compressing');
2
3const tarStream = new compressing.tar.Stream();
4tarStream.addEntry('dir/path/to/compress');
5
6tarStream
7 .on('error', handleError)
8 .pipe(fs.createWriteStream('path/to/destination.tar'))
9 .on('error', handleError);
10
11// You should take care of stream errors in caution, use pump to handle error in one place
12const tarStream = new compressing.tar.Stream();
13tarStream.addEntry('dir/path/to/compress');
14const destStream = fs.createWriteStream('path/to/destination.tar');
15pump(tarStream, destStream, handleError);
Stream is very powerful, you can compress multiple entries in it;
1const tarStream = new compressing.tar.Stream();
2// dir
3tarStream.addEntry('dir/path/to/compress');
4
5// file
6tarStream.addEntry('file/path/to/compress');
7
8// buffer
9tarStream.addEntry(buffer);
10
11// stream
12tarStream.addEntry(stream);
13
14const destStream = fs.createWriteStream('path/to/destination.tar');
15pipe(tarStream, destStream, handleError);
promise style
1const compressing = require('compressing'); 2 3// uncompress a file 4compressing.tgz.uncompress('file/path/to/uncompress.tgz', 'path/to/destination/dir') 5.then(uncompressDone) 6.catch(handleError); 7 8// uncompress a file buffer 9compressing.tgz.uncompress(buffer, 'path/to/destination/dir') 10.then(uncompressDone) 11.catch(handleError); 12 13// uncompress a stream 14compressing.tgz.uncompress(stream, 'path/to/destination/dir') 15.then(uncompressDone) 16.catch(handleError);
Note: tar, tgz and zip have the same uncompressing API as above: destination should be a path of a directory, while that of gzip is slightly different: destination must be a file or filestream.
And working with urllib is super easy. Let's download a tgz file and uncompress to a directory:
1const urllib = require('urllib'); 2const targetDir = require('os').tmpdir(); 3const compressing = require('compressing'); 4 5urllib.request('http://registry.npmjs.org/pedding/-/pedding-1.1.0.tgz', { 6 streaming: true, 7 followRedirect: true, 8}) 9.then(result => compressing.tgz.uncompress(result.res, targetDir)) 10.then(() => console.log('uncompress done')) 11.catch(console.error);
stream style
1const compressing = require('compressing'); 2const mkdirp = require('mkdirp'); 3 4function onEntry(header, stream, next) => { 5 stream.on('end', next); 6 7 // header.type => file | directory 8 // header.name => path name 9 10 if (header.type === 'file') { 11 stream.pipe(fs.createWriteStream(path.join(destDir, header.name))); 12 } else { // directory 13 mkdirp(path.join(destDir, header.name), err => { 14 if (err) return handleError(err); 15 stream.resume(); 16 }); 17 } 18} 19 20new compressing.tgz.UncompressStream({ source: 'file/path/to/uncompress.tgz' }) 21 .on('error', handleError) 22 .on('finish', handleFinish) // uncompressing is done 23 .on('entry', onEntry); 24 25// It's a writable stream, so you can pipe to it 26fs.createReadStream('file/path/to/uncompress') 27 .on('error', handleError) 28 .pipe(new compressing.tgz.UncompressStream()) 29 .on('error', handleError) 30 .on('finish', handleFinish) // uncompressing is done 31 .on('entry', onEntry);
Note: tar, tgz and zip have the same uncompressing streaming API as above: it's a writable stream, and entries will be emitted while uncompressing one after one another, while that of gzip is slightly different: gzip.UncompressStream is a transform stream, so no entry
event will be emitted and you can just pipe to another stream
This constrants is brought by Gzip algorithm itself, it only support compressing one file and uncompress one file.
1new compressing.gzip.UncompressStream({ source: 'file/path/to/uncompress.gz' })
2 .on('error', handleError)
3 .pipe(fs.createWriteStream('path/to/dest/file'))
4 .on('error', handleError);
Use this API to compress a single file. This is a convenient method, which wraps FileStream API below, but you can handle error in one place.
Params
/path/to/xx.tgz
), or a writable stream.Returns a promise object.
Use this API to compress a dir. This is a convenient method, which wraps Stream API below, but you can handle error in one place.
Note: gzip do not have a compressDir method, you may need tgz instead.
Params
/path/to/xx.tgz
), or a writable stream.Use this API to uncompress a file. This is a convenient method, which wraps UncompressStream API below, but you can handle error in one place. RECOMMANDED.
Params
/path/to/xx
). When uncompressing gzip, it should be a file path or a writable stream.opts.zipFileNameEncoding {String} - Only work on zip format, default is 'utf8'. Major non-UTF8 encodings by languages:
The transform stream to compress a single file.
Note: If you are not very familiar with streams, just use compressFile() API, error can be handled in one place.
Common params:
Gzip params:
Tar params:
Tgz params:
tgz.FileStream is a combination of tar.FileStream and gzip.FileStream, so the params are the combination of params of tar and gzip.
Zip params:
The readable stream to compress anything as you need.
Note: If you are not very familiar with streams, just use compressFile() and compressDir() API, error can be handled in one place.
Gzip only support compressing a single file. So gzip.Stream is not available.
Constructor
No options in all constructors.
Instance methods
Params
The writable stream to uncompress anything as you need.
Note: If you are not very familiar with streams, just use uncompress()
API, error can be handled in one place.
Gzip only support compressing and uncompressing one single file. So gzip.UncompressStream is a transform stream which is different from others.
Constructor
Common params:
CAUTION for zip.UncompressStream
Due to the design of the .zip file format, it's impossible to interpret a .zip file without loading all data into memory.
Although the API is streaming style(try to keep it handy), it still loads all data into memory.
https://github.com/thejoshwolfe/yauzl#no-streaming-unzip-api
shaoshuai0102 | fengmk2 | popomore | DiamondYuan | bytemain | Ryqsky |
---|---|---|---|---|---|
ShadyZOZ |
This project follows the git-contributor spec, auto updated at Mon Jun 13 2022 13:26:08 GMT+0800
.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
Found 11/30 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More