unpack-stream
Unpack a tarball stream
Last updated 7 years ago by zkochan .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install unpack-stream 
SYNC missed versions from official npm registry.

unpack-stream

Unpack a tarball stream

npm version Build Status

Installation

npm i -S unpack-stream

Usage

'use strict'
const got = require('got')
const unpackStream = require('unpack-stream')

const tarball = 'https://registry.npmjs.org/is-negative/-/is-negative-2.1.0.tgz'
const stream = got.stream(tarball)
unpackStream.remote(stream, './tmp')
  .then(index =>
    Promise.all(
      Object.keys(index)
        .map(filename =>
          index[filename].generatingIntegrity.then(integrity => ({filename, integrity})))
    )
  )
  .then(files => console.log(files))
  //> [ { filename: 'package.json',
  //      integrity: 'sha512-RA0APKvtxz85WYCFX3M/TkVeJZZBcylEwh+GrV7uO/NNJO4G3rzgTrpsypp9AU2hM2QBk9SxCHi1Gb9aaWzpYg==' },
  //    { filename: 'index.js',
  //      integrity: 'sha512-3dL1OHn8VWhVDT37f3ZBdou4NrYq2ll//W1lWqx7+4tKBW/WqUx3mDcGyqrBfBeWTIPCd+RiUdF7hp3MQYB9+g==' },
  //    { filename: 'license',
  //      integrity: 'sha512-lSw93JVg7wfwyVXKrg6yIFjF9Bidgr+tA/l6XNlrRhjnE6NhwkyPL3xNL47OZScS8qoQkYUwE6slmo7jGesH0Q==' },
  //    { filename: 'readme.md',
  //      integrity: 'sha512-fM882axp7XaC6nzj5XYuzB0KhYpYwwsR3RjyiqOcIrI6C0b9KxrEEug9VpKTfbSbqTOmZ2KEqZLPKrMXFW1Y+g==' } ]

API

remote(stream, destination, [opts]): Promise<Index>

Unpacks a remote stream fetched via HTTP.

Arguments:

  • stream - Stream
  • destination - string - the directory to which the stream will be unpacked
  • [opts.shasum] - string - shasum to verify tarball
  • [opts.onStart] - Function - called on download start
  • [opts.onProgress] - (downloaded, size) => void - tracks the download progress
  • [opts.generateIntegrity] - Boolean - true by default. If true, generates Subresource Integrity for each unpacked file
  • [opts.ignore] - (filename: string) => boolean - a function that decides whether a file should be unpacked from the tarball.

local(stream, destination, [opts]): Promise<Index>

Unpacks a stream from the local filesystem.

Arguments:

  • [opts.generateIntegrity] - Boolean - true by default. If true, generates Subresource Integrity for each unpacked file
  • [opts.ignore] - (filename: string) => boolean - a function that decides whether a file should be unpacked from the tarball.

License

MIT © Zoltan Kochan

Current Tags

  • 0.1.1                                ...           beta (9 years ago)
  • 6.0.0                                ...           latest (7 years ago)
  • 5.0.1                                ...           next (7 years ago)

24 Versions

  • 6.0.2                                ...           6 years ago
  • 6.0.1                                ...           7 years ago
  • 6.0.0                                ...           7 years ago
  • 5.0.1                                ...           7 years ago
  • 5.0.0                                ...           7 years ago
  • 4.0.2                                ...           7 years ago
  • 4.0.1                                ...           7 years ago
  • 4.0.0                                ...           8 years ago
  • 3.0.3                                ...           8 years ago
  • 3.0.2                                ...           8 years ago
  • 3.0.1                                ...           8 years ago
  • 3.0.0                                ...           8 years ago
  • 2.2.0                                ...           8 years ago
  • 2.1.1                                ...           9 years ago
  • 2.1.0                                ...           9 years ago
  • 2.0.0                                ...           9 years ago
  • 2.0.0-beta.1                                ...           9 years ago
  • 1.2.0                                ...           9 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.2                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 0.1.1                                ...           9 years ago
  • 0.1.0                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (4)
Dev Dependencies (12)

Copyright 2013 - present © cnpmjs.org | Home |