主要封装 业务中常用 的函数,特别是lodash未实现的一些业务函数,但一定程度上和lodash有交集。如果lodash已实现同样功能的函数,建议采用lodash。
rollup打包、ES6编码、babel7.0转译、jest测试
# 构建 npm run build # 测试 npm run test # 只测试某一个模块 e.g. npm run test array.test.js wutils模块的默认构建方式是 es,即ES6模块。如果想要生成commonjs或amd模块,请修改 rollup.config.js 文件里的 OUTPUT_MODULE_TYPE 属性即可。
ES6模块使用举例
// 整个模块引入 import wutils from 'wutils.js' wutils.getBrowser()// 按需引入 import { getBrowser, getOS } from 'wutils.js' getBrowser() getOS()- isArr
- quickSortArr
- uniqueArr
- shuffleArr
- binarySearchArr
- formatDate
- getDateObj
- setClass
- hasClass
- addClass
- removeClass
- debounce (同 lodash.debounce)
- throttle (同 lodash.throttle)
- poll
- once
- isPlainObj
- isEmptyObj
- extend (同 jQuery.extend)
- stringfyQueryString
- getOS
- getBrowser
- isWeixin
- chalkPrint
- randomColor
- randomInt
- randomString
- isEmail
- isIdCard
- isPhoneNum
- isUrl
- setCookie
- getCookie
- removeCookie
- cutString
- upcaseMoney
- replaceXSS
- parseQueryString
- b64EncodeUnicode
- b64DecodeUnicode
持续更新中