An open API service indexing awesome lists of open source software.

https://github.com/chenxuan0000/comutils

:honeybee:前端代码常用工具类
https://github.com/chenxuan0000/comutils

common-api common-utils

Last synced: about 1 year ago
JSON representation

:honeybee:前端代码常用工具类

Awesome Lists containing this project

README

          

# comutils  [![GitHub forks](https://img.shields.io/github/forks/chenxuan0000/comutils.svg?style=social&label=Fork)](https://www.npmjs.com/package/comutils)[![GitHub stars](https://img.shields.io/github/stars/chenxuan0000/comutils.svg?style=social&label=Stars)](https://www.npmjs.com/package/comutils)
[![npm](https://img.shields.io/npm/dw/chenxuan0000/comutils.svg)]()
[![Build Status](https://img.shields.io/appveyor/ci/gruntjs/grunt/master.svg) ![LICENSE MIT](https://img.shields.io/npm/l/express.svg)](https://www.npmjs.com/package/comutils) ![](https://img.shields.io/npm/v/comutils.svg)


前端代码常用工具类

> 目的:集成前端常用工具类

## 安装使用

1. 直接下载`bulid`目录下的[comutils.min.js](https://github.com/chenxuan0000/comutils/blob/master/build/comutils.min.js)使用,支持UMD通用模块规范

``` html


var copyObj = comutils.copyObj(obj1,obj2)

```

2. 使用npm安装
``` bash
$ npm install --save-dev comutils
```

**推荐使用方法**

不需要完整引入所有函数,只引入需要使用的方法即可
``` javascript
// 只引入部分方法('outils/<方法名>')
const isUrl = require('outils/isUrl')
const isUrl = isUrl()
```

## API文档
### Class
####   [classApi][classApi]  className的操作api
#####     classApi.isElement(el) //是否元素节点
#####     classApi.hasClass(el,cls)
#####     classApi.addClass(el,cls)
#####     classApi.removeClass(el,cls)
#####     classApi.toggleClass(el,cls)

### Object
####   [copyObj][copyObj]  对象合并/深浅拷贝

### Regexp
####   [isEmail][isEmail]  判断是否为邮箱地址
####   [isIdCard][isIdCard]  判断是否为身份证号
####   [isPhoneNum][isPhoneNum]  判断是否为手机号
####   [isUrl][isUrl]  判断是否为URL地址
####   [priceSubstr][priceSubstr]  千位分割方法

### Secret
####   [secretInfo][secretInfo]  给隐私信息标记号加密

### Time
####   [formatPassTime][formatPassTime]  格式化时间戳为天时分秒[d,h,m,s]
####   [formatTime][formatTime]  格式化时间戳为年月日时分秒[y-m-d h:m:s]

### device
####   [isWeixin][isWeixin]  是否是微信浏览器
####   [mobileType][mobileType]  设备类型iphone or android
####   [getOs][getOs]  是否是手机mobile or web

### function
####   [throttle][throttle]  节流函数
####   [debounce][debounce]  防抖函数

### dom
####   [scrollApi][scrollApi]  scrollApi方法
#####     scrollApi.getScrollTop()
#####     scrollApi.setScrollTop(h)
#####     scrollApi.scrollTo(to,duration)
####   [softKeyCal][softKeyCal]  移动端端软键盘呼出和消失的事件回调

### localStorage
####   [localStorageApi][localStorageApi]  本地持久化存储
#####     localStorageApi.set(name)
#####     localStorageApi.get(name)
#####     localStorageApi.remove(name)
#####     localStorageApi.clear(name)

### cookie
####   [cookieApi][cookieApi]  cookie存储(适用和服务端交互)
#####     cookieApi.set(name, value[, end[, path[, domain[, secure]]]])
#####     cookieApi.get(name)
#####     cookieApi.has(name)
#####     cookieApi.remove(name)
#####     cookieApi.keys()

### Type
####   [typeOf][typeOf]  判断类型

### Url
####   [getUrlParams][getUrlParams]  url参数转对象
####   [stringfyQs][stringfyQs]  对象序列化

### random
####   [getRandom][getRandom]  返回选定返回的随机整数

### collections
####   [shuffle][shuffle]  数组打乱随机乱序

### array
####   [arrayEqual][arrayEqual]  判断数组是否相等

### animationFrame
####   [animationFrame][animationFrame]  AnimationFrame简单兼容hack

### prefixStyle
####   [prefixStyle][prefixStyle]  prefixStyle css针对不同浏览器加前缀

[arrayEqual]:https://github.com/chenxuan0000/comutils/blob/master/src/arrayEqual.js
[animationFrame]:https://github.com/chenxuan0000/comutils/blob/master/src/animationFrame/animationFrame.js
[getRandom]:https://github.com/chenxuan0000/comutils/blob/master/src/random/getRandom.js
[shuffle]:https://github.com/chenxuan0000/comutils/blob/master/src/collections/shuffle.js
[throttle]:https://github.com/chenxuan0000/comutils/blob/master/src/function/throttle.js
[debounce]:https://github.com/chenxuan0000/comutils/blob/master/src/function/debounce.js
[scrollApi]:https://github.com/chenxuan0000/comutils/blob/master/src/dom/scrollApi.js
[softKeyCal]:https://github.com/chenxuan0000/comutils/blob/master/src/dom/softKeyCal.js
[isWeixin]:https://github.com/chenxuan0000/comutils/blob/master/src/device/isWeixin.js
[mobileType]:https://github.com/chenxuan0000/comutils/blob/master/src/device/mobileType.js
[getOs]:https://github.com/chenxuan0000/comutils/blob/master/src/device/getOs.js
[secretInfo]:https://github.com/chenxuan0000/comutils/blob/master/src/secret/secretInfo.js
[typeOf]:https://github.com/chenxuan0000/comutils/blob/master/src/type/typeOf.js
[classApi]:https://github.com/chenxuan0000/comutils/blob/master/src/class/classApi.js
[copyObj]:https://github.com/chenxuan0000/comutils/blob/master/src/object/copyObj.js
[isEmail]:https://github.com/chenxuan0000/comutils/blob/master/src/regexp/isEmail.js
[isIdCard]:https://github.com/chenxuan0000/comutils/blob/master/src/regexp/isIdCard.js
[isPhoneNum]:https://github.com/chenxuan0000/comutils/blob/master/src/regexp/isPhoneNum.js
[isUrl]:https://github.com/chenxuan0000/comutils/blob/master/src/regexp/isUrl.js
[priceSubstr]:https://github.com/chenxuan0000/comutils/blob/master/src/regexp/priceSubstr.js
[formatPassTime]:https://github.com/chenxuan0000/comutils/blob/master/src/time/formatPassTime.js
[formatTime]:https://github.com/chenxuan0000/comutils/blob/master/src/time/formatTime.js
[getUrlParams]:https://github.com/chenxuan0000/comutils/blob/master/src/url/getUrlParams.js
[stringfyQs]:https://github.com/chenxuan0000/comutils/blob/master/src/url/stringfyQs.js
[localStorageApi]:https://github.com/chenxuan0000/comutils/blob/master/src/stroge/localStorage.js
[cookieApi]:https://github.com/chenxuan0000/comutils/blob/master/src/cookie/cookie.js
[prefixStyle]:https://github.com/chenxuan0000/comutils/blob/master/src/prefixStyle/prefixStyle.js