UNPKG

@fruits-chain/react-native-xiaoshu

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