function replace (regex, replacement, fileFilter) {
  if (fileFilter instanceof Array) {
    fileFilter = fileFilter.reduce(pcomp);
  } else if (!fileFilter) {
    fileFilter = () => true;
  }
  return files => {
    _.forEach(files, (file, path) => {
      if (fileFilter(file, path)) {
        file.contents = new Buffer(file.contents.toString().replace(regex, replacement));
      }
    });
  }
}
function replace (regex, replacement, fileFilter) {
  if (fileFilter instanceof Array) {
    fileFilter = fileFilter.reduce(pcomp);
  } else if (!fileFilter) {
    fileFilter = () => true;
  }
  return files => {
    _.forEach(files, (file, path) => {
      if (fileFilter(file, path)) {
        file.contents = new Buffer(file.contents.toString().replace(regex, replacement));
      }
    });
  }
}
function replace ( regex , replacement , fileFilter ) { if ( fileFilter instanceof Array ) { fileFilter = fileFilter . reduce ( pcomp ) ; } else if ( ! fileFilter ) { fileFilter = ( ) => true ; } return files => { _ . forEach ( files , ( file , path ) => { if ( fileFilter ( file , path ) ) { file . contents = new Buffer ( file . contents . toString ( ) . replace ( regex , replacement ) ) ; } } ) ; } }
return metalsmith ware for carrying out the given replacement
on files for which the given fileFilter returns true
return metalsmith ware for carrying out the given replacement on files for which the given fileFilter returns true