<commit_before>'use strict';

let somefilter  = require('somefilter');
let checkResult = value => value && value.length;
let limier      = somefilter(checkResult, [
    findByAbr,
    findByName
]);

module.exports = function(pattern, list) {
    check(pattern, list);
    
    return limier(pattern, list) || [];
};

function findByName(str, names) {
    return names.filter(name =>
        ~name.indexOf(str)
    );
}

function findByAbr(str, names) {
    let regstr = str.split('').join('.*') + '.*';
    let regexp = RegExp(`^${ regstr }$`, 'i');
    
    return names.filter(name =>
        regexp.test(name)
    );
}

function check(pattern, list) {
    if (typeof pattern !== 'string')
        throw Error('pattern should be string!');
    
    if (!Array.isArray(list))
        throw Error('list should be an array!');
}<commit_msg>chore(limier) let -> const<commit_after>'use strict';

const somefilter  = require('somefilter');
const checkResult = value => value && value.length;
const limier      = somefilter(checkResult, [
    findByAbr,
    findByName
]);

module.exports = function(pattern, list) {
    check(pattern, list);
    
    return limier(pattern, list) || [];
};

function findByName(str, names) {
    return names.filter(name =>
        ~name.indexOf(str)
    );
}

function findByAbr(str, names) {
    const regstr = str.split('').join('.*') + '.*';
    const regexp = RegExp(`^${ regstr }$`, 'i');
    
    return names.filter(name =>
        regexp.test(name)
    );
}

function check(pattern, list) {
    if (typeof pattern !== 'string')
        throw Error('pattern should be string!');
    
    if (!Array.isArray(list))
        throw Error('list should be an array!');
}
{'fraction_non_alphanumeric': 0.1655901350557839, 'fraction_numerical': 0.0, 'mean_word_length': 3.0668257756563246, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '7268483', 'n_tokens_mistral': 541, 'n_tokens_neox': 543, 'n_words': 128}