mirror of
https://github.com/un-pany/v3-admin-vite.git
synced 2025-04-22 20:09:19 +08:00
16 lines
441 B
TypeScript
16 lines
441 B
TypeScript
/** 判断是否为数组 */
|
|
export function isArray<T>(arg: T) {
|
|
return Array.isArray ? Array.isArray(arg) : Object.prototype.toString.call(arg) === "[object Array]"
|
|
}
|
|
|
|
/** 判断是否为字符串 */
|
|
export function isString<T>(str: T) {
|
|
return typeof str === "string" || str instanceof String
|
|
}
|
|
|
|
/** 判断是否为外链 */
|
|
export function isExternal(path: string) {
|
|
const reg = /^(https?:|mailto:|tel:)/
|
|
return reg.test(path)
|
|
}
|