lib/ignore.js
function filter(p, rules, root, isDirectory, included) {
  p = path.relative(root, p);
  for (var i in rules) {
    var rule = rules[i];
    if (isDirectory) {
      if (rule.match(p) || rule.match("/" + p) ||
          rule.match(p + "/") || rule.match("/" + p + "/")
         ) {
        return rule.negate;
      }
    } else {
      if (rule.match(p) || rule.match("/" + p)) {
        return rule.negate;
      }
    }
  }
  return included;
}
function filter(p, rules, root, isDirectory, included) {
  p = path.relative(root, p);
  for (var i in rules) {
    var rule = rules[i];
    if (isDirectory) {
      if (rule.match(p) || rule.match("/" + p) ||
          rule.match(p + "/") || rule.match("/" + p + "/")
         ) {
        return rule.negate;
      }
    } else {
      if (rule.match(p) || rule.match("/" + p)) {
        return rule.negate;
      }
    }
  }
  return included;
}
function filter ( p , rules , root , isDirectory , included ) { p = path . relative ( root , p ) ; for ( var i in rules ) { var rule = rules [ i ] ; if ( isDirectory ) { if ( rule . match ( p ) || rule . match ( "/" + p ) || rule . match ( p + "/" ) || rule . match ( "/" + p + "/" ) ) { return rule . negate ; } } else { if ( rule . match ( p ) || rule . match ( "/" + p ) ) { return rule . negate ; } } } return included ; }
check if a given file or dir should be kept

@param {String}  p
@param {Array}   rules
@param {String}  root
@param {Boolean} isDirectory
@param {Boolean} included
@return {Boolean}
check if a given file or dir should be kept