{ "name": "tar-stream", "version": "0.4.7", "description": "tar-stream is a streaming tar parser and generator and nothing else. It is streams2 and operates purely using streams which means you can easily extract/parse tarballs without ever hitting the file system.", "repository": { "type": "git", "url": "git://github.com:mafintosh/tar-stream.git" }, "author": { "name": "Mathias Buus", "email": "mathiasbuus@gmail.com" }, "engines": { "node": ">= 0.8.0" }, "dependencies": { "bl": "^0.9.0", "end-of-stream": "^1.0.0", "readable-stream": "^1.0.27-1", "xtend": "^4.0.0" }, "devDependencies": { "concat-stream": "^1.4.6", "tape": "^2.14.0" }, "scripts": { "test": "tape test/*.js" }, "keywords": [ "tar", "tarball", "parse", "parser", "generate", "generator", "stream", "stream2", "streams", "streams2", "streaming", "pack", "extract", "modify" ], "bugs": { "url": "https://github.com/mafintosh/tar-stream/issues" }, "homepage": "https://github.com/mafintosh/tar-stream", "main": "index.js", "directories": { "test": "test" }, "license": "MIT", "readme": "# tar-stream\n\ntar-stream is a streaming tar parser and generator and nothing else. It is streams2 and operates purely using streams which means you can easily extract/parse tarballs without ever hitting the file system.\n\n```\nnpm install tar-stream\n```\n\n[![build status](https://secure.travis-ci.org/mafintosh/tar-stream.png)](http://travis-ci.org/mafintosh/tar-stream)\n\n## Usage\n\ntar-stream exposes two streams, [pack](https://github.com/mafintosh/tar-stream#packing) which creates tarballs and [extract](https://github.com/mafintosh/tar-stream#extracting) which extracts tarballs. To [modify an existing tarball](https://github.com/mafintosh/tar-stream#modifying-existing-tarballs) use both.\n\n\nIt implementes USTAR with additional support for pax extended headers. It should be compatible with all popular tar distributions out there (gnutar, bsdtar etc)\n\n## Related\n\nIf you want to pack/unpack directories on the file system check out [tar-fs](https://github.com/mafintosh/tar-fs) which provides file system bindings to this module.\n\n## Packing\n\nTo create a pack stream use `tar.pack()` and call `pack.entry(header, [callback])` to add tar entries.\n\n``` js\nvar tar = require('tar-stream')\nvar pack = tar.pack() // p is a streams2 stream\n\n// add a file called my-test.txt with the content \"Hello World!\"\npack.entry({ name: 'my-test.txt' }, 'Hello World!')\n\n// add a file called my-stream-test.txt from a stream\nvar entry = pack.entry({ name: 'my-stream-test.txt' }, function(err) {\n // the stream was added\n // no more entries\n pack.finalize()\n})\nmyStream.pipe(entry)\n\n// pipe the pack stream somewhere\npack.pipe(process.stdout)\n```\n\n## Extracting\n\nTo extract a stream use `tar.extract()` and listen for `extract.on('entry', header, stream, callback)`\n\n``` js\nvar extract = tar.extract()\n\nextract.on('entry', function(header, stream, callback) {\n // header is the tar header\n // stream is the content body (might be an empty stream)\n // call next when you are done with this entry\n\n stream.resume() // just auto drain the stream\n stream.on('end', function() {\n callback() // ready for next entry\n })\n})\n\nextract.on('finish', function() {\n // all entries read\n})\n\npack.pipe(extract)\n```\n\n## Headers\n\nThe header object using in `entry` should contain the following properties.\nMost of these values can be found by stat'ing a file.\n\n``` js\n{\n name: 'path/to/this/entry.txt',\n size: 1314, // entry size. defaults to 0\n mode: 0644, // entry mode. defaults to to 0755 for dirs and 0644 otherwise\n mtime: new Date(), // last modified date for entry. defaults to now.\n type: 'file', // type of entry. defaults to file. can be:\n // file | link | symlink | directory | block-device\n // character-device | fifo | contigious-file\n linkname: 'path', // linked file name\n uid: 0, // uid of entry owner. defaults to 0\n gid: 0, // gid of entry owner. defaults to 0\n uname: 'maf', // uname of entry owner. defaults to null\n gname: 'staff', // gname of entry owner. defaults to null\n devmajor: 0, // device major version. defaults to 0\n devminor: 0 // device minor version. defaults to 0\n}\n```\n\n## Modifying existing tarballs\n\nUsing tar-stream it is easy to rewrite paths / change modes etc in an existing tarball.\n\n``` js\nvar extract = tar.extract()\nvar pack = tar.pack()\nvar path = require('path')\n\nextract.on('entry', function(header, stream, callback) {\n // let's prefix all names with 'tmp'\n header.name = path.join('tmp', header.name)\n // write the new entry to the pack stream\n stream.pipe(pack.entry(header, callback))\n})\n\nextract.on('finish', function() {\n // all entries done - lets finalize it\n pack.finalize()\n})\n\n// pipe the old tarball to the extractor\noldTarball.pipe(extract)\n\n// pipe the new tarball the another stream\npack.pipe(newTarball)\n```\n\n## Performance\n\n[See tar-fs for a performance comparison with node-tar](https://github.com/mafintosh/tar-fs/blob/master/README.md#performance)\n\n# License\n\nMIT\n", "readmeFilename": "README.md", "_id": "tar-stream@0.4.7", "_shasum": "1f1d2ce9ebc7b42765243ca0e8f1b7bfda0aadcd", "_from": "tar-stream@^0.4.6", "_resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-0.4.7.tgz" }