util-helpers 4.12.0 → 4.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/util-helpers.js +106 -58
  2. package/dist/util-helpers.js.map +1 -1
  3. package/dist/util-helpers.min.js +1 -1
  4. package/dist/util-helpers.min.js.map +1 -1
  5. package/esm/divide.js +19 -17
  6. package/esm/index.js +21 -22
  7. package/esm/minus.js +10 -8
  8. package/esm/plus.js +10 -8
  9. package/esm/round.js +5 -4
  10. package/esm/times.js +10 -8
  11. package/esm/utils/config.js +2 -1
  12. package/esm/utils/math.util.js +50 -3
  13. package/lib/divide.js +18 -16
  14. package/lib/index.js +6 -0
  15. package/lib/minus.js +9 -7
  16. package/lib/plus.js +9 -7
  17. package/lib/round.js +4 -3
  18. package/lib/times.js +9 -7
  19. package/lib/utils/config.js +3 -1
  20. package/lib/utils/math.util.js +51 -2
  21. package/package.json +3 -1
  22. package/types/src/blobToDataURL.d.ts +25 -0
  23. package/types/src/bytesToSize.d.ts +24 -0
  24. package/types/src/calculateCursorPosition.d.ts +26 -0
  25. package/types/src/dataURLToBlob.d.ts +15 -0
  26. package/types/src/divide.d.ts +21 -0
  27. package/types/src/formatBankCard.d.ts +35 -0
  28. package/types/src/formatMobile.d.ts +27 -0
  29. package/types/src/formatMoney.d.ts +50 -0
  30. package/types/src/index.d.ts +45 -0
  31. package/types/src/isBankCard.d.ts +32 -0
  32. package/types/src/isBusinessLicense.d.ts +29 -0
  33. package/types/src/isChinese.d.ts +41 -0
  34. package/types/src/isEmail.d.ts +19 -0
  35. package/types/src/isHMCard.d.ts +24 -0
  36. package/types/src/isIPv4.d.ts +25 -0
  37. package/types/src/isIPv6.d.ts +50 -0
  38. package/types/src/isIdCard.d.ts +34 -0
  39. package/types/src/isMobile.d.ts +19 -0
  40. package/types/src/isPassport.d.ts +21 -0
  41. package/types/src/isPassword.d.ts +46 -0
  42. package/types/src/isPostcode.d.ts +19 -0
  43. package/types/src/isPromiseLike.d.ts +21 -0
  44. package/types/src/isQQ.d.ts +19 -0
  45. package/types/src/isSocialCreditCode.d.ts +31 -0
  46. package/types/src/isSwiftCode.d.ts +22 -0
  47. package/types/src/isTWCard.d.ts +23 -0
  48. package/types/src/isTelephone.d.ts +25 -0
  49. package/types/src/isUrl.d.ts +34 -0
  50. package/types/src/isVehicle.d.ts +29 -0
  51. package/types/src/isWX.d.ts +19 -0
  52. package/types/src/minus.d.ts +21 -0
  53. package/types/src/normalizeString.d.ts +22 -0
  54. package/types/src/numberToChinese.d.ts +57 -0
  55. package/types/src/padZero.d.ts +24 -0
  56. package/types/src/parseIdCard.d.ts +107 -0
  57. package/types/src/plus.d.ts +21 -0
  58. package/types/src/randomString.d.ts +19 -0
  59. package/types/src/replaceChar.d.ts +54 -0
  60. package/types/src/round.d.ts +22 -0
  61. package/types/src/safeDate.d.ts +22 -0
  62. package/types/src/setDataURLPrefix.d.ts +24 -0
  63. package/types/src/strlen.d.ts +20 -0
  64. package/types/src/times.d.ts +21 -0
  65. package/types/src/utils/config.d.ts +13 -0
  66. package/types/src/utils/constants.d.ts +2 -0
  67. package/types/src/utils/convertToString.d.ts +8 -0
  68. package/types/src/utils/devWarn.d.ts +7 -0
  69. package/types/src/utils/math.util.d.ts +71 -0
  70. package/types/src/utils/type/index.d.ts +19 -0
  71. package/types/src/utils/type/isArguments.d.ts +18 -0
  72. package/types/src/utils/type/isArray.d.ts +18 -0
  73. package/types/src/utils/type/isBoolean.d.ts +18 -0
  74. package/types/src/utils/type/isDate.d.ts +18 -0
  75. package/types/src/utils/type/isError.d.ts +18 -0
  76. package/types/src/utils/type/isFunction.d.ts +18 -0
  77. package/types/src/utils/type/isMap.d.ts +18 -0
  78. package/types/src/utils/type/isNaN.d.ts +18 -0
  79. package/types/src/utils/type/isNil.d.ts +11 -0
  80. package/types/src/utils/type/isNull.d.ts +18 -0
  81. package/types/src/utils/type/isNumber.d.ts +27 -0
  82. package/types/src/utils/type/isObject.d.ts +21 -0
  83. package/types/src/utils/type/isRegExp.d.ts +18 -0
  84. package/types/src/utils/type/isSet.d.ts +18 -0
  85. package/types/src/utils/type/isString.d.ts +18 -0
  86. package/types/src/utils/type/isSymbol.d.ts +18 -0
  87. package/types/src/utils/type/isType.d.ts +11 -0
  88. package/types/src/utils/type/isUndefined.d.ts +21 -0
  89. package/types/src/utils/type/isWeakMap.d.ts +18 -0
  90. package/types/src/utils/type/isWeakSet.d.ts +18 -0
  91. package/types/src/validatePassword.d.ts +134 -0
  92. package/types/src/waitTime.d.ts +20 -0
