<commit_before>'use strict';

const isStream = require('is-stream');
const Promise  = require('pinkie-promise');
const globby   = require('globby');
const pify     = require('pify');
const tar      = require('tar-stream');
const fs       = require('fs');
const _        = require('lodash');

/**
 * Writes the given file to the given tar pack
 * @param {string} file
 * @param {Pack} pack
 * @returns {Promise.<boolean>} A promise for whether the file was packed
 */
const packFile = function (file, pack) {
    return pify(fs.stat)(file)
        .then(stat => !stat.isFile() ? Promise.resolve() : new Promise((resolve, reject) => {
            let entry = pack.entry(_.assign(stat, {name: file}), err => err ? reject(err) : resolve(true));
            fs.createReadStream(file).pipe(entry);
        }));
};

/**
 * Writes the given files to the given tar pack
 * @param {string[]} paths
 * @param {Pack} pack
 * @returns {Promise.<string[]>} A promise for an array of packed files
 */
const packAll = function (paths, pack) {
    let entries = [];
    return _.reduce(paths, (queue, path) => queue.then(() =>
            packFile(path, pack).then(packed => packed ? entries.push(path) : true)), Promise.resolve())
        .then(() => entries);
};

/**
 * Creates a tar archive containing all files matched by the given input glob(s). The directory structure is preserved.
 * @param {string|string[]} globs
 * @param {string} [output]
 * @returns {stream.Readable|Promise.<string[]>} A readable stream of the tar archive if no output argument is provided,
 *      or a promise for writing the tar archive to the given output destination.
 */
const nectar = function (globs, output) {
    let writeStream = null;<commit_msg>Use lstat instead of stat<commit_after>'use strict';

const isStream = require('is-stream');
const Promise  = require('pinkie-promise');
const globby   = require('globby');
const pify     = require('pify');
const tar      = require('tar-stream');
const fs       = require('fs');
const _        = require('lodash');

/**
 * Writes the given file to the given tar pack
 * @param {string} file
 * @param {Pack} pack
 * @returns {Promise.<boolean>} A promise for whether the file was packed
 */
const packFile = function (file, pack) {
    return pify(fs.lstat)(file)
        .then(stat => !stat.isFile() ? Promise.resolve() : new Promise((resolve, reject) => {
            let entry = pack.entry(_.assign(stat, {name: file}), err => err ? reject(err) : resolve(true));
            fs.createReadStream(file).pipe(entry);
        }));
};

/**
 * Writes the given files to the given tar pack
 * @param {string[]} paths
 * @param {Pack} pack
 * @returns {Promise.<string[]>} A promise for an array of packed files
 */
const packAll = function (paths, pack) {
    let entries = [];
    return _.reduce(paths, (queue, path) => queue.then(() =>
            packFile(path, pack).then(packed => packed ? entries.push(path) : true)), Promise.resolve())
        .then(() => entries);
};

/**
 * Creates a tar archive containing all files matched by the given input glob(s). The directory structure is preserved.
 * @param {string|string[]} globs
 * @param {string} [output]
 * @returns {stream.Readable|Promise.<string[]>} A readable stream of the tar archive if no output argument is provided,
 *      or a promise for writing the tar archive to the given output destination.
 */
const nectar = function (globs, output) {
    let writeStream = null;
{'fraction_non_alphanumeric': 0.14859786065336802, 'fraction_numerical': 0.0, 'mean_word_length': 3.476067270375162, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, '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': '4063513', 'n_tokens_mistral': 993, 'n_tokens_neox': 987, 'n_words': 353}