@particle/unpack-file
v3.0.2
Published
unpack .tar.gz and .zip files, optionally reporting progress
Downloads
63
Maintainers
Keywords
Readme
@particle/unpack-file
unpack .tar.gz and .zip files, optionally reporting progress
Installation
npm install @particle/unpack-file --save
API
@particle/unpack-file
- @particle/unpack-file
- static
- .unpackTarGz(source, destination, [options]) ⇒ Promise.<(UnpackedFile|Error)>
- .unpackZip(source, destination, [options]) ⇒ Promise.<(UnpackedFile|Error)>
- inner
- ~UnpackedFile : Object
- static
unpackFile.unpackTarGz(source, destination, [options]) ⇒ Promise.<(UnpackedFile|Error)>
Unpack a tarball (.tar.gz
, .tgz
, etc) file and optionally report progress.
Kind: static method of @particle/unpack-file
Returns: Promise.<(UnpackedFile|Error)> - A promise for the downloaded file or
an error
| Param | Type | Default | Description | | --- | --- | --- | --- | | source | string | | Absolute path to the tarball you want to unpack | | destination | string | | Absolute path to the directory where unpacked bits will be saved | | [options] | object | | | | [options.onProgress] | function | | Function to call with progess info (optional) | | [options.interval] | number | 100 | How often to report progress in milliseconds (optional) |
Example
const source = '/path/to/my.tar.gz';
const destination = '/path/to/folder';
// unpack a tarball
const { dirname } = await unpackTarGz(source, destination);
// unpack a tarball and report progress
const onProgress = (progress) => console.log(progress);
const options = { onProgress, interval: 250 };
const { dirname } = await unpackTarGz(source, destination, options);
unpackFile.unpackZip(source, destination, [options]) ⇒ Promise.<(UnpackedFile|Error)>
Unpack a zip (.zip
, etc) file and optionally report progress.
Kind: static method of @particle/unpack-file
Returns: Promise.<(UnpackedFile|Error)> - A promise for the downloaded file or
an error
| Param | Type | Default | Description | | --- | --- | --- | --- | | source | string | | Absolute path to the zip file you want to unpack | | destination | string | | Absolute path to the directory where unpacked bits will be saved | | [options] | object | | | | [options.onProgress] | function | | Function to call with progess info (optional) | | [options.interval] | number | 100 | How often to report progress in milliseconds (optional) |
Example
const source = '/path/to/my.zip';
const destination = '/path/to/folder';
// unpack a tarball
const { dirname } = await unpackZip(source, destination);
// unpack a tarball and report progress
const onProgress = (progress) => console.log(progress);
const options = { onProgress, interval: 250 };
const { dirname } = await unpackZip(source, destination, options);
@particle/unpack-file~UnpackedFile : Object
Object returned after successfully unpacking a file
Kind: inner typedef of @particle/unpack-file
Properties
| Name | Type | Description | | --- | --- | --- | | dirname | string | Absolute path to the directory containing your unpacked files |
NOTE: Unfortunately, docs have a nasty habit of falling out of date. When in doubt, check usage in tests