chore(runtime-core): add `isRegExp` to check `RegExp` (#6041)
This commit is contained in:
parent
c513126c5d
commit
0187f998f7
|
@ -26,6 +26,7 @@ import {
|
|||
import {
|
||||
isString,
|
||||
isArray,
|
||||
isRegExp,
|
||||
ShapeFlags,
|
||||
remove,
|
||||
invokeArrayFns
|
||||
|
@ -350,7 +351,7 @@ function matches(pattern: MatchPattern, name: string): boolean {
|
|||
return pattern.some((p: string | RegExp) => matches(p, name))
|
||||
} else if (isString(pattern)) {
|
||||
return pattern.split(',').includes(name)
|
||||
} else if (pattern.test) {
|
||||
} else if (isRegExp(pattern)) {
|
||||
return pattern.test(name)
|
||||
}
|
||||
/* istanbul ignore next */
|
||||
|
|
|
@ -54,6 +54,8 @@ export const isSet = (val: unknown): val is Set<any> =>
|
|||
|
||||
export const isDate = (val: unknown): val is Date =>
|
||||
toTypeString(val) === '[object Date]'
|
||||
export const isRegExp = (val: unknown): val is RegExp =>
|
||||
toTypeString(val) === '[object RegExp]'
|
||||
export const isFunction = (val: unknown): val is Function =>
|
||||
typeof val === 'function'
|
||||
export const isString = (val: unknown): val is string => typeof val === 'string'
|
||||
|
|
Loading…
Reference in New Issue