{"id":26197728,"url":"https://github.com/wxingheng/jcommon","last_synced_at":"2025-04-15T04:26:11.783Z","repository":{"id":42204955,"uuid":"259789705","full_name":"wxingheng/jcommon","owner":"wxingheng","description":"JavaScript 常用纯函数工具库","archived":false,"fork":false,"pushed_at":"2023-03-07T07:33:56.000Z","size":1143,"stargazers_count":15,"open_issues_count":11,"forks_count":2,"subscribers_count":3,"default_branch":"dev","last_synced_at":"2024-04-24T08:07:41.716Z","etag":null,"topics":["commonjs","javascript","tools","util","utility-scripts","utils"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wxingheng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-29T01:03:58.000Z","updated_at":"2024-06-20T00:06:46.247Z","dependencies_parsed_at":"2024-06-20T00:06:31.433Z","dependency_job_id":"2be91218-172c-4d32-9028-be3be8f3d9d5","html_url":"https://github.com/wxingheng/jcommon","commit_stats":{"total_commits":33,"total_committers":3,"mean_commits":11.0,"dds":"0.33333333333333337","last_synced_commit":"d07418a0cfeed7df18d301286c9882720166c16c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wxingheng%2Fjcommon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wxingheng%2Fjcommon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wxingheng%2Fjcommon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wxingheng%2Fjcommon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wxingheng","download_url":"https://codeload.github.com/wxingheng/jcommon/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249005397,"owners_count":21197053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["commonjs","javascript","tools","util","utility-scripts","utils"],"created_at":"2025-03-12T02:48:32.402Z","updated_at":"2025-04-15T04:26:11.765Z","avatar_url":"https://github.com/wxingheng.png","language":"TypeScript","readme":"jcommon文档库 / [Exports](modules.md)\n\n\u003c!--\n * @Author: wuxh\n * @Date: 2020-05-07 10:09:44\n * @LastEditTime: 2023-05-19 22:30:58\n * @LastEditors: wxingheng\n * @Description:\n * @FilePath: /jcommon/pack/base.md\n --\u003e\n\n# jcommon\n\nJavaScript 常用纯函数工具库 （当前版本已在项目中使用，后续更新会向前兼容） 持续丰富中...\n\n## 简介\n\n**在日常工作中，会经常用到一些`日期格式化`，`url相关操作`，`浏览器类型判断`，`常用验证格式`等等函数，虽然大部分只需谷歌/百度一下就能找到，但是大多数都存在着一些问题，于是整理了网上和自己平常用到的工具类，方便大家以后的使用，提升开发效率。**\n\n## 安装\n\n### 使用\n\n```bash\n# 安装\n$ npm install jcommon\n```\n\n```bash\n# 引入\n\nimport { isObject, isArray } from 'jcommon'\n\nor\n\nconst { isObject, isArray } = require('jcommon')\n\nor\n\n\u003cscript type=\"text/javascript\" src=\"./dist/jcommon.js\"\u003e\u003c/script\u003e\n\n\u003cscript\u003e\n    jcommon.isObject({})\n\u003c/script\u003e\n\n```\n\n## 项目特点\n\n- [x] 完全的按需引用，我们只导出纯函数\n- [x] 不同于传统 js 工具库导出一整个大模块（moment, utils, ...）\n- [x] 支持 npm 安装方式\n- [x] 支持 script 标签直接引入（考虑通过全局一个模块的方式，jcommon，避免全局命名空间污染）\n- [x] TypeScript支持\n- [x] dom\n- [x] 增加单元测试\n- [x] 根据 .d.ts 文件自动生成文档\n- [ ] lint\n- [x] typedoc\n- [ ] 文档自动部署，Github page\n\n## 建议，交流，推荐，反馈\n\n联系我 wxingheng@outlook.com\n\n\n\n\n[jcommon文档库 - v1.9.36](README.md) / Exports\n\n# jcommon文档库 - v1.9.36\n\n## Table of contents\n\n### Classes\n\n- [EventBus](classes/EventBus.md)\n- [Queue](classes/Queue.md)\n- [Typewriter](classes/Typewriter.md)\n\n### Array Type Aliases\n\n- [DoubleRankingOption](modules.md#doublerankingoption)\n\n### Other Type Aliases\n\n- [getBrowserInfoResult](modules.md#getbrowserinforesult)\n- [osInfoResult](modules.md#osinforesult)\n\n### Variables\n\n- [globalCache](modules.md#globalcache)\n\n### Array\n@description:\n@author: wxingheng\n@Date: 2022-09-30 11:45:04 Functions\n\n- [sortCallBackTime](modules.md#sortcallbacktime)\n\n### Array\n@description:  reduce方法，用于数组对象的求和\n@author: wxingheng\n@Date: 2022-09-30 11:51:39 Functions\n\n- [reduceCallBackNumber](modules.md#reducecallbacknumber)\n\n### Array\n@description:  数组排序的回调函数，用于sort方法，按照对象的某个属性进行中文排序\n@author: wxingheng\n@Date: 2022-09-30 11:43:11 Functions\n\n- [sortCallBackChinese](modules.md#sortcallbackchinese)\n\n### Array\n@description: 处理复杂数组的两级排序（一级按照自定义顺序，二级可正序倒序）\n@author: wuxh\n@Date: 2020-05-06 11:37:17 Functions\n\n- [doubleRanking](modules.md#doubleranking)\n\n### Array\n@description: 数值转对象 （常用于处理后台返回的枚举转换，工作中很常用）\n@author: wuxh\n@Date: 2020-05-06 11:51:49 Functions\n\n- [arrByObj](modules.md#arrbyobj)\n\n### Array\n@description: 数组交集\n@author: wxingheng\n@Date: 2022-05-18 10:56:47 Functions\n\n- [difference](modules.md#difference)\n\n### Array\n@description: 数组元素是否相同\n@author: wxingheng\n@Date: 2022-05-18 10:56:04 Functions\n\n- [arrayCompare](modules.md#arraycompare)\n\n### Array\n@description: 简单数组去重，Set 处理\n@author: wxingheng\n@Date: 2022-10-12 11:16:32 Functions\n\n- [uniqueArray](modules.md#uniquearray)\n\n### Array \n@description: 产生随机数据\n@author: wxingheng\n@Date: 2022-10-12 11:08:50 Functions\n\n- [randomData](modules.md#randomdata)\n\n### Other Functions\n\n- [addZero](modules.md#addzero)\n- [cleanObject](modules.md#cleanobject)\n- [cloneJson](modules.md#clonejson)\n- [cloneObj](modules.md#cloneobj)\n- [convertDataToTree](modules.md#convertdatatotree)\n- [convertDateToStandard](modules.md#convertdatetostandard)\n- [convertDateToStandardDay](modules.md#convertdatetostandardday)\n- [convertDateToStandardHours](modules.md#convertdatetostandardhours)\n- [convertDateToView](modules.md#convertdatetoview)\n- [convertTreeToList](modules.md#converttreetolist)\n- [copyToBoar](modules.md#copytoboar)\n- [cutNumber](modules.md#cutnumber)\n- [dateFormat](modules.md#dateformat)\n- [dateInterval](modules.md#dateinterval)\n- [dateMonthDays](modules.md#datemonthdays)\n- [debounce](modules.md#debounce)\n- [deepClone](modules.md#deepclone)\n- [download](modules.md#download)\n- [downloadFile](modules.md#downloadfile)\n- [dragScroll](modules.md#dragscroll)\n- [endWith](modules.md#endwith)\n- [everyTrim](modules.md#everytrim)\n- [exportJson](modules.md#exportjson)\n- [fetchToSlow](modules.md#fetchtoslow)\n- [formatQueryParam](modules.md#formatqueryparam)\n- [formatRhBloodGroup](modules.md#formatrhbloodgroup)\n- [getBase64](modules.md#getbase64)\n- [getBirthdatByIdNo](modules.md#getbirthdatbyidno)\n- [getBrowserInfo](modules.md#getbrowserinfo)\n- [getCookie](modules.md#getcookie)\n- [getCountDays](modules.md#getcountdays)\n- [getExt](modules.md#getext)\n- [getFormData](modules.md#getformdata)\n- [getSexByIdNO](modules.md#getsexbyidno)\n- [getStorage](modules.md#getstorage)\n- [getStringLen](modules.md#getstringlen)\n- [getUrlQuery](modules.md#geturlquery)\n- [getV](modules.md#getv)\n- [groupBy](modules.md#groupby)\n- [hideIdNum](modules.md#hideidnum)\n- [importJson](modules.md#importjson)\n- [isAndroidMobileDevice](modules.md#isandroidmobiledevice)\n- [isAppleMobileDevice](modules.md#isapplemobiledevice)\n- [isArray](modules.md#isarray)\n- [isBoolean](modules.md#isboolean)\n- [isDate](modules.md#isdate)\n- [isEmail](modules.md#isemail)\n- [isEmptyObject](modules.md#isemptyobject)\n- [isEqual](modules.md#isequal)\n- [isError](modules.md#iserror)\n- [isFalsy](modules.md#isfalsy)\n- [isFunc](modules.md#isfunc)\n- [isNull](modules.md#isnull)\n- [isNumber](modules.md#isnumber)\n- [isObject](modules.md#isobject)\n- [isPhone](modules.md#isphone)\n- [isQQ](modules.md#isqq)\n- [isReg](modules.md#isreg)\n- [isRhNegative](modules.md#isrhnegative)\n- [isRhPositive](modules.md#isrhpositive)\n- [isString](modules.md#isstring)\n- [isSupportStorage](modules.md#issupportstorage)\n- [isType](modules.md#istype)\n- [isUndefined](modules.md#isundefined)\n- [isUserId](modules.md#isuserid)\n- [isVoid](modules.md#isvoid)\n- [isWX](modules.md#iswx)\n- [mergeObj](modules.md#mergeobj)\n- [moreClick](modules.md#moreclick)\n- [oneClickToMoreClick](modules.md#oneclicktomoreclick)\n- [operattelecom](modules.md#operattelecom)\n- [osInfo](modules.md#osinfo)\n- [processStreamResponse](modules.md#processstreamresponse)\n- [randomColor](modules.md#randomcolor)\n- [removeStorage](modules.md#removestorage)\n- [saveStorage](modules.md#savestorage)\n- [scaleLinear](modules.md#scalelinear)\n- [scopeRandom](modules.md#scoperandom)\n- [similar](modules.md#similar)\n- [sleep](modules.md#sleep)\n- [sorterCallBack](modules.md#sortercallback)\n- [throttle](modules.md#throttle)\n- [timeFormat](modules.md#timeformat)\n- [trim](modules.md#trim)\n- [uniqueId](modules.md#uniqueid)\n- [urlByObj](modules.md#urlbyobj)\n- [uuid](modules.md#uuid)\n- [versionCount](modules.md#versioncount)\n\n## Array Type Aliases\n\n### DoubleRankingOption\n\nƬ **DoubleRankingOption**: `Object`\n\n#### Type declaration\n\n| Name | Type | Description |\n| :------ | :------ | :------ |\n| `filterRuleKey?` | `string` | 一级过滤和排序的key |\n| `rule?` | `string`[] | 一级排序规则 |\n| `sortKey?` | `string` | 二级正常排序的key |\n| `sortOrder?` | `number` | - |\n\n___\n\n## Other Type Aliases\n\n### getBrowserInfoResult\n\nƬ **getBrowserInfoResult**: `Object`\n\n#### Type declaration\n\n| Name | Type |\n| :------ | :------ |\n| `name` | `string` \\| `RegExp` |\n| `version` | `string` |\n\n___\n\n### osInfoResult\n\nƬ **osInfoResult**: `Object`\n\n@description: 获取用户系统平台信息\n@author: wuxh\n@Date: 2020-05-06 12:07:03\n\n**`Param`**\n\n{os: \"mac\", version: \"10.15.3\"}\n@example: \n```\n osInfo()\n =\u003e {os: \"mac\", version: \"10.15.3\"}\n```\n\n#### Type declaration\n\n| Name | Type |\n| :------ | :------ |\n| `os` | `string` \\| `RegExp` |\n| `version` | `string` |\n\n## Variables\n\n### globalCache\n\n• `Const` **globalCache**: `GlobalCache`\n\n## Array\n@description:\n@author: wxingheng\n@Date: 2022-09-30 11:45:04 Functions\n\n### sortCallBackTime\n\n▸ **sortCallBackTime**(`key`, `desc?`): (`a`: `any`, `b`: `any`) =\u003e `void`\n\n#### Parameters\n\n| Name | Type | Default value | Description |\n| :------ | :------ | :------ | :------ |\n| `key` | `string` | `undefined` | 对象的key |\n| `desc` | `boolean` | `false` | 是否倒序, 默认是正序 |\n\n#### Returns\n\n`fn`\n\n```\narr.sort(sortCallBackNumber('age')) =\u003e [{age: 18}, {age: 20}]\narr.sort(sortCallBackNumber('age', true)) =\u003e [{age: 20}, {age: 18}]\n```\n\n▸ (`a`, `b`): `void`\n\n##### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `a` | `any` |\n| `b` | `any` |\n\n##### Returns\n\n`void`\n\n___\n\n## Array\n@description:  reduce方法，用于数组对象的求和\n@author: wxingheng\n@Date: 2022-09-30 11:51:39 Functions\n\n### reduceCallBackNumber\n\n▸ **reduceCallBackNumber**(`key`): (`acc`: `any`, `cur`: `any`) =\u003e `void`\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `key` | `string` |\n\n#### Returns\n\n`fn`\n\n```\narr.reduce(reduceSum('num'), 0) =\u003e 10\n```\n\n▸ (`acc`, `cur`): `void`\n\n##### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `acc` | `any` |\n| `cur` | `any` |\n\n##### Returns\n\n`void`\n\n___\n\n## Array\n@description:  数组排序的回调函数，用于sort方法，按照对象的某个属性进行中文排序\n@author: wxingheng\n@Date: 2022-09-30 11:43:11 Functions\n\n### sortCallBackChinese\n\n▸ **sortCallBackChinese**(`key`): (`a`: `any`, `b`: `any`) =\u003e `void`\n\n#### Parameters\n\n| Name | Type | Description |\n| :------ | :------ | :------ |\n| `key` | `string` | 排序的属性 |\n\n#### Returns\n\n`fn`\n\n```\n arr.sort(sortCallBackChinese('name')) =\u003e [{name: '张三'}, {name: '李四'}]\n```\n\n▸ (`a`, `b`): `void`\n\n##### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `a` | `any` |\n| `b` | `any` |\n\n##### Returns\n\n`void`\n\n___\n\n## Array\n@description: 处理复杂数组的两级排序（一级按照自定义顺序，二级可正序倒序）\n@author: wuxh\n@Date: 2020-05-06 11:37:17 Functions\n\n### doubleRanking\n\n▸ **doubleRanking**(`arr`, `options`): `any`[]\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `arr` | \\{ `[key: string]`: `any`;  }[] |\n| `options` | [`DoubleRankingOption`](modules.md#doublerankingoption) |\n\n#### Returns\n\n`any`[]\n\n___\n\n## Array\n@description: 数值转对象 （常用于处理后台返回的枚举转换，工作中很常用）\n@author: wuxh\n@Date: 2020-05-06 11:51:49 Functions\n\n### arrByObj\n\n▸ **arrByObj**(`arr`, `key`, `v?`): `Object`\n\n#### Parameters\n\n| Name | Type | Default value | Description |\n| :------ | :------ | :------ | :------ |\n| `arr` | \\{ `[key: string]`: `any`;  }[] | `undefined` | 需要作为转换后对象的key需要转换的数组 |\n| `key` | `string` | `undefined` | 需要作为转换后对象的key |\n| `v` | `string` | `''` | 对象的value取值，默认是数组的每一个元素作为值 @return: Object ``` const arr = arr = [{name: 111, value: 222},{name: 333, value:444}] arrByObj(arr, 'name') =\u003e {\"111\":{\"name\":111,\"value\":222},\"333\":{\"name\":333,\"value\":444}} arrByObj(arr, 'name', value) =\u003e {\"111\":222,\"333\":444} ``` |\n\n#### Returns\n\n`Object`\n\n___\n\n## Array\n@description: 数组交集\n@author: wxingheng\n@Date: 2022-05-18 10:56:47 Functions\n\n### difference\n\n▸ **difference**(`a`, `b`): `any`[]\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `a` | `undefined` \\| ``null`` \\| `Iterable`\\\u003c`unknown`\\\u003e |\n| `b` | `undefined` \\| ``null`` \\| `Iterable`\\\u003c`unknown`\\\u003e |\n\n#### Returns\n\n`any`[]\n\nArray\n```\ndifference([2,3,4,5], [1,2,3,4]) =\u003e [5, 1] ;\ndifference([1,2,3,4], [2,3,4,5]) =\u003e [1, 5];\ndifference([1,2,3,4], [1,2,3,4]) =\u003e [];\ndifference([1,2,3,4], []) =\u003e [1, 2, 3, 4]\n```\n\n___\n\n## Array\n@description: 数组元素是否相同\n@author: wxingheng\n@Date: 2022-05-18 10:56:04 Functions\n\n### arrayCompare\n\n▸ **arrayCompare**(`arr1`, `arr2`): `boolean`\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `arr1` | `any`[] |\n| `arr2` | `any`[] |\n\n#### Returns\n\n`boolean`\n\n```\narrayCompare([2,3,4,5], [5,4,3,2]) =\u003e true ; \narrayCompare([2,3,4,5], [5,4,3,2,1]) =\u003e false;\narrayCompare([2,3,4,5], []) =\u003e true;\narrayCompare([], [1,2,3,4]) =\u003e false;\narrayCompare([1,2,3,4], []) =\u003e true;\n```\n\n___\n\n## Array\n@description: 简单数组去重，Set 处理\n@author: wxingheng\n@Date: 2022-10-12 11:16:32 Functions\n\n### uniqueArray\n\n▸ **uniqueArray**(`arr`): `any`[]\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `arr` | `undefined` \\| ``null`` \\| `string` \\| `Iterable`\\\u003c`any`\\\u003e |\n\n#### Returns\n\n`any`[]\n\n```\n uniqueArray([1,1,1,1,1]) =\u003e [1]; uniqueArray([1,2,3,4,5]) =\u003e [1,2,3,4,5]; \n ```\n\n___\n\n## Array \n@description: 产生随机数据\n@author: wxingheng\n@Date: 2022-10-12 11:08:50 Functions\n\n### randomData\n\n▸ **randomData**(`num`, `arr`): `any`[]\n\n#### Parameters\n\n| Name | Type | Description |\n| :------ | :------ | :------ |\n| `num` | `number` | 数量 |\n| `arr` | `string`[] | 每个元素对象的keys |\n\n#### Returns\n\n`any`[]\n\n```\n randomData(2, ['name', 'value'])\n =\u003e [{\"name\":\"name323\",\"value\":\"value699\"},{\"name\":\"name573\",\"value\":\"value393\"}]\n ```\n\n___\n\n## Other Functions\n\n### addZero\n\n▸ **addZero**(`v`, `size`): `string`\n\n@description: 字符串补0，目前提供给dateFormat使用\n@author: wuxh\n@Date: 2020-05-11 14:01:20\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `v` | `string` \\| `number` |\n| `size` | `number` |\n\n#### Returns\n\n`string`\n\n___\n\n### cleanObject\n\n▸ **cleanObject**(`object`): `Object`\n\n@description: cleanObject 去除对象中value为空(null,undefined,'')的属性\n@author: wuxh\n@Date: 2021-09-02 22:07:34\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `object` | `Object` |\n\n#### Returns\n\n`Object`\n\n{ [k: string]: any }\n@example: \ncleanObject({\n name: '',\n pageSize: 10,\n page: 1\n}) =\u003e {\n pageSize: 10,\n page: 1\n}\n\n___\n\n### cloneJson\n\n▸ **cloneJson**(`obj`): `any`\n\n@description: 简单的深拷贝\n@author: wuxh\n@Date: 2021-09-02 22:33:47\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `obj` | `any` |\n\n#### Returns\n\n`any`\n\nobj\n@example: \nconst person={name:'xiaoming',child:{name:'Jack'}}\ncloneJson(person) =\u003e {name:'xiaoming',child:{name:'Jack'}}\n\n___\n\n### cloneObj\n\n▸ **cloneObj**(`obj`): `any`\n\n@description: 深拷贝，克隆（只包含可遍历属性\u003c常用\u003e）\n@author: wuxh\n@Date: 2020-05-06 12:14:45\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `obj` | `any` |\n\n#### Returns\n\n`any`\n\n___\n\n### convertDataToTree\n\n▸ **convertDataToTree**(`data`, `id?`, `pid?`, `children?`): `any`[]\n\n@description: 将list转换为树结构\n@author: wxingheng\n@Date: 2022-09-30 11:37:32\n\n#### Parameters\n\n| Name | Type | Default value |\n| :------ | :------ | :------ |\n| `data` | `any`[] | `undefined` |\n| `id` | `string` | `'id'` |\n| `pid` | `string` | `'pid'` |\n| `children` | `string` | `'children'` |\n\n#### Returns\n\n`any`[]\n\n@example: convertDataToTree(data) =\u003e treeData\n\n___\n\n### convertDateToStandard\n\n▸ **convertDateToStandard**(`date`): `string`\n\n@description:  时间的转换 \"YYYY-MM-DD HH:II:SS\"\n@author: wxingheng\n@Date: 2022-09-30 11:48:15\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `date` | `string` \\| `number` \\| `Date` |\n\n#### Returns\n\n`string`\n\n@example: convertDateToStandard(new Date()) =\u003e \"2021-09-30 11:48:15\"\n\n___\n\n### convertDateToStandardDay\n\n▸ **convertDateToStandardDay**(`date`): `string`\n\n@description:  时间的转换 \"YYYY-MM-DD\"\n@author: wxingheng\n@Date: 2022-09-30 11:49:14\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `date` | `string` \\| `number` \\| `Date` |\n\n#### Returns\n\n`string`\n\n@example: convertDateToStandardDay(new Date()) =\u003e \"2021-09-30\"\n\n___\n\n### convertDateToStandardHours\n\n▸ **convertDateToStandardHours**(`date`): `string`\n\n@description: 时间的转换 \"YYYY-MM-DD HH\"\n@author: wxingheng\n@Date: 2022-09-30 11:49:37\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `date` | `string` \\| `number` \\| `Date` |\n\n#### Returns\n\n`string`\n\n@example: convertDateToStandardHours(new Date()) =\u003e \"2021-09-30 11\"\n\n___\n\n### convertDateToView\n\n▸ **convertDateToView**(`date`, `template?`, `defaultResult?`): `string`\n\n@description:  时间的转换（目前支持 年，月，日，时，分，秒，星期）, 与dateFormat的区别是，这个方法可以传入时间戳\n@author: wxingheng\n@Date: 2022-09-30 11:46:22\n\n#### Parameters\n\n| Name | Type | Default value |\n| :------ | :------ | :------ |\n| `date` | `string` \\| `number` \\| `Date` | `undefined` |\n| `template` | `string` | `\"YYYY-MM-DD HH:II:SS\"` |\n| `defaultResult` | `string` | `\"\"` |\n\n#### Returns\n\n`string`\n\n@example:  convertDateToView(new Date(), '当前时间 YY-MM-DD HH:II:SS 星期W')\n\n___\n\n### convertTreeToList\n\n▸ **convertTreeToList**(`tree`, `children?`): `any`[]\n\n@description: 将树结构转换为list\n@author: wxingheng\n@Date: 2022-09-30 11:40:43\n\n#### Parameters\n\n| Name | Type | Default value | Description |\n| :------ | :------ | :------ | :------ |\n| `tree` | `any`[] | `undefined` | 树结构 |\n| `children` | `string` | `'children'` | 子节点字段 |\n\n#### Returns\n\n`any`[]\n\n@example: convertTreeToList (treeData) =\u003e listData\n\n___\n\n### copyToBoar\n\n▸ **copyToBoar**(`value`): `boolean`\n\n@description: 复制内容到剪贴板\n@author: wuxh\n@Date: 2021-09-02 22:22:03\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `value` | `string` |\n\n#### Returns\n\n`boolean`\n\nboolean\n@example: \ncopyToBoard('lalallala') =\u003e true // 如果复制成功返回true\n\n___\n\n### cutNumber\n\n▸ **cutNumber**(`number`, `no?`): `number`\n\n@description: 保留到小数点以后n位\n@author: wuxh\n@Date: 2021-09-02 22:54:36\n\n#### Parameters\n\n| Name | Type | Default value |\n| :------ | :------ | :------ |\n| `number` | `number` | `undefined` |\n| `no` | `number` | `2` |\n\n#### Returns\n\n`number`\n\nNumber\n@example: \ncutNumber('3123.22312') =\u003e 3123.22\n\n___\n\n### dateFormat\n\n▸ **dateFormat**(`date`, `formatStr`): `string`\n\n@description:  时间的转换（目前支持 年，月，日，时，分，秒，星期）\n@author: wuxh\n@Date: 2020-05-06 12:05:28\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `date` | `Date` |\n| `formatStr` | `string` |\n\n#### Returns\n\n`string`\n\n___\n\n### dateInterval\n\n▸ **dateInterval**(`st`, `et`): `string`\n\n@description: 获取两个时间的间隔\n@author: wuxh\n@Date: 2020-05-06 12:04:39\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `st` | `number` |\n| `et` | `number` |\n\n#### Returns\n\n`string`\n\n___\n\n### dateMonthDays\n\n▸ **dateMonthDays**(`str`): `number`\n\n@description: 获取当前月份的天数\n@author: wuxh\n@Date: 2020-05-06 12:06:24\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `str` | `string` |\n\n#### Returns\n\n`number`\n\n___\n\n### debounce\n\n▸ **debounce**(`func`, `wait?`, `immediate?`): (...`args`: `any`) =\u003e `void`\n\n@description: debounce 防抖, 固定时间内持续触发，只执行最后一次\n@author: wuxh\n@Date: 2021-09-02 21:30:44\n\n#### Parameters\n\n| Name | Type | Default value | Description |\n| :------ | :------ | :------ | :------ |\n| `func` | (...`rest`: `any`) =\u003e `void` | `undefined` | - |\n| `wait` | `number` | `500` | 等待时间,默认500ms |\n| `immediate` | `boolean` | `false` | 是否立即执行 |\n\n#### Returns\n\n`fn`\n\nFunction \n@example: \nfunction onInput() {\n               console.log('1111')\n           }\n           const debounceOnInput = debounce(onInput)\n           document\n               .getElementById('input')\n               .addEventListener('input', debounceOnInput)\n\n▸ (`...args`): `void`\n\n##### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `...args` | `any` |\n\n##### Returns\n\n`void`\n\n| Name | Type |\n| :------ | :------ |\n| `cancel` | () =\u003e `void` |\n\n___\n\n### deepClone\n\n▸ **deepClone**(`target`): `any`\n\n@description: 深克隆 deepClone\n@author: wxingheng\n@Date: 2022-04-10 22:19:43\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `target` | `any` |\n\n#### Returns\n\n`any`\n\n@example: deepClone(obj) =\u003e new obj\n\n___\n\n### download\n\n▸ **download**(`link`, `name`): `any`\n\n@description: 下载一个链接文档\n@author: wuxh\n@Date: 2021-09-01 23:27:00\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `link` | `string` |\n| `name` | `string` |\n\n#### Returns\n\n`any`\n\n@example:\ndownload('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fblog%2F202008%2F04%2F20200804215427_fc3ff.thumb.1000_0.jpeg\u0026refer=http%3A%2F%2Fc-ssl.duitang.com\u0026app=2002\u0026size=f9999,10000\u0026q=a80\u0026n=0\u0026g=0n\u0026fmt=jpeg?sec=1633102668\u0026t=5f2cf4e9273be91527efb91ecd5cb6dd')\n下载后端返回的流\n\n___\n\n### downloadFile\n\n▸ **downloadFile**(`name`, `content`): `any`\n\n@description: 在浏览器中自定义下载一些内容\n@author: wuxh\n@Date: 2021-09-01 23:32:30\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `name` | `string` |\n| `content` | `BlobPart` |\n\n#### Returns\n\n`any`\n\n@example: 场景：我想下载一些DOM内容，我想下载一个JSON文件\n\ndownloadFile('1.txt','lalalallalalla')\n  downloadFile('1.json',JSON.stringify({name:'hahahha'}))\n\n___\n\n### dragScroll\n\n▸ **dragScroll**(`scrollDom`): `object`\n\n@description: 拖拽滚动\n@author: wxingheng\n@Date: 2022-07-15 18:16:15\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `scrollDom` | `any` |\n\n#### Returns\n\n`object`\n\n@example: 待增加惯性效果\n\n___\n\n### endWith\n\n▸ **endWith**(`str`, `endStr`): `boolean`\n\n@description: 字符串判断结尾\n@author: wuxh\n@Date: 2021-11-10 11:35:30\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `str` | `string` |\n| `endStr` | `string` |\n\n#### Returns\n\n`boolean`\n\n@example: endWith('1231231', '21') =\u003e false ;  endWith('1231231', '31') =\u003e true\n\n___\n\n### everyTrim\n\n▸ **everyTrim**(`data`): `any`\n\n@description: 去除值类型为string的前后空格\n@author: wuxh\n@Date: 2021-08-21 22:11:23\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `data` | `object` \\| `any`[] |\n\n#### Returns\n\n`any`\n\n@example: everyTrim({name: '  123  ', arr: [' 33 ']}) =\u003e {name: '123': arr: ['33']}\n\n___\n\n### exportJson\n\n▸ **exportJson**(`data`, `name?`): `any`\n\n@description: JSON 对象导出为.json文件\n@author: wxingheng\n@Date: 2022-09-30 11:00:54\n\n#### Parameters\n\n| Name | Type | Default value |\n| :------ | :------ | :------ |\n| `data` | `any` | `undefined` |\n| `name` | `string` | `\"data\"` |\n\n#### Returns\n\n`any`\n\n@example:\n\n___\n\n### fetchToSlow\n\n▸ **fetchToSlow**(`fastestTime`): (`func`: `any`) =\u003e `any`\n\n@description: 转换请求为慢响应\n\n#### Parameters\n\n| Name | Type | Description |\n| :------ | :------ | :------ |\n| `fastestTime` | `undefined` \\| `number` | 最快响应时间 |\n\n#### Returns\n\n`fn`\n\n@example: const data = await fetchToSlow(1000 * 2)(getKgDetail(kg_id));\n\n▸ (`func`): `any`\n\n##### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `func` | `any` |\n\n##### Returns\n\n`any`\n\n___\n\n### formatQueryParam\n\n▸ **formatQueryParam**(`obj`): `string`\n\n@description: 格式化GET请求的请求头\n@author: wuxh\n@Date: 2020-05-06 13:47:40\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `obj` | `Object` |\n\n#### Returns\n\n`string`\n\n___\n\n### formatRhBloodGroup\n\n▸ **formatRhBloodGroup**(`input`, `optiongs?`): `string` \\| `number` \\| `boolean`\n\n@description: 转换Rh血型\n@author: wuxh\n@Date: 2021-09-07 13:44:36\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `input` | `string` |\n| `optiongs?` | `Object` |\n| `optiongs.default?` | `string` \\| `number` \\| `boolean` |\n| `optiongs.format?` | [`string` \\| `number` \\| `boolean`, `string` \\| `number` \\| `boolean`] |\n| `optiongs.negative?` | `string`[] |\n| `optiongs.positive?` | `string`[] |\n\n#### Returns\n\n`string` \\| `number` \\| `boolean`\n\n@example:  formatRhBloodGroup('**D**') =\u003e 阳性\nformatRhBloodGroup('+') =\u003e 阳性\n\n___\n\n### getBase64\n\n▸ **getBase64**(`file`): `Promise`\\\u003c`any`\\\u003e\n\n@description: 获取图片的 base64\n@author: wxingheng\n@Date: 2022-09-30 10:53:33\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `file` | `File` |\n\n#### Returns\n\n`Promise`\\\u003c`any`\\\u003e\n\n@example: getBase64(file).then(res =\u003e console.log(res))\n\n___\n\n### getBirthdatByIdNo\n\n▸ **getBirthdatByIdNo**(`iIdNo`): `string`\n\n@description: 身份证号码解析出生日期\n@author: wuxh\n@Date: 2020-06-09 09:17:50\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `iIdNo` | `string` |\n\n#### Returns\n\n`string`\n\n___\n\n### getBrowserInfo\n\n▸ **getBrowserInfo**(): [`getBrowserInfoResult`](modules.md#getbrowserinforesult)\n\n@description: 获取浏览器相关信息\n@author: wuxh\n@Date: 2020-05-06 11:53:35\n\n#### Returns\n\n[`getBrowserInfoResult`](modules.md#getbrowserinforesult)\n\n___\n\n### getCookie\n\n▸ **getCookie**(`name`): ``null`` \\| `string`\n\n@description: 获取cookie值\n@author: wuxh\n@Date: 2020-06-09 09:28:06\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `name` | `string` |\n\n#### Returns\n\n``null`` \\| `string`\n\n___\n\n### getCountDays\n\n▸ **getCountDays**(`str`): `number`\n\n@description: 获取当前月份天数\n@author: wuxh\n@Date: 2021-08-21 22:43:58\n\n#### Parameters\n\n| Name | Type | Description |\n| :------ | :------ | :------ |\n| `str` | `string` \\| `number` \\| `Date` | YYYY-MM-DD mm:ss |\n\n#### Returns\n\n`number`\n\nnumber\n@example:\n\n___\n\n### getExt\n\n▸ **getExt**(`filename`): `undefined` \\| `string`\n\n@description: 获取文件后缀名\n@author: wuxh\n@Date: 2021-09-02 22:17:57\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `filename` | `string` |\n\n#### Returns\n\n`undefined` \\| `string`\n\n@example: \ngetExt(\"1.mp4\") =\u003e mp4\n\n___\n\n### getFormData\n\n▸ **getFormData**(`object`): `FormData`\n\n@description: 对象转化为FormData对象\n@author: wuxh\n@Date: 2021-09-02 22:52:34\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `object` | `Object` |\n\n#### Returns\n\n`FormData`\n\n@example: \nlet req={\n   file:xxx,\n   userId:1,\n   phone:'15198763636',\n   //...\n}\nfetch(getFormData(req))\n\n___\n\n### getSexByIdNO\n\n▸ **getSexByIdNO**(`IdNO`): ``\"\"`` \\| ``\"FEMALE\"`` \\| ``\"MALE\"``\n\n@description: 身份证号码解析性别\n@author: wuxh\n@Date: 2020-06-09 09:16:28\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `IdNO` | `string` |\n\n#### Returns\n\n``\"\"`` \\| ``\"FEMALE\"`` \\| ``\"MALE\"``\n\n___\n\n### getStorage\n\n▸ **getStorage**(`key`): `any`\n\n@description: 获取\n@author: wuxh\n@Date: 2020-05-06 12:00:37\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `key` | `string` |\n\n#### Returns\n\n`any`\n\n___\n\n### getStringLen\n\n▸ **getStringLen**(`str`): `number`\n\n@description: 计算文本长度（中文算两个字符，英文算一个字符）\n@author: wxingheng\n@Date: 2022-09-30 10:49:41\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `str` | `string` |\n\n#### Returns\n\n`number`\n\n@example: getStringLen(\"阿斯顿发123\") =\u003e 11 ; getStringLen(\"asd123\") =\u003e 6 ; getStringLen(\"asd123顿发\") =\u003e 10\n\n___\n\n### getUrlQuery\n\n▸ **getUrlQuery**(`name`): `string`\n\n@description: 获取浏览器url中的一个参数\n@author: wuxh\n@Date: 2020-05-06 13:46:28\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `name` | `string` |\n\n#### Returns\n\n`string`\n\n___\n\n### getV\n\n▸ **getV**\\\u003c`T`\\\u003e(`defaultResult`, `...args`): `any`\n\n@description: 获取嵌套数据,处理空值异常\n@author: wuxh\n@Date: 2020-05-06 12:13:59\n\n#### Type parameters\n\n| Name |\n| :------ |\n| `T` |\n\n#### Parameters\n\n| Name | Type | Description |\n| :------ | :------ | :------ |\n| `defaultResult` | `T` | 默认值 |\n| `...args` | `any`[] | 属性访问路径 |\n\n#### Returns\n\n`any`\n\n目标值或默认值\n@example: \n getV('', {name: {children: 123}}, 'name', 'children')\n =\u003e 123\n\n___\n\n### groupBy\n\n▸ **groupBy**(`arr`, `key`): `any`\n\n@description:  数组的分类，根据某个字段分类，返回一个对象，key为字段值，value为数组\n@author: wxingheng\n@Date: 2022-09-30 11:53:38\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `arr` | `any`[] |\n| `key` | `string` |\n\n#### Returns\n\n`any`\n\n@example:\nconst arr = [\n{type: 1, name: 'a'},\n{type: 2, name: 'b'},\n{type: 1, name: 'c'},\n{type: 2, name: 'd'},\n{type: 1, name: 'e'},\n{type: 2, name: 'f'},\n]\ngroupBy(arr, 'type') =\u003e {1: [{type: 1, name: 'a'}, {type: 1, name: 'c'}, {type: 1, name: 'e'}], 2: [{type: 2, name: 'b'}, {type: 2, name: 'd'}, {type: 2, name: 'f'}]}\n\n___\n\n### hideIdNum\n\n▸ **hideIdNum**(`str`): `string`\n\n@description: 隐藏身份证号码\n@author: wuxh\n@Date: 2020-06-09 09:19:26\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `str` | `string` |\n\n#### Returns\n\n`string`\n\n___\n\n### importJson\n\n▸ **importJson**(): `object`\n\n@description: 前端文件导入，JSON文件导入\n@author: wxingheng\n@Date: 2022-09-30 10:57:58\n\n#### Returns\n\n`object`\n\n@example: importJson() =\u003e {name: 'wxh'}\n\n___\n\n### isAndroidMobileDevice\n\n▸ **isAndroidMobileDevice**(): `boolean`\n\n@description: 是否是安卓设备\n@author: wuxh\n@Date: 2020-06-09 09:31:04\n\n#### Returns\n\n`boolean`\n\n___\n\n### isAppleMobileDevice\n\n▸ **isAppleMobileDevice**(): `boolean`\n\n@description: 是否是苹果设备\n@author: wuxh\n@Date: 2020-06-09 09:31:55\n\n#### Returns\n\n`boolean`\n\n___\n\n### isArray\n\n▸ **isArray**(`data`): `boolean`\n\n@description: 判断Array类型\n@author: wuxh\n@Date: 2020-05-06 13:53:16\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `data` | `any` |\n\n#### Returns\n\n`boolean`\n\n___\n\n### isBoolean\n\n▸ **isBoolean**(`data`): `boolean`\n\n@description: 判断Boolean类型\n@author: wuxh\n@Date: 2020-05-06 13:53:16\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `data` | `any` |\n\n#### Returns\n\n`boolean`\n\n___\n\n### isDate\n\n▸ **isDate**(`data`): `boolean`\n\n@description: 判断Date类型\n@author: wuxh\n@Date: 2020-05-06 13:53:16\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `data` | `any` |\n\n#### Returns\n\n`boolean`\n\n___\n\n### isEmail\n\n▸ **isEmail**(`str`): `boolean`\n\n@description: 校验是否为邮箱地址\n@author: wuxh\n@Date: 2020-06-09 09:49:29\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `str` | `string` |\n\n#### Returns\n\n`boolean`\n\n___\n\n### isEmptyObject\n\n▸ **isEmptyObject**(`obj`): `boolean`\n\n@description: 判断对象是否为空\n@author: wuxh\n@Date: 2021-08-21 23:08:42\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `obj` | `any` |\n\n#### Returns\n\n`boolean`\n\nboolean\n@example: isEmptyObject({}) =\u003e true\n\n___\n\n### isEqual\n\n▸ **isEqual**(`a`, `b`): `boolean`\n\n@description: 判断两个对象是否相等\n@author: wxingheng\n@Date: 2022-05-13 16:35:33\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `a` | `any` |\n| `b` | `any` |\n\n#### Returns\n\n`boolean`\n\n@example: isEqual({a: 1}, {a: 1}) =\u003e true; isEqual({a: 1}, {a: 2}) =\u003e false; isEqual({a: 1}, {b: 1}) =\u003e false\n\n___\n\n### isError\n\n▸ **isError**(`data`): `boolean`\n\n@description: 判断Error类型\n@author: wuxh\n@Date: 2020-05-06 13:53:16\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `data` | `any` |\n\n#### Returns\n\n`boolean`\n\n___\n\n### isFalsy\n\n▸ **isFalsy**(`value`): `boolean`\n\n@description: 判断 js是否是false， 0除外。\n@author: wuxh\n@Date: 2021-09-02 22:01:50\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `value` | `any` |\n\n#### Returns\n\n`boolean`\n\nvalue === 0 ? false : !value\n@example: \nisFalsy('') =\u003e true\nisFalsy(0) =\u003e false\nisFalsy(null) =\u003e true\nisFalsy(undefined) =\u003e true\n\n___\n\n### isFunc\n\n▸ **isFunc**(`data`): `boolean`\n\n@description: 判断Function类型\n@author: wuxh\n@Date: 2020-05-06 13:53:16\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `data` | `any` |\n\n#### Returns\n\n`boolean`\n\n___\n\n### isNull\n\n▸ **isNull**(`data`): `boolean`\n\n@description: 判断Null类型\n@author: wuxh\n@Date: 2020-05-06 13:53:16\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `data` | `string` |\n\n#### Returns\n\n`boolean`\n\n___\n\n### isNumber\n\n▸ **isNumber**(`data`): `boolean`\n\n@description: 判断Number类型\n@author: wuxh\n@Date: 2020-05-06 13:53:16\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `data` | `any` |\n\n#### Returns\n\n`boolean`\n\n___\n\n### isObject\n\n▸ **isObject**(`data`): `boolean`\n\n@description: 判断Object类型\n@author: wuxh\n@Date: 2020-05-06 13:53:16\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `data` | `any` |\n\n#### Returns\n\n`boolean`\n\n___\n\n### isPhone\n\n▸ **isPhone**(`phone`): `boolean`\n\n@description: 手机号校验\n@author: wuxh\n@Date: 2020-06-09 09:21:15\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `phone` | `string` |\n\n#### Returns\n\n`boolean`\n\n___\n\n### isQQ\n\n▸ **isQQ**(): `boolean`\n\n@description: 是否是QQ平台\n@author: wuxh\n@Date: 2020-05-06 12:10:41\n\n#### Returns\n\n`boolean`\n\n___\n\n### isReg\n\n▸ **isReg**(`data`): `boolean`\n\n@description: 判断RegExp类型\n@author: wuxh\n@Date: 2020-05-06 13:53:16\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `data` | `any` |\n\n#### Returns\n\n`boolean`\n\n___\n\n### isRhNegative\n\n▸ **isRhNegative**(`input`): `string` \\| `number` \\| `boolean`\n\n@description: 是否阴性\n@author: wuxh\n@Date: 2022-01-17 23:57:31\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `input` | `string` |\n\n#### Returns\n\n`string` \\| `number` \\| `boolean`\n\n@example:\n\n___\n\n### isRhPositive\n\n▸ **isRhPositive**(`input`): `string` \\| `number` \\| `boolean`\n\n@description: 是否阳性\n@author: wuxh\n@Date: 2022-01-17 23:57:19\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `input` | `string` |\n\n#### Returns\n\n`string` \\| `number` \\| `boolean`\n\n@example:\n\n___\n\n### isString\n\n▸ **isString**(`data`): `boolean`\n\n@description: 判断String类型\n@author: wuxh\n@Date: 2020-05-06 13:53:16\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `data` | `any` |\n\n#### Returns\n\n`boolean`\n\n___\n\n### isSupportStorage\n\n▸ **isSupportStorage**(): `boolean`\n\n@description: 是否支持local\n@author: wuxh\n@Date: 2020-05-06 12:01:43\n\n#### Returns\n\n`boolean`\n\n___\n\n### isType\n\n▸ **isType**(`data`, `type`): `boolean`\n\n@description: 精准判断数据类型\n@author: wuxh\n@Date: 2020-05-06 13:51:50\n\n#### Parameters\n\n| Name | Type | Description |\n| :------ | :------ | :------ |\n| `data` | `any` | - |\n| `type` | `string` | 'String' \\| 'Number' \\| 'Boolean' \\| 'Undefined' \\| 'Null' \\| 'Function' \\| 'Date' \\| 'Array' \\| 'RegExp' \\| 'Error' \\| 'Object' @return: Boolean @example: isType(123, 'String') =\u003e false isType('123', 'String') =\u003e true |\n\n#### Returns\n\n`boolean`\n\n___\n\n### isUndefined\n\n▸ **isUndefined**(`data`): `boolean`\n\n@description: 判断Undefined类型\n@author: wuxh\n@Date: 2020-05-06 13:53:16\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `data` | `any` |\n\n#### Returns\n\n`boolean`\n\n___\n\n### isUserId\n\n▸ **isUserId**(`e`): ``\"\"`` \\| ``\"身份证号码不能为空\"`` \\| ``\"身份证号码长度应该为18位\"`` \\| ``\"身份证格式错误\"`` \\| ``\"身份证生日无效。\"`` \\| ``\"身份证生日不在有效范围\"`` \\| ``\"身份证月份无效\"`` \\| ``\"身份证日期无效\"`` \\| ``\"身份证地区编码错误\"`` \\| ``\"不是合法的身份证号码\"``\n\n@description: 身份证号码校验（精准）\n@author: wuxh\n@Date: 2020-05-06 13:49:58\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `e` | `string` |\n\n#### Returns\n\n``\"\"`` \\| ``\"身份证号码不能为空\"`` \\| ``\"身份证号码长度应该为18位\"`` \\| ``\"身份证格式错误\"`` \\| ``\"身份证生日无效。\"`` \\| ``\"身份证生日不在有效范围\"`` \\| ``\"身份证月份无效\"`` \\| ``\"身份证日期无效\"`` \\| ``\"身份证地区编码错误\"`` \\| ``\"不是合法的身份证号码\"``\n\n___\n\n### isVoid\n\n▸ **isVoid**(`value`): `boolean`\n\n@description: 判断是否为空 undefined || null || \"\"\n@author: wuxh\n@Date: 2021-09-02 22:03:36\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `value` | `any` |\n\n#### Returns\n\n`boolean`\n\nboolean\n@example: \nisVoid(0) =\u003e false\nisVoid(undefined) =\u003e true\nisVoid('') =\u003e true\nisVoid(null) =\u003e true\nisVoid() =\u003e true\n\n___\n\n### isWX\n\n▸ **isWX**(): `boolean`\n\n@description: 是否是微信平台\n@author: wuxh\n@Date: 2020-05-06 12:10:41\n\n#### Returns\n\n`boolean`\n\n___\n\n### mergeObj\n\n▸ **mergeObj**(`oldObj`, `newObj`, `keys`): `Object`\n\n@description: 深度合并对象(当前用于合并系统配置文件 app-data.json) 已存在的属性默认不覆盖\n@author: wuxh\n@Date: 2020-05-06 12:15:30\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `oldObj` | `Object` |\n| `newObj` | `Object` |\n| `keys` | `string` \\| `string`[] |\n\n#### Returns\n\n`Object`\n\n___\n\n### moreClick\n\n▸ **moreClick**(`fun`, `n?`, `wait?`): (...`args`: `any`[]) =\u003e `void`\n\n@description: 单击事件转换为多击事件\n@author: wxingheng\n@Date: 2022-08-09 14:03:34\n\n#### Parameters\n\n| Name | Type | Default value | Description |\n| :------ | :------ | :------ | :------ |\n| `fun` | (...`args`: `any`) =\u003e `void` | `undefined` | 回调函数 |\n| `n` | `number` | `2` | 连续几次触发才触发回调函数 |\n| `wait` | `number` | `300` | 两次之间的间隔时间 |\n\n#### Returns\n\n`fn`\n\n@example:  const dobuleClick = moreClick(handleClick)\n   // 连续点击三次触发\n       var moreClickCallBack = jcommon.moreClick(() =\u003e {\n           console.log(\"moreClickCallBack\")\n       }, 3)\n       dom.addEventListener('click', moreClickCallBack);\n\n▸ (`...args`): `void`\n\n##### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `...args` | `any`[] |\n\n##### Returns\n\n`void`\n\n___\n\n### oneClickToMoreClick\n\n▸ **oneClickToMoreClick**(`wait?`, `...events`): () =\u003e `void`\n\n@description: 单击事件转换为多击事件\n@author: wxingheng\n@Date: 2022-05-04 14:20:22\n\n#### Parameters\n\n| Name | Type | Default value |\n| :------ | :------ | :------ |\n| `wait` | `number` | `300` |\n| `...events` | (...`args`: `any`[]) =\u003e `void`[] | `undefined` |\n\n#### Returns\n\n`fn`\n\n@example: \n   // 连续点击一次触发，连续点击两次触发，连续点击三次触发\n       var oneClickToMoreClickCallBack = jcommon.oneClickToMoreClick(300, () =\u003e {\n           console.log(111)\n       }, () =\u003e {\n           console.log(222)\n       }, ()=\u003e {\n           console.log(333)\n       })\n       dom.addEventListener('click', oneClickToMoreClickCallBack);\n\n▸ (): `void`\n\n##### Returns\n\n`void`\n\n___\n\n### operattelecom\n\n▸ **operattelecom**(`e`): ``false`` \\| ``\"联通\"`` \\| ``\"电信\"`` \\| ``\"移动\"`` \\| ``\"未知\"``\n\n@description: 获取手机运营商\n@author: wuxh\n@Date: 2020-05-06 12:11:39\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `e` | `string` |\n\n#### Returns\n\n``false`` \\| ``\"联通\"`` \\| ``\"电信\"`` \\| ``\"移动\"`` \\| ``\"未知\"``\n\n___\n\n### osInfo\n\n▸ **osInfo**(`e`): [`osInfoResult`](modules.md#osinforesult)\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `e` | `string` |\n\n#### Returns\n\n[`osInfoResult`](modules.md#osinforesult)\n\n___\n\n### processStreamResponse\n\n▸ **processStreamResponse**(`response`, `typewriter`): `Promise`\\\u003c`void`\\\u003e\n\n@description:  处理流响应数据\n@author: wxingheng\n@Date: 2023-06-13 16:14:34\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `response` | `any` |\n| `typewriter` | `Object` |\n| `typewriter.add` | (`arg0`: `any`) =\u003e `void` |\n| `typewriter.done` | () =\u003e `void` |\n| `typewriter.start` | () =\u003e `void` |\n\n#### Returns\n\n`Promise`\\\u003c`void`\\\u003e\n\n@example:\n\n___\n\n### randomColor\n\n▸ **randomColor**(): `any`\n\n@description: 产生一个随机颜色\n@author: wxingheng\n@Date: 2022-09-30 11:13:13\n\n#### Returns\n\n`any`\n\n@example: randomColor() =\u003e \"rgba(107, 35, 72, 1)\";\n\n___\n\n### removeStorage\n\n▸ **removeStorage**(`key`): `void`\n\n@description: 删除\n@author: wuxh\n@Date: 2020-05-06 11:56:29\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `key` | `any` |\n\n#### Returns\n\n`void`\n\n___\n\n### saveStorage\n\n▸ **saveStorage**(`key`, `value`): `void`\n\n@description: 保存\n@author: wuxh\n@Date: 2020-05-06 11:56:29\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `key` | `string` |\n| `value` | `string` |\n\n#### Returns\n\n`void`\n\n___\n\n### scaleLinear\n\n▸ **scaleLinear**(`value`, `source`, `target`, `toFixedLength?`): `any`\n\n@description: 比例计算\n@author: wxingheng\n@Date: 2022-09-30 11:13:27\n\n#### Parameters\n\n| Name | Type | Default value | Description |\n| :------ | :------ | :------ | :------ |\n| `value` | `number` | `undefined` | 当前值 |\n| `source` | `number` | `undefined` | 当前值所在的区间 |\n| `target` | `number` | `undefined` | 目标区间 |\n| `toFixedLength` | `any` | `2` | 保留小数位数 |\n\n#### Returns\n\n`any`\n\n@example:  scaleLinear(50, 100, 10, 2) =\u003e 5; scaleLinear(50, 100, 10, 0) =\u003e 5;\n\n___\n\n### scopeRandom\n\n▸ **scopeRandom**(`str`, `end`): `number`\n\n@description: 范围随机整数\n@author: wuxh\n@Date: 2020-05-06 12:09:34\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `str` | `number` |\n| `end` | `number` |\n\n#### Returns\n\n`number`\n\n___\n\n### similar\n\n▸ **similar**(`s`, `t`, `f?`): `number`\n\n@description: 计算两个字符串相似度\n@author: wxingheng\n@Date: 2022-07-25 10:07:23\n\n#### Parameters\n\n| Name | Type | Default value | Description |\n| :------ | :------ | :------ | :------ |\n| `s` | `string` | `undefined` | 文本1 |\n| `t` | `string` | `undefined` | 文本2 |\n| `f` | `number` | `2` | 小数位精确度，默认2位 |\n\n#### Returns\n\n`number`\n\n百分数前的数值，最大100. 比如 ：90.32\n@example: similar(\"12\", \"12\") =\u003e 100 ; similar(\"12\", \"123\") =\u003e 75 ; similar(\"12\", \"1234\") =\u003e 50\n\n___\n\n### sleep\n\n▸ **sleep**(`milliseconds`): `Promise`\\\u003c`unknown`\\\u003e\n\n@description: 休眠多少毫秒\n@author: wuxh\n@Date: 2021-09-02 23:08:19\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `milliseconds` | `undefined` \\| `number` |\n\n#### Returns\n\n`Promise`\\\u003c`unknown`\\\u003e\n\n@example: \n fetchData = async () =\u003e {\n   await sleep(1000)\n }\n\n___\n\n### sorterCallBack\n\n▸ **sorterCallBack**(`key`, `isAscend?`): (`a`: `any`, `b`: `any`) =\u003e ``1`` \\| ``-1``\n\n@description: sort []\n@author: wuxh\n@Date: 2021-09-07 14:12:06\n\n#### Parameters\n\n| Name | Type | Default value |\n| :------ | :------ | :------ |\n| `key` | `string` | `undefined` |\n| `isAscend` | `boolean` | `true` |\n\n#### Returns\n\n`fn`\n\n@example:\nconst arr = [{name: '666'}, {name: '333'}]\narr.sorterCallBackString('name') =\u003e [{name: '333'}, {name: '666'}]\narr.sorterCallBackString('name', false) =\u003e [{name: '666'}, {name: '333'}]\n\n▸ (`a`, `b`): ``1`` \\| ``-1``\n\n##### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `a` | `any` |\n| `b` | `any` |\n\n##### Returns\n\n``1`` \\| ``-1``\n\n___\n\n### throttle\n\n▸ **throttle**(`func`, `wait?`, `options`): () =\u003e `void`\n\n@description: 节流 多次调用方法，按照一定的时间间隔执行\n@author: wuxh\n@Date: 2021-09-02 21:46:38\n\n#### Parameters\n\n| Name | Type | Default value |\n| :------ | :------ | :------ |\n| `func` | () =\u003e `void` | `undefined` |\n| `wait` | `number` | `500` |\n| `options` | `Object` | `undefined` |\n| `options.leading` | `boolean` | `undefined` |\n| `options.trailing` | `boolean` | `undefined` |\n\n#### Returns\n\n`fn`\n\nFunction\n@example: \n\nleading，函数在每个等待时延的开始被调用，默认值为false\ntrailing，函数在每个等待时延的结束被调用，默认值是true\n可以根据不同的值来设置不同的效果：\nleading-false，trailing-true：默认情况，即在延时结束后才会调用函数\nleading-true，trailing-true：在延时开始时就调用，延时结束后也会调用\nleading-true, trailing-false：只在延时开始时调用\n\n▸ (): `void`\n\n##### Returns\n\n`void`\n\n___\n\n### timeFormat\n\n▸ **timeFormat**(`time`): `string`\n\n@description: 时间个性化输出功能\n@author: wuxh\n@Date: 2020-06-09 09:44:23\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `time` | `Date` |\n\n#### Returns\n\n`string`\n\n___\n\n### trim\n\n▸ **trim**(`str`, `global?`): `string`\n\n@description: 去除字符串空格, 默认去除前后空格 （常用）\n@author: wuxh\n@Date: 2020-05-06 13:43:52\n\n#### Parameters\n\n| Name | Type | Default value |\n| :------ | :------ | :------ |\n| `str` | `string` | `undefined` |\n| `global` | `boolean` | `false` |\n\n#### Returns\n\n`string`\n\n___\n\n### uniqueId\n\n▸ **uniqueId**(): `string`\n\n@description: 随机数 + 时间戳\n@author: wuxh\n@Date: 2020-06-09 09:47:34\n\n#### Returns\n\n`string`\n\n___\n\n### urlByObj\n\n▸ **urlByObj**(`params`): `Object`\n\n@description: 处理url参数(window.location.search)转换为 {key: value}\n@author: wuxh\n@Date: 2020-05-06 13:48:36\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `params` | `string` |\n\n#### Returns\n\n`Object`\n\n___\n\n### uuid\n\n▸ **uuid**(`length`, `chars`): `string`\n\n@description: 生成随机字符串,第一个参数指定位数，第二个字符串指定字符，都是可选参数，如果都不传，默认生成8位\n@author: wuxh\n@Date: 2021-09-02 22:29:02\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `length` | `number` |\n| `chars` | `string` \\| `any`[] |\n\n#### Returns\n\n`string`\n\n@example: \nuuid() =\u003e 'ghijklmn'\n\n___\n\n### versionCount\n\n▸ **versionCount**(`version`, `maxNum?`): `string`\n\n@description: 版本号累加\n@author: wuxh\n@Date: 2021-08-24 11:19:07\n\n#### Parameters\n\n| Name | Type | Default value | Description |\n| :------ | :------ | :------ | :------ |\n| `version` | `string` | `undefined` | : string |\n| `maxNum` | `number` | `99` | - |\n\n#### Returns\n\n`string`\n\nstring\n@example: versionCount('0.0.1') =\u003e '0.0.2'\nversionCount('0.2.9') =\u003e '0.3.0'\nversionCount('0.2.9.1') =\u003e '0.2.9.2'\n\n\n\n\n[jcommon文档库 - v1.9.36](../README.md) / [Exports](../modules.md) / EventBus\n\n# Class: EventBus\n\n@description: EventBus  class\n@author: wuxh\n@Date: 2021-08-24 11:19:07\n@example: const eventBus = new EventBus()\n\n## Table of contents\n\n### Constructors\n\n- [constructor](EventBus.md#constructor)\n\n### Methods\n\n- [addListener](EventBus.md#addlistener)\n- [emit](EventBus.md#emit)\n- [getListeners](EventBus.md#getlisteners)\n- [once](EventBus.md#once)\n- [removeAllListener](EventBus.md#removealllistener)\n- [removeListener](EventBus.md#removelistener)\n- [setMaxListeners](EventBus.md#setmaxlisteners)\n\n## Constructors\n\n### constructor\n\n• **new EventBus**()\n\n## Methods\n\n### addListener\n\n▸ **addListener**(`event`, `cb`): `void`\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `event` | `string` |\n| `cb` | (...`args`: `any`[]) =\u003e `any` |\n\n#### Returns\n\n`void`\n\n___\n\n### emit\n\n▸ **emit**(`event`, `...args`): `void`\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `event` | `string` |\n| `...args` | `any`[] |\n\n#### Returns\n\n`void`\n\n___\n\n### getListeners\n\n▸ **getListeners**(`event`): `any`\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `event` | `string` |\n\n#### Returns\n\n`any`\n\n___\n\n### once\n\n▸ **once**(`event`, `cb`): `void`\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `event` | `string` |\n| `cb` | (...`args`: `any`[]) =\u003e `any` |\n\n#### Returns\n\n`void`\n\n___\n\n### removeAllListener\n\n▸ **removeAllListener**(`event`): `void`\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `event` | `string` |\n\n#### Returns\n\n`void`\n\n___\n\n### removeListener\n\n▸ **removeListener**(`event`, `listener`): `void`\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `event` | `string` |\n| `listener` | (...`args`: `any`[]) =\u003e `any` |\n\n#### Returns\n\n`void`\n\n___\n\n### setMaxListeners\n\n▸ **setMaxListeners**(`maxListener`): `void`\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `maxListener` | `number` |\n\n#### Returns\n\n`void`\n\n\n\n\n[jcommon文档库 - v1.9.36](../README.md) / [Exports](../modules.md) / Queue\n\n# Class: Queue\n\n@description: Queue 队列 class\n@author: wuxh\n@Date: 2021-08-24 11:19:07\n@example: const queue = new Queue()\n\n## Table of contents\n\n### Constructors\n\n- [constructor](Queue.md#constructor)\n\n### Methods\n\n- [clear](Queue.md#clear)\n- [dequeue](Queue.md#dequeue)\n- [enqueue](Queue.md#enqueue)\n- [front](Queue.md#front)\n- [isEmpty](Queue.md#isempty)\n- [print](Queue.md#print)\n- [size](Queue.md#size)\n\n## Constructors\n\n### constructor\n\n• **new Queue**(`items`)\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `items` | `never`[] |\n\n## Methods\n\n### clear\n\n▸ **clear**(): `void`\n\n#### Returns\n\n`void`\n\n___\n\n### dequeue\n\n▸ **dequeue**(): `void`\n\n#### Returns\n\n`void`\n\n___\n\n### enqueue\n\n▸ **enqueue**(`element`): `void`\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `element` | `never` |\n\n#### Returns\n\n`void`\n\n___\n\n### front\n\n▸ **front**(): `never`\n\n#### Returns\n\n`never`\n\n___\n\n### isEmpty\n\n▸ **isEmpty**(): `boolean`\n\n#### Returns\n\n`boolean`\n\n___\n\n### print\n\n▸ **print**(): `void`\n\n#### Returns\n\n`void`\n\n___\n\n### size\n\n▸ **size**(): `number`\n\n#### Returns\n\n`number`\n\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwxingheng%2Fjcommon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwxingheng%2Fjcommon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwxingheng%2Fjcommon/lists"}