npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

meta-global-utils

v1.0.0

Published

vgohm 函数封装

Downloads

3

Readme

VHMUtils 工具类

安装

npm install @vgohm/utils

yarn add @vgohm/utils

引入

// 整体引入
import VHMUtils from '@vgohm/utils';
const { base, data, datetime, global, tree, validate } = VHMUtils;

OR;

// 单独引入
import { vhmBase, vhmData, vhmDatetime, vhmGlobal, vhmTree, vhmValidate } from '@vgohm/utils';

说明

工具类 添加了第三方工具类 lodash、dayjs

vhmBase - 基础类型工具
vhmData - 数据结构工具
vhmDatetime - 时间工具
vhmGlobal - 全局公共工具
vhmTree - 树形操作
vhmValidate - 表单验证工具

API 接口

vhmBase - 基础类型工具
// VHMBase 中集成了 lodash 工具

// 工具实现
declare class VHMBase {
	lodash: EmptyObjectType;
	merge: Fn;
	extend: Fn;
	browser: Browser;

	/**
	 * @description 深度克隆
	 * @param {Object} data 克隆对象
	 */
	clone(data: any): any;

	/**
	 * @description 去掉数组中的 假[false, null, 0, "", undefined, NaN] 值
	 * @param {Array} ary
	 */
	compactArray(ary: EmptyArrayType): EmptyArrayType;

	/**
	 * @description 合并对象
	 * @param {Object} data 对象
	 */
	extendObject(...data: any): any;

	/**
	 * @description 合并对象数组 [根据 text 字段区分]
	 * @param {Array} resource 源数组
	 * @param {Array} target 替换数组
	 */
	mergeObjArray(resource: EmptyArrayType, target: EmptyArrayType): EmptyArrayType;

	/**
	 * @description 深度合并
	 * @param {Array} src 源数组
	 * @param {Array} target 替换数组
	 */
	deepMerge<T = any>(src?: any, target?: any): T;

	/**
	 * @description 数组去重
	 * @param {Array} resource 源数组
	 */
	dedupeArray(resource: EmptyArrayType): EmptyArrayType;

	/**
	 * @description 验证是否是数组
	 * @param {Array} ary  数据源
	 * @returns {Boolean}
	 */
	isArray(ary: any): boolean;

	/**
	 * @description 验证是否是对象
	 * @param {Object} obj  数据源
	 * @returns {Boolean}
	 */
	isObject(obj: any): boolean;

	/**
	 * @description 验证是否是字符串
	 * @param {String} str  数据源
	 * @returns {Boolean}
	 */
	isString(str: any): boolean;

	/**
	 * @description 验证是否是布尔
	 * @param {String} boolean  数据源
	 * @returns {Boolean}
	 */
	isBoolean(boolean: any): boolean;

	/**
	 * @description 验证是否是数字类型
	 * @param {Number} num 数据源
	 * @returns {Boolean}
	 */
	isNumber(num: any): boolean;

	/**
	 * @description 是否是 JSON 字符串
	 * @param {String} str
	 * @returns {Boolean}
	 */
	isJsonString(str: any): boolean;

	/**
	 * @description 是否为假
	 * @param {String | Number | null | undefined} val 验证的值
	 * @returns {Boolean}
	 */
	isFalse(val: any): boolean;

	/**
	 * @description 验证对象是否为空
	 * @param {Object} obj 数据源
	 * @returns {Boolean}
	 */
	isObjectEmpty(obj: EmptyObjectType): boolean;

	/**
	 * @description 验证对象中每一项的值是否为空
	 * @param {Object} obj 数据源
	 * @returns {Boolean}
	 */
	isObjectItemEmpty(obj: EmptyObjectType): boolean;

	/**
	 * @description 验证数组是否为空
	 * @param {Array} array
	 * @returns {Boolean}
	 */
	isArrayEmpty(array: EmptyArrayType): boolean;

	/**
	 * @description 验证数据是否为空
	 * @param {Array | Object | String} data
	 * @returns {Boolean}
	 */
	isEmpty(data: any): boolean;

	/**
	 * @description 获取随机id
	 * @param {Number} length 位数
	 * @returns {String}
	 */
	uuid(length?: number): string;

	/**
	 * @description min 到 max 的随机数
	 * @param {Number} min 最小值
	 * @param {Number} max 最大值
	 * @returns {Number}
	 */
	random(min: number, max: number): number;
}

