var textCache = {};
const textFilter = function(where, what) {
  var prepared = textCache[what];
  if(!prepared){
    var tokens = what.split(/\s/)
    textCache[what] = prepared = tokens.map(token => token[0] === '-' ? {has: false, text: token.substr(1)}: {has: true, text: token});
  }

  var yep = true;
  for( var i = 0, _i = prepared.length; i < _i; i++ ){
    var preparedElement = prepared[ i ];
    if(preparedElement.text === '')
      continue;
    var matched = where.indexOf(preparedElement.text)>-1;
    if(preparedElement.has === false && matched){
      return false
    }else if(preparedElement.has === true && !matched)
      yep = false;
  }

  return yep;
};
export {textFilter};