@fruits-chain/react-native-xiaoshu
Version:
React Native UI library
41 lines (32 loc) • 1.01 kB
JavaScript
const isType = t => v => Object.prototype.toString.call(v) === `[object ${t}]`;
/** 已经声明/定义的数据 */
export function isDef(val) {
return val !== undefined && val !== null;
}
/** 是数组 */
export const isArray = v => isType('Array')(v);
/** 是对象 */
export const isObject = v => isType('Object')(v);
/** 是函数 */
export const isFunction = v => isType('Function')(v);
/** 是一个 Promise */
export const isPromise = val => {
return isObject(val) && isFunction(val.then) && isFunction(val.catch);
};
/** 是手机号码 */
export function isMobile(value) {
value = value.replace(/[^-|\d]/g, '');
return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
}
/** 是空 */
export function isNullish(value) {
return ['', undefined, null].includes(value);
}
/**
* 是否是 value 类型
* @description 在业务中,null 可以是一个 value 值
*/
export function isValue(val) {
return val !== undefined;
}
//# sourceMappingURL=typeof.js.map