| 名称 | 实现 | 说明 | 返回 | | ----------------- | ----------------------------------------------------------------------- | --------------------------------- | -------------- | | browser | vhmBase.browser() | 浏览器实例 | Browser | | clone | vhmBase.clone(data: any) | 深度克隆 | | compactArray | vhmBase.compactArray(ary: EmptyArrayType) | 去掉数组中的假值 | EmptyArrayType | | extendObject | vhmBase.extendObject(...data: any) | 合并对象 | | mergeObjArray | vhmBase.mergeObjArray(resource: EmptyArrayType, target: EmptyArrayType) | 合并对象数组 [根据 text 字段区分] | EmptyArrayType | | deepMerge | vhmBase.deepMerge<T = any>(src?: any, target?: any) | 深度合并 | T | | dedupeArray | vhmBase.dedupeArra(resource: EmptyArrayType) | 数组去重 | EmptyArrayType | | isArray | vhmBase.isArray(ary: any) | 验证是否是数组 | boolean | | isObject | vhmBase.isObject(obj: any) | 验证是否是对象 | boolean | | isString | vhmBase.isString(str: any) | 验证是否是字符串 | boolean | | isBoolean | vhmBase.isBoolean(boolean: any) | 验证是否是布尔 | boolean | | isNumber | vhmBase.isNumber(num: any) | 验证是否是数字类型 | boolean | | isJsonString | vhmBase.isJsonString(str: any) | 是否是 JSON 字符串 | boolean | | isFalse | vhmBase.isFalse(val: any) | 是否为假 | boolean | | isObjectEmpty | vhmBase.isObjectEmpty(obj: EmptyObjectType) | 验证对象是否为空 | boolean | | isObjectItemEmpty | vhmBase.isObjectItemEmpty(obj: EmptyObjectType) | 验证对象中每一项的值是否为空 | boolean | | isArrayEmpty | vhmBase.isArrayEmpty(array: EmptyArrayType) | 验证数组是否为空 | boolean | | isEmpty | vhmBase.isEmpty(data: any) | 验证数据是否为空 | boolean | | uuid | vhmBase.uuid(length?: number) | 获取随机 id | string | | random | vhmBase.random(min: number, max: number) | min 到 max 的随机数 | number |

vhmData - 数据结构工具
declare class VHMData {
	/**
	 * @description 清空数组
	 * @param {Array} ary 数据源
	 * @returns {Array}
	 */
	emptyArray(ary: EmptyArrayType): EmptyArrayType;

	/**
	 * @description 清空对象
	 * @param {Object} obj 数据源
	 * @returns {Object}
	 */
	emptyObject(obj: EmptyObjectType): EmptyObjectType;

	/**
	 * @description 清空数据
	 * @param {Array | Object | String} data 数据源
	 * @returns
	 */
	emptyData(data: any): EmptyObjectType | EmptyArrayType | string;

	/**
	 * @description 深度清空渲染源 [带又value的渲染数据]
	 * @param {Object} render 数据源
	 * @returns
	 */
	emptyObjectDeep(render: any): void;

	/**
	 * @description 深度清空数据源 [不带value的接口数据]
	 * @param {Object} form 数据源
	 * @param {Boolean} isOnlyOneArray 数组是否只保留一个
	 * @returns
	 */
	emptyDataDeep(form: any, isOnlyOneArray?: boolean): void;

	/**
	 * @description 对比子对象中的元素是否在父对象中存在且值相同
	 * @param {Object} parent 父辈对象
	 * @param {Object} child 子类对象
	 * @returns
	 */
	isUniteObjectByChild(parent: EmptyObjectType, child: EmptyObjectType): boolean;

	/**
	 * @description 合并多维数组
	 * @param {Array} ary
	 * @returns
	 */
	mergeDimensionsArray(ary: EmptyArrayType): EmptyArrayType;

	/**
	 * @description 数组、数组对象去重
	 * @param {Array} arr 数组内容
	 * @param {Array} attr 需要去重的键值(数组对象)
	 * @returns
	 */
	removeArrayDuplicate(arr: EmptyArrayType, attr?: string): EmptyArrayType;

	/**
	 * @description 判断两数组字符串是否相同,数组字符串中存在相同时会自动去重(按钮权限标识不会重复)
	 * @param news 新数据
	 * @param old 源数据
	 * @returns 两数组相同返回 `true`,反之则反
	 */
	judementSameArr(newArr: unknown[] | string[], oldArr: string[]): boolean;

	/**
	 * @description 判断两个对象是否相同
	 * @param a 要比较的对象一
	 * @param b 要比较的对象二
	 * @returns 相同返回 true,反之则反
	 */
	isObjectValueEqual<T>(a: T, b: T): boolean;

