3.0.2 • Published 2 years ago

@particle/unpack-file v3.0.2

Weekly downloads
61
License
UNLICENSED
Repository
-
Last release
2 years ago

@particle/unpack-file

unpack .tar.gz and .zip files, optionally reporting progress

Installation

npm install @particle/unpack-file --save

API

@particle/unpack-file


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

ParamTypeDefaultDescription
sourcestringAbsolute path to the tarball you want to unpack
destinationstringAbsolute path to the directory where unpacked bits will be saved
optionsobject
options.onProgressfunctionFunction to call with progess info (optional)
options.intervalnumber100How 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

ParamTypeDefaultDescription
sourcestringAbsolute path to the zip file you want to unpack
destinationstringAbsolute path to the directory where unpacked bits will be saved
optionsobject
options.onProgressfunctionFunction to call with progess info (optional)
options.intervalnumber100How 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

NameTypeDescription
dirnamestringAbsolute 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

3.0.2

2 years ago

3.0.1

2 years ago

2.0.6

2 years ago

3.0.0

2 years ago

2.0.5

2 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.0

4 years ago