@@ -0,0 +1,13 @@
1
+ export namespace config {
2
+ const disableWarning: boolean;
3
+ }
4
+ /**
5
+ * 设置禁止warning提示
6
+ * @static
7
+ * @alias module:Debug.formatBankCard
8
+ * @since 3.6.1
9
+ * @param {boolean} bool 是否禁止warning提示
10
+ */
11
+ export function setDisableWarning(bool: boolean): void;
12
+ import { version } from "../../package.json";
13
+ export { version };
@@ -0,0 +1,2 @@
1
+ export const MAX_SAFE_INTEGER: number;
2
+ export const MIN_SAFE_INTEGER: number;
@@ -0,0 +1,8 @@
1
+ export default convertToString;
2
+ /**
3
+ * 转换为字符串
4
+ *
5
+ * @param {*} value 值
6
+ * @returns {string} 字符串
7
+ */
8
+ declare function convertToString(value: any): string;
@@ -0,0 +1,7 @@
1
+ export default devWarn;
2
+ /**
3
+ * 打印警告信息
4
+ *
5
+ * @param {any[]} args 打印的信息
6
+ */
7
+ declare function devWarn(...args: any[]): void;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * 值是否为有效的数值
3
+ *
4
+ * @deprecated 已废弃
5
+ * @param {*} value 待检测的值
6
+ * @returns {boolean} 是否为有效的数值
7
+ */
8
+ export function isEffectiveNumeric(value?: any): boolean;
9
+ /**
10
+ * 将值转换为有效数值
11
+ *
12
+ * @param {*} value 要转换的值
13
+ * @returns {number|string} 有效数值
14
+ */
15
+ export function transformEffectiveNumber(value: any): number | string;
16
+ /**
17
+ * 是否为科学计数法数字
18
+ *
19
+ * @param {string} num 检查值
20
+ * @returns {boolean}
21
+ */
22
+ export function isScientificNumber(num: string): boolean;
23
+ /**
24
+ * 把错误的数据转正
25
+ *
26
+ * @param {number} num 输入数
27
+ * @param {number} [precision=12] 小数点的精度
28
+ * @returns {number}
29
+ * @example
30
+ *
31
+ * strip(0.09999999999999998)=0.1
32
+ */
33
+ export function strip(num: number, precision?: number | undefined): number;
34
+ /**
35
+ * 计算数字的小数点长度,支持科学记数法
36
+ *
37
+ * @param {number|string} num 输入数
38
+ * @returns {number} 小数点长度
39
+ */
40
+ export function digitLength(num: number | string): number;
41
+ /**
42
+ * 把小数转成整数,支持科学计数法。如果是小数则放大成整数
43
+ *
44
+ * @param {number|string} num 输入数
45
+ * @returns {number}
46
+ */
47
+ export function float2Fixed(num: number | string): number;
48
+ /**
49
+ * 检测数字是否越界,如果越界给出提示
50
+ * @param {number} num 输入数
51
+ * @returns
52
+ */
53
+ export function checkBoundary(num: number): void;
54
+ /**
55
+ * 去掉左边数字0
56
+ *
57
+ * @param {string} num 数字字符串
58
+ * @returns {string}
59
+ */
60
+ export function trimLeftZero(num: string): string;
61
+ /**
62
+ * 科学计数法转换成普通数字
63
+ *
64
+ * JavaScript在以下情景会自动将数值转换为科学计数法:
65
+ * 1.小数点前的数字个数大于等于22位
66
+ * 2.小数点前边是0,小数点后十分位(包含十分位)之后连续零的个数大于等于6个
67
+ *
68
+ * @param {string | number} num 科学计数法数字
69
+ * @returns {string | number} 转换后的数字字符串
70
+ */
71
+ export function scientificToNumber(num: string | number): string | number;
@@ -0,0 +1,19 @@
1
+ import isArguments from "./isArguments";
2
+ import isArray from "./isArray";
3
+ import isBoolean from "./isBoolean";
4
+ import isDate from "./isDate";
5
+ import isError from "./isError";
6
+ import isFunction from "./isFunction";
7
+ import isObject from "./isObject";
8
+ import isNull from "./isNull";
9
+ import isNaN from "./isNaN";
10
+ import isNumber from "./isNumber";
11
+ import isRegExp from "./isRegExp";
12
+ import isString from "./isString";
13
+ import isSymbol from "./isSymbol";
14
+ import isMap from "./isMap";
15
+ import isWeakMap from "./isWeakMap";
16
+ import isSet from "./isSet";
17
+ import isWeakSet from "./isWeakSet";
18
+ import isUndefined from "./isUndefined";
19
+ export { isArguments, isArray, isBoolean, isDate, isError, isFunction, isObject, isNull, isNaN, isNumber, isRegExp, isString, isSymbol, isMap, isWeakMap, isSet, isWeakSet, isUndefined };
@@ -0,0 +1,18 @@
1
+ export default isArguments;
2
+ /**
3
+ * 检查值是否为Arguments
4
+ *
5
+ * @static
6
+ * @alias module:Type.isArguments
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为Arguments
10
+ * @example
11
+ *
12
+ * isArguments(function() { return arguments }())
13
+ * // => true
14
+ *
15
+ * isArguments([1, 2, 3])
16
+ * // => false
17
+ */
18
+ declare function isArguments(value: any): boolean;
@@ -0,0 +1,18 @@
1
+ export default isArray;
2
+ /**
3
+ * 检查值是否为Array
4
+ *
5
+ * @static
6
+ * @alias module:Type.isArray
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为Array
10
+ * @example
11
+ *
12
+ * isArray([])
13
+ * // => true
14
+ *
15
+ * isArray(1)
16
+ * // => false
17
+ */
18
+ declare function isArray(value: any): boolean;
@@ -0,0 +1,18 @@
1
+ export default isBoolean;
2
+ /**
3
+ * 检查值是否为Boolean
4
+ *
5
+ * @static
6
+ * @alias module:Type.isBoolean
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为Boolean
10
+ * @example
11
+ *
12
+ * isBoolean(false)
13
+ * // => true
14
+ *
15
+ * isBoolean(null)
16
+ * // => false
17
+ */
18
+ declare function isBoolean(value: any): boolean;
@@ -0,0 +1,18 @@
1
+ export default isDate;
2
+ /**
3
+ * 检查值是否为Date
4
+ *
5
+ * @static
6
+ * @alias module:Type.isDate
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为Date
10
+ * @example
11
+ *
12
+ * isDate(new Date)
13
+ * // => true
14
+ *
15
+ * isDate('Mon April 23 2012')
16
+ * // => false
17
+ */
18
+ declare function isDate(value: any): boolean;
@@ -0,0 +1,18 @@
1
+ export default isError;
2
+ /**
3
+ * 检查值是否为Error、EvalError、RangeError、ReferenceError、SyntaxError、TypeError、URIError|DOMException
4
+ *
5
+ * @static
6
+ * @alias module:Type.isError
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为Error、EvalError、RangeError、ReferenceError、SyntaxError、TypeError、URIError|DOMException
10
+ * @example
11
+ *
12
+ * isError(new Error)
13
+ * // => true
14
+ *
15
+ * isError(Error)
16
+ * // => false
17
+ */
18
+ declare function isError(value: any): boolean;
@@ -0,0 +1,18 @@
1
+ export default isFunction;
2
+ /**
3
+ * 检查值是否为Function|AsyncFunction|GeneratorFunction|Proxy
4
+ *
5
+ * @static
6
+ * @alias module:Type.isFunction
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为Function|AsyncFunction|GeneratorFunction|Proxy
10
+ * @example
11
+ *
12
+ * isFunction(()=>{}))
13
+ * // => true
14
+ *
15
+ * isFunction(/abc/)
16
+ * // => false
17
+ */
18
+ declare function isFunction(value: any): boolean;
@@ -0,0 +1,18 @@
1
+ export default isMap;
2
+ /**
3
+ * 检查值是否为Map
4
+ *
5
+ * @static
6
+ * @alias module:Type.isMap
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为Map
10
+ * @example
11
+ *
12
+ * isMap(new Map)
13
+ * // => true
14
+ *
15
+ * isMap(new WeakMap)
16
+ * // => false
17
+ */
18
+ declare function isMap(value: any): boolean;
@@ -0,0 +1,18 @@
1
+ export default _isNaN;
2
+ /**
3
+ * 检查值是否为NaN
4
+ *
5
+ * @static
6
+ * @alias module:Type.isNaN
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为NaN
10
+ * @example
11
+ *
12
+ * isNaN(NaN)
13
+ * // => true
14
+ *
15
+ * isNaN(1)
16
+ * // => false
17
+ */
18
+ declare function _isNaN(value: any): boolean;
@@ -0,0 +1,11 @@
1
+ export default isNil;
2
+ /**
3
+ * 检查值是否为 undefined 或 null
4
+ *
5
+ * @static
6
+ * @alias module:Type.isNaN
7
+ * @since 4.3.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为 undefined 或 null
10
+ */
11
+ declare function isNil(value: any): boolean;
@@ -0,0 +1,18 @@
1
+ export default isNull;
2
+ /**
3
+ * 检查值是否为Null
4
+ *
5
+ * @static
6
+ * @alias module:Type.isNull
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为Null
10
+ * @example
11
+ *
12
+ * isNull(null)
13
+ * // => true
14
+ *
15
+ * isNull(void 0)
16
+ * // => false
17
+ */
18
+ declare function isNull(value: any): boolean;
@@ -0,0 +1,27 @@
1
+ export default isNumber;
2
+ /**
3
+ * 检查值是否为Number
4
+ *
5
+ * @static
6
+ * @alias module:Type.isNumber
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为Number
10
+ * @example
11
+ *
12
+ * isNumber(1)
13
+ * // => true
14
+ *
15
+ * isNumber(Number.MIN_VALUE)
16
+ * // => true
17
+ *
18
+ * isNumber(Infinity)
19
+ * // => true
20
+ *
21
+ * isNumber(NaN)
22
+ * // => true
23
+ *
24
+ * isNumber('1')
25
+ * // => false
26
+ */
27
+ declare function isNumber(value: any): boolean;
@@ -0,0 +1,21 @@
1
+ export default isObject;
2
+ /**
3
+ * 检查值是否为Object
4
+ *
5
+ * @static
6
+ * @alias module:Type.isObject
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为Object
10
+ * @example
11
+ *
12
+ * isObject({})
13
+ * // => true
14
+ *
15
+ * isObject([1,2,3])
16
+ * // => true
17
+ *
18
+ * isObject(null)
19
+ * // => false
20
+ */
21
+ declare function isObject(value: any): boolean;
@@ -0,0 +1,18 @@
1
+ export default isRegExp;
2
+ /**
3
+ * 检查值是否为RegExp
4
+ *
5
+ * @static
6
+ * @alias module:Type.isRegExp
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为RegExp
10
+ * @example
11
+ *
12
+ * isRegExp(/abc/)
13
+ * // => true
14
+ *
15
+ * isRegExp('/abc/')
16
+ * // => false
17
+ */
18
+ declare function isRegExp(value: any): boolean;
@@ -0,0 +1,18 @@
1
+ export default isSet;
2
+ /**
3
+ * 检查值是否为Set
4
+ *
5
+ * @static
6
+ * @alias module:Type.isSet
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为Set
10
+ * @example
11
+ *
12
+ * isSet(new Set)
13
+ * // => true
14
+ *
15
+ * isSet(new WeakSet)
16
+ * // => false
17
+ */
18
+ declare function isSet(value: any): boolean;
@@ -0,0 +1,18 @@
1
+ export default isString;
2
+ /**
3
+ * 检查值是否为String
4
+ *
5
+ * @static
6
+ * @alias module:Type.isString
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为String
10
+ * @example
11
+ *
12
+ * isString('abc')
13
+ * // => true
14
+ *
15
+ * isString(1)
16
+ * // => false
17
+ */
18
+ declare function isString(value: any): boolean;
@@ -0,0 +1,18 @@
1
+ export default isSymbol;
2
+ /**
3
+ * 检查值是否为Symbol
4
+ *
5
+ * @static
6
+ * @alias module:Type.isSymbol
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为Symbol
10
+ * @example
11
+ *
12
+ * isSymbol(Symbol.iterator)
13
+ * // => true
14
+ *
15
+ * isSymbol("abc")
16
+ * // => false
17
+ */
18
+ declare function isSymbol(value: any): boolean;
@@ -0,0 +1,11 @@
1
+ export default isType;
2
+ /**
3
+ * 检测值的 `toString` 类型
4
+ *
5
+ * @private
6
+ * @since 1.1.0
7
+ * @param {*} value 检查值
8
+ * @param {string} typename 类型名称
9
+ * @returns {boolean} 返回值的 `toString` 类型是否匹配
10
+ */
11
+ declare function isType(value: any, typename: string): boolean;
@@ -0,0 +1,21 @@
1
+ export default isUndefined;
2
+ /**
3
+ * 检查值是否为Undefined
4
+ *
5
+ * @static
6
+ * @alias module:Type.isUndefined
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为Undefined
10
+ * @example
11
+ *
12
+ * isUndefined(undefined)
13
+ * // => true
14
+ *
15
+ * isUndefined(void 0)
16
+ * // => true
17
+ *
18
+ * isUndefined(null)
19
+ * // => false
20
+ */
21
+ declare function isUndefined(value: any): boolean;
@@ -0,0 +1,18 @@
1
+ export default isWeakMap;
2
+ /**
3
+ * 检查值是否为WeakMap
4
+ *
5
+ * @static
6
+ * @alias module:Type.isWeakMap
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为WeakMap
10
+ * @example
11
+ *
12
+ * isWeakMap(new WeakMap)
13
+ * // => true
14
+ *
15
+ * isWeakMap(new Map)
16
+ * // => false
17
+ */
18
+ declare function isWeakMap(value: any): boolean;
@@ -0,0 +1,18 @@
1
+ export default isWeakSet;
2
+ /**
3
+ * 检查值是否为WeakSet
4
+ *
5
+ * @static
6
+ * @alias module:Type.isWeakSet
7
+ * @since 1.1.0
8
+ * @param {*} value 检查值
9
+ * @returns {boolean} 是否为WeakSet
10
+ * @example
11
+ *
12
+ * isWeakSet(new WeakSet)
13
+ * // => true
14
+ *
15
+ * isWeakSet(new Set)
16
+ * // => false
17
+ */
18
+ declare function isWeakSet(value: any): boolean;
@@ -0,0 +1,134 @@
1
+ export default validatePassword;
2
+ /**
3
+ * - 验证密码的包含内容
4
+ */
5
+ export type PasswordContaines = {
6
+ /**
7
+ * - 包含数字
8
+ */
9
+ number: boolean;
10
+ /**
11
+ * - 包含小写字母
12
+ */
13
+ lowerCaseLetter: boolean;
14
+ /**
15
+ * - 包含大写字母
16
+ */
17
+ upperCaseLetter: boolean;
18
+ /**
19
+ * - 包含特殊字符
20
+ */
21
+ specialCharacter: boolean;
22
+ /**
23
+ * - 包含非法字符
24
+ */
25
+ unallowableCharacter: boolean;
26
+ };
27
+ /**
28
+ * - 验证结果
29
+ */
30
+ export type ValidatePasswordReturn = {
31
+ /**
32
+ * - 验证结果,根据密码强度、是否包含非法字符得出
33
+ */
34
+ validated: boolean;
35
+ /**
36
+ * - 强度级别,包含数字/大小写字母/特殊字符
37
+ */
38
+ level: number;
39
+ /**
40
+ * - 包含内容
41
+ */
42
+ containes: PasswordContaines;
43
+ };
44
+ /**
45
+ * @typedef {Object} PasswordContaines - 验证密码的包含内容
46
+ * @property {boolean} number - 包含数字
47
+ * @property {boolean} lowerCaseLetter - 包含小写字母
48
+ * @property {boolean} upperCaseLetter - 包含大写字母
49
+ * @property {boolean} specialCharacter - 包含特殊字符
50
+ * @property {boolean} unallowableCharacter - 包含非法字符
51
+ */
52
+ /**
53
+ * @typedef {Object} ValidatePasswordReturn - 验证结果
54
+ * @property {boolean} validated - 验证结果,根据密码强度、是否包含非法字符得出
55
+ * @property {number} level - 强度级别,包含数字/大小写字母/特殊字符
56
+ * @property {PasswordContaines} containes - 包含内容
57
+ */
58
+ /**
59
+ * 验证密码(数字、大小写字母、特殊字符、非法字符)
60
+ *
61
+ * @see 参考 {@link https://baike.baidu.com/item/ASCII#3|ASCII}
62
+ * @static
63
+ * @alias module:Validator.validatePassword
64
+ * @since 3.7.0
65
+ * @param {string} value 要检测的值
66
+ * @param {Object} [options] 配置项
67
+ * @param {number} [options.level=2] 密码强度 1-包含一种字符 2-包含两种字符 3-包含三种字符。(大写字母、小写字母、数字、特殊字符)
68
+ * @param {boolean} [options.ignoreCase=false] 是否忽略大小写,为 ture 时,大小写字母视为一种字符
69
+ * @param {string} [options.special="!@#$%^&*()-=_+[]\|{},./?<>~"] 支持的特殊字符
70
+ * @returns {ValidatePasswordReturn} 验证结果
71
+ * @example
72
+ *
73
+ * validatePassword('a12345678');
74
+ * // =>
75
+ * {
76
+ * validated: true, // 验证结果,根据密码强度、是否包含非法字符得出
77
+ * level: 2, // 强度级别
78
+ * containes: {
79
+ * number: true, // 包含数字
80
+ * lowerCaseLetter: true, // 包含小写字母
81
+ * upperCaseLetter: false, // 包含大写字母
82
+ * specialCharacter: false, // 包含特殊字符
83
+ * unallowableCharacter: false // 包含非法字符
84
+ * }
85
+ * }
86
+ *
87
+ * validatePassword('a12345678', { level: 3 });
88
+ * // =>
89
+ * {
90
+ * validated: false,
91
+ * level: 2,
92
+ * containes: {
93
+ * number: true,
94
+ * lowerCaseLetter: true,
95
+ * upperCaseLetter: false,
96
+ * specialCharacter: false,
97
+ * unallowableCharacter: false
98
+ * }
99
+ * }
100
+ *
101
+ * validatePassword('_Aa一二三45678', { level: 3, ignoreCase: true });
102
+ * // =>
103
+ * {
104
+ * validated: false,
105
+ * level: 3,
106
+ * containes: {
107
+ * number: true,
108
+ * lowerCaseLetter: true,
109
+ * upperCaseLetter: true,
110
+ * specialCharacter: true,
111
+ * unallowableCharacter: true
112
+ * }
113
+ * }
114
+ *
115
+ * // 自定义特殊字符
116
+ * validatePassword('_Aa一二三45678', { level: 3, ignoreCase: true, special: '_一二三' });
117
+ * // =>
118
+ * {
119
+ * validated: true,
120
+ * level: 3,
121
+ * containes: {
122
+ * number: true,
123
+ * lowerCaseLetter: true,
124
+ * upperCaseLetter: true,
125
+ * specialCharacter: true,
126
+ * unallowableCharacter: false
127
+ * }
128
+ * }
129
+ */
130
+ declare function validatePassword(value: string, { level, ignoreCase, special }?: {
131
+ level?: number | undefined;
132
+ ignoreCase?: boolean | undefined;
133
+ special?: string | undefined;
134
+ } | undefined): ValidatePasswordReturn;
@@ -0,0 +1,20 @@
1
+ export default waitTime;
2
+ /**
3
+ * 等待时间返回 Promise 。常用于异步方法中延时。
4
+ *
5
+ * @static
6
+ * @alias module:Other.waitTime
7
+ * @since 4.2.0
8
+ * @param {number} [time=1000] 延时时间,单位毫秒
9
+ * @returns {Promise<void>}
10
+ * @example
11
+ * const test = async ()=>{
12
+ * await waitTime();
13
+ * // do something
14
+ * }
15
+ *
16
+ * waitTime(500).then(()=>{
17
+ * // do something
18
+ * })
19
+ */
20
+ declare function waitTime(time?: number | undefined): Promise<void>;