UNPKG

ts-cast

Version:
6 lines (5 loc) 232 B
import { withName } from '../helpers/names'; export const matching = (pattern) => { const re = pattern instanceof RegExp ? pattern : new RegExp(pattern); return withName((value) => re.test(value), `matching ${pattern}`); };