tar-parse-one

Parse a single file from tar.gz and pipe contents

Usage no npm install needed!

<script type="module">
  import tarParseOne from 'https://cdn.skypack.dev/tar-parse-one';
</script>

README

⚒️ tar-parse-one

Parse a single file from tar.gz archive and pipe contents

license commonjs module npm version npm downloads

Install

npm install --save tar-parse-one

or

yarn install tar-parse-one

Import module

const parseOne = require('tar-parse-one');

or

import parseOne from 'tar-parse-one';

Usage

parseOne([regex]) is a convenience method that unpacks only one file from the archive and pipes the contents down (not the entry itself). If no search criteria is specified, the first file in the archive will be unpacked. Otherwise, each filename will be compared to the criteria and the first one to match will be unpacked and piped down. If no file matches then the the stream will end without any content.

Example:

fs.createReadStream('path/to/archive.tar.gz')
  .pipe(parseOne())
  .pipe(fs.createWriteStream('firstFile.txt'));

Build

npm run build // for single build

npm run watch // to watch changes

or

yarn build // for single build

yarn watch // to watch changes

Author

Sergey Frangulov

License

ISC License

Copyright (c) 2020 Sergey Frangulov

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.