@technobuddha/library
Version:
A large library of useful functions
15 lines (14 loc) • 469 B
JavaScript
import isRegExp from 'lodash/isRegExp';
import isString from 'lodash/isString';
export function matches(text, match) {
text = text.trim().toLowerCase();
if (isRegExp(match))
return match.test(text);
if (isString(match))
return match.toLowerCase() === text;
for (const m of match)
if ((isRegExp(m) && m.test(text)) || (isString(m) && m.toLowerCase() === text))
return true;
return false;
}
export default matches;