Files
fredy/lib/utils.js

12 lines
265 B
JavaScript
Raw Normal View History

function isOneOf(word, arr) {
if (arr == null || arr.length === 0) {
return false;
}
2018-01-20 20:23:27 +01:00
const expression = String.raw`\b(${arr.join('|')})\b`;
const blacklist = new RegExp(expression, 'ig');
return blacklist.test(word);
2018-01-20 20:23:27 +01:00
}
module.exports = { isOneOf };