开发者社区> 镜像站> NPM> unpacker-with-progress
unpacker-with-progress
Unpack .tar.gz or .zip archives, provide progress info, and an idempotent + resumable API.
Last updated a year ago by bret .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install unpacker-with-progress 
SYNC missed versions from official npm registry.

unpacker-with-progress

Actions Status

Unpack .tar, .tar.gz and .zip archives, provide progress info, and an idempotent + resumable API.

Usage

const unpacker = require('unpacker-with-progress')
const zip = './some-zip.zip'
const tar = './some-zip.tar.gz'
const dest = './some-dest'

function unpack () {
  return Promise.all([
    unpacker(zip, dest, { onprogress (progress) { console.log(progress.percent) } }),
    unpacker(tar, dest, { onprogress (progress) { console.log(progress.percent) } })
  ])
}

unpack().then(stats => console.log('done'))

Installation

$ npm install unpacker-with-progress -g

API

promise(stats) = unpacker(src, dest, [opts])

Unpack a zip or tar.gz at the given src path, to the dest path. Returns a promise that resolves to a stats object.

Opts include:

{
  resume: true, // Skip files if they are already extracted in dest
  onprogress (stats) { /* noop */ } // progress function.  Use this to track progress while extraacting.
}

The stats object contains the following properties:

{
  entriesProcessed, // running total of entries processed
  percent, // percentage of extraction complete 0.0 - 1.0
  skipped, // number of entries skipped
  unpacked, // number of files extracted
  totalEntries, // Total number of entries
  total, // total number of bytes after extraction
  loaded // running total of bytes written
}

See also

This module implements the desired interface over the following modules:

Liscense

MIT

Current Tags

  • 2.0.3                                ...           latest (a year ago)

4 Versions

  • 2.0.3                                ...           a year ago
  • 2.0.2                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (7)
Dev Dependencies (4)
Dependents (0)
None