moy-fp
Version:
A functional programming library.
22 lines (19 loc) • 463 B
JavaScript
import curry from '../Function/curry'
/**
* RegExp -> String -> Boolean
*/
const test = curry(
(pattern, string) => {
const regexp = new RegExp(
pattern.source,
(pattern.global ? 'g' : '') +
(pattern.ignoreCase ? 'i' : '') +
(pattern.multiline ? 'm' : '') +
(pattern.sticky ? 'y' : '') +
(pattern.unicode ? 'u' : '') +
(pattern.dotAll ? 's' : '')
);
return regexp.test(string)
}
)
export default test