	/**
	 * @description 查询数组中元素出现的个数 [不包含对象数组]
	 * @param {Array} array
	 * @returns
	 */
	queryFieldsNumber(array: EmptyArrayType): EmptyArrayType;

	/**
	 * @description 格式化picker选择数据
	 * @param {Array} data  数据源
	 * @param {String} text  替换的文本
	 * @param {String} code  替换的code
	 * @returns {Array} 返回改造后的数据
	 */
	formatPickerData(data: EmptyArrayType, text: string, code: string): EmptyArrayType;

	/**
	 * @description 将枚举转换成数组
	 * @param enums 枚举
	 * @returns
	 */
	enum2Array(enums: any): Array<any>;

	/**
	 * @description 将对象抓换成对应的数组
	 * @param {Object} obj 数据源
	 * @param {String} key 对象数组中子项的 key
	 * @param {String} value 对象数组中子项的 value
	 * @param {Array} array 返回数组
	 * @returns {Array} 返回改造后的数据
	 */
	object2Array(obj: EmptyObjectType, key?: string, value?: string, array?: EmptyArrayType): boolean | EmptyArrayType;

	/**
	 * @description 通过 value 从 array 中获取对应 field 的数组数据
	 * @param {Array} array
	 * @param {String} field 集合中需要筛选对比的字段
	 * @param {String} value
	 * @param {Array} result
	 * @returns {Array}
	 */
	getArrayByFieldValue(array: EmptyArrayType, field: string, value: string, result?: EmptyArrayType): EmptyArrayType;

	/**
	 * @description 根据传入值返回在数组的位置
	 * @param value  某个字符
	 * @param arr  数组
	 * @param fields  数组中判断依据的字段
	 * @returns {Number}
	 */
	getArrayIndexByVal(value: string, arr: EmptyArrayType, fields?: string): number;

	/**
	 * @description 根据传入Id返回对应的值
	 * @param id  id
	 * @param arr  数组
	 * @param fields  数组中判断依据的字段
	 * @param rFields  数组中判断依据的字段返回想要的字段
	 * @returns {String}
	 */
	getArrayValueById(id: string | number | boolean, arr: EmptyArrayType, fields?: string, rFields?: string): string;

	/**
	 * @description 通过 field 字段 在源对象中提取出新的对象
	 * @param {Object} data 源
	 * @param {String} field 特殊字符
	 * @param {Object} result 返回对象
	 * @returns {Object}
	 */
	extractObjectByField(data: EmptyDataType, field: string, result?: EmptyObjectType): EmptyObjectType | boolean;

	/**
	 * @description 去掉提交表单中的空属性
	 * @param {Object} form
	 * @returns {Object}
	 */
	doEmptyObject(form: EmptyObjectType): EmptyObjectType;

	/**
	 * @description 去掉提交表单中的空属性 [只有字符串]
	 * @param {Object} form
	 * @returns {Object}
	 */
	doEmptyString(form: EmptyObjectType): EmptyObjectType;

	/**
	 * @description 获取对象中指定 key 的 item
	 * @param {Object} source
	 * @param {String | Array} key 数组的时候返回数组
	 * @param {Object} result
	 * @returns {Object}
	 */
	getObjectItemByKey(source: EmptyObjectType, key: string | Array<string>, result?: EmptyObjectType): EmptyObjectType;

	/**
	 * @description 设置导出表格的格式 title 和 字段
	 * @param {Object} data 需要格式化的数据
	 * @param {Object} result 返回结果 header:表格头部 fields:表格头部对应的字段
	 * @returns
	 */
	formatExportLayout(data: EmptyObjectType, result?: EmptyObjectType): EmptyObjectType | boolean;

	/**
	 * @description 格式化导出数据
	 * @param {Array} source 源数据
	 * @param {Array} fields 需要提取源数据中的字段数组
	 * @param {Object} validateFields 验证源数据中的字段 转换相应的需求
	 * @param {Object} result 返回值
	 * @returns
	 */
	formatExportData(
		source: EmptyArrayType,
		fields: EmptyArrayType,
		validateFields: EmptyObjectType,
		result?: EmptyArrayType
	): EmptyArrayType | boolean;

