提交 | 用户 | age
|
53cc6f
|
1 |
export function isFunction(val) { |
S |
2 |
return typeof val === 'function'; |
|
3 |
} |
|
4 |
export function isPlainObject(val) { |
|
5 |
return val !== null && typeof val === 'object' && !Array.isArray(val); |
|
6 |
} |
|
7 |
export function isPromise(val) { |
|
8 |
return isPlainObject(val) && isFunction(val.then) && isFunction(val.catch); |
|
9 |
} |
|
10 |
export function isDef(value) { |
|
11 |
return value !== undefined && value !== null; |
|
12 |
} |
|
13 |
export function isObj(x) { |
|
14 |
const type = typeof x; |
|
15 |
return x !== null && (type === 'object' || type === 'function'); |
|
16 |
} |
|
17 |
export function isNumber(value) { |
|
18 |
return /^\d+(\.\d+)?$/.test(value); |
|
19 |
} |
|
20 |
export function isBoolean(value) { |
|
21 |
return typeof value === 'boolean'; |
|
22 |
} |
|
23 |
const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i; |
|
24 |
const VIDEO_REGEXP = /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv)/i; |
|
25 |
export function isImageUrl(url) { |
|
26 |
return IMAGE_REGEXP.test(url); |
|
27 |
} |
|
28 |
export function isVideoUrl(url) { |
|
29 |
return VIDEO_REGEXP.test(url); |
|
30 |
} |