<commit_before>var assert = require('assert');
var R = require('..');

describe('filter', function() {
    var even = function(x) {return x % 2 === 0;};

    it('reduces an array to those matching a filter', function() {
        assert.deepEqual(R.filter(even, [1, 2, 3, 4, 5]), [2, 4]);
    });

    it('returns an empty array if no element matches', function() {
        assert.deepEqual(R.filter(function(x) { return x > 100; }, [1, 9, 99]), []);
    });

    it('returns an empty array if asked to filter an empty array', function() {
        assert.deepEqual(R.filter(function(x) { return x > 100; }, []), []);
    });

    it('should be automatically curried', function() {
        var onlyEven = R.filter(even);
        assert.deepEqual(onlyEven([1, 2, 3, 4, 5, 6, 7]), [2, 4, 6]);
    });

    it('throws on zero arguments', function() {
        assert.throws(R.filter, TypeError);
    });
});

describe('filter.idx', function() {
    var even = function(x) {return x % 2 === 0;};
    var everyOther = function(val, idx) {return idx % 2 === 0;};
    var lastTwo = function(val, idx, list) {return list.length - idx < 3;};

    it('works just like a normal filter', function() {
        assert.deepEqual(R.filter.idx(even, [1, 2, 3, 4, 5]), [2, 4]);
    });<commit_msg>test for filter dispatch<commit_after>var assert = require('assert');
var R = require('..');

describe('filter', function() {
    var even = function(x) {return x % 2 === 0;};

    it('reduces an array to those matching a filter', function() {
        assert.deepEqual(R.filter(even, [1, 2, 3, 4, 5]), [2, 4]);
    });

    it('returns an empty array if no element matches', function() {
        assert.deepEqual(R.filter(function(x) { return x > 100; }, [1, 9, 99]), []);
    });

    it('returns an empty array if asked to filter an empty array', function() {
        assert.deepEqual(R.filter(function(x) { return x > 100; }, []), []);
    });

    it('dispatches to passed-in non-Array object with a `filter` method', function() {
        var f = {filter: function(f) { return f('called f.filter'); }};
        assert.equal(R.filter(function(s) { return s; }, f), 'called f.filter');
    });

    it('should be automatically curried', function() {
        var onlyEven = R.filter(even);
        assert.deepEqual(onlyEven([1, 2, 3, 4, 5, 6, 7]), [2, 4, 6]);
    });

    it('throws on zero arguments', function() {
        assert.throws(R.filter, TypeError);
    });
});

describe('filter.idx', function() {
    var even = function(x) {return x % 2 === 0;};
    var everyOther = function(val, idx) {return idx % 2 === 0;};
    var lastTwo = function(val, idx, list) {return list.length - idx < 3;};

    it('works just like a normal filter', function() {
        assert.deepEqual(R.filter.idx(even, [1, 2, 3, 4, 5]), [2, 4]);
    });
{'fraction_non_alphanumeric': 0.19274537695590327, 'fraction_numerical': 0.029160739687055477, 'mean_word_length': 3.059163059163059, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '876712', 'n_tokens_mistral': 985, 'n_tokens_neox': 901, 'n_words': 286}