	/**
	 * @description 格式化 form 数据提交到接口
	 * @param {Object | Array} renderData 渲染页面的不规则数据格式
	 * @param {Boolean} deep 深度赋值,去掉父辈字段,只保留最里层字段 [默认:true]
	 * @param {Boolean} cutting 深度切割数组 将数组里面的 对象拆分 [默认:false]
	 * @param {Boolean} submit 是否是提交模式 用于区分渲染还是提交 [默认:true]
	 * @param {Object} result 返回的对象
	 * @returns {Object}
	 */
	formatFormData(renderData: EmptyObjectType | Array<any>, { deep, cutting, submit }?: EmptyObjectType, result?: EmptyObjectType): EmptyObjectType;

	/**
	 * @description 回显接口返回的数据
	 * @param {Object} form 页面上渲染的数据
	 * @param {Object} data 接口返回的数据
	 * @param {Object} isNotSame 返回数据的可以不相同
	 * @returns
	 */
	setAjaxFormatData(form: any, data: any, isNotSame?: boolean): boolean;

	/**
	 * @description 父子关系的数组转换成树形结构数据
	 * @param {Array} data
	 * @returns {*}
	 */
	translateDataToTree(data: EmptyArrayType): EmptyArrayType;

	/**
	 * @description 树形结构数据转换成父子关系的数组
	 * @param {Array} data
	 * @returns {[]}
	 */
	translateTreeToData(data: EmptyArrayType): EmptyArrayType;
}
vhmDatetime - 日期工具
// 继承了 dayjs

declare class VHMDatetime {
	dayjs: any;

	/**
	 * @description 返回某年某月的天数
	 * @param {String} date 日期年月
	 * @returns
	 */
	getCountDays(date: string | Date): string | number;

	/**
	 * @description 通过毫秒格式换时间
	 * @param {Number | String} time 时间字符串 时间毫秒
	 * @param {String} type 格式时间类型
	 * @param {String} split 格式时间的字符
	 * @returns
	 */
	getFormatDateByTime(time: string | Date, type: string, split?: string): any;

	/**
	 * @description 格式化时间
	 * @param {Number | String} time
	 * @param {String} cFormat 格式化模式
	 * @returns {string | null}
	 */
	formatDatetime(time?: Date | string | number, format?: string): string | number | null;

	/**
	 * @description 获取最近时间
	 * @param {Number} day 附近几天
	 * @param {String} format 格式化模式
	 * @returns
	 */
	getDayWithFormat(day: number, format: string): string | number | null;

	/**
	 * @description 获取最近时间数组
	 * @param {Number | Object} day 附近几天
	 * @param {String} format 格式化模式
	 * @param {Date | String} time 指定时间
	 * @returns
	 */
	getDatetimeArrayWithFormat(day: number | EmptyObjectType, time: Date | string, format: string): EmptyArrayType;

	/**
	 * @description 倒计时
	 * @param {Number | Object} start 开始时间
	 * @param {Number | Object} end 技术时间
	 * @param {String} format 格式化模式
	 * @returns
	 */
	getCutdownDatetime({ start, end, differ }?: EmptyObjectType, format?: string): string | boolean;

	/**
	 * 将时间转换为 `几秒前`、`几分钟前`、`几小时前`、`几天前`
	 * @param param 当前时间,new Date() 格式或者字符串时间格式
	 * @param format 需要转换的时间格式字符串
	 * @description param 10秒:  10 * 1000
	 * @description param 1分:   60 * 1000
	 * @description param 1小时: 60 * 60 * 1000
	 * @description param 24小时:60 * 60 * 24 * 1000
	 * @description param 3天:   60 * 60* 24 * 1000 * 3
	 * @returns 返回拼接后的时间字符串
	 */
	formatPast(param: string | Date, format?: string): string | number | null;

	/**
	 * 时间问候语
	 * @param param 当前时间,new Date() 格式
	 * @description param 调用 `formatAxis(new Date())` 输出 `上午好`
	 * @returns 返回拼接后的时间字符串
	 */
	formatAxis(param: Date): string;
}
vhmGlobal - 公共工具
declare class VHMGlobal {
	count: {
		/**
		 * @description 加法
		 * @param {String | Number} arg1
		 * @param {String | Number} arg2
		 * @returns
		 */
		add: (arg1: number | string, arg2: number | string) => number | string;

		/**
		 * @description 减法
		 * @param {String | Number} arg1
		 * @param {String | Number} arg2
		 * @returns
		 */
		sub: (arg1: number | string, arg2: number | string) => number | string;

		/**
		 * @description 乘法
		 * @param {String | Number} arg1
		 * @param {String | Number} arg2
		 * @returns
		 */
		mul: (arg1: number | string, arg2: number | string) => number | string;

		/**
		 * @description 除法
		 * @param {String | Number} arg1
		 * @param {String | Number} arg2
		 * @returns
		 */
		div: (arg1: number | string, arg2: number | string) => number | string;
	};

