<commit_before>'use strict';

module.exports = ignore;
ignore.Ignore = Ignore;

var EE        = require('events').EventEmitter;
var node_util = require('util');
var node_fs   = require('fs');

function ignore (options){
    return new Ignore(options);
}

var exists = node_fs.existsSync ?
    function (file) {
        return node_fs.existsSync(file);
    } :

    // if node <= 0.6, there's no fs.existsSync method.
    function (file) {
        try {
            node_fs.statSync(file);
            return true;
        } catch(e) {
            return false;
        }
    };

// Select the first existing file of the file list
ignore.select = function (files) {
    var selected;

    files.some(function (file) {
        if( exists(file) ){
            selected = file;
            return true;
        }
    });

    return selected;
};


// @param {Object} options
// - ignore: {Array}
// - twoGlobstars: {boolean=false} enable pattern `'**'` (two consecutive asterisks), default to `false`.
//      If false, ignore patterns with two globstars will be omitted
// - matchCase: {boolean=true} case sensitive.
//      By default, git is case-insensitive
function Ignore (options){
    options = options || {};

    this.options = options;
    this._patterns = [];
    this._rules = [];
    this._ignoreFiles = [];

    options.ignore = options.ignore || [
        // Some files or directories which we should ignore for most cases.
        '.git',
        '.svn',
        '.DS_Store'
    ];

    this.addPattern(options.ignore);
}

// Events:
// 'warn': , 
//      will warn when encounter '`**`' (two consecutive asterisks)
//      which is not compatible with all platforms (not works on Mac OS for example)
node_util.inherits(Ignore, EE);

function makeArray (subject) {
    return Array.isArray(subject) ? 
        subject :
        subject === undefined || subject === null ?
            [] :
            [subject];
}


// @param {Array.<string>|string} pattern
Ignore.prototype.addPattern = function(pattern) {
    makeArray(pattern).forEach(this._addPattern, this);
    return this;
};


Ignore.prototype._addPattern = function(pattern) {
    if(this._simpleTest(pattern)){
        var rule = this._createRule(pattern);
        this._rules.push(rule);
    }
};


Ignore.prototype.filter = function(paths) {
    return paths.filter(this._filter, this);
};


Ignore.prototype._simpleTest = function(pattern) {
    var pass = 
        // Whitespace dirs are allowed, so only filter blank pattern.
        pattern && 
        // And not start with a '#'
        pattern.indexOf('#') !== 0 && 

        ! ~ this._patterns.indexOf(pattern);

    this._patterns.push(pattern);

    if( ~ pattern.indexOf('**') ){
        this.emit('warn', {
            code: 'WGLOBSTARS',
            data: {
                pattern: origin
            },
            message: '`**` found, which is not compatible cross all platforms.' 
        });

        if(!this.options.twoGlobstars){
            return false;
        }
    }
<commit_msg>typo on line #118<commit_after>'use strict';

module.exports = ignore;
ignore.Ignore = Ignore;

var EE        = require('events').EventEmitter;
var node_util = require('util');
var node_fs   = require('fs');

function ignore (options){
    return new Ignore(options);
}

var exists = node_fs.existsSync ?
    function (file) {
        return node_fs.existsSync(file);
    } :

    // if node <= 0.6, there's no fs.existsSync method.
    function (file) {
        try {
            node_fs.statSync(file);
            return true;
        } catch(e) {
            return false;
        }
    };

// Select the first existing file of the file list
ignore.select = function (files) {
    var selected;

    files.some(function (file) {
        if( exists(file) ){
            selected = file;
            return true;
        }
    });

    return selected;
};


// @param {Object} options
// - ignore: {Array}
// - twoGlobstars: {boolean=false} enable pattern `'**'` (two consecutive asterisks), default to `false`.
//      If false, ignore patterns with two globstars will be omitted
// - matchCase: {boolean=true} case sensitive.
//      By default, git is case-insensitive
function Ignore (options){
    options = options || {};

    this.options = options;
    this._patterns = [];
    this._rules = [];
    this._ignoreFiles = [];

    options.ignore = options.ignore || [
        // Some files or directories which we should ignore for most cases.
        '.git',
        '.svn',
        '.DS_Store'
    ];

    this.addPattern(options.ignore);
}

// Events:
// 'warn': , 
//      will warn when encounter '`**`' (two consecutive asterisks)
//      which is not compatible with all platforms (not works on Mac OS for example)
node_util.inherits(Ignore, EE);

function makeArray (subject) {
    return Array.isArray(subject) ? 
        subject :
        subject === undefined || subject === null ?
            [] :
            [subject];
}


// @param {Array.<string>|string} pattern
Ignore.prototype.addPattern = function(pattern) {
    makeArray(pattern).forEach(this._addPattern, this);
    return this;
};


Ignore.prototype._addPattern = function(pattern) {
    if(this._simpleTest(pattern)){
        var rule = this._createRule(pattern);
        this._rules.push(rule);
    }
};


Ignore.prototype.filter = function(paths) {
    return paths.filter(this._filter, this);
};


Ignore.prototype._simpleTest = function(pattern) {
    var pass = 
        // Whitespace dirs are allowed, so only filter blank pattern.
        pattern && 
        // And not start with a '#'
        pattern.indexOf('#') !== 0 && 

        ! ~ this._patterns.indexOf(pattern);

    this._patterns.push(pattern);

    if( ~ pattern.indexOf('**') ){
        this.emit('warn', {
            code: 'WGLOBSTARS',
            data: {
                origin: pattern
            },
            message: '`**` found, which is not compatible cross all platforms.' 
        });

        if(!this.options.twoGlobstars){
            return false;
        }
    }

{'fraction_non_alphanumeric': 0.13497033618984838, 'fraction_numerical': 0.0014831905075807514, 'mean_word_length': 2.2213375796178343, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '6448024', 'n_tokens_mistral': 1784, 'n_tokens_neox': 1715, 'n_words': 461}