ericcarraway / typo-hunter

tools for finding typos in codebases and prose
http://typo-hunter.com/
MIT License
0 stars 0 forks source link

filter by array #15

Closed ericcarraway closed 8 years ago

ericcarraway commented 8 years ago

https://lodash.com/docs _.difference(array, [values])

screen shot 2016-04-28 at 9 57 30 pm screen shot 2016-04-28 at 10 00 14 pm

ericcarraway commented 8 years ago
/**
 * Filter from the input values contained in the filter arr
 * @param {array} inputArr - an unfiltered array
 * @param {array} filterArr - an array of values to filter out
 * @return {array}
 */

var filterByArr = function (inputArr, filterArr) {
    // return false if input is in the filterArr
    // return true if input is NOT in the filterArr
    var isAllowed = function (input) {
        return filterArr.indexOf(input) === -1;
    };

    return inputArr.filter(isAllowed);
};