mix-ui
Version:
mix-ui,对于uView UI的补充和组合,用于uni-app生态的UI框架
75 lines (67 loc) • 1.31 kB
JavaScript
/**
* Created by PanJiaChen on 16/11/18.
*/
/**
* 是否全是小写字母
* @param {string} str
* @returns {Boolean}
*/
function lower(str) {
const reg = /^[a-z]+$/
return reg.test(str)
}
/**
* 是否全是大写字母
* @param {string} str
* @returns {Boolean}
*/
function upper(str) {
const reg = /^[A-Z]+$/
return reg.test(str)
}
/**
* 是否字符串
* @param {string} str
* @returns {Boolean}
*/
function string(str) {
if (typeof str === 'string' || str instanceof String) {
return true
}
return false
}
/**
* 是否布尔
* @param {Object} arg
* @returns {Boolean}
*/
function boolean(arg) {
return Object.prototype.toString.call(arg) === '[object Boolean]'
}
/**
* 是否数组(这个在uView中也有)
* @param {Array} arg
* @returns {Boolean}
*/
function array(arg) {
if (typeof Array.isArray === 'undefined') {
return Object.prototype.toString.call(arg) === '[object Array]'
}
return Array.isArray(arg)
}
/**
* 是否对象(这个在uView中也有)
* @param {Object} arg
* @returns {Boolean}
*/
function object(arg) {
return Object.prototype.toString.call(arg) === '[object Object]'
}
export default {
lower,
upper,
string,
object,
array,
boolean
}