	/**
	 * @constructor 数据补零
	 * @param {Number | String} num 需要补零的值
	 * @param {Number} n 补零的位数
	 * @returns {String}
	 */
	zero(num: number | string, n: number): string;

	/**
	 * @description 去掉所有空格
	 * @param {String} str 需要处理的字符
	 * @returns {String} 去掉空格的字符
	 */
	removeAllSpace(str: string): string;

	/**
	 * @description 提取字符串中的小数
	 * @param {String} str
	 * @returns {Number}
	 */
	getFlaotByStr(str: string): number;

	/**
	 * @description 获取页面URL中的参数
	 * @param {String} name 参数名
	 * @returns {String}
	 */
	getUrlQueryString(name: string): string | null;

	/**
	 * @description 将url请求参数转为json格式
	 * @param {String} url
	 * @returns {{} | any}
	 */
	getUrlParamsObject(url: string): EmptyObjectType;

	/**
	 * @description 将对象转换成URL 参数
	 * @param {String} baseUrl
	 * @param {Object} obj
	 * @returns {{} | any}
	 */
	setUrlParamsByObject(baseUrl: string, obj: any): string;

	/**
	 * @description 格式化货币格式
	 * @param {Number | String} number 需要格式换的金额
	 * @param {Number} places 保留小数位数
	 * @param {String} symbol 前缀 [货币符号]
	 * @param {String} thousand 切割货币的字符
	 * @param {String} decimal 小数点字符
	 * @returns {String}
	 */
	moneyFormat(number?: number | string, places?: number, symbol?: string, thousand?: string, decimal?: string): string | number;

	/**
	 * @description 小写金额转换成大写金额
	 * @param {Number | String} n 需要转换的小写金额
	 * @return {String}
	 */
	moneyToCapital(n: number | string): string;

	/**
	 * @description 将数字转换为汉字
	 * @param {Number | String} num 需要转换的数字
	 * @returns
	 */
	convertToChinaNum(num: number | string): string;

	/**
	 * @description 精度计算
	 * @returns
	 */
	precisionCount(): {
		/**
		 * @description 加法
		 * @param {String | Number} arg1
		 * @param {String | Number} arg2
		 * @returns
		 */
		add: (arg1: number | string, arg2: number | string) => number | string;

		/**
		 * @description 减法
		 * @param {String | Number} arg1
		 * @param {String | Number} arg2
		 * @returns
		 */
		sub: (arg1: number | string, arg2: number | string) => number | string;

		/**
		 * @description 乘法
		 * @param {String | Number} arg1
		 * @param {String | Number} arg2
		 * @returns
		 */
		mul: (arg1: number | string, arg2: number | string) => number | string;

		/**
		 * @description 除法
		 * @param {String | Number} arg1
		 * @param {String | Number} arg2
		 * @returns
		 */
		div: (arg1: number | string, arg2: number | string) => number | string;
	};

	/**
	 * @description 递归生成数据树
	 * @param {Array} data 数据源
	 * @param {String} parentCode 父辈code 与 parentField 对比
	 * @param {String} parentField 父辈筛选字段
	 * @param {String} parentValue 父辈筛选值
	 * @returns
	 */
	createTreeData(data: Array<any>, parentCode: string | number, parentField: string, parentValue: string): EmptyArrayType;

	/**
	 * @description 在树中查找父Id
	 * @param {String} id 当前Id
	 * @param {Array} tree 树形结构
	 * @returns
	 */
	queryParentIdArrayById(id: string | number, tree: EmptyArrayType): EmptyObjectType;
}
vhmValidate - 表单验证
declare class VHMValidate {
	// 正则表达式
	verifyExp: EmptyObjectType;

	/**
	 * @description 判读是否为外链
	 * @param path
	 * @returns {boolean}
	 */
	isExternal(path: string): boolean;

	/**
	 * @description 判断是否为IP
	 * @param ip
	 * @returns {boolean}
	 */
	isIP(ip: string): boolean;

	/**
	 * @description 判断是否是小写字母
	 * @param value
	 * @returns {boolean}
	 */
	isLowerCase(value: string): boolean;

	/**
	 * @description 判断是否是大写字母
	 * @param value
	 * @returns {boolean}
	 */
	isUpperCase(value: string): boolean;

