![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
decompress
Advanced tools
Package description
The decompress npm package is a module that allows for decompressing archive files such as zip, tar, tar.gz, and many others. It provides a simple API to easily extract files from these archives.
Extracting archive files
This feature allows you to extract files from an archive like a zip file into a specified directory. The 'decompress' function returns a promise that resolves with an array of file objects when the extraction is complete.
const decompress = require('decompress');
decompress('unicorn.zip', 'dist').then(files => {
console.log('Files decompressed successfully');
});
Extracting specific files
This feature allows you to extract only specific files from an archive by using a filter function. The filter function is passed each file object, and you return a boolean to indicate whether the file should be extracted.
const decompress = require('decompress');
const filesToExtract = ['unicorn.png', 'rainbow.jpg'];
decompress('archive.zip', 'dist', {
filter: file => filesToExtract.includes(file.path)
}).then(files => {
console.log('Selected files decompressed successfully');
});
Using plugins to handle different archive types
The decompress package can be extended with plugins to support more archive types. In this example, the 'decompress-targz' plugin is used to decompress a '.tar.gz' file.
const decompress = require('decompress');
const decompressTargz = require('decompress-targz');
decompress('unicorn.tar.gz', 'dist', {
plugins: [
decompressTargz()
]
}).then(files => {
console.log('tar.gz file decompressed successfully');
});
adm-zip is a JavaScript implementation for zip data compression for NodeJS. It provides functionalities to read and write zip files, much like decompress, but it is focused solely on zip format.
yauzl is another npm package for reading and extracting zip files. It aims to be a low-level and high-performance library for zip file I/O, and unlike decompress, it does not support multiple file formats.
The 'tar' package provides the ability to create, extract, and list tar archives. It is similar to decompress in handling tar files but does not support other types of archives.
unzipper is a fully streaming unzip library for NodeJS, which provides a simple API for parsing and extracting zip files. It is similar to decompress but focuses on the zip format and offers a streaming interface.
Readme
Extracting archives made easy
See decompress-cli for the command-line version.
$ npm install --save decompress
const Decompress = require('decompress');
new Decompress({mode: '755'})
.src('foo.zip')
.dest('dest')
.use(Decompress.zip({strip: 1}))
.run();
Creates a new Decompress
instance.
Type: string
Set mode on the extracted files, i.e { mode: '755' }
.
Type: number
Equivalent to --strip-components
for tar.
Type: array
, buffer
or string
Set the files to be extracted.
Type: string
Set the destination to where your file will be extracted to.
Type: function
Add a plugin
to the middleware stack.
Extract your file with the given settings.
Type: function
The callback will return an array of vinyl files in files
.
The following plugins are bundled with decompress:
Extract TAR files.
const Decompress = require('decompress');
new Decompress()
.use(Decompress.tar({strip: 1}));
Extract TAR.BZ files.
const Decompress = require('decompress');
new Decompress()
.use(Decompress.tarbz2({strip: 1}));
Extract TAR.GZ files.
const Decompress = require('decompress');
new Decompress()
.use(Decompress.targz({strip: 1}));
Extract ZIP files.
const Decompress = require('decompress');
new Decompress()
.use(Decompress.zip({strip: 1}));
MIT © Kevin Mårtensson
FAQs
Extracting archives made easy
The npm package decompress receives a total of 2,705,054 weekly downloads. As such, decompress popularity was classified as popular.
We found that decompress demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.