( patterns: Array<string | RegExp>, str: string, )
| 1 | import picomatch from 'picomatch' |
| 2 | |
| 3 | export const matcher = ( |
| 4 | patterns: Array<string | RegExp>, |
| 5 | str: string, |
| 6 | ): boolean => { |
| 7 | if (patterns.length === 0) { |
| 8 | return false |
| 9 | } |
| 10 | const matchers = patterns.map((pattern) => { |
| 11 | if (typeof pattern === 'string') { |
| 12 | return picomatch(pattern) |
| 13 | } else { |
| 14 | return (s: string) => pattern.test(s) |
| 15 | } |
| 16 | }) |
| 17 | |
| 18 | return matchers.some((isMatch) => isMatch(str)) |
| 19 | } |
no outgoing calls
no test coverage detected