code: function fileFilter(filter) {
    if (filter) {
       if (typeof filter === 'string') {
          var regex = new RegExp(filter);
          return function(filePath) { return regex.test(filePath); }
       }
       else if (filter instanceof RegExp)
          return function(filePath) { return filter.test(filePath); }
       else {   // must be a function itself
          return filter;
       }
     }
     else  // none, return "pass all"
        return function() { return true; };
  }
docs: /* calculate file filter function