<commit_before>(function() {
    'use strict';
    
    var path        = require('path'),
        fs          = require('fs'),
        zlib        = require('zlib'),
        
        tar         = require('tar'),
        fstream     = require('fstream'),
        
        check       = require('checkup'),
        pipe        = require('pipe-io'),
        files       = require('files-io');
    
    exports.pack    = function(from, to, callback) {
        check
            .type('callback', callback, 'function')
            .check({
                to: to,
                from: from
            });
        
        isDir(from, function(is) {
            var dir, name,
                
                optionsDir  = { path: from, type: 'Directory' },
                optionsTar  = { noProprietary: true },
                
                streamDir,
                streamTar,
                streamZip   = zlib.createGzip(),
                streamFile,
                
                isStr   = typeof to === 'string', 
                options = {
                    gzip: true
                };
            
            if (!is) {
                files.pipe(from, to, options, callback);
            } else {
                streamDir   = fstream.Reader(optionsDir);
                streamTar   = tar.Pack(optionsTar);
                    
                if (!isStr) {
                    streamFile  = to;
                } else {
                    dir     = path.dirname(to);
                    name    = path.basename(to, '.gz');
                    
                    if (dir !== '/')
                        dir += path.sep;
                    
                    to      = dir + name + '.tar.gz';
                    
                    streamFile = fs.createWriteStream(to);
                }
                
                pipe([
                    streamDir,
                    streamTar,
                    streamZip,
                    streamFile
                ], callback);
            }
        });
    };
    
    exports.unpack  = function(from, to, callback) {
        var write, error,
            isStr   = typeof from === 'string',
            isTarGz = /(\.gz|\.tar\.gz)$/.test(from),
            
            options = {
                gunzip    : true
            };
        
        check
            .type('callback', callback, 'function')
            .check({
                to: to,
                from: from
            });
        
        if (!isStr)
            write   = to;
        else if (isTarGz)
            write   = tar.Extract({ path: path.dirname(to) });
        else<commit_msg>fix(jag) unpack: tar extract when gzip only<commit_after>(function() {
    'use strict';
    
    var path        = require('path'),
        fs          = require('fs'),
        zlib        = require('zlib'),
        
        tar         = require('tar'),
        fstream     = require('fstream'),
        
        check       = require('checkup'),
        pipe        = require('pipe-io'),
        files       = require('files-io');
    
    exports.pack    = function(from, to, callback) {
        check
            .type('callback', callback, 'function')
            .check({
                to: to,
                from: from
            });
        
        isDir(from, function(is) {
            var dir, name,
                
                optionsDir  = { path: from, type: 'Directory' },
                optionsTar  = { noProprietary: true },
                
                streamDir,
                streamTar,
                streamZip   = zlib.createGzip(),
                streamFile,
                
                isStr   = typeof to === 'string', 
                options = {
                    gzip: true
                };
            
            if (!is) {
                files.pipe(from, to, options, callback);
            } else {
                streamDir   = fstream.Reader(optionsDir);
                streamTar   = tar.Pack(optionsTar);
                    
                if (!isStr) {
                    streamFile  = to;
                } else {
                    dir     = path.dirname(to);
                    name    = path.basename(to, '.gz');
                    
                    if (dir !== '/')
                        dir += path.sep;
                    
                    to      = dir + name + '.tar.gz';
                    
                    streamFile = fs.createWriteStream(to);
                }
                
                pipe([
                    streamDir,
                    streamTar,
                    streamZip,
                    streamFile
                ], callback);
            }
        });
    };
    
    exports.unpack  = function(from, to, callback) {
        var write, error,
            isStr   = typeof from === 'string',
            isGz    = /\.gz$/.test(from),
            isTarGz = /\.tar\.gz$/.test(from),
            
            options = {
                gunzip    : true
            };
        
        check
            .type('callback', callback, 'function')
            .check({
                to: to,
                from: from
            });
        
        if (!isStr || isGz)
            write   = to;
        else if (isTarGz)
            write   = tar.Extract({ path: path.dirname(to) });
        else 
{'fraction_non_alphanumeric': 0.10833953834698436, 'fraction_numerical': 0.0, 'mean_word_length': 0.7963891675025075, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2909697', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1293, 'n_words': 272}