chore(runtime-core): add `isRegExp` to check `RegExp` (#6041)

This commit is contained in:
webfansplz 2022-11-14 09:14:28 +08:00 committed by GitHub
parent c513126c5d
commit 0187f998f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -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 */

View File

@ -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'