const patterns = [
'foo',
'bar',
'baz',
'qux',
'quux',
'abc',
'def',
'ghi'
];
const re = new RegExp('(' + patterns.join('|') + ')');
const toTest = patterns.slice().sort();for (const path of toTest) {
const isOkay = patterns.some((pat) => pat === path);
}for (const path of toTest) {
const isOkay = re.test(path);
}