<commit_before>'use strict';

var bz2 = require('seek-bzip');
var File = require('vinyl');
var isBzip2 = require('is-bzip2');
var stripDirs = require('strip-dirs');
var tar = require('tar-stream');
var through = require('through2');

/**
 * tar.bz2 decompress plugin
 *
 * @param {Object} opts
 * @api public
 */

module.exports = function (opts) {
	opts = opts || {};
	opts.strip = +opts.strip || 0;

	return through.obj(function (file, enc, cb) {
		var self = this;
		var extract = tar.extract();

		if (file.isNull()) {
			cb(null, file);
			return;
		}

		if (file.isStream()) {
			cb(new Error('Streaming is not supported'));
			return;
		}

		if (!isBzip2(file.contents)) {
			cb(null, file);
			return;
		}

		extract.on('error', function (err) {
			cb(err);
			return;
		});

		extract.on('entry', function (header, stream, done) {
			var chunk = [];
			var len = 0;

			stream.on('data', function (data) {
				chunk.push(data);
				len += data.length;
			});

			stream.on('end', function () {
				if (header.type !== 'directory') {
					self.push(new File({
						contents: Buffer.concat(chunk, len),
						path: stripDirs(header.name, opts.strip)
					}));
				}

				done();
			});
		});

		extract.on('finish', function () {
			cb();
		});

		extract.end(bz2.decode(file.contents));
	});
};<commit_msg>Tweaks<commit_after>'use strict';

var bz2 = require('seek-bzip');
var File = require('vinyl');
var isBzip2 = require('is-bzip2');
var stripDirs = require('strip-dirs');
var tar = require('tar-stream');
var through = require('through2');

/**
 * tar.bz2 decompress plugin
 *
 * @param {Object} opts
 * @api public
 */

module.exports = function (opts) {
	opts = opts || {};
	opts.strip = +opts.strip || 0;

	return through.obj(function (file, enc, cb) {
		var self = this;
		var extract = tar.extract();

		if (file.isNull()) {
			cb(null, file);
			return;
		}

		if (file.isStream()) {
			cb(new Error('Streaming is not supported'));
			return;
		}

		if (!isBzip2(file.contents)) {
			cb(null, file);
			return;
		}

		extract.on('entry', function (header, stream, done) {
			var chunk = [];
			var len = 0;

			stream.on('data', function (data) {
				chunk.push(data);
				len += data.length;
			});

			stream.on('end', function () {
				if (header.type !== 'directory') {
					self.push(new File({
						contents: Buffer.concat(chunk, len),
						path: stripDirs(header.name, opts.strip)
					}));
				}

				done();
			});
		});

		extract.on('error', cb);
		extract.on('finish', cb);
		extract.end(bz2.decode(file.contents));
	});
};
{'fraction_non_alphanumeric': 0.19444444444444445, 'fraction_numerical': 0.007042253521126761, 'mean_word_length': 3.104333868378812, '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': '7329418', 'n_tokens_mistral': 1075, 'n_tokens_neox': 896, 'n_words': 204}