2023-06-07 12:38:58 +08:00
|
|
|
/** 判断是否为数组 */
|
2024-11-18 19:40:44 +08:00
|
|
|
export function isArray<T>(arg: T) {
|
2023-06-07 12:38:58 +08:00
|
|
|
return Array.isArray ? Array.isArray(arg) : Object.prototype.toString.call(arg) === "[object Array]"
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 判断是否为字符串 */
|
2024-11-18 19:40:44 +08:00
|
|
|
export function isString<T>(str: T) {
|
2023-06-08 13:39:06 +08:00
|
|
|
return typeof str === "string" || str instanceof String
|
2023-06-07 12:38:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** 判断是否为外链 */
|
2024-11-18 19:40:44 +08:00
|
|
|
export function isExternal(path: string) {
|
2022-08-22 10:17:28 +08:00
|
|
|
const reg = /^(https?:|mailto:|tel:)/
|
|
|
|
return reg.test(path)
|
|
|
|
}
|