https://github.com/szqlovepk/utilibs
js通用方法库
https://github.com/szqlovepk/utilibs
library rollup
Last synced: 12 months ago
JSON representation
js通用方法库
- Host: GitHub
- URL: https://github.com/szqlovepk/utilibs
- Owner: szqlovepk
- License: mit
- Created: 2022-04-18T13:15:54.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-02T18:57:09.000Z (about 4 years ago)
- Last Synced: 2024-10-28T16:10:09.819Z (over 1 year ago)
- Topics: library, rollup
- Language: TypeScript
- Homepage:
- Size: 10.7 MB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# utilibs
js 通用方法库
### 安装
`npm i utilibs or yarn add utilibs`
### API
- 深拷贝
` deepClone(obj: Object): object;`
- 判断字符串是否是十六进制的颜色值
`isColor: (value: string) => boolean;`
- 防抖函数,返回函数连续调用时,空闲时间必须大于或等于 wait,func 才会执行
`debounce(func: Function, wait: number, immediate: boolean): () => any;`
- 节流函数,返回函数连续调用时,func 执行频率限定为 次 / wait
`throttle(func: Function, wait: number, options: any): () => any;`
- 通过名称获取 cookie
`getCookie: (name: string) => any;`
- 通过名称删除 cookie
`deleteCookie: (name: string) => void;`
- 设置 cookie
`setCookie: (cname: string, cvalue: string, exdays: number) => void;`
- 空字符串 空数组 空对象值统一处理成 null
`filterEmptyValue: (values: object) => any;`
- Date 转换字符串
`getDateStr: (theDate: Date) => string;`
- 清除字符串所有空格
`removeAllSpace: (str: string) => string;`
- 判断是否为正整数或 0
`isInteger: (value: string | number, isZero: boolean) => boolean;`
- 一维数组去重
`arrayUnique: (arr: Array) => (string | number)[];`
- 判断数组内容是否相同 忽略顺序
`arrIsEqualContent: (arr1: Array, arr2: Array) => boolean;`
### 本地开发
```
git clone至本地
npm install
src下新建文件编写
```
### 打包编译
```
npm run build 生成index.ts文件和.d.ts声明文件
```
### npm 发布
```
1.更新package.json的version(比npm现有的版本大)
2.copy根目录下的package.json和README.md至dist目录下
3.cd dist
4.npm publish
```