[@daysnap/utils](README.md) / Exports

# @daysnap/utils

## Table of contents

### Classes

- [Poller](classes/Poller.md)
- [Storage](classes/Storage.md)

### Interfaces

- [CreateWithToastOptions](interfaces/CreateWithToastOptions.md)
- [EventBusCallback](interfaces/EventBusCallback.md)
- [PollerOptions](interfaces/PollerOptions.md)
- [StorageManager](interfaces/StorageManager.md)
- [SwipeHandlers](interfaces/SwipeHandlers.md)
- [SwipeListener](interfaces/SwipeListener.md)
- [SwipeListenerEvent](interfaces/SwipeListenerEvent.md)
- [SwipeOptions](interfaces/SwipeOptions.md)
- [Trap](interfaces/Trap.md)

### Type Aliases

- [PollerTask](modules.md#pollertask)
- [SwipeDirection](modules.md#swipedirection)
- [SwipeHandlerEvent](modules.md#swipehandlerevent)

### Variables

- [eventBus](modules.md#eventbus)
- [sounds](modules.md#sounds)
- [trap](modules.md#trap)

### Functions

- [ato](modules.md#ato)
- [atob](modules.md#atob)
- [base64ToBlob](modules.md#base64toblob)
- [blobToBase64](modules.md#blobtobase64)
- [btoa](modules.md#btoa)
- [cached](modules.md#cached)
- [camelCase](modules.md#camelcase)
- [canvasToBlob](modules.md#canvastoblob)
- [capitalize](modules.md#capitalize)
- [chooseMedia](modules.md#choosemedia)
- [clamp](modules.md#clamp)
- [clone](modules.md#clone)
- [cloneSimple](modules.md#clonesimple)
- [colorGenByHash](modules.md#colorgenbyhash)
- [compareVersion](modules.md#compareversion)
- [compressImage](modules.md#compressimage)
- [crToBr](modules.md#crtobr)
- [createFactory](modules.md#createfactory)
- [createLinearFunction](modules.md#createlinearfunction)
- [createSwipeHandler](modules.md#createswipehandler)
- [createSwipeHandlers](modules.md#createswipehandlers)
- [createTrapInstance](modules.md#createtrapinstance)
- [createWithLoading](modules.md#createwithloading)
- [createWithToast](modules.md#createwithtoast)
- [crlfToBr](modules.md#crlftobr)
- [debounce](modules.md#debounce)
- [downloadFile](modules.md#downloadfile)
- [each](modules.md#each)
- [exitFullscreen](modules.md#exitfullscreen)
- [factory](modules.md#factory)
- [filterBankCardNo](modules.md#filterbankcardno)
- [filterCRLF](modules.md#filtercrlf)
- [filterEmoji](modules.md#filteremoji)
- [filterEmptyValue](modules.md#filteremptyvalue)
- [filterIdCard](modules.md#filteridcard)
- [filterName](modules.md#filtername)
- [filterPhone](modules.md#filterphone)
- [filterString](modules.md#filterstring)
- [formatAmount](modules.md#formatamount)
- [formatDate](modules.md#formatdate)
- [formatDateStr](modules.md#formatdatestr)
- [formatDateToZN](modules.md#formatdatetozn)
- [formatFileSize](modules.md#formatfilesize)
- [formatGapDate](modules.md#formatgapdate)
- [formatMessage](modules.md#formatmessage)
- [formatPathParams](modules.md#formatpathparams)
- [getBlobByUrl](modules.md#getblobbyurl)
- [getCache](modules.md#getcache)
- [getDateBoundsByMonths](modules.md#getdateboundsbymonths)
- [getDayMillisecond](modules.md#getdaymillisecond)
- [getDaysOfMonth](modules.md#getdaysofmonth)
- [getImageInfo](modules.md#getimageinfo)
- [getLocal](modules.md#getlocal)
- [getMonthBounds](modules.md#getmonthbounds)
- [getRandom](modules.md#getrandom)
- [getRandomColor](modules.md#getrandomcolor)
- [getRandomNumber](modules.md#getrandomnumber)
- [getRangeDate](modules.md#getrangedate)
- [getScrollTop](modules.md#getscrolltop)
- [getVideoInfo](modules.md#getvideoinfo)
- [getWeekBounds](modules.md#getweekbounds)
- [getWeekday](modules.md#getweekday)
- [inBrowser](modules.md#inbrowser)
- [insertLink](modules.md#insertlink)
- [insertScript](modules.md#insertscript)
- [insertStyle](modules.md#insertstyle)
- [isAmount](modules.md#isamount)
- [isAndroid](modules.md#isandroid)
- [isArray](modules.md#isarray)
- [isBoolean](modules.md#isboolean)
- [isChinese](modules.md#ischinese)
- [isDate](modules.md#isdate)
- [isEmail](modules.md#isemail)
- [isEmpty](modules.md#isempty)
- [isEmptyArray](modules.md#isemptyarray)
- [isEmptyObject](modules.md#isemptyobject)
- [isError](modules.md#iserror)
- [isFunction](modules.md#isfunction)
- [isIE](modules.md#isie)
- [isIOS](modules.md#isios)
- [isIdCard](modules.md#isidcard)
- [isJSONString](modules.md#isjsonstring)
- [isLan](modules.md#islan)
- [isLeapYear](modules.md#isleapyear)
- [isLicenseCode](modules.md#islicensecode)
- [isMobile](modules.md#ismobile)
- [isNativeFunction](modules.md#isnativefunction)
- [isNotEmpty](modules.md#isnotempty)
- [isNull](modules.md#isnull)
- [isNumber](modules.md#isnumber)
- [isNumeric](modules.md#isnumeric)
- [isObject](modules.md#isobject)
- [isPhone](modules.md#isphone)
- [isPromise](modules.md#ispromise)
- [isPromiseLike](modules.md#ispromiselike)
- [isRegExp](modules.md#isregexp)
- [isString](modules.md#isstring)
- [isType](modules.md#istype)
- [isUndefined](modules.md#isundefined)
- [isUrl](modules.md#isurl)
- [isValidDate](modules.md#isvaliddate)
- [isWeChat](modules.md#iswechat)
- [isWeChatMiniProgram](modules.md#iswechatminiprogram)
- [isWeixin](modules.md#isweixin)
- [isWindow](modules.md#iswindow)
- [kebabCase](modules.md#kebabcase)
- [lfToBr](modules.md#lftobr)
- [listGenerator](modules.md#listgenerator)
- [makePhoneCall](modules.md#makephonecall)
- [merge](modules.md#merge)
- [mousewheel](modules.md#mousewheel)
- [nf](modules.md#nf)
- [normalizeDate](modules.md#normalizedate)
- [normalizePath](modules.md#normalizepath)
- [numberToLetter](modules.md#numbertoletter)
- [omit](modules.md#omit)
- [omitBy](modules.md#omitby)
- [padding](modules.md#padding)
- [parseDate](modules.md#parsedate)
- [parseDecimalString](modules.md#parsedecimalstring)
- [parseError](modules.md#parseerror)
- [parseNumberString](modules.md#parsenumberstring)
- [parseObject](modules.md#parseobject)
- [parsePath](modules.md#parsepath)
- [parseQuery](modules.md#parsequery)
- [parseQueryString](modules.md#parsequerystring)
- [pascalCase](modules.md#pascalcase)
- [pick](modules.md#pick)
- [pickBy](modules.md#pickby)
- [replaceCrlf](modules.md#replacecrlf)
- [requestFullScreen](modules.md#requestfullscreen)
- [reserve](modules.md#reserve)
- [rgbToHex](modules.md#rgbtohex)
- [round](modules.md#round)
- [roundUpToNearestInteger](modules.md#rounduptonearestinteger)
- [scrollToTop](modules.md#scrolltotop)
- [setScrollTop](modules.md#setscrolltop)
- [sleep](modules.md#sleep)
- [splitArray](modules.md#splitarray)
- [stringTrim](modules.md#stringtrim)
- [stringifyQuery](modules.md#stringifyquery)
- [stringifyQueryString](modules.md#stringifyquerystring)
- [throttle](modules.md#throttle)
- [throttleLeading](modules.md#throttleleading)
- [throttleTrailing](modules.md#throttletrailing)
- [toCDB](modules.md#tocdb)
- [toDBC](modules.md#todbc)
- [toFormData](modules.md#toformdata)
- [toPosix](modules.md#toposix)
- [typeOf](modules.md#typeof)
- [typedKeys](modules.md#typedkeys)
- [withCache](modules.md#withcache)
- [withPreventConsecutiveClicks](modules.md#withpreventconsecutiveclicks)

## Type Aliases

### PollerTask

Ƭ **PollerTask**: (`poller`: [`Poller`](classes/Poller.md)) => `void` \| `Promise`<`void`\>

#### Type declaration

▸ (`poller`): `void` \| `Promise`<`void`\>

##### Parameters

| Name | Type |
| :------ | :------ |
| `poller` | [`Poller`](classes/Poller.md) |

##### Returns

`void` \| `Promise`<`void`\>

#### Defined in

[poller.ts:7](https://github.com/daysnap/utils/blob/9ced15e/src/poller.ts#L7)

___

### SwipeDirection

Ƭ **SwipeDirection**: ``"left"`` \| ``"right"`` \| ``"up"`` \| ``"down"`` \| ``"none"``

#### Defined in

[createSwipeHandlers.ts:1](https://github.com/daysnap/utils/blob/9ced15e/src/createSwipeHandlers.ts#L1)

___

### SwipeHandlerEvent

Ƭ **SwipeHandlerEvent**: `TouchEvent` \| `MouseEvent`

#### Defined in

[createSwipeHandlers.ts:3](https://github.com/daysnap/utils/blob/9ced15e/src/createSwipeHandlers.ts#L3)

## Variables

### eventBus

• `Const` **eventBus**: `Object`

#### Type declaration

| Name | Type |
| :------ | :------ |
| `clear` | (`eventName?`: `string`) => `void` |
| `emit` | (`eventName`: `string`, ...`args`: `any`[]) => `void` |
| `off` | (`eventName`: `string`, `callback`: [`EventBusCallback`](interfaces/EventBusCallback.md)) => `void` |
| `on` | (`eventName`: `string`, `callback`: [`EventBusCallback`](interfaces/EventBusCallback.md)) => () => `void` |

#### Defined in

[eventBus.ts:38](https://github.com/daysnap/utils/blob/9ced15e/src/eventBus.ts#L38)

___

### sounds

• `Const` **sounds**: `Object`

#### Type declaration

| Name | Type |
| :------ | :------ |
| `click` | () => `void` |
| `confirm` | () => `void` |
| `error` | () => `void` |
| `hover` | () => `void` |
| `pop` | () => `void` |
| `success` | () => `void` |
| `tick` | () => `void` |
| `toggle` | () => `void` |
| `warning` | () => `void` |
| `whoosh` | () => `void` |

#### Defined in

[sounds.ts:13](https://github.com/daysnap/utils/blob/9ced15e/src/sounds.ts#L13)

___

### trap

• `Const` **trap**: [`Trap`](interfaces/Trap.md)

#### Defined in

[trap.ts:15](https://github.com/daysnap/utils/blob/9ced15e/src/trap.ts#L15)

## Functions

### ato

▸ **ato**<`T`, `K`\>(`options`, `labelKey`): `Record`<`T`[`K`], `T`\>

数组转换称对象
const options = [
 {label: '男', value: '1'}
 {label: '女', value: '2'}
]
const res = ato(options, 'value')
res = { '1': {label: '男', value: '1'}, '2': {label: '女', value: '2'} }
const res = ato(options, 'value', 'label')
res = { '1': '男', '2': '女' }

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends `Record`<`string`, `any`\> |
| `K` | extends `string` \| `number` \| `symbol` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `options` | readonly `T`[] |
| `labelKey` | `K` |

#### Returns

`Record`<`T`[`K`], `T`\>

#### Defined in

[ato.ts:12](https://github.com/daysnap/utils/blob/9ced15e/src/ato.ts#L12)

▸ **ato**<`T`, `K`, `V`\>(`options`, `labelKey`, `valueKey`): `Record`<`T`[`K`], `T`[`V`]\>

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends `Record`<`string`, `any`\> |
| `K` | extends `string` \| `number` \| `symbol` |
| `V` | extends `string` \| `number` \| `symbol` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `options` | readonly `T`[] |
| `labelKey` | `K` |
| `valueKey` | `V` |

#### Returns

`Record`<`T`[`K`], `T`[`V`]\>

#### Defined in

[ato.ts:16](https://github.com/daysnap/utils/blob/9ced15e/src/ato.ts#L16)

___

### atob

▸ **atob**(`string`): `string`

#### Parameters

| Name | Type |
| :------ | :------ |
| `string` | `string` |

#### Returns

`string`

#### Defined in

[decode.ts:41](https://github.com/daysnap/utils/blob/9ced15e/src/decode.ts#L41)

___

### base64ToBlob

▸ **base64ToBlob**(`base64`, `contentType?`): `Blob`

base64 转 blob

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `base64` | `string` | base64字符串 |
| `contentType?` | `string` | 文件类型 |

#### Returns

`Blob`

#### Defined in

[base64ToBlob.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/base64ToBlob.ts#L6)

___

### blobToBase64

▸ **blobToBase64**(`blob`): `Promise`<`string` \| `ArrayBuffer`\>

blob 转 base64

#### Parameters

| Name | Type |
| :------ | :------ |
| `blob` | `Blob` |

#### Returns

`Promise`<`string` \| `ArrayBuffer`\>

#### Defined in

[blobToBase64.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/blobToBase64.ts#L4)

___

### btoa

▸ **btoa**(`string`): `string`

#### Parameters

| Name | Type |
| :------ | :------ |
| `string` | `string` |

#### Returns

`string`

#### Defined in

[decode.ts:8](https://github.com/daysnap/utils/blob/9ced15e/src/decode.ts#L8)

___

### cached

▸ **cached**<`T`\>(`fn`): (...`args`: `Parameters`<`T`\>) => `ReturnType`<`T`\>

缓存、记忆函数，缓存函数的运算结果
需注意缓存的函数得是纯函数

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends (...`args`: `any`[]) => `any` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `fn` | `T` |

#### Returns

`fn`

▸ (`...args`): `ReturnType`<`T`\>

##### Parameters

| Name | Type |
| :------ | :------ |
| `...args` | `Parameters`<`T`\> |

##### Returns

`ReturnType`<`T`\>

#### Defined in

[cached.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/cached.ts#L5)

___

### camelCase

▸ **camelCase**(`str`): `string`

驼峰
camelCase('hello-world') => helloWorld

#### Parameters

| Name | Type |
| :------ | :------ |
| `str` | `string` |

#### Returns

`string`

#### Defined in

[camelCase.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/camelCase.ts#L5)

___

### canvasToBlob

▸ **canvasToBlob**(`canvas`, `type?`, `quality?`): `Promise`<`Blob`\>

canvas 转 blob 文件

#### Parameters

| Name | Type |
| :------ | :------ |
| `canvas` | `HTMLCanvasElement` |
| `type?` | `string` |
| `quality?` | `any` |

#### Returns

`Promise`<`Blob`\>

#### Defined in

[canvasToBlob.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/canvasToBlob.ts#L4)

___

### capitalize

▸ **capitalize**(`str`): `string`

首字母大写
capitalize('hello world') => Hello world

#### Parameters

| Name | Type |
| :------ | :------ |
| `str` | `string` |

#### Returns

`string`

#### Defined in

[capitalize.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/capitalize.ts#L5)

___

### chooseMedia

▸ **chooseMedia**(`options?`): `Promise`<`File`[]\>

创建 input 触发选择文件
因为 iOS 必须把 input 元素添加到 document 才会获取到文件，所以这里做了兼容处理

#### Parameters

| Name | Type |
| :------ | :------ |
| `options` | `Object` |
| `options.accept?` | `string` |
| `options.multiple?` | `boolean` |

#### Returns

`Promise`<`File`[]\>

#### Defined in

[chooseMedia.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/chooseMedia.ts#L5)

___

### clamp

▸ **clamp**(`min`, `val`, `max`): `number`

首选值超出最小值，返回最小值；首选值超出最大值，返回最大值；其余返回首选值

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `min` | `number` | 最小值 |
| `val` | `number` | - |
| `max` | `number` | 最大值 |

#### Returns

`number`

#### Defined in

[clamp.ts:7](https://github.com/daysnap/utils/blob/9ced15e/src/clamp.ts#L7)

___

### clone

▸ **clone**<`T`\>(`source`): `T`

深拷贝

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends `Record`<`string`, `any`\> |

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `source` | `T` | 需要转换的值 |

#### Returns

`T`

#### Defined in

[clone.ts:8](https://github.com/daysnap/utils/blob/9ced15e/src/clone.ts#L8)

___

### cloneSimple

▸ **cloneSimple**<`T`\>(`source`): `T`

拷贝对象

#### Type parameters

| Name |
| :------ |
| `T` |

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `source` | `T` | 需要转换的值 需要注意 当值为 undefined、function、symbol 会在转换过程中被忽略 |

#### Returns

`T`

#### Defined in

[cloneSimple.ts:7](https://github.com/daysnap/utils/blob/9ced15e/src/cloneSimple.ts#L7)

___

### colorGenByHash

▸ **colorGenByHash**(`str`): `string`

根据字符串hash值生成颜色值

#### Parameters

| Name | Type |
| :------ | :------ |
| `str` | `string` |

#### Returns

`string`

#### Defined in

[createHexColorByHash.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/createHexColorByHash.ts#L4)

___

### compareVersion

▸ **compareVersion**(`nv`, `v`): ``-1`` \| ``0`` \| ``1``

比对版本
-1 => nv < v
0 => nv === v
1 => nv > v

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `nv` | `string` | 新版本 |
| `v` | `string` | 版本 |

#### Returns

``-1`` \| ``0`` \| ``1``

#### Defined in

[compareVersion.ts:9](https://github.com/daysnap/utils/blob/9ced15e/src/compareVersion.ts#L9)

___

### compressImage

▸ **compressImage**(`image`, `mw`): `Promise`<`HTMLCanvasElement`\>

利用 canvas 压缩图片

#### Parameters

| Name | Type |
| :------ | :------ |
| `image` | `HTMLImageElement` |
| `mw` | `number` |

#### Returns

`Promise`<`HTMLCanvasElement`\>

#### Defined in

[compressImage.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/compressImage.ts#L4)

___

### crToBr

▸ **crToBr**(`v`): `string`

\r to <br/>

#### Parameters

| Name | Type |
| :------ | :------ |
| `v` | `string` |

#### Returns

`string`

#### Defined in

[crToBr.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/crToBr.ts#L4)

___

### createFactory

▸ **createFactory**<`T`\>(`initial?`): readonly [(`value`: `T`) => `T`, () => `T`]

创建工厂函数

#### Type parameters

| Name |
| :------ |
| `T` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `initial?` | `T` |

#### Returns

readonly [(`value`: `T`) => `T`, () => `T`]

#### Defined in

[createFactory.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/createFactory.ts#L4)

___

### createLinearFunction

▸ **createLinearFunction**(`x1`, `x2`, `y1`, `y2`): (`x`: `number`) => `number`

创建一个线性函数
主要用于动画值计算

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `x1` | `number` | 坐标轴 x1 |
| `x2` | `number` | 坐标轴 x2 |
| `y1` | `number` | 坐标轴 y1 |
| `y2` | `number` | 坐标轴 y2 |

#### Returns

`fn`

▸ (`x`): `number`

##### Parameters

| Name | Type |
| :------ | :------ |
| `x` | `number` |

##### Returns

`number`

#### Defined in

[createLinearFunction.ts:9](https://github.com/daysnap/utils/blob/9ced15e/src/createLinearFunction.ts#L9)

___

### createSwipeHandler

▸ **createSwipeHandler**(`listener`, `options?`): [`SwipeHandlers`](interfaces/SwipeHandlers.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `listener` | [`SwipeListener`](interfaces/SwipeListener.md) |
| `options` | [`SwipeOptions`](interfaces/SwipeOptions.md) |

#### Returns

[`SwipeHandlers`](interfaces/SwipeHandlers.md)

#### Defined in

[createSwipeHandlers.ts:58](https://github.com/daysnap/utils/blob/9ced15e/src/createSwipeHandlers.ts#L58)

___

### createSwipeHandlers

▸ **createSwipeHandlers**(`listener`, `options?`): [`SwipeHandlers`](interfaces/SwipeHandlers.md)

#### Parameters

| Name | Type |
| :------ | :------ |
| `listener` | [`SwipeListener`](interfaces/SwipeListener.md) |
| `options` | [`SwipeOptions`](interfaces/SwipeOptions.md) |

#### Returns

[`SwipeHandlers`](interfaces/SwipeHandlers.md)

#### Defined in

[createSwipeHandlers.ts:58](https://github.com/daysnap/utils/blob/9ced15e/src/createSwipeHandlers.ts#L58)

___

### createTrapInstance

▸ **createTrapInstance**<`T`\>(`id`): `Object`

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | `any` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `id` | `string` |

#### Returns

`Object`

| Name | Type |
| :------ | :------ |
| `create` | (`cb`: (`data`: `T`) => `void`) => `void` |
| `delete` | () => `void` |
| `trigger` | (`data?`: `T`) => `void` |

#### Defined in

[trap.ts:49](https://github.com/daysnap/utils/blob/9ced15e/src/trap.ts#L49)

___

### createWithLoading

▸ **createWithLoading**<`O`\>(`showLoading`, `defaultOptions?`): <T\>(`fn`: `T`, `options`: `WithFalse`<`O`\>) => (...`params`: [...Parameters<T\>[], WithFalse<O\>?]) => `Promise`<`Awaited`<`ReturnType`<`T`\>\>\>

loading 生成器
const withLoading = createWithLoading(() => showLoading())
const fn = withLoading(async () => { // ... })
fn() 执行的时候就会执行showLoading

#### Type parameters

| Name | Type |
| :------ | :------ |
| `O` | `any` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `showLoading` | (`options`: `O`) => `Loose`<{ `close`: () => `any`  }\> |
| `defaultOptions?` | `O` |

#### Returns

`fn`

▸ <`T`\>(`fn`, `options?`): (...`params`: [...Parameters<T\>[], WithFalse<O\>?]) => `Promise`<`Awaited`<`ReturnType`<`T`\>\>\>

##### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends (...`args`: `any`[]) => `Promise`<`any`\> |

##### Parameters

| Name | Type |
| :------ | :------ |
| `fn` | `T` |
| `options` | `WithFalse`<`O`\> |

##### Returns

`fn`

▸ (`...params`): `Promise`<`Awaited`<`ReturnType`<`T`\>\>\>

##### Parameters

| Name | Type |
| :------ | :------ |
| `...params` | [...Parameters<T\>[], WithFalse<O\>?] |

##### Returns

`Promise`<`Awaited`<`ReturnType`<`T`\>\>\>

#### Defined in

[createWithLoading.ts:11](https://github.com/daysnap/utils/blob/9ced15e/src/createWithLoading.ts#L11)

___

### createWithToast

▸ **createWithToast**(`options?`): <T\>(`fn`: `T`) => `T`

#### Parameters

| Name | Type |
| :------ | :------ |
| `options` | [`CreateWithToastOptions`](interfaces/CreateWithToastOptions.md) |

#### Returns

`fn`

▸ <`T`\>(`fn`): `T`

##### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends (...`args`: `any`) => `any` |

##### Parameters

| Name | Type |
| :------ | :------ |
| `fn` | `T` |

##### Returns

`T`

#### Defined in

[createWithToast.ts:11](https://github.com/daysnap/utils/blob/9ced15e/src/createWithToast.ts#L11)

___

### crlfToBr

▸ **crlfToBr**(`v`): `string`

\r \n to <br/>

#### Parameters

| Name | Type |
| :------ | :------ |
| `v` | `string` |

#### Returns

`string`

#### Defined in

[crlfToBr.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/crlfToBr.ts#L4)

___

### debounce

▸ **debounce**<`T`\>(`fn`, `ms`): (`this`: `unknown`, ...`args`: `Parameters`<`T`\>) => `void`

防抖函数
事件频繁触发，只会执行最后一次

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends (...`args`: `any`[]) => `any` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `fn` | `T` |
| `ms` | `number` |

#### Returns

`fn`

▸ (`this`, `...args`): `void`

##### Parameters

| Name | Type |
| :------ | :------ |
| `this` | `unknown` |
| `...args` | `Parameters`<`T`\> |

##### Returns

`void`

#### Defined in

[debounce.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/debounce.ts#L5)

___

### downloadFile

▸ **downloadFile**(`data`, `options?`): `void`

通过 a 标签下载文件

#### Parameters

| Name | Type |
| :------ | :------ |
| `data` | `string` \| `Blob` \| `MediaSource` |
| `options?` | `Object` |
| `options.fileName?` | `string` |

#### Returns

`void`

#### Defined in

[downloadFile.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/downloadFile.ts#L4)

___

### each

▸ **each**<`T`\>(`data`, `callback`): `void`

支持遍历数组和对象

#### Type parameters

| Name |
| :------ |
| `T` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `data` | `T`[] |
| `callback` | (`item`: `T`, `index`: `number`) => `void` |

#### Returns

`void`

#### Defined in

[each.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/each.ts#L4)

▸ **each**<`T`\>(`data`, `callback`): `void`

#### Type parameters

| Name |
| :------ |
| `T` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `data` | `Record`<`string`, `T`\> |
| `callback` | (`item`: `T`, `key`: `string`) => `void` |

#### Returns

`void`

#### Defined in

[each.ts:8](https://github.com/daysnap/utils/blob/9ced15e/src/each.ts#L8)

___

### exitFullscreen

▸ **exitFullscreen**(): `Promise`<`any`\>

退出全屏
成功则 resolve , 如果不支持退出全屏或退出失败则 rejected
[MDN Reference](https://developer.mozilla.org/zh-CN/docs/Web/API/Document/exitFullscreen)

#### Returns

`Promise`<`any`\>

#### Defined in

[exitFullscreen.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/exitFullscreen.ts#L6)

___

### factory

▸ **factory**(`type`): `Object`

#### Parameters

| Name | Type |
| :------ | :------ |
| `type` | ``"sessionStorage"`` \| ``"localStorage"`` |

#### Returns

`Object`

| Name | Type |
| :------ | :------ |
| `clear` | () => `void` |
| `generate` | <T\>(`key`: `string`) => { `getItem`: (`defaultVal?`: `Partial`<`T`\>) => `T` ; `removeItem`: () => `void` ; `setItem`: (`val`: `T`) => `T` ; `updateItem`: (`val`: `Partial`<`T`\>) => `T`  } |
| `getItem` | <T\>(`key`: `string`, `defaultVal`: ``null`` \| `Partial`<`T`\>) => `T` |
| `removeItem` | (`key`: `string`) => `void` |
| `setItem` | <T\>(`key`: `string`, `val`: `T`) => `T` |
| `updateItem` | <T\>(`key`: `string`, `val`: `Partial`<`T`\>) => `T` |

#### Defined in

[storage/factory.ts:11](https://github.com/daysnap/utils/blob/9ced15e/src/storage/factory.ts#L11)

___

### filterBankCardNo

▸ **filterBankCardNo**(`val`): `string`

过滤银行卡号

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `string` |

#### Returns

`string`

#### Defined in

[filterBankCardNo.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/filterBankCardNo.ts#L4)

___

### filterCRLF

▸ **filterCRLF**(`v`): `string`

替换字符串里面的回车换行符

**`Deprecated`**

请使用

**`See`**

[crlfToBr](modules.md#crlftobr).

#### Parameters

| Name | Type |
| :------ | :------ |
| `v` | `string` |

#### Returns

`string`

#### Defined in

[crlfToBr.ts:12](https://github.com/daysnap/utils/blob/9ced15e/src/crlfToBr.ts#L12)

___

### filterEmoji

▸ **filterEmoji**(`val`): `string`

过滤emoji

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `string` |

#### Returns

`string`

#### Defined in

[filterEmoji.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/filterEmoji.ts#L4)

___

### filterEmptyValue

▸ **filterEmptyValue**(`obj`, `expand?`): `Record`<`string`, `any`\>

过滤对象的 undefined null '' 属性，返回一个新对象

#### Parameters

| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `obj` | `Record`<`string`, `any`\> | `undefined` | 需要过滤的对象 |
| `expand` | `boolean` \| (`key`: `string`, `value`: `any`) => `boolean` | `false` | 如果是传的是布尔类型 true， 则还会过滤空数组、空对象的情况 |

#### Returns

`Record`<`string`, `any`\>

#### Defined in

[filterEmptyValue.ts:12](https://github.com/daysnap/utils/blob/9ced15e/src/filterEmptyValue.ts#L12)

___

### filterIdCard

▸ **filterIdCard**(`val`): `string`

身份证号码加 *
430421202312121234 => 430421********1234

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `string` |

#### Returns

`string`

#### Defined in

[filterIdCard.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/filterIdCard.ts#L5)

___

### filterName

▸ **filterName**(`val`): `string`

过滤姓名

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `string` |

#### Returns

`string`

#### Defined in

[filterName.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/filterName.ts#L4)

___

### filterPhone

▸ **filterPhone**(`val`, `sep?`): `string`

手机号加 *
filterPhone('13177778888') => 131****8888
filterPhone('13177778888', ' ') => 131 **** 8888

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `val` | `string` | `undefined` |
| `sep` | `string` | `''` |

#### Returns

`string`

#### Defined in

[filterPhone.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/filterPhone.ts#L6)

___

### filterString

▸ **filterString**(`val`, `sep?`, `start?`, `end?`): `string`

过滤字符串
const str = filterString('13188888888', '*', 3, 7)
str = '131****8888'

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `val` | `string` | `undefined` |
| `sep` | `string` | `'*'` |
| `start` | `number` | `0` |
| `end?` | `number` | `undefined` |

#### Returns

`string`

#### Defined in

[filterString.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/filterString.ts#L6)

___

### formatAmount

▸ **formatAmount**(`s`, `radix?`): `string`

格式化金额，默认元

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `s` | `string` \| `number` | `undefined` |
| `radix` | `number` | `1` |

#### Returns

`string`

#### Defined in

[formatAmount.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/formatAmount.ts#L4)

___

### formatDate

▸ **formatDate**(`val?`, `fmt?`): `string`

格式化日期
默认的当前日期 yyyy-MM-dd hh:mm:ss

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `val` | `string` \| `number` \| `Date` | `undefined` |
| `fmt` | `string` | `'yyyy-MM-dd hh:mm:ss'` |

#### Returns

`string`

#### Defined in

[formatDate.ts:7](https://github.com/daysnap/utils/blob/9ced15e/src/formatDate.ts#L7)

___

### formatDateStr

▸ **formatDateStr**(`v`): `Date`

str 转换成 date
fix iOS 日期时间格式如果是 - 就会报错的问题

**`Deprecated`**

请使用

**`See`**

[normalizeDate](modules.md#normalizedate).

#### Parameters

| Name | Type |
| :------ | :------ |
| `v` | `string` |

#### Returns

`Date`

#### Defined in

[formatDateStr.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/formatDateStr.ts#L6)

___

### formatDateToZN

▸ **formatDateToZN**(`v`): `string`

#### Parameters

| Name | Type |
| :------ | :------ |
| `v` | `string` \| `number` \| `Date` |

#### Returns

`string`

#### Defined in

[formartDateToZN.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/formartDateToZN.ts#L4)

___

### formatFileSize

▸ **formatFileSize**(`bytes`, `decimals?`): `string`

格式化字节大小

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `bytes` | `number` | `undefined` |
| `decimals` | `number` | `2` |

#### Returns

`string`

#### Defined in

[formatFileSize.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/formatFileSize.ts#L4)

___

### formatGapDate

▸ **formatGapDate**(`val`, `gap?`): `string`

yyyyMMdd -> yyyy-MM-dd

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `val` | `string` \| `number` | `undefined` |
| `gap` | `string` | `'-'` |

#### Returns

`string`

#### Defined in

[formatGapDate.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/formatGapDate.ts#L4)

___

### formatMessage

▸ **formatMessage**(`message`, `keys?`): `string`

格式化消息
formatMessage({ a: '123', b: { ba: '456' } }, ['a']) => '123'
formatMessage({ a: '123', b: { ba: '456' } }, ['b.ba']) => '456'

#### Parameters

| Name | Type |
| :------ | :------ |
| `message` | `unknown` |
| `keys` | `string`[] |

#### Returns

`string`

#### Defined in

[formatMessage.ts:11](https://github.com/daysnap/utils/blob/9ced15e/src/formatMessage.ts#L11)

___

### formatPathParams

▸ **formatPathParams**(`path`, `params?`): `Object`

格式化字符串参数，一般用来处理 api path params
const url = 'api/v1/user/{id}'
const { path, rest } = formatPathParams(url, { id: 123, xxx: 1 })
path = 'api/v1/user/123'
rest = { xxx: 1 }

#### Parameters

| Name | Type |
| :------ | :------ |
| `path` | `string` |
| `params` | `Record`<`string`, `any`\> |

#### Returns

`Object`

| Name | Type |
| :------ | :------ |
| `path` | `string` |
| `rest` | {} |

#### Defined in

[formatPathParams.ts:8](https://github.com/daysnap/utils/blob/9ced15e/src/formatPathParams.ts#L8)

___

### getBlobByUrl

▸ **getBlobByUrl**(`url`): `Promise`<`Blob`\>

根据在线 url 返回 blob

#### Parameters

| Name | Type |
| :------ | :------ |
| `url` | `string` |

#### Returns

`Promise`<`Blob`\>

#### Defined in

[getBlobByUrl.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/getBlobByUrl.ts#L4)

___

### getCache

▸ **getCache**(): `Object`

#### Returns

`Object`

| Name | Type |
| :------ | :------ |
| `clear` | () => `void` |
| `generate` | <T\>(`key`: `string`) => { `getItem`: (`defaultVal?`: `Partial`<`T`\>) => `T` ; `removeItem`: () => `void` ; `setItem`: (`val`: `T`) => `T` ; `updateItem`: (`val`: `Partial`<`T`\>) => `T`  } |
| `getItem` | <T\>(`key`: `string`, `defaultVal`: ``null`` \| `Partial`<`T`\>) => `T` |
| `removeItem` | (`key`: `string`) => `void` |
| `setItem` | <T\>(`key`: `string`, `val`: `T`) => `T` |
| `updateItem` | <T\>(`key`: `string`, `val`: `Partial`<`T`\>) => `T` |

#### Defined in

[storage/index.ts:10](https://github.com/daysnap/utils/blob/9ced15e/src/storage/index.ts#L10)

___

### getDateBoundsByMonths

▸ **getDateBoundsByMonths**(`monthsCount`, `date`): [`Date`, `Date`]

获取月份开始时间、结束时间

#### Parameters

| Name | Type |
| :------ | :------ |
| `monthsCount` | `number` |
| `date` | `string` \| `number` \| `Date` |

#### Returns

[`Date`, `Date`]

#### Defined in

[getDateBoundsByMonths.ts:8](https://github.com/daysnap/utils/blob/9ced15e/src/getDateBoundsByMonths.ts#L8)

▸ **getDateBoundsByMonths**(`monthsCount`, `date`, `fmt`): [`string`, `string`]

#### Parameters

| Name | Type |
| :------ | :------ |
| `monthsCount` | `number` |
| `date` | `string` \| `number` \| `Date` |
| `fmt` | `string` |

#### Returns

[`string`, `string`]

#### Defined in

[getDateBoundsByMonths.ts:12](https://github.com/daysnap/utils/blob/9ced15e/src/getDateBoundsByMonths.ts#L12)

___

### getDayMillisecond

▸ **getDayMillisecond**(`day?`): `number`

获取多少天的毫秒数 默认获取1天的

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `day` | `number` | `1` |

#### Returns

`number`

#### Defined in

[getDayMillisecond.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/getDayMillisecond.ts#L4)

___

### getDaysOfMonth

▸ **getDaysOfMonth**(`year`, `month`): `number`

获取一个月当中的天数

#### Parameters

| Name | Type |
| :------ | :------ |
| `year` | `number` |
| `month` | `number` |

#### Returns

`number`

#### Defined in

[getDaysOfMonth.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/getDaysOfMonth.ts#L4)

___

### getImageInfo

▸ **getImageInfo**(`src`, `attrs?`): `Promise`<`HTMLImageElement`\>

获取图片信息

#### Parameters

| Name | Type |
| :------ | :------ |
| `src` | `string` |
| `attrs` | `Record`<`string`, `any`\> |

#### Returns

`Promise`<`HTMLImageElement`\>

#### Defined in

[getImageInfo.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/getImageInfo.ts#L4)

___

### getLocal

▸ **getLocal**(): `Object`

#### Returns

`Object`

| Name | Type |
| :------ | :------ |
| `clear` | () => `void` |
| `generate` | <T\>(`key`: `string`) => { `getItem`: (`defaultVal?`: `Partial`<`T`\>) => `T` ; `removeItem`: () => `void` ; `setItem`: (`val`: `T`) => `T` ; `updateItem`: (`val`: `Partial`<`T`\>) => `T`  } |
| `getItem` | <T\>(`key`: `string`, `defaultVal`: ``null`` \| `Partial`<`T`\>) => `T` |
| `removeItem` | (`key`: `string`) => `void` |
| `setItem` | <T\>(`key`: `string`, `val`: `T`) => `T` |
| `updateItem` | <T\>(`key`: `string`, `val`: `Partial`<`T`\>) => `T` |

#### Defined in

[storage/index.ts:10](https://github.com/daysnap/utils/blob/9ced15e/src/storage/index.ts#L10)

___

### getMonthBounds

▸ **getMonthBounds**(`value`): [`Date`, `Date`]

获取月份的开始时间和结束时间

#### Parameters

| Name | Type |
| :------ | :------ |
| `value` | `string` \| `number` \| `Date` |

#### Returns

[`Date`, `Date`]

#### Defined in

[getMonthBounds.ts:7](https://github.com/daysnap/utils/blob/9ced15e/src/getMonthBounds.ts#L7)

▸ **getMonthBounds**(`value`, `fmt`): [`string`, `string`]

#### Parameters

| Name | Type |
| :------ | :------ |
| `value` | `string` \| `number` \| `Date` |
| `fmt` | `string` |

#### Returns

[`string`, `string`]

#### Defined in

[getMonthBounds.ts:8](https://github.com/daysnap/utils/blob/9ced15e/src/getMonthBounds.ts#L8)

___

### getRandom

▸ **getRandom**(`length`, `alphabet?`): `string`

生成一个随机字符串

#### Parameters

| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `length` | `number` | `undefined` | 生成随机字符串的长度 |
| `alphabet` | `string` | `'1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'` | 字母表 |

#### Returns

`string`

#### Defined in

[getRandom.ts:7](https://github.com/daysnap/utils/blob/9ced15e/src/getRandom.ts#L7)

___

### getRandomColor

▸ **getRandomColor**(): `string`

随机颜色

#### Returns

`string`

#### Defined in

[getRandomColor.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/getRandomColor.ts#L4)

___

### getRandomNumber

▸ **getRandomNumber**(`length`): `string`

生成一个随机数字

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `length` | `number` | 生成一个随机数字的长度 |

#### Returns

`string`

#### Defined in

[getRandomNumber.ts:7](https://github.com/daysnap/utils/blob/9ced15e/src/getRandomNumber.ts#L7)

___

### getRangeDate

▸ **getRangeDate**(`sv`, `ev`): `Date`[]

获取一个时间段的日期

#### Parameters

| Name | Type |
| :------ | :------ |
| `sv` | `string` \| `number` \| `Date` |
| `ev` | `string` \| `number` \| `Date` |

#### Returns

`Date`[]

#### Defined in

[getRangeDate.ts:7](https://github.com/daysnap/utils/blob/9ced15e/src/getRangeDate.ts#L7)

▸ **getRangeDate**(`sv`, `ev`, `fmt`): `string`[]

#### Parameters

| Name | Type |
| :------ | :------ |
| `sv` | `string` \| `number` \| `Date` |
| `ev` | `string` \| `number` \| `Date` |
| `fmt` | `string` |

#### Returns

`string`[]

#### Defined in

[getRangeDate.ts:11](https://github.com/daysnap/utils/blob/9ced15e/src/getRangeDate.ts#L11)

___

### getScrollTop

▸ **getScrollTop**(): `number`

获取 scrollTop

#### Returns

`number`

#### Defined in

[getScrollTop.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/getScrollTop.ts#L4)

___

### getVideoInfo

▸ **getVideoInfo**(`src`): `Promise`<`HTMLVideoElement`\>

获取 video 信息

#### Parameters

| Name | Type |
| :------ | :------ |
| `src` | `string` |

#### Returns

`Promise`<`HTMLVideoElement`\>

#### Defined in

[getVideoInfo.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/getVideoInfo.ts#L4)

___

### getWeekBounds

▸ **getWeekBounds**(`value`, `sundayIsFirstDay`): [`Date`, `Date`]

获取一周的开始时间和结束时间

#### Parameters

| Name | Type |
| :------ | :------ |
| `value` | `string` \| `number` \| `Date` |
| `sundayIsFirstDay` | `boolean` |

#### Returns

[`Date`, `Date`]

#### Defined in

[getWeekBounds.ts:7](https://github.com/daysnap/utils/blob/9ced15e/src/getWeekBounds.ts#L7)

▸ **getWeekBounds**(`value`, `sundayIsFirstDay`, `fmt`): [`string`, `string`]

#### Parameters

| Name | Type |
| :------ | :------ |
| `value` | `string` \| `number` \| `Date` |
| `sundayIsFirstDay` | `boolean` |
| `fmt` | `string` |

#### Returns

[`string`, `string`]

#### Defined in

[getWeekBounds.ts:11](https://github.com/daysnap/utils/blob/9ced15e/src/getWeekBounds.ts#L11)

___

### getWeekday

▸ **getWeekday**(`value?`, `prefix?`): `string`

获取星期几

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `value` | `string` \| `number` \| `Date` | `undefined` |
| `prefix` | `string` | `'周'` |

#### Returns

`string`

#### Defined in

[getWeekday.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/getWeekday.ts#L6)

___

### inBrowser

▸ **inBrowser**(): `boolean`

判断是否是浏览器环境

#### Returns

`boolean`

#### Defined in

[inBrowser.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/inBrowser.ts#L4)

___

### insertLink

▸ **insertLink**(`href`): `Promise`<`HTMLLinkElement`\>

插入 link

#### Parameters

| Name | Type |
| :------ | :------ |
| `href` | `string` |

#### Returns

`Promise`<`HTMLLinkElement`\>

#### Defined in

[insertLink.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/insertLink.ts#L4)

▸ **insertLink**(`href`, `callback`): `void`

#### Parameters

| Name | Type |
| :------ | :------ |
| `href` | `string` |
| `callback` | (`err`: `unknown`, `el`: `HTMLLinkElement`) => `void` |

#### Returns

`void`

#### Defined in

[insertLink.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/insertLink.ts#L5)

___

### insertScript

▸ **insertScript**(`src`): `Promise`<`HTMLScriptElement`\>

插入外部 script 标签

#### Parameters

| Name | Type |
| :------ | :------ |
| `src` | `string` |

#### Returns

`Promise`<`HTMLScriptElement`\>

#### Defined in

[insertScript.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/insertScript.ts#L4)

▸ **insertScript**(`src`, `callback`): `void`

#### Parameters

| Name | Type |
| :------ | :------ |
| `src` | `string` |
| `callback` | (`err`: `unknown`, `el`: `HTMLScriptElement`) => `void` |

#### Returns

`void`

#### Defined in

[insertScript.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/insertScript.ts#L5)

___

### insertStyle

▸ **insertStyle**(`content`): `HTMLStyleElement`

插入样式

#### Parameters

| Name | Type |
| :------ | :------ |
| `content` | `string` |

#### Returns

`HTMLStyleElement`

#### Defined in

[insertStyle.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/insertStyle.ts#L4)

___

### isAmount

▸ **isAmount**(`val`): `boolean`

判断是否是合法金额
只能是数字,小数点后只能保留两位或一位
isAmount(0) => true
isAmount('01') => false
isAmount('1.') => true
isAmount('1.1') => true
isAmount('1.12') => true
isAmount('1.123') => false

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `string` |

#### Returns

`boolean`

#### Defined in

[isAmount.ts:11](https://github.com/daysnap/utils/blob/9ced15e/src/isAmount.ts#L11)

___

### isAndroid

▸ **isAndroid**(): `boolean`

校验是否是安卓

#### Returns

`boolean`

#### Defined in

[isAndroid.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isAndroid.ts#L4)

___

### isArray

▸ **isArray**<`T`\>(`val`): val is T[]

判断是否是数组

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | `any` |

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `val` | `unknown` | 待判断值 |

#### Returns

val is T[]

是否

#### Defined in

[isArray.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/isArray.ts#L6)

___

### isBoolean

▸ **isBoolean**(`val`): val is boolean

判断是否是布尔值

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `val` | `unknown` | 需要判断的值 |

#### Returns

val is boolean

#### Defined in

[isBoolean.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/isBoolean.ts#L5)

___

### isChinese

▸ **isChinese**(`val`): `boolean`

判断是否是中文

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `string` |

#### Returns

`boolean`

#### Defined in

[isChinese.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isChinese.ts#L4)

___

### isDate

▸ **isDate**(`val`): val is Date

判断是否日期 Date

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `unknown` |

#### Returns

val is Date

#### Defined in

[isDate.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isDate.ts#L4)

___

### isEmail

▸ **isEmail**(`val`): `boolean`

校验是否是邮箱

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `string` |

#### Returns

`boolean`

#### Defined in

[isEmail.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isEmail.ts#L4)

___

### isEmpty

▸ **isEmpty**(`val`): `boolean`

校验是否为空 ''、undefined、null

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `unknown` |

#### Returns

`boolean`

#### Defined in

[isEmpty.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/isEmpty.ts#L6)

___

### isEmptyArray

▸ **isEmptyArray**(`val`): `boolean`

判断是否是空数组

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `unknown` |

#### Returns

`boolean`

#### Defined in

[isEmptyArray.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/isEmptyArray.ts#L6)

___

### isEmptyObject

▸ **isEmptyObject**(`val`): `boolean`

判断是否是空对象

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `val` | `object` | 对象 |

#### Returns

`boolean`

#### Defined in

[isEmptyObject.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/isEmptyObject.ts#L5)

___

### isError

▸ **isError**(`val`): val is Error

校验是否是 error

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `unknown` |

#### Returns

val is Error

#### Defined in

[isError.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isError.ts#L4)

___

### isFunction

▸ **isFunction**<`T`\>(`val`): val is T

校验是否是函数

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends (...`args`: `any`[]) => `any` = (...`args`: `any`[]) => `any` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `unknown` |

#### Returns

val is T

#### Defined in

[isFunction.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isFunction.ts#L4)

___

### isIE

▸ **isIE**(): ``false`` \| `number`

判断浏览器是否是 ie
如果是 ie 则会返回对应 ie 版本
如果不是则返回false

#### Returns

``false`` \| `number`

#### Defined in

[isIE.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/isIE.ts#L6)

___

### isIOS

▸ **isIOS**(): `boolean`

校验是否是ios

#### Returns

`boolean`

#### Defined in

[isIOS.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isIOS.ts#L4)

___

### isIdCard

▸ **isIdCard**(`val`): `boolean`

校验是否是身份证

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `string` |

#### Returns

`boolean`

#### Defined in

[isIdCard.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isIdCard.ts#L4)

___

### isJSONString

▸ **isJSONString**(`v`): `boolean`

是否是JSON 字符串

#### Parameters

| Name | Type |
| :------ | :------ |
| `v` | `string` |

#### Returns

`boolean`

#### Defined in

[isJSONString.ts:7](https://github.com/daysnap/utils/blob/9ced15e/src/isJSONString.ts#L7)

___

### isLan

▸ **isLan**(`ip`): `boolean`

判断 ip 是否是局域网 ip，仅支持 ipv4

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `ip` | `string` | ipv4 地址 |

#### Returns

`boolean`

#### Defined in

[isLan.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/isLan.ts#L5)

___

### isLeapYear

▸ **isLeapYear**(`year`): `boolean`

判断是否是闰年
规则：四年一闰，百年不闰，四百年再闰

#### Parameters

| Name | Type |
| :------ | :------ |
| `year` | `number` |

#### Returns

`boolean`

#### Defined in

[isLeapYear.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/isLeapYear.ts#L5)

___

### isLicenseCode

▸ **isLicenseCode**(`v`): `boolean`

校验是否是车牌号

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `v` | `string` | 车牌号 |

#### Returns

`boolean`

#### Defined in

[isLicenseCode.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/isLicenseCode.ts#L5)

___

### isMobile

▸ **isMobile**(): `boolean`

校验设备是否是手机

#### Returns

`boolean`

#### Defined in

[isMobile.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isMobile.ts#L4)

___

### isNativeFunction

▸ **isNativeFunction**(`val`): `boolean`

判断是不是内置函数
内置函数toString后的主体代码块为 [native code]

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `unknown` |

#### Returns

`boolean`

#### Defined in

[isNativeFunction.ts:7](https://github.com/daysnap/utils/blob/9ced15e/src/isNativeFunction.ts#L7)

___

### isNotEmpty

▸ **isNotEmpty**(`val`): `boolean`

校验非 ''、undefined、null

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `unknown` |

#### Returns

`boolean`

#### Defined in

[isNotEmpty.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/isNotEmpty.ts#L5)

___

### isNull

▸ **isNull**(`val`): val is null

校验是否是 null

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `unknown` |

#### Returns

val is null

#### Defined in

[isNull.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isNull.ts#L4)

___

### isNumber

▸ **isNumber**(`val`): val is number

判断是否是数字

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `val` | `unknown` | 需要判断的值 |

#### Returns

val is number

#### Defined in

[isNumber.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/isNumber.ts#L5)

___

### isNumeric

▸ **isNumeric**(`val`): val is string \| number

判断是否是数字或数字字符串

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `val` | `unknown` | 需要判断的值 |

#### Returns

val is string \| number

#### Defined in

[isNumeric.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/isNumeric.ts#L5)

___

### isObject

▸ **isObject**<`T`\>(`val`): val is T

校验是否是对象

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends `Record`<`string`, `any`\> = `Record`<`string`, `any`\> |

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `unknown` |

#### Returns

val is T

#### Defined in

[isObject.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isObject.ts#L4)

___

### isPhone

▸ **isPhone**(`val`): `boolean`

校验是否是手机号码

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `string` |

#### Returns

`boolean`

#### Defined in

[isPhone.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isPhone.ts#L4)

___

### isPromise

▸ **isPromise**<`T`\>(`val`): val is Promise<T\>

校验是否是 promise

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | `any` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `unknown` |

#### Returns

val is Promise<T\>

#### Defined in

[isPromise.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isPromise.ts#L4)

___

### isPromiseLike

▸ **isPromiseLike**<`T`\>(`value`): value is PromiseLike<T\>

说明

#### Type parameters

| Name |
| :------ |
| `T` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `value` | `unknown` |

#### Returns

value is PromiseLike<T\>

#### Defined in

[isPromiseLike.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isPromiseLike.ts#L4)

___

### isRegExp

▸ **isRegExp**(`val`): val is RegExp

校验是否是正则表达式

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `unknown` |

#### Returns

val is RegExp

#### Defined in

[isRegExp.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isRegExp.ts#L4)

___

### isString

▸ **isString**(`val`): val is string

校验是否是字符串

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `unknown` |

#### Returns

val is string

#### Defined in

[isString.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isString.ts#L4)

___

### isType

▸ **isType**<`T`\>(`val`, `checker`): val is T

联合类型判断成其中某种类型

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | `any` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `unknown` |
| `checker` | (`v`: `any`) => `boolean` |

#### Returns

val is T

#### Defined in

[isType.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isType.ts#L4)

___

### isUndefined

▸ **isUndefined**(`val`): val is undefined

校验是否是 undefined

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `unknown` |

#### Returns

val is undefined

#### Defined in

[isUndefined.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isUndefined.ts#L4)

___

### isUrl

▸ **isUrl**(`val`): `boolean`

判断是否是链接

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `string` |

#### Returns

`boolean`

#### Defined in

isUrl.ts:4

___

### isValidDate

▸ **isValidDate**(`v`): `boolean`

验证是否有效日期

#### Parameters

| Name | Type |
| :------ | :------ |
| `v` | `string` \| `number` \| `Date` |

#### Returns

`boolean`

#### Defined in

[isValidDate.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/isValidDate.ts#L6)

___

### isWeChat

▸ **isWeChat**(): `boolean`

判断是否是微信浏览器

#### Returns

`boolean`

#### Defined in

[isWeChat.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/isWeChat.ts#L4)

___

### isWeChatMiniProgram

▸ **isWeChatMiniProgram**(): `boolean`

判断是否是微信小程序web-view环境
https://developers.weixin.qq.com/miniprogram/dev/component/web-view.html

#### Returns

`boolean`

#### Defined in

[isWeChatMiniProgram.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/isWeChatMiniProgram.ts#L5)

___

### isWeixin

▸ **isWeixin**(): `boolean`

判断是否是微信浏览器

**`Deprecated`**

请使用

**`See`**

[isWeChat](modules.md#iswechat).

#### Returns

`boolean`

#### Defined in

[isWeChat.ts:12](https://github.com/daysnap/utils/blob/9ced15e/src/isWeChat.ts#L12)

___

### isWindow

▸ **isWindow**(`val`): val is Window

判断是否是 window 对象

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `val` | `unknown` | 需要判断的值 |

#### Returns

val is Window

#### Defined in

[isWindow.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/isWindow.ts#L5)

___

### kebabCase

▸ **kebabCase**(`key`): `string`

说明
kebabCase('helloWorld') => hello-world

#### Parameters

| Name | Type |
| :------ | :------ |
| `key` | `string` |

#### Returns

`string`

#### Defined in

[kebabCase.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/kebabCase.ts#L5)

___

### lfToBr

▸ **lfToBr**(`v`): `string`

\n to <br/>

#### Parameters

| Name | Type |
| :------ | :------ |
| `v` | `string` |

#### Returns

`string`

#### Defined in

[lfToBr.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/lfToBr.ts#L4)

___

### listGenerator

▸ **listGenerator**(`length`): `number`[]

list 生成器，快速生成数据

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `length` | `number` | 个数 |

#### Returns

`number`[]

#### Defined in

[listGenerator.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/listGenerator.ts#L5)

▸ **listGenerator**<`T`\>(`length`, `fn`): `T`[]

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | `any` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `length` | `number` |
| `fn` | (`index`: `number`) => `T` |

#### Returns

`T`[]

#### Defined in

[listGenerator.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/listGenerator.ts#L6)

___

### makePhoneCall

▸ **makePhoneCall**(`phoneNumber`): `void`

#### Parameters

| Name | Type |
| :------ | :------ |
| `phoneNumber` | `string` \| `number` |

#### Returns

`void`

#### Defined in

[makePhoneCall.ts:1](https://github.com/daysnap/utils/blob/9ced15e/src/makePhoneCall.ts#L1)

___

### merge

▸ **merge**<`R`\>(`target`, `...sources`): `R`

深度合并对象，返回新对象

#### Type parameters

| Name | Type |
| :------ | :------ |
| `R` | extends `Record`<`string`, `any`\> = `any` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `target` | `Record`<`string`, `any`\> |
| `...sources` | `Record`<`string`, `any`\>[] |

#### Returns

`R`

#### Defined in

[merge.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/merge.ts#L6)

___

### mousewheel

▸ **mousewheel**(`scrolling`, `options?`): `Object`

#### Parameters

| Name | Type |
| :------ | :------ |
| `scrolling` | `MousewheelScrolling` |
| `options?` | `MousewheelOptions` |

#### Returns

`Object`

| Name | Type |
| :------ | :------ |
| `listener` | (`e`: `any`) => `undefined` \| ``false`` |

#### Defined in

[mousewheel.ts:22](https://github.com/daysnap/utils/blob/9ced15e/src/mousewheel.ts#L22)

___

### nf

▸ **nf**(): `void`

空函数

#### Returns

`void`

#### Defined in

[nf.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/nf.ts#L4)

___

### normalizeDate

▸ **normalizeDate**(`value`): `Date`

格式化日期
fix iOS 日期时间格式如果类似是 2020-12-12 12:12:12 就会报错的问题
2020/12/12 12:12:12 这种就是通用的

#### Parameters

| Name | Type |
| :------ | :------ |
| `value` | `string` \| `number` \| `Date` |

#### Returns

`Date`

#### Defined in

[normalizeDate.ts:8](https://github.com/daysnap/utils/blob/9ced15e/src/normalizeDate.ts#L8)

___

### normalizePath

▸ **normalizePath**(`path`): `string`

格式化处理路径 平台兼容

#### Parameters

| Name | Type |
| :------ | :------ |
| `path` | `string` |

#### Returns

`string`

#### Defined in

[normalizePath.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/normalizePath.ts#L4)

___

### numberToLetter

▸ **numberToLetter**(`index`): `string`

说明 0 => A

#### Parameters

| Name | Type |
| :------ | :------ |
| `index` | `number` |

#### Returns

`string`

#### Defined in

[numberToLetter.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/numberToLetter.ts#L4)

___

### omit

▸ **omit**<`T`, `K`\>(`obj`, `fields?`): `Omit`<`T`, `K`\>

排除对象里的某些属性，返回剩下的对象，浅拷贝

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends `object` |
| `K` | extends `string` \| `number` \| `symbol` |

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `obj` | `T` | `undefined` |
| `fields` | `K`[] | `[]` |

#### Returns

`Omit`<`T`, `K`\>

#### Defined in

[omit.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/omit.ts#L4)

___

### omitBy

▸ **omitBy**<`T`\>(`object`, `predicate`): `Partial`<`T`\>

const object = { 'a': 1, 'b': '2', 'c': 3 };
omitBy(object, isNumber);
=> { 'b': '2' }

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends `Record`<`string`, `any`\> |

#### Parameters

| Name | Type |
| :------ | :------ |
| `object` | `T` |
| `predicate` | (`value`: `T`[keyof `T`], `key`: keyof `T`) => `boolean` |

#### Returns

`Partial`<`T`\>

#### Defined in

[omitBy.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/omitBy.ts#L6)

___

### padding

▸ **padding**(`message`, `before?`, `after?`): `string`

增添空格

#### Parameters

| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `message` | `string` | `undefined` | 文字信息 |
| `before` | `number` | `1` | 前空格个数 |
| `after` | `number` | `1` | 后空格个数 |

#### Returns

`string`

#### Defined in

[padding.ts:7](https://github.com/daysnap/utils/blob/9ced15e/src/padding.ts#L7)

___

### parseDate

▸ **parseDate**(`v`): `Date`

解析成Date

**`Deprecated`**

请使用 normalizeDate() 方法

#### Parameters

| Name | Type |
| :------ | :------ |
| `v` | `string` \| `number` \| `Date` |

#### Returns

`Date`

#### Defined in

[parseDate.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/parseDate.ts#L5)

___

### parseDecimalString

▸ **parseDecimalString**(`val`, `options?`): `string`

解析小数数字
主要用户处理用户输入，只让输入数字的情况

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `string` |
| `options` | `Object` |
| `options.allowNegativeNumber?` | `boolean` |
| `options.precision?` | `number` |

#### Returns

`string`

#### Defined in

[parseDecimalString.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/parseDecimalString.ts#L5)

___

### parseError

▸ **parseError**(`val`, `keys?`): `string`

解析格式化 error 获取对应的 message

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `any` |
| `keys` | `string`[] |

#### Returns

`string`

#### Defined in

[parseError.ts:8](https://github.com/daysnap/utils/blob/9ced15e/src/parseError.ts#L8)

___

### parseNumberString

▸ **parseNumberString**(`val`): `string`

解析数字
主要用户处理用户输入，只让输入数字的情况
0123xxxx => 0123
x0123 => ''

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `string` |

#### Returns

`string`

#### Defined in

[parseNumberString.ts:7](https://github.com/daysnap/utils/blob/9ced15e/src/parseNumberString.ts#L7)

___

### parseObject

▸ **parseObject**<`T`\>(`path`, `value`): `T`

返回对象
parseObject('a.b.c', 1) => { a: { b: { c: 1 } } }

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | `Record`<`string`, `any`\> |

#### Parameters

| Name | Type |
| :------ | :------ |
| `path` | `string` |
| `value` | `any` |

#### Returns

`T`

#### Defined in

[parseObject.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/parseObject.ts#L5)

___

### parsePath

▸ **parsePath**<`T`\>(`obj`, `path`): `T`

根据路径解析值

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | `any` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `obj` | `Record`<`string`, `any`\> |
| `path` | `string` |

#### Returns

`T`

#### Defined in

[parsePath.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/parsePath.ts#L6)

___

### parseQuery

▸ **parseQuery**(`v?`, `k?`): `any`

解析url参数

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `v?` | `string` | URl |
| `k?` | `string` | 键名 |

#### Returns

`any`

#### Defined in

[parseQuery.ts:8](https://github.com/daysnap/utils/blob/9ced15e/src/parseQuery.ts#L8)

___

### parseQueryString

▸ **parseQueryString**<`T`\>(`value`): `T`

解析 url 参数

在不支持 URLSearchParams 的环境下使用该方法

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends `Record`<`string`, `any`\> |

#### Parameters

| Name | Type |
| :------ | :------ |
| `value` | `string` |

#### Returns

`T`

#### Defined in

[parseQueryString.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/parseQueryString.ts#L6)

___

### pascalCase

▸ **pascalCase**(`str`): `string`

首字母大写的驼峰
pascalCase('hello-world') => HelloWorld

#### Parameters

| Name | Type |
| :------ | :------ |
| `str` | `string` |

#### Returns

`string`

#### Defined in

[pascalCase.ts:8](https://github.com/daysnap/utils/blob/9ced15e/src/pascalCase.ts#L8)

___

### pick

▸ **pick**<`T`, `K`\>(`obj`, `fields?`): `Pick`<`T`, `K`\>

挑选对象里的某些属性，新对象返回

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends `object` |
| `K` | extends `string` \| `number` \| `symbol` |

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `obj` | `T` | `undefined` |
| `fields` | `K`[] | `[]` |

#### Returns

`Pick`<`T`, `K`\>

#### Defined in

[pick.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/pick.ts#L4)

___

### pickBy

▸ **pickBy**<`T`\>(`object`, `predicate`): `Partial`<`T`\>

const object = { 'a': 1, 'b': '2', 'c': 3 };
pickBy(object, isNumber);
=> { 'a': 1, 'c': 3 }

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends `Record`<`string`, `any`\> |

#### Parameters

| Name | Type |
| :------ | :------ |
| `object` | `T` |
| `predicate` | (`value`: `T`[keyof `T`], `key`: keyof `T`) => `boolean` |

#### Returns

`Partial`<`T`\>

#### Defined in

[pickBy.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/pickBy.ts#L6)

___

### replaceCrlf

▸ **replaceCrlf**(`val`, `replaceVal`): `string`

替换字符串里面的回车换行

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `string` |
| `replaceVal` | `string` |

#### Returns

`string`

#### Defined in

[replaceCrlf.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/replaceCrlf.ts#L4)

___

### requestFullScreen

▸ **requestFullScreen**(`ele?`): `Promise`<`any`\>

开启全屏
成功则 resolve , 如果不支持全屏或开启失败则 rejected
[MDN Reference] https://developer.mozilla.org/zh-CN/docs/Web/API/Element/requestFullscreen

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `ele` | `HTMLElement` | `window.document.documentElement` |

#### Returns

`Promise`<`any`\>

#### Defined in

[requestFullScreen.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/requestFullScreen.ts#L6)

___

### reserve

▸ **reserve**(`val`, `defaultVal?`): `any`

值为 ''、undefined、null 则取默认值
解决：
0 || '--' => '--'
reserve(0, '--') => 0

#### Parameters

| Name | Type |
| :------ | :------ |
| `val` | `any` |
| `defaultVal?` | `any` |

#### Returns

`any`

#### Defined in

[reserve.ts:8](https://github.com/daysnap/utils/blob/9ced15e/src/reserve.ts#L8)

___

### rgbToHex

▸ **rgbToHex**(`r`, `g`, `b`): `string`

说明 rgb 转 十六进制值

#### Parameters

| Name | Type |
| :------ | :------ |
| `r` | `string` \| `number` |
| `g` | `string` \| `number` |
| `b` | `string` \| `number` |

#### Returns

`string`

#### Defined in

[rgbToHex.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/rgbToHex.ts#L4)

___

### round

▸ **round**(`val`, `fractionDigits`): `string`

四舍五入

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `val` | `number` | 需要四舍五入的值 |
| `fractionDigits` | `number` | 需要保留的小数点位数 |

#### Returns

`string`

#### Defined in

[round.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/round.ts#L6)

___

### roundUpToNearestInteger

▸ **roundUpToNearestInteger**(`num`): `number`

向上圆整最接近的整数
0 => 1
123 => 200
-123 => -200

#### Parameters

| Name | Type |
| :------ | :------ |
| `num` | `number` |

#### Returns

`number`

#### Defined in

[roundUpToNearestInteger.ts:7](https://github.com/daysnap/utils/blob/9ced15e/src/roundUpToNearestInteger.ts#L7)

___

### scrollToTop

▸ **scrollToTop**(): `void`

滚动到页面顶部

#### Returns

`void`

#### Defined in

[scrollToTop.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/scrollToTop.ts#L4)

___

### setScrollTop

▸ **setScrollTop**(`scrollTop?`): `void`

设置 scrollTop

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `scrollTop` | `number` | `0` |

#### Returns

`void`

#### Defined in

[setScrollTop.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/setScrollTop.ts#L4)

___

### sleep

▸ **sleep**(`ms`, `isSuccess?`, `res?`): `Promise`<`void`\>

休眠方法

#### Parameters

| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `ms` | `number` | `undefined` | 休眠时长 毫秒 |
| `isSuccess` | `boolean` | `true` | 默认执行成功 |
| `res?` | `any` | `undefined` | 数据 |

#### Returns

`Promise`<`void`\>

#### Defined in

[sleep.ts:7](https://github.com/daysnap/utils/blob/9ced15e/src/sleep.ts#L7)

___

### splitArray

▸ **splitArray**<`T`\>(`source`, `size`): `T`[][]

分割数组

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | `any` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `source` | `T`[] |
| `size` | `number` |

#### Returns

`T`[][]

#### Defined in

[splitArray.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/splitArray.ts#L4)

___

### stringTrim

▸ **stringTrim**(`str`, `type?`): `string`

去除字符串空格

#### Parameters

| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `str` | `string` | `undefined` | 字符串值 |
| `type` | ``1`` \| ``2`` \| ``3`` \| ``4`` | `1` | 方式 1-所有空格，2-前后空格，3-前空格，4-后空格 |

#### Returns

`string`

#### Defined in

[stringTrim.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/stringTrim.ts#L6)

___

### stringifyQuery

▸ **stringifyQuery**(`v`): `string`

对象转 URLSearchParams

#### Parameters

| Name | Type |
| :------ | :------ |
| `v` | `Record`<`string`, `any`\> |

#### Returns

`string`

#### Defined in

[stringifyQuery.ts:7](https://github.com/daysnap/utils/blob/9ced15e/src/stringifyQuery.ts#L7)

___

### stringifyQueryString

▸ **stringifyQueryString**(`value`): `string`

将对象转换为查询字符串

在不支持 URLSearchParams 的环境下使用该方法

#### Parameters

| Name | Type |
| :------ | :------ |
| `value` | `Record`<`string`, `any`\> |

#### Returns

`string`

#### Defined in

[stringifyQueryString.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/stringifyQueryString.ts#L6)

___

### throttle

▸ **throttle**<`T`\>(`fn`, `ms`, `mode?`): (`this`: `unknown`, ...`args`: `Parameters`<`T`\>) => `void`

节流函数
减少事件执行次数，有规律的执行

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends (...`args`: `any`[]) => `any` |

#### Parameters

| Name | Type | Default value |
| :------ | :------ | :------ |
| `fn` | `T` | `undefined` |
| `ms` | `number` | `undefined` |
| `mode` | ``"leading"`` \| ``"trailing"`` | `'trailing'` |

#### Returns

`fn`

▸ (`this`, `...args`): `void`

##### Parameters

| Name | Type |
| :------ | :------ |
| `this` | `unknown` |
| `...args` | `Parameters`<`T`\> |

##### Returns

`void`

#### Defined in

[throttle.ts:48](https://github.com/daysnap/utils/blob/9ced15e/src/throttle.ts#L48)

___

### throttleLeading

▸ **throttleLeading**<`T`\>(`fn`, `ms`): (`this`: `unknown`, ...`args`: `Parameters`<`T`\>) => `void`

节流函数，时间戳模式
减少事件执行次数，有规律的执行，事件触发后立即执行

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends (...`args`: `any`[]) => `any` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `fn` | `T` |
| `ms` | `number` |

#### Returns

`fn`

▸ (`this`, `...args`): `void`

##### Parameters

| Name | Type |
| :------ | :------ |
| `this` | `unknown` |
| `...args` | `Parameters`<`T`\> |

##### Returns

`void`

#### Defined in

[throttle.ts:5](https://github.com/daysnap/utils/blob/9ced15e/src/throttle.ts#L5)

___

### throttleTrailing

▸ **throttleTrailing**<`T`\>(`fn`, `ms`): (`this`: `unknown`, ...`args`: `Parameters`<`T`\>) => `void`

节流函数，定时器模式
减少事件执行次数，有规律的执行，事件触发后延迟执行

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends (...`args`: `any`[]) => `any` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `fn` | `T` |
| `ms` | `number` |

#### Returns

`fn`

▸ (`this`, `...args`): `void`

##### Parameters

| Name | Type |
| :------ | :------ |
| `this` | `unknown` |
| `...args` | `Parameters`<`T`\> |

##### Returns

`void`

#### Defined in

[throttle.ts:25](https://github.com/daysnap/utils/blob/9ced15e/src/throttle.ts#L25)

___

### toCDB

▸ **toCDB**(`str`): `string`

全角转换为半角

#### Parameters

| Name | Type |
| :------ | :------ |
| `str` | `string` |

#### Returns

`string`

#### Defined in

[toCDB.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/toCDB.ts#L4)

___

### toDBC

▸ **toDBC**(`str`): `string`

半角转换为全角

#### Parameters

| Name | Type |
| :------ | :------ |
| `str` | `string` |

#### Returns

`string`

#### Defined in

[toDBC.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/toDBC.ts#L4)

___

### toFormData

▸ **toFormData**(`data`): `FormData`

对象转 formdata 不考虑深层对象

#### Parameters

| Name | Type |
| :------ | :------ |
| `data` | `Record`<`string`, `any`\> |

#### Returns

`FormData`

#### Defined in

[toFormData.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/toFormData.ts#L4)

___

### toPosix

▸ **toPosix**(`value`): `string`

转换到 Posix 标准

#### Parameters

| Name | Type |
| :------ | :------ |
| `value` | `string` |

#### Returns

`string`

#### Defined in

[toPosix.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/toPosix.ts#L4)

___

### typeOf

▸ **typeOf**(`val`): `string`

判断类型

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `val` | `unknown` | 待判断数据 |

#### Returns

`string`

'undefined'|'null'|'boolean'|'string'|'number'|'object'|'array'|'function'|'symbol'|'map'|'weakmap'|'bigint'|'regexp'|'date'

#### Defined in

[typeOf.ts:6](https://github.com/daysnap/utils/blob/9ced15e/src/typeOf.ts#L6)

___

### typedKeys

▸ **typedKeys**<`T`\>(`data`): keyof `T`[]

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends `Record`<`string`, `any`\> |

#### Parameters

| Name | Type |
| :------ | :------ |
| `data` | `T` |

#### Returns

keyof `T`[]

#### Defined in

[typedKeys.ts:1](https://github.com/daysnap/utils/blob/9ced15e/src/typedKeys.ts#L1)

___

### withCache

▸ **withCache**<`T`\>(`fn`): `T`

缓存函数

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends (...`args`: `any`[]) => `any` |

#### Parameters

| Name | Type |
| :------ | :------ |
| `fn` | `T` |

#### Returns

`T`

#### Defined in

[withCache.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/withCache.ts#L4)

___

### withPreventConsecutiveClicks

▸ **withPreventConsecutiveClicks**<`T`\>(`fn`, `ms?`): `T`

防止连续点击

#### Type parameters

| Name | Type |
| :------ | :------ |
| `T` | extends (...`args`: `any`[]) => `Promise`<`any`\> |

#### Parameters

| Name | Type |
| :------ | :------ |
| `fn` | `T` |
| `ms?` | `number` |

#### Returns

`T`

#### Defined in

[withPreventConsecutiveClicks.ts:4](https://github.com/daysnap/utils/blob/9ced15e/src/withPreventConsecutiveClicks.ts#L4)
