@particle/unpack-file

3.0.2 • Public • Published

@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

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

Readme

Keywords

none

Package Sidebar

Install

npm i @particle/unpack-file

Weekly Downloads

5

Version

3.0.2

License

UNLICENSED

Unpacked Size

11.4 kB

Total Files

4

Last publish

Collaborators

  • jackson-particle
  • mike.grundy.npm
  • mohitparticle
  • eugene_particle
  • kmok23
  • karlag
  • cole-abbeduto-particle
  • pedrosordo
  • guohui
  • sbrust
  • particlebot
  • no1089
  • carlos.hdez
  • keeramis5
  • monkbroc
  • suda
  • mstan
  • sergeuz
  • debbie23
  • avtolstoy
  • mlauer
  • wraithan
  • azenk
  • bwalach
  • parteberseth
  • rickkas7
  • mrlambchop_particle
  • hugo.montero
  • mphsi