	/**
	 * @description 判断是否是大写字母开头
	 * @param value
	 * @returns {boolean}
	 */
	isAlphabets(value: string): boolean;

	/**
	 * @description 判断是否是端口号
	 * @param value
	 * @returns {boolean}
	 */
	isPort(value: string): boolean;

	/**
	 * @description 判断是否是手机号
	 * @param value
	 * @returns {boolean}
	 */
	isPhone(value: string): boolean;

	/**
	 * @description 判断是否是身份证号(第二代)
	 * @param value
	 * @returns {boolean}
	 */
	isIdCard(value: string): boolean;

	/**
	 * @description 判断是否是邮箱
	 * @param value
	 * @returns {boolean}
	 */
	isEmail(value: string): boolean;

	/**
	 * @description 判断是否中文
	 * @param value
	 * @returns {boolean}
	 */
	isChina(value: string): boolean;

	/**
	 * @description 验证年利率
	 * @param {Object} rule 规则
	 * @param {Any} value 验证的值
	 * @param {Function} callback 回调方法
	 */
	checkYearRate(rule: EmptyObjectType, value: any, callback: Fn): void;

	/**
	 * @description 验证金额必须大于 0
	 * @param {Object} rule 规则
	 * @param {Any} value 验证的值
	 * @param {Function} callback 回调方法
	 */
	greaterThanZero(rule: EmptyObjectType, value: any, callback: Fn): void;

	/**
	 * @description 验证输入的文案不能包含空格
	 * @param {Object} rule 规则
	 * @param {Any} value 验证的值
	 * @param {Function} callback 回调方法
	 */
	checkSpaceText(rule: EmptyObjectType, value: any, callback: Fn): void;

	/**
	 * @description 格式化数字数据
	 * @param {String | Number} number 需要格式化的值
	 * @param {String} type 类型
	 * @param {Number} s 开始位置
	 * @param {Number} e 结束位置
	 * @param {String} split 截取字符
	 * @returns
	 */
	formatNumberByExp(number: string | number, type: string, s?: number, e?: number, split?: string): number | string;

	/**
	 * @description form 表单验证
	 * @param {Object} context 当前作用域
	 * @param {Array} rules 验证规则
	 * @param {Function} tips 错误提示方法
	 * @param {Function} callback 验证的回调方法
	 * @returns
	 */
	validateForm(context: EmptyObjectType, rules: EmptyArrayType, tips: EmptyObjectType, callback: Fn): boolean;

	/**
	 * @description 生成 el-form 对应的规则集
	 * @param {Object} source 数据源
	 * @param {Object} result 返回结果
	 * @param {Object} fixedrRequired 固定必填规则 不在根据每一项的 isNotrequired 觉得是否必填
	 * @returns
	 */
	createRuleData(source: EmptyObjectType | EmptyArrayType, result?: EmptyObjectType, fixedrRequired?: boolean): EmptyObjectType;

	/**
	 * @description 更新规则
	 * @param {Object | Array} source 源渲染数据
	 * @param {Object | Array} rules 源规则集
	 * @returns
	 */
	updateRuleData(source: EmptyDataType, rules: EmptyDataType): boolean | EmptyDataType;

	/**
	 * @description 更新某个字段的key规则
	 * @param {String} key 源渲染数据
	 * @param {Boolean} required 是否必填
	 * @param {Array} rules 源规则集
	 * @returns
	 */
	updateRuleDataByKey(key: string, required: boolean, rules: EmptyObjectType): boolean | EmptyObjectType;

	/**
	 * @description 使用 asyncValidator 验证表单
	 * @param {Object} form 当前作用域
	 * @param {Object} rules 验证规则
	 * @param {Function} toast 错误提示方法
	 * @param {Function} callback 验证的回调方法
	 */
	asyncValidator(form: EmptyObjectType, rules: EmptyObjectType, toast: Record<string, any>, callback: Fn): void;
}

类型

// 浏览器
type Browser = {
	isIE: boolean;
	isOpra: boolean;
	isChromeOrApple: boolean;
	isFirefox: boolean;
	isIOSPC: boolean;
	isIPad: boolean;
	isIPhone: boolean;
	isAndroidOrUC: boolean;
	isSafari: boolean;
	isWechat: boolean;
	isMobile: boolean;
};

// 函数
type Fn<T = any, R = T> = {
	(...arg: T[]): R;
};

// 申明 数组
type EmptyArrayType<T = any> = T[];

// 申明 对象
type EmptyObjectType<T = any> = {
	[key: string]: T;
};