You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.2 KiB
66 lines
1.2 KiB
export { |
|
isArguments, |
|
isArrayBuffer, |
|
isArrayLike, |
|
isArrayLikeObject, |
|
isBuffer, |
|
isBoolean, |
|
isDate, |
|
isElement, |
|
isEmpty, |
|
isEqual, |
|
isEqualWith, |
|
isError, |
|
isFunction, |
|
isFinite, |
|
isLength, |
|
isMap, |
|
isMatch, |
|
isMatchWith, |
|
isNative, |
|
isNil, |
|
isNumber, |
|
isNull, |
|
isObjectLike, |
|
isPlainObject, |
|
isRegExp, |
|
isSafeInteger, |
|
isSet, |
|
isString, |
|
isSymbol, |
|
isTypedArray, |
|
isUndefined, |
|
isWeakMap, |
|
isWeakSet, |
|
} from 'lodash-es' |
|
|
|
const toString = Object.prototype.toString |
|
|
|
export function is(val: unknown, type: string) { |
|
return toString.call(val) === `[object ${type}]` |
|
} |
|
|
|
export function isDef<T = unknown>(val?: T): val is T { |
|
return typeof val !== 'undefined' |
|
} |
|
|
|
export function isObject(val: any): val is Record<any, any> { |
|
return val !== null && is(val, 'Object') |
|
} |
|
|
|
export function isArray(val: any): val is Array<any> { |
|
return val && Array.isArray(val) |
|
} |
|
|
|
export function isWindow(val: any): val is Window { |
|
return typeof window !== 'undefined' && is(val, 'Window') |
|
} |
|
|
|
export const isServer = typeof window === 'undefined' |
|
|
|
export const isClient = !isServer |
|
|
|
export function isHttpUrl(path: string): boolean { |
|
const reg = /^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- ./?%&=]*)?/ |
|
return reg.test(path) |
|
}
|
|
|