@kexiaojun/tools
v0.0.2
Published
## 使用方法 ``` npm install @kexiaojun/tools
Downloads
4
Readme
前端工具类
使用方法
npm install @kexiaojun/tools
import tools from '@kexiaojun/tools'
console.log('is arr:',tools.isArr(['1','2']))
数组
|方法名|作用|参数|返回值| |--|--|--|--| |isArr|判断是否是数组|any|Boolean 值| |arrRemoveRepeat|数组去重|arr|去重后的数组| |arrOrderAscend|数组排序|arr|排序后的数组| |arrMax|数组中最大值|arr|数组中的最大值参数| |arrSum|数组求和|arr|所有参数相加总和| |arrConcat|数组合并|arrOne:数组一;arrTwo:数组二|合并后的数组| |arrIncludeValue|数组中是否包含某值|arr: 数组; value: 判断的值|Boolean 值| |arrAndSet|数组并集|arrOne:数组一;arrTwo:数组二|并集后的数组| |arrIntersection|数组交集|arrOne:数组一;arrTwo:数组二|Array,数组中交集的参数| |arrDifference|数组差集|arrOne:数组一;arrTwo:数组二|Array,数组中差集的参数|
对象
|方法名|作用|参数|返回值| |--|--|--|--| |objIsEqual|判断两个对象是否相等| oneObj:对象一;twoObj:对象二;|Boolean 值| |objDeepClone|对象深度拷贝| obj:拷贝对象;| obj:拷贝后的对象;|
字符串
|方法名|作用|参数|返回值| |--|--|--|--| |strTrimLeftOrRight|去除字符串左右空格| str:待处理字符串;|处理后的字符串| |strInclude|字符串是否包含某个字符| str:待处理字符串;value:需要判断的值;|Boolean 值| |strBeginWith| 字符串是否以某一字符开头| str:待判断字符串;value:需要判断的值;|Boolean 值| |strReplace|替换字符串中某个字符| str:待处理字符串;valueOne:需要替换的值;valueTwo:替换后的值;|处理后的字符串| |strToCapital| 字符串全部转化成大写| str:待处理字符串;|处理后的字符串| |strToLowercase| 字符串全部转化成小写| str:待处理字符串;|处理后的字符串| |strToCapitalLetter| 字符串转化成以大写开头| str:待处理字符串;|处理后的字符串|
日期时间
|方法名|作用|参数|返回值| |--|--|--|--| |getYear|获取当前年份|-|年份值| |getMonth|获取当前月份|-|月份值| |getDay|获取当前日|-|日值| |getWhatDay|获取当前星期几|-|星期几| |getMonthNum|获取当前月份天数|-|月份天数值| |getYyMmDdHhMmSs|获取当前时间|-|当前时间:yyyy-mm-dd,hh:mm:ss| |timesToYyMmDd|时间戳转化为年月日|times:时间戳;ymd:格式类型,值可为yyyy-mm-dd,yyyy/mm/dd;hms:时分秒,值可为;hh,hh:mm,hh:mm:ss|处理后的年月日| |YyMmDdToTimes|年月日转化成时间戳|yyyy/mm/dd 或yyyy-mm-dd 或yyyy-mm-dd hh:mm 或yyyy-mm-dd hh:mm:ss|时间戳| |compareTimeOneLessTwo|比较时间一小于二|timeOne:时间一;timeTwo:时间二;| Boolean| |isLeapYear|是否闰年|year:年份| Boolean|
缓存
|方法名|作用|参数|返回值| |--|--|--|--| |localStorageSet|localStorage 存贮| key:存贮属性;value:存贮属性值;| -| |localStorageGet|localStorage 获取| key:获取属性;|存贮属性值| |localStorageRemove|localStorage 删除| key:删除属性;| -| |localStorageSetExpire|localStorage 存贮一段时间| key:存贮属性;value:存贮属性值;expire:有效期,单位毫秒;| -| |sessionStorageSet|sessionStorageSet 存贮| key:存贮属性;value:存贮属性值;| -| |sessionStorageGet|sessionStorage 获取| key:获取属性;| 存贮属性值| |sessionStorageRemove|sessionStorage 删除| key:删除属性;| -| |sessionStorageSetExpire|sessionStorage 存贮一段时间| key:存贮属性;value:存贮属性值;expire:有效期,单位毫秒;| -| |cookieSet|cookieSet 存贮一段时间| key:存贮属性;value:存贮属性值;expire:有效期,单位天;| -| |cookieGet|cookie 获取| key:获取属性;| 存贮的属性值| |cookieRemove|cookie 删除| key:删除属性;| -|
校验
|方法名|作用|参数|返回值| |--|--|--|--| |checkNum|判断是否是数字|data: 判断的值|Boolean 值| |checkLetter|判断是否是数字|data|Boolean 值| |checkLowercaseLetter|判断是否全部是小写字母|Boolean 值|data| |checkCapitalLetter|判断是否是大写字母|data|Boolean 值| |checkNumOrLetter|判断是否是字母或数字|data|Boolean 值| |checkChinese|判断是否是中文|data|Boolean 值| |checkChineseNumberLettter|判断是否是中文,数字或字母|Boolean 值|data| |checkEmail| 判断是否是邮箱|Boolean 值| data| |checkTelphone|判断是否是手机号|Boolean 值|data| |checkUrl| 判断是正确的网址| data|Boolean 值|
客户端
|方法名|作用|参数|返回值| |--|--|--|--| |checkBrowser|判断浏览器|-|trident:IE;presto:opera;webKit:苹果、谷歌内核;gecko:火狐;| |checkIosAndroidIpad|判断客户端类型|-|ios:ios;android:android;iPad:iPad;| |checkWeixinQqUc|判断微信,qq 或uc|-|weixin:微信; qq:qq;uc:uc;| |checkIsIphoneX|判断是否是 iPhoneX 序列|-| Boolean|
节流、防抖
|方法名|作用|参数|返回值| |--|--|--|--| |throttle|节流|func:处理函数;delay:延时;|执行函数| |debounce|防抖|func:处理函数;delay:延时;|执行函数|
url
|方法名|作用|参数|返回值| |--|--|--|--| |getQueryString|获取路由指定传参| name:传参属性|属性值| |getUrlParams|获取路由所有传参| url:指定url 不传默认取当前浏览器的url|属性值|