targz-glob
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

This is a TypeScript module that provides a function to extract files from a gzipped tar archive using glob patterns.

The tarGzGlob function takes a Stream object representing the gzipped tar archive and an array of glob patterns. It returns a promise that resolves to a map of file names to file contents.

import { tarGzGlob } from 'targz-glob';

const stream = fs.createReadStream('archive.tar.gz');
const patterns = ['**/*.txt', '**/*.md'];
// globs to match files against, relative to the archive root directory (e.g., '/foo/bar')
const files = await tarGzGlob(stream, patterns);

console.log(files);

The tarGzGlobFromFile function is a convenience function that takes a file path and an array of glob patterns and calls the tarGzGlob function with a Stream object that is created from the file.

import { tarGzGlobFromFile } from 'targz-glob';
const file = './path_to_/archive.tar.gz' // or a Buffer instance of the contents of that file
const patterns = ['**/*.txt', '**/*.md'];

const files = await tarGzGlobFromFile(file, patterns);
console.log(files)

Auto-generated with Blackbox AI

Readme

Keywords

none

Package Sidebar

Install

npm i targz-glob

Weekly Downloads

2

Version

0.0.5

License

MIT

Unpacked Size

10.4 kB

Total Files

8

Last publish

Collaborators

  • dominicvonk