return a predicate which matches files with the given extension(s);
function filenameExtensionFilter (ext) {
  if (typeof ext === 'string') {
    return (_, path) => path.endsWith('.' + ext);
  } else if (ext instanceof Array) {
    return ext
      .map(filenameExtensionFilter)
      .reduce(pcomp);
  }
}