Files: e6f6f8953f02f539bb377ecd4fc0a5eb4db2f900 / README.md
1117 bytesRaw
pull-tar-extract
tar parser pull-stream. based on tar-stream.
Usage
pull-tar-extract
exposes a function which returns a through-stream which
consumes a tar file and produces a stream of entries.
Each entry is an object with a header
object property and read
function
property which is a pull-stream source of the contents of that entry (or is
empty if the entry is not a file).
The entry stream (entry.read
function) must be drained before the next
entry can be read.
var Extract = require('pull-tar-extract')
var pull = require('pull-stream')
var fs = require('fs')
pull(
pull.once(fs.readFileSync('package.tar')),
Extract(),
pull.drain(function (entry) {
console.log('entry:', entry.header.name)
pull(entry.read, pull.collect(function (err, bufs) {
if (err) throw err
var data = Buffer.concat(bufs)
console.log('contents:', data.toString('ascii'))
}))
}, function (err) {
if (err) throw err
// done
})
)
License
MIT
Built with git-ssb-web