ソースを参照

持续更新中······

striveDJiang 8 年 前
コミット
9aedddf443

+ 74 - 133
README.md

@@ -1,134 +1,75 @@
-# JavaScript-utils
+# JavaScript-utils 
+============
+
+> JavaScript工具函数库
+
+### array
+* [arrayDisorder]  [打乱数组顺序](https://github.com/striveDJiang/JavaScript-utils/blob/master/array/arrayDisorder.js)
+* [arrayEqual]  [判断两个数组是否相等](https://github.com/striveDJiang/JavaScript-utils/blob/master/array/arrayEqual.js)
+* [arrayFlattening]  [数组扁平化](https://github.com/striveDJiang/JavaScript-utils/blob/master/array/arrayFlattening.js)
+* [arrayRandom]  [从数组中随机获取元素](https://github.com/striveDJiang/JavaScript-utils/blob/master/array/arrayRandom.js)
+* [arrayRemoveRepeat]  [数组去重](https://github.com/striveDJiang/JavaScript-utils/blob/master/array/arrayRemoveRepeat.js)
+* [arraySum]  [数组求和(数字类型的数组)](https://github.com/striveDJiang/JavaScript-utils/blob/master/array/arraySum.js)
+* [getCount]  [返回数组(或字符串)中出现最多的元素和出现次数](https://github.com/striveDJiang/JavaScript-utils/blob/master/array/getCount.js)
+* [getEleCount]  [返回数组或字符串中一个元素出现的次数](https://github.com/striveDJiang/JavaScript-utils/blob/master/array/getEleCount.js)
+* [maxArr]  [找出数组中的最大值(数字类型的数组)](https://github.com/striveDJiang/JavaScript-utils/blob/master/array/maxArr.js)
+* [minArr]  [找出数组中的最小值(数字类型的数组)](https://github.com/striveDJiang/JavaScript-utils/blob/master/array/minArr.js)
+
+## string
+* [changeCase]  [大小写转换](https://github.com/striveDJiang/JavaScript-utils/blob/master/string/changeCase.js)
+* [digitUppercase]  [现金额转大写](https://github.com/striveDJiang/JavaScript-utils/blob/master/string/digitUppercase.js)
+* [removeSpace]  [字符串去除空格](https://github.com/striveDJiang/JavaScript-utils/blob/master/string/removeSpace.js)
+* [repeatCopy]  [字符串重复复制](https://github.com/striveDJiang/JavaScript-utils/blob/master/string/repeatCopy.js)
+* [stringFormat]  [格式化字符串](https://github.com/striveDJiang/JavaScript-utils/blob/master/string/stringFormat.js)
+* [stringReplace]  [字符串替换](https://github.com/striveDJiang/JavaScript-utils/blob/master/string/stringReplace.js)
+
+## object
+* [dataType]  [数据类型判断](https://github.com/striveDJiang/JavaScript-utils/blob/master/object/dataType.js)
+* [deepClone]  [深拷贝,支持常见类型](https://github.com/striveDJiang/JavaScript-utils/blob/master/object/deepClone.js)
+* [isEmptyObject]  [判断`obj`是否为空](https://github.com/striveDJiang/JavaScript-utils/blob/master/object/isEmptyObject.js)
+
+## function
+* [debounce]  [函数防抖](https://github.com/striveDJiang/JavaScript-utils/blob/master/function/debounce.js)
+* [throttle]  [函数节流](https://github.com/striveDJiang/JavaScript-utils/blob/master/function/throttle.js)
+
+## dom
+* [addClass]  [为元素添加class](https://github.com/striveDJiang/JavaScript-utils/blob/master/dom/addClass.js)
+* [hasClass]  [判断元素是否有某个class](https://github.com/striveDJiang/JavaScript-utils/blob/master/dom/hasClass.js)
+* [removeClass]  [为元素移除class](https://github.com/striveDJiang/JavaScript-utils/blob/master/dom/removeClass.js)
+
+## bom
+* [getScrollTop]  [获取滚动条距顶部的距离](https://github.com/striveDJiang/JavaScript-utils/blob/master/bom/getScrollTop.js)
+* [isSupportWebP]  [设置滚动条距顶部的距离](https://github.com/striveDJiang/JavaScript-utils/blob/master/bom/isSupportWebP.js)
+* [offset]  [在${duration}时间内,滚动条平滑滚动到${to}指定位置](https://github.com/striveDJiang/JavaScript-utils/blob/master/bom/offset.js)
+* [scrollTo]  [获取一个元素的距离文档(document)的位置,类似jQ中的offset()](https://github.com/striveDJiang/JavaScript-utils/blob/master/bom/scrollTo.js)
+* [setScrollTop]  [判断浏览器是否支持webP格式图片](https://github.com/striveDJiang/JavaScript-utils/blob/master/bom/setScrollTop.js)
+
+## date
+* [formatPassTime]  [格式化${startTime}距现在的已过时间](https://github.com/striveDJiang/JavaScript-utils/blob/master/date/formatPassTime.js)
+* [formatRemainTime]  [格式化现在距${endTime}的剩余时间](https://github.com/striveDJiang/JavaScript-utils/blob/master/date/formatRemainTime.js)
+
+## random
+* [randomColor]  [随机生成颜色](https://github.com/striveDJiang/JavaScript-utils/blob/master/random/randomColor.js)
+* [randomNum]  [生成指定范围随机数](https://github.com/striveDJiang/JavaScript-utils/blob/master/random/randomNum.js)
+
+## regexp
+* [isEmail]  [判断是否为邮箱地址](https://github.com/striveDJiang/JavaScript-utils/blob/master/regexp/isEmail.js)
+* [isIdCard]  [判断是否为身份证号](https://github.com/striveDJiang/JavaScript-utils/blob/master/regexp/isIdCard.js)
+* [isPhoneNum]  [判断是否为手机号](https://github.com/striveDJiang/JavaScript-utils/blob/master/regexp/isPhoneNum.js)
+* [isUrl]  [判断是否为URL地址](https://github.com/striveDJiang/JavaScript-utils/blob/master/regexp/isUrl.js)
+
+## url
+* [parseQueryString]  [url参数转对象](https://github.com/striveDJiang/JavaScript-utils/blob/master/url/parseQueryString.js)
+* [stringfyQueryString]  [对象序列化](https://github.com/striveDJiang/JavaScript-utils/blob/master/url/stringfyQueryString.js)
+
+## cookie
+* [getCookie]  [根据name读取cookie](https://github.com/striveDJiang/JavaScript-utils/blob/master/cookie/getCookie.js)
+* []  [根据name删除cookie](https://github.com/striveDJiang/JavaScript-utils/blob/master/cookie/removeCookie.js)
+* [removeCookie]  [根据name删除cookie](https://github.com/striveDJiang/JavaScript-utils/blob/master/cookie/removeCookie.js)
+* [setCookie]  [设置Cookie](https://github.com/striveDJiang/JavaScript-utils/blob/master/cookie/setCookie.js)
+
+## device
+* [getExplore]  [获取浏览器类型和版本](https://github.com/striveDJiang/JavaScript-utils/blob/master/device/getExplore.js)
+* [getOS]  [获取操作系统类型](https://github.com/striveDJiang/JavaScript-utils/blob/master/device/getOS.js)
+* [getKeyName]  [根据keycode获得键名](https://github.com/striveDJiang/JavaScript-utils/blob/master/device/getKeyName.js)
 
-### Array  
-####   [arrayEqual][arrayEqual]  判断两个数组是否相等 
-####   [arrayRemoveRepeat][arrayRemoveRepeat]  数组去重
-####   [arrayDisorder][arrayDisorder]  打乱数组顺序
-####   [maxArr][maxArr]  找出数组中的最大值
-####   [minArr][minArr]  找出数组中的最小值
-####   [arraySum][arraySum]  数组求和
-####   [arrayRandom][arrayRandom]  从数组中随机获取元素
-####   [getEleCount][getEleCount]  返回数组或字符串中一个元素出现的次数
-####   [getCount][getCount]  返回数组(或字符串)中出现最多的元素和出现次数
-####   [arrayFlattening][arrayFlattening]  数组扁平化
-
-### Class
-####   [addClass][addClass]  为元素添加class  
-####   [hasClass][hasClass]  判断元素是否有某个class  
-####   [removeClass][removeClass]  为元素移除class  
-
-### Cookie 
-####   [getCookie][getCookie]  根据name读取Cookie  
-####   [removeCookie][removeCookie]  根据name删除Cookie
-####   [setCookie][setCookie]  添加Cookie 
-
-### Device  
-####   [getExplore][getExplore]  获取浏览器类型和版本号  
-####   [getOS][getOS]  获取操作系统类型
-
-### Dom  
-####   [getScrollTop][getScrollTop]  获取滚动条距顶部的距离
-####   [offset][offset]  获取一个元素的距离文档(document)的位置,类似jQ中的offset()
-####   [scrollTo][scrollTo]  在${duration}时间内,滚动条平滑滚动到${to}指定位置
-####   [setScrollTop][setScrollTop]  设置滚动条距顶部的距离
-
-### Function  
-####   [debounce][debounce]  函数防抖   
-####   [throttle][throttle]  函数节流   
-
-### Keycode  
-####   [getKeyName][getKeyName]  根据keycode获得键名 
-
-### Object  
-####   [deepClone][deepClone]  深拷贝,支持常见类型
-####   [isEmptyObject][isEmptyObject]  判断Object是否为空
-####   [dataType][dataType]  判断Object是否为空
-
-### Random  
-####   [randomColor][randomColor]   随机生成颜色
-####   [randomNum][randomNum]  生成指定范围随机数 
-
-### RegExp  
-####   [isEmail][isEmail]  判断是否为邮箱地址 
-####   [isIdCard][isIdCard]  判断是否为身份证号
-####   [isPhoneNum][isPhoneNum]  判断是否为手机号  
-####   [isUrl][isUrl]  判断是否为URL地址
-
-### String  
-####   [digitUppercase][digitUppercase]  现金额转大写
-####   [removeSpace][removeSpace]  去除空格
-####   [changeCase][changeCase]  大小写转换
-####   [repeatCopy][repeatCopy]  重复复制
-####   [stringReplace][stringReplace]  字符串替换
-####   [stringFormat][stringFormat]  字符串格式化
-
-### Support  
-####   [isSupportWebP][isSupportWebP]  判断浏览器是否支持webP格式图片
-#### 
-
-### Time  
-####   [formatPassTime][formatPassTime]  格式化${startTime}距现在的已过时间
-####   [formatRemainTime][formatRemainTime]  格式化现在距${endTime}的剩余时间
-
-### Url
-####   [parseQueryString][parseQueryString]  url参数转对象
-####   [stringfyQueryString][stringfyQueryString]  对象序列化
-
-[arrayEqual]:https://github.com/striveDJiang/utils/blob/master/array/arrayEqual.js
-[arrayRemoveRepeat]:https://github.com/striveDJiang/utils/blob/master/array/arrayRemoveRepeat.js
-[arrayDisorder]:https://github.com/striveDJiang/utils/blob/master/array/arrayDisorder.js
-[maxArr]:https://github.com/striveDJiang/utils/blob/master/array/maxArr.js
-[minArr]:https://github.com/striveDJiang/utils/blob/master/array/minArr.js
-[arraySum]:https://github.com/striveDJiang/utils/blob/master/array/arraySum.js
-[arrayRandom]:https://github.com/striveDJiang/utils/blob/master/array/arrayRandom.js
-[getEleCount]:https://github.com/striveDJiang/utils/blob/master/array/getEleCount.js
-[getCount]:https://github.com/striveDJiang/utils/blob/master/array/getCount.js
-[arrayFlattening]:https://github.com/striveDJiang/utils/blob/master/array/arrayFlattening.js
-
-[addClass]:https://github.com/striveDJiang/utils/blob/master/class/addClass.js
-[hasClass]:https://github.com/striveDJiang/utils/blob/master/class/hasClass.js
-[removeClass]:https://github.com/striveDJiang/utils/blob/master/class/removeClass.js
-
-[getCookie]:https://github.com/striveDJiang/utils/blob/master/cookie/getCookie.js
-[removeCookie]:https://github.com/striveDJiang/utils/blob/master/cookie/removeCookie.js
-[setCookie]:https://github.com/striveDJiang/utils/blob/master/cookie/setCookie.js
-
-[getExplore]:https://github.com/striveDJiang/utils/blob/master/device/getExplore.js
-[getOS]:https://github.com/striveDJiang/utils/blob/master/device/getOS.js
-
-[getScrollTop]:https://github.com/striveDJiang/utils/blob/master/dom/getScrollTop.js
-[offset]:https://github.com/striveDJiang/utils/blob/master/dom/offset.js
-[scrollTo]:https://github.com/striveDJiang/utils/blob/master/dom/scrollTo.js
-[setScrollTop]:https://github.com/striveDJiang/utils/blob/master/dom/setScrollTop.js
-
-[debounce]:https://github.com/striveDJiang/utils/blob/master/function/debounce.js
-[throttle]:https://github.com/striveDJiang/utils/blob/master/function/throttle.js
-
-[getKeyName]:https://github.com/striveDJiang/utils/blob/master/keycode/getKeyName.js
-
-[deepClone]:https://github.com/striveDJiang/utils/blob/master/object/deepClone.js
-[isEmptyObject]:https://github.com/striveDJiang/utils/blob/master/object/isEmptyObject.js
-[dataType]:https://github.com/striveDJiang/utils/blob/master/object/dataType.js
-
-[randomColor]:https://github.com/striveDJiang/utils/blob/master/random/randomColor.js
-[randomNum]:https://github.com/striveDJiang/utils/blob/master/random/randomNum.js
-
-[isEmail]:https://github.com/striveDJiang/utils/blob/master/regexp/isEmail.js
-[isIdCard]:https://github.com/striveDJiang/utils/blob/master/regexp/isIdCard.js
-[isPhoneNum]:https://github.com/striveDJiang/utils/blob/master/regexp/isPhoneNum.js
-[isUrl]:https://github.com/striveDJiang/utils/blob/master/regexp/isUrl.js
-
-[digitUppercase]:https://github.com/striveDJiang/utils/blob/master/string/digitUppercase.js
-[removeSpace]:https://github.com/striveDJiang/utils/blob/master/string/removeSpace.js
-[changeCase]:https://github.com/striveDJiang/utils/blob/master/string/changeCase.js
-[repeatCopy]:https://github.com/striveDJiang/utils/blob/master/string/repeatCopy.js
-[stringReplace]:https://github.com/striveDJiang/utils/blob/master/string/stringReplace.js
-[stringFormat]:https://github.com/striveDJiang/utils/blob/master/string/stringFormat.js
-
-[isSupportWebP]:https://github.com/striveDJiang/utils/blob/master/support/isSupportWebP.js
-
-[formatPassTime]:https://github.com/striveDJiang/utils/blob/master/time/formatPassTime.js
-[formatRemainTime]:https://github.com/striveDJiang/utils/blob/master/time/formatRemainTime.js
-
-[parseQueryString]:https://github.com/striveDJiang/utils/blob/master/url/parseQueryString.js
-[stringfyQueryString]:https://github.com/striveDJiang/utils/blob/master/url/stringfyQueryString.js

dom/getScrollTop.js → bom/getScrollTop.js


support/isSupportWebP.js → bom/isSupportWebP.js


dom/offset.js → bom/offset.js


dom/scrollTo.js → bom/scrollTo.js


dom/setScrollTop.js → bom/setScrollTop.js


time/formatPassTime.js → date/formatPassTime.js


time/formatRemainTime.js → date/formatRemainTime.js


keycode/getKeyName.js → device/getKeyName.js


class/addClass.js → dom/addClass.js


class/hasClass.js → dom/hasClass.js


class/removeClass.js → dom/removeClass.js


+ 1 - 1
function/throttle.js

@@ -1,5 +1,5 @@
 /**
- * @desc   函数节流
+ * @desc   函数节流
  * 适用于限制`resize`和`scroll`等函数的调用频率
  *
  * @param  {Number}    delay          0 或者更大的毫秒数。 对于事件回调,大约100或250毫秒(或更高)的延迟